Picaxe-40x pinout

fretei

New Member
Hi.
Question about the picaxe 40x1, In the doc I can see that you can have max
17 output pins and 20 input, since the 40x1 is a pic 16f887 wich can have 35 indevidualy controlled i/o's (as it says in the doc), I wonder if there is a way to reconfigure lets say input5 to make it an output port,

I need all the output ports I can get...:confused:

tore
 

hippy

Ex-Staff (retired)
No, there's no way to turn those inputs into outputs. To get more outputs you can use SEROUT/SERTXD to send I/O data bytes to another PICAXE and use that as an I/O extender and there are other hardware solutions, I2C and SPI.
 

Andrew Cowan

Senior Member
As hippy says, serout/sertxd is the best way to go.

Serout can be used on any output pin, any chip, and at a large range of baud rates.

Sertxd can be used on A, M and X chips, and is limited to 4800 baud only. It works on the 'serial out' pin.

A
 

womai

Senior Member
To get one more additional output pin, you could use the serial output pin (the one that gets driven by sertxd). You'd have to access it through poke commands to set it high and low. I remember there was a thread about that topic (which register addresses to peek/poke) but can't find it right now. Maybe hippy or somebody else knows?

The other good options (that can provide many more pins) are:

- use a 74HCxx series serial shift register (very cheap, around $0.25); typically 8 parallel outputs, driven by 2 lines for the Picaxe (clock and data), can be cascaded for even more outputs. On the X1 parts you can use hardware SPI for very fast update rates. On types that have parallel load you can use then as additional inputs as well. Disadvantage: you need to supply all the data for all outputs every time you want to change a single output, and unless the parallel outputs are latched, they will randomly change states during the load process (often ok for display drivers, but not for logic that may get clocked by those changes).

- port expander, e.g. Maxim MAX7300 or MAX6956: driven through I2C or SPI bus. Can access outputs individually. Usually pins can also be set as inputs, so very flexible. Typically 16 - 20 I/O's per expander (28 pin DIP package). Microchip has suitable expanders as well. You can get the MAX6956 as free sample fromk Maxim.

- slave Picaxe: communicate through serial (serin/serout) - simple - or SPI (more involved and only on X1 parts which can be I2C slaves). Advantage - potential for multitasking (second Picaxe can do other things, especially X1 series that can do background serial receive and background I2C). Disadvantage - more complex, and a X1 Picaxe is much more expensive than an I/O expander or shift register.

Wolfgang
 
Top