AXE049 Code Questions

DDJ2011

Member
I now have an AXE049 (http://www.picaxe.com/Hardware/Teaching-Systems/PICAXE-Tutorial-Board/) which comes with various peripherals and there is also a pdf tutorial (http://www.picaxe.com/docs/axe049.pdf) that I have been working through.

This program - to flash the decimal point on the LED display works:

Code:
main:
[INDENT]high 7
pause 1000
low 7
pause 1000
goto main
[/INDENT]
However, this program, from TUTORIAL 7 - NUMBER SYSTEMS does not work. It is supposed to display the numbers from 0 to 9 on the LED. I assumed (incorrectly?) that a tutorial program would just work fine. Can anyone advise why this doesn't work? The chip is an 18M2.

Code:
main:
[INDENT]let pins = %00111111
pause 250
let pins = %00000110
pause 250
let pins = %01011011
pause 250
let pins = %01001111
pause 250
let pins = %01100110
pause 250
let pins = %01101101
pause 250
let pins = %01111101
pause 250
let pins = %00000111
pause 250
let pins = %01111111
pause 250
let pins = %01101111
pause 250
goto main
[/INDENT]
Many thanks.
 

BeanieBots

Moderator
Could you please explain with a little more detail what you mean by "does not work".
Won't download?, gives a syntax error?, displays the numbers backwards? .....
 

hippy

Ex-Staff (retired)
The problem is the AXE049 now using the 18M2 and "pins=" only sets pin output levels and does not make those pins outputs - they would be outputs by default on the 18M used originally.

As you have got an 18M2, it's recommended to change "pins=" to "pinsB=" and also add a "dirsB=$FF" at the start of the program.

Code:
#Picaxe 18M2
main:
  let dirsB = $FF
  let pinsB = %00111111 : pause 250
  let pinsB = %00000110 : pause 250
  let pinsB = %01011011 : pause 250
  let pinsB = %01001111 : pause 250
  let pinsB = %01100110 : pause 250
  let pinsB = %01101101 : pause 250
  let pinsB = %01111101 : pause 250
  let pinsB = %00000111 : pause 250
  let pinsB = %01111111 : pause 250
  let pinsB = %01101111 : pause 250
  goto main
 

g6ejd

Senior Member
replace the pins with pinsB or pinsC it becuase it has a later part now see the picaxe manual
 

Armp

Senior Member
As you have got an 18M2, it's recommended to change "pins=" to "pinsB=" and also add a "dirsB=$FF" at the start of the program.
Shouldn't that be "OutPinsB = " for an 18M2, or is it optional?

Manual2, page 15 says:

PICAXE-14M2 / 18M2 / 20M2 Special Function Registers
pinsB - the portB input pins
outpinsB - the portB output pins
 
Last edited:

nick12ab

Senior Member
Shouldn't that be "OutPinsB = " for an 18M2, or is it optional?
You don't have to use outpinsB when writing to a port.

The difference is in reading pins or outpins - outpins is the output register and pins is the input register so if a high output pin is forced low by an external force, then pins will have the appropriate bit for that pin set to 0 since that's the voltage state of the pin but outpins will have that bit set to 1 because the output is supposed to be high.
 

Armp

Senior Member
Thats not what the manual seems to say for the M2 part IMO.

Manual2, page 17 says for the other '18 family parts:

PICAXE-18 / 18A / 18M / 18X Special Function Registers (NOT 18M2)
pins = the input port when reading from the port
(out)pins = the output port when writing to the port
Maybe RevEd can take a look and provide some clarification?
 

DDJ2011

Member
Brilliant. Thanks all. I would also advise RevEd to update their documentation about this particular board as it is now supplied with an 18M2 chip.
 

hippy

Ex-Staff (retired)
Maybe RevEd can take a look and provide some clarification?
For current M2 and X2 PICAXE with individually addressable pins when setting an output; 'pin' and 'outpin' are synonymous but some may prefer to use 'outpin' to show more clearly they are setting outputs, some may recommend doing that, and it would be consistent with use on earlier PICAXE. When reading; 'pin' is an input pin, 'outpin' is, as nick12ab says, the value which was set on an output pins.

For earlier PICAXE with fixed input and output pins the situation is much the same but 'pin' variables were only defined for input pins. The 18X and earlier 18-pin are the most notable in this respect where 'pin3' doesn't exist as an input but there was an output pin 3. On the earlier 18-pin chips it was not possible to use 'pin3=' and one had to use 'outpin3='.

From all that one could say, use 'outpin=' to set an output pin, use 'pin' to read an input pin, use 'outpin' to read the level set on an output pin. Plus you can also get away with 'pin=' being the same as 'outpin=' where that 'pin' variable is defined.
 

Armp

Senior Member
So then would this be the correction for Manual2 Page 15, or am I still missing something?

PICAXE-14M2 / 18M2 / 20M2 Special Function Registers
pinsB - the portB input pins
(out)pinsB - the portB output pins
 
Top