Addressing Pins

tommo_NZ

New Member
Hi All, I apologise in advance to those accomplished users that have grasped the concept of addressing pins. I on the otherhand am more confused than ever. My conumdrum is that after studying the picaxem2.pdf document, the diagram of the 14M2 pin assignment shows that C.5 to C.0 addresses pins 2 to 7 and B.0 to B.5 addresses pins 13 to 8.

So when the following
high 2
low B.2
high C.2
low 2
is run in the simulator, I find they all operate on the same pin.
Can anyone clear this up for me..
I have searched for all references to pin addressing and still can't get it to work in my head.
Thanks,
tommo_NZ.
 

nick12ab

Senior Member
Did you stick any pauses in your program? Your test code should have looked something like this:
Code:
#picaxe 14m2
do
    high 2
    pause 500
    low b.2
    pause 500
    high c.2
    pause 500
    low 2
    pause 500
loop
In this case it does work properly. As B.2 is just a constant except you don't see it's symbol definition, a pin number can also be used to reference that pin. symbol B.2 = 2. Therefore high 2 will do the same thing as high B.2.
 

tommo_NZ

New Member
Hi Nick12ab,

Thanks Nick, after I posted I thought of inserting the directive "#picaxe 14m2"...
and yes, I did have pauses, just stripped them out for readability.
It seems to work Ok, I shall follow this up.
Thanks very much again.
 

hippy

Technical Support
Staff member
So when the following
high 2
low B.2
high C.2
low 2
is run in the simulator, I find they all operate on the same pin.
If you add a DO:LOOP at the end of the program the simulator won't automatically close and you will (should) see that high C.2 sets a different pin to B.2 ( or 2 ) and that the LOW 2 doesn't clear the previous HIGH C.2

2 maps to B.2 where the B port was the output port on earlier 14M. This often makes it possible to run code for the 14M on the 14M2 unchanged.
 

tommo_NZ

New Member
Thanks guys.. problem sorted.
I did have the pauses and loops in my test code but I was only listing the commands that addressed the pins.
Mistook #1: Wrong chip type set in options and no compiler directive.
Result #1: Only leg 11 (B.2) cycled
Observation #1, Including the compiler directive (#picaxe 14m2) made it work as desired.
It also changed the chip selected in options.
Thanks again for your patience.
 

westaust55

Moderator
If you look at pages 9 to 11 in PICAXE manual 1 you with have a diagram/"map" for the pin versus physical leg allocations for all PICAXE chips.
While as nick12ab has indicated, B.0 is in effect an inbuilt constant with a value of 0,
If may be considered good practice to use straight values 0 to 7 when the code applies to earlier chips and to use the port.pin nomenclature for code developed for M2 and X2 parts.
This does have some advantage in that those helping wll have a better idea what chips are involved when, as is often the case, the original poster does not indicate (through code declaration or words) which chips is being used.
 
Top