Shop OBEX P1 Docs P2 Docs Learn Events
help with 74hc165 shift register — Parallax Forums

help with 74hc165 shift register

remmi870remmi870 Posts: 79
edited 2009-02-11 18:12 in BASIC Stamp
im having problems getting my 74hc165 parallel to serial shift register to work with my bs2, ive connected it up the way i think it should be with the data line, clock line, and load input.
here is my code
CS············· PIN···· 0······················ ' chip select
AData·········· PIN···· 1······················ ' data pin
Clk············ PIN···· 2······················ ' clock pin
adcRes········· VAR···· Byte··················· ' result

Setup:
HIGH CS······································
Main:
· DO
··· LOW· cs
··· SHIFTIN AData, Clk, LSBPOST, [noparse][[/noparse]adcRes\9]···· ' shift in the data
··· HIGH cs
··· DEBUG HOME
··· DEBUG DEC ? adcRes
··· PAUSE 1000································· ' wait one second
· LOOP········································· ' repeat
· END

right now when i run the program if i connect a pin to logic high, i get a random number output, if i disconnect the pin it stays at 255, any help?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-02-11 17:37
    Hello,

    First it looks like you’re using the example code for the ADC0831, which won’t work here…not exactly. Another issue is if you’re input on your 74xx165 are floating, you can’t be sure of what value they will read when shifted in. All 8 inputs must be defined before the shift for you to get the expected data.

    The Stamp Works manual has an example of reading the 74xx165 shift register. You can download the manual and example code free at the following link. I hope this helps. Take care.

    http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/StampWorks/List/1/ProductID/329/Default.aspx?SortField=ProductName%2cProductName

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • remmi870remmi870 Posts: 79
    edited 2009-02-11 17:46
    so i would have to tie all the inputs to either low or high so it will set the pins, like tieing a transistor base to ground to keep it from saturating, thanks for the help, i just wanted to get it to work first, i plan on having a few boards with a hc595 and a hc165 so i can easily add ouputs and inputs to my projects without having to use up all my pins.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-02-11 18:12
    Correct, and the material I referenced shows how to connect both and share clock and data lines to conserve I/O pins.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
Sign In or Register to comment.