Picaxe 20M - can one increase inputs

Marcwolf

Senior Member
Hi folks.
I know that with poking and other things one can do some interedting things with the 18X etc..

I was wondering if anyone knew hoe to increate the number of inputs on a 20M. I am hoping to get 10!!!

Any idea's?

Many Thanks
Dave
 

Dippy

Moderator
I have never tried it, but may just be a simple change of the TRISB values for PICAXE 'Outputs 5,6,7' = i.c. pins 13,12,11 = PIC Port RB.4, RB.5, RB.6.

They tie up with TRISB (Address 86h) bits 4,5,6 on the PIC 16F.
Poking those bits to a 1 will set them as inputs. 1=Input 0=Output. Easy to remember: 1 looks like I and 0 looks like 0.

Check out the PIC Data Sheet for the PIC 16F677 from microchip.com.
TRISx determines the 'direction' of a pin on a PIC.

As to whether it'll work or that it won't upset something else I really don't know.
 

hippy

Ex-Staff (retired)
I don't know if it would be possible, I suspect not.

Poking TRISB or TRISC registers as Dippy suggests is one way to try it; after you've done a Poke do a Peek and see if the registers hold what was written or if they've been changed back to their firmware defaults.

Directly poking TRISB or TRISC might not work anyway, it doesn't on the 18X which can have its outputs made into inputs. The 18X required a particular 'firmware variable' to be identified to make it work and there's no reason to believe that the 20M has such a variable and if it did one would have to discover where it is.
 

Dippy

Moderator
I haven't got a 20M to try, so it's up to you to try Dave. I just don't know how poking will interact with the firmware, but from the hardware point of view TRISx is the thing to look into. I confess I'd never heard of this 'firmware variable' before, i haven't got a clue what it means.

Maybe Kranenborg has some comments...?
 

Technical

Technical Support
Staff member
There is no shadow register in the 20M, the i/o are fixed and cannot be changed.
For 10 separate inputs use a 28X1.

Or if just using switches consider a resistor ladder network on an analogue input to give 3 or 4 separately identifable inputs on one analogue pin! e.g. a 1k, 4k7 and 10k resistor in series with a switch shorting out each resistor (remember to also have an extra resistor to prevent short circuit conditions).
 

hippy

Ex-Staff (retired)
I confess I'd never heard of this 'firmware variable' before, i haven't got a clue what it means.
It's at $AE AFAIR, the 'shadow register' as I've also called it for TRISB. For the 18X the TRISB isn't set from a hard-wired constant after every Basic command as is the case with other PICAXE's ( to ensure outputs stay as outputs and inputs stay as inputs ) but from a 'byte variable' in SFR intended to be used only by the firmware. It has to be this way to allow the firmware to use I2C and it's just lucky fortune that it exists in this form, was found and can be used to control the whole of TRISB.

Using outputs as inputs isn't a great idea and not always that useful because they will be set as outputs at reset. I'd recommend using a PICAXE designed for the task or, as Technical suggests, redesigning so what's required can work with what the PICAXE officially supports.
 

Marcwolf

Senior Member
Thanks for all of your advice

Hi Folks.

Many thanks for all of your advice. I may have to look at a 28X if I want more inputs

What I am trying to do is to attach a 20M onto a 8bit bus, and still have a couple of pins left over so I can use them as a latch or output enable.

Best thing - think of a programmable 74ls373 :>

Again thanks Tech, Dippy, and Hippy for your advice.

Dave
 
Top