Out of pins!
Sabai
Posts: 27
I am kind of new to basic stamp and I am working my way with the first application. My problem is the amount of pins on Basic stamp 2.
My application will use this.
Lcd parallel need 7 pins
ADC0831 need 3 pins (humidity sensor)
DS1620 need 3 pins (temp sensor)
4 buttons 4 pins
1 pulse in (From wind sensor)
2 pins for output
20 pins!
This is what I need and as you can see I need 20 pins. How can this be done, or can it not be done.
Regards
Bert
My application will use this.
Lcd parallel need 7 pins
ADC0831 need 3 pins (humidity sensor)
DS1620 need 3 pins (temp sensor)
4 buttons 4 pins
1 pulse in (From wind sensor)
2 pins for output
20 pins!
This is what I need and as you can see I need 20 pins. How can this be done, or can it not be done.
Regards
Bert
Comments
For the DS1620, holding the /RST line low disables the device. For the ADC0831, holding the /CS line high disables the device. For most parallel LCDs, holding the E (enable) line low disables the device.
You can use a 74HC165 serial shift register to handle up to 8 buttons. It also has a clock and data line that can be shared. It would require 2 additional pins, one for /CE (chip enable) and the other a clock to sample the button state.
The LCD would need the 7 pins with 4 pins available to be shared
The ADC0831 would need one additional pin
The DS1620 would need one additional pin
The 74HC165 would need two additional pins
The wind sensor would need one pin
The unspecified outputs would need 2 pins
That's a total of 14
Look for the StampWorks Manual on Parallax's website and download it. There's a chapter on the use of a 74HC165.
A much simpler alternative would be to switch to a serial LCD which would only require one I/O pin instead of 7
Post Edited (Mike Green) : 10/2/2009 6:37:07 PM GMT
I do agree with you that a serial LCD is the easiest way to do this.
But can you just explain for me how to share pins? For example I got this
'
[noparse][[/noparse] I/O Definitions ]
E PIN 1 ' Enable pin
RW PIN 2 ' Read/Write
RS CON 3 ' Register Select
LcdDirs VAR DIRB ' bus DDR
LcdBusOut VAR OUTB ' 4-bit LCD data bus
LcdBusIn VAR INB
BtnOk PIN 13
BtnCancel PIN 14
How do I write this if I share pins?
B
ADCCS PIN 8
ADCCLK PIN 4
ADCDO PIN 5
You'd do a "HIGH ADCCS" during your program initialization to turn off the ADC0831 and start your "read a value" routine with
LOW ADCCLK
INPUT ADCDO
... normal read from ADC0831 code ...
The LCD at this point is disabled (although it's still displaying what was last sent to it) and not using I/O pins 4-7. The next time the LCD is enabled, the data pins' direction (4-7) would have to be reinitialized. The existing sample routines might do that anyway.
Pin 2 is for the lcd RW since I am only going to write can I keep this low so that will save one pin on the lcd.
0 Pulse
1 e LCD
2 Clock Shift
3 rs LCD
4 bus LCD
5 bus LCD
6 bus LCD
7 DO DS & ADC
8 Clock DS & ADC
9 RST DS
10 CS ADC
11 Do Shift
12 Load Shift
13 Out
14 Out
http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/CategoryID/9/List/0/SortField/0/Level/a/ProductID/8/Default.aspx
Just a thought.
Jim
B