40X2 how many I/O

Vroom

Member
Just curious about 40X2, if use maximum output are 32 and how many input? 8?
Little confuse basic about A0-7, B0-7, C0-7, and D0-3, know A0-7 for input only or what? where page basic info input and output lists use A-7, B0-7, C0-7, and D0-3 for 40X2 only?
 

hippy

Ex-Staff (retired)
The 40X2 has up to 32 outputs including Serial Out (A.4).

Serial Out is output only but those other pins can be input, so there are up to 31 inputs, plus Serial In which can be an input for SERRXD.

Of those inputs, up to 12 may be used for analogue input.

The pinouts and I/O pin allocations are mainly described in PICAXE Manual 1 with specific X2 information in http://www.rev-ed.co.uk/docs/picaxex2.pdf
 
Last edited:

Vroom

Member
Thanks, but how need to know code number for output like HIGH 0, 1, 2, etc which number code can output.
 

hippy

Ex-Staff (retired)
The HIGH PORTC and related commands are used with earlier PICAXE but for the X2 and M2 the convention has become more rationalised with each pin identified as port.pin so one has control over all the I/O just by specifying which pin is used ...

HIGH C.0
COUNT B.3, 1000, w0

@ Vroom : I'm afraid I cannot understand exactly what you are asking for in post #3. If you can phrase it in some other way that may help. Or give an example for how you'd do it for another PICAXE you understand and we can explain how to do that for an X2. Or you could use the X2 Conversion Wizard of Programming Editor.
 

Vroom

Member
Right, put code like HIGH C.0, understand its clear, me bit experienced with 08M, 18M, and 20M, I never had use with 40X2 before, I should to more learn about them. Thanks.
 

Vroom

Member
I make code for output like pins=%00000001 for 18M. Now use 40X2 I just practice simple code first, I not surely code is right or wrong I test output B0-7 but not work, show like this

main:
pinsB=%11110000
wait 1
pinsB=%00000000
wait 1
goto main
 

eclectic

Moderator
I make code for output like pins=%00000001 for 18M. Now use 40X2 I just practice simple code first, I not surely code is right or wrong I test output B0-7 but not work, show like this

main:
pinsB=%11110000
wait 1
pinsB=%00000000
wait 1
goto main
From page 2 of the 40X2 document
"All pins (with the exception of the download serial output pin) are configured as digital inputs at power-up. Most
output commands (high, low, pulsout, serout etc.) automatically convert the pin to an output. However the
configuration of the pins can also be controlled by the dirsX variables or the input/output/reverse commands.
let dirsB = %11110000
input C.1
output B.2"

So, at the start of your program

Let DirsB = %11111111

e
 

ValueAdd

Senior Member
I make code for output like pins=%00000001 for 18M. Now use 40X2 I just practice simple code first, I not surely code is right or wrong I test output B0-7 but not work, show like this

main:
pinsB=%11110000
wait 1
pinsB=%00000000
wait 1
goto main
Untested myself, but I believe that if you use the PE wizard for conversion of code from earlier Picaxe chips to the X2 parts that the wizard will add the

DirsB = %11111111

As mentioned by eclectic as well as alter the IO references accordingly.
As stated, untested by me, but give it a go.
 

Vroom

Member
I tested by Programming Editor Simulate Run with DirsB = %11111111 but all output are low (dark green), no high (light green).

I tried turn on PortB output like this high portb = %00001111, is it wrong?

when code use port A, B, C, or D output %00001111 like low, low, low, low, high, high, high, and high output each other like 18M use pins=%00000001.
 

Technical

Technical Support
Staff member
DirsB make the portB outputs, it does not switch them high or low.

To turn them high/low either use

pinsb =

or individual

high b.0
low b.2

type commands.

Code:
dirsB=%11111111

main:
pinsB=%11110000
wait 1
pinsB=%00000000
wait 1
goto main
 
Top