Shop OBEX P1 Docs P2 Docs Learn Events
Expanded digital input (74HC165) — Parallax Forums

Expanded digital input (74HC165)

RinoRino Posts: 15
edited 2009-01-05 16:42 in BASIC Stamp
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
·

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-01-01 15:24
    You need to specify the number of bits that the '165 is supposed to clock for in your SHIFTIN statement:

    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
  • RinoRino Posts: 15
    edited 2009-01-01 15:36
    Thanks,
    I did try that line -- no difference
    SHIFTIN command is supposed to default at 8 bits
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-01-01 15:38
    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.

    [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
  • RinoRino Posts: 15
    edited 2009-01-01 16:01
    The 8 inputs of the 165 are connected to two bcd rotary switches with pull-up resistors (10k) Rotating the switches seem to not affect the display.· The switches common is connected to ground.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-01-01 17:03
    Your program is pretty much the same as that in the Parallax demo, except for the pins you're using for DataIn (which you call Out) and Load.
    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.
  • kelvin jameskelvin james Posts: 531
    edited 2009-01-02 03:39
    As a matter of interest, try dropping all of your own debug code, and use the original to see what you get.
  • RinoRino Posts: 15
    edited 2009-01-02 12:57
    I used the file attachement in the preceding post -- same problem, eratic display and about 3 switches seem to affect the display. Rewired the circuit a few times and tried different 74hc165 components.

    Thanks
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-01-05 00:31
    Today, I built the 74165 circuit on a piece of experimenter board (pic attached), as shown in StampWorks_V2, p.137 (Clk = P0, Data = P1, Load = P2; program attached)·and tested it.· Works perfectly.

    Post Edit -- Added pics 260, 263

    Post Edited (PJ Allen) : 1/11/2009 6:19:38 PM GMT
    600 x 450 - 35K
    640 x 480 - 77K
    640 x 480 - 61K
  • RinoRino Posts: 15
    edited 2009-01-05 16:42
    Thanks for the reply.
    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
Sign In or Register to comment.