Expanded digital input (74HC165)
Rino
Posts: 15
I am working with EXPERIMENT 24 in the Stamp Works manual.· Expanded digital inputs with shift registers.· I CANNOT make it work, maybe another set of eyes could see my mistake.· I get erratic zeros and ones on the display, it is not reading the input switches to the shift register 74HC165.· My circuit is the same as in page 137 of the manual.· Here is the code I use:
Switch VAR· Byte
Clock· PIN 0
Out··· PIN 1
Load·· PIN 2
Reset:
· HIGH· Load
· DEBUG CLS
·· "Switch·· 76543210",· CR,
···"
····
",· CR,
·· "Status···
"
Main:
·· DO
····· GOSUB· get_165
····· DEBUG· CRSRXY,· 8,· 2,· BIN8 Switch
····· DEBUG· CR,· DEC3· switch
····· PAUSE 100
·· LOOP
Get_165
·· PULSOUT· Load, 5
·· SHIFTIN· Out, Clock, MSBPRE,· [noparse][[/noparse]Switch]
·· RETURN
·
Switch VAR· Byte
Clock· PIN 0
Out··· PIN 1
Load·· PIN 2
Reset:
· HIGH· Load
· DEBUG CLS
·· "Switch·· 76543210",· CR,
···"
····
",· CR,
·· "Status···
"
Main:
·· DO
····· GOSUB· get_165
····· DEBUG· CRSRXY,· 8,· 2,· BIN8 Switch
····· DEBUG· CR,· DEC3· switch
····· PAUSE 100
·· LOOP
Get_165
·· PULSOUT· Load, 5
·· SHIFTIN· Out, Clock, MSBPRE,· [noparse][[/noparse]Switch]
·· RETURN
·
Comments
SHIFTIN· Out, Clock, MSBPRE,·[noparse]/noparse]Switch[color=red][b]\8[/b][/color
Post Edit -- OK, I guess that if it's not specified then the default is 8 bits.· Are you using the 10K resistors (pull-ups) on each input?· If not, leaving them to 'float' would result "erratic" data.
Post Edited (PJ Allen) : 1/1/2009 3:39:35 PM GMT
I did try that line -- no difference
SHIFTIN command is supposed to default at 8 bits
[noparse][[/noparse]You Replied as I was Post Editing previous.]
Post Edit -- *Like if·one were switching +5/open_ckt into the '165 inputs.
Post Edited (PJ Allen) : 1/1/2009 3:48:37 PM GMT
All I can think of·is that you try the circuit, hard-wiring the inputs in place of the switch, or use a DIP_switch assembly and see how that works, in case it's your bcd_switch.
Thanks
Post Edit -- Added pics 260, 263
Post Edited (PJ Allen) : 1/11/2009 6:19:38 PM GMT
I found the problem last night.
The reason, I had NO COMMON GROUND between the BS2 board and the circuit board I was using.
Now the reading is stable and I get the right switch positions on the display.
Lesson learned: When using a different power supply for the experimental circuit, HAVE A COMMON GROUND WITH THE bs2 CIRCUIT.
Thanks again for the help