Shop OBEX P1 Docs P2 Docs Learn Events
74hc595 serial to serial using shiftin — Parallax Forums

74hc595 serial to serial using shiftin

lfreezelfreeze Posts: 174
edited 2005-11-15 19:07 in BASIC Stamp
Can anyone share some code with me? I am attempting to connect a 74hc595 to a [url=mailto:BS2@stampn]BS2[/url]. I am reading clocked data at
a very slow rate into the 595.· My problem is in reading the data out (serial) via Q7'. My objective in this is to save
some stamp pins by reading it out in serial format, instead of parallel. I've read most of the previous posts and can't
find any examples that help. This is really frustrating and I am beginning to think that the 595 chip may be the wrong
selection. Any help would be greatly appreciated

Larry··

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2005-11-14 23:55
    I have just last week been doing some experiments with the 74HC164, the·biggest difference is that the '595 has a tri-state output.·
    The SHIFTOUT command worked, but I made this up intending to use it with a BS1 (it has no SHIFTOUT.)· My program uses a Button-push for manual Clocking and 'Bit Testing'.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' Adventures with the 74xx164 SIPO
    ' Manual Bit Shifting, Doesn't use SHIFTOUT
    ' MSB Goes First so that LSB is on SIPO's Bit0 output
    TR      VAR Nib      'Trial
    EX      VAR Byte     'Example Byte to SIPO
    BW      VAR Bit
    BP      VAR Byte     'Bit Position
    RB      VAR Bit      'Result Bit from EX & BP
    Prelims:
       DIRS = $0F        'MSB INs, LSB OUTs -- P0=D, P1=CLK, P8=Btn, P2 = /MR
       OUTL = %00000100  'preset OUTs; P2=1; P1,0 = 0
       INH  = %00000000  'preset INs; button bit0, Term bit1
    EX = %11110001
    Begin:
       TR = 0
       BP = $80
       PULSOUT 2,50    'CLEAR SIPO OUTs
       PAUSE 250       'need for using BUTTON
       FOR TR = 0 TO 8
       Push:
         BUTTON 8,1,255,0,BW,1,Got1
         GOTO Push
       Got1:
         IF TR = 8 THEN Begin
         GOSUB Bit_Test
         OUT0 = RB
         PULSOUT 1,25
         BP = BP / 2
         PAUSE 250
         NEXT
       Bit_Test:
         IF EX & BP = 0 THEN Zero
         GOTO One
       Zero:
         RB = 0
         RETURN
       One:
         RB = 1
         RETURN
    
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-15 00:07
    What are you trying to accomplish? The 74HC595 is used to create outputs -- why do you want to read the serial output? You can use SHIFTIN to do it, but I don't know what it buys you....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • lfreezelfreeze Posts: 174
    edited 2005-11-15 00:58
    Thanks for the quick response... briefly described, I am receiving a· serial byte via a radio link. Each bit is clocked and

    cascaded into the 595. I thought it would be simpler (less code and wiring) to read it serially at the byte level out to the stamp.

    and have the stamp react to the different numbers that would wind up as control character for a variety of tasks.

    Would it be easier to use shiftin for each bit and then combine the result as a single byte? If· this is true, I should be able

    to remove the 595 completely.

    ·Larry
  • SteelSteel Posts: 313
    edited 2005-11-15 01:11
    I think you may be confused.· The 74595 is a Serial to Parallel converter.· It sounds like you are looking for a parallel to serial converter, which is a 74HC165.

    You would use a 74595 to output serial from the BS2·SEROUT command.· You would use a ·74165 to input serial into the BS2 with a SERIN command.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-11-15 02:05
    Steel -

    Neither chip works with SERIN or SEROUT, rather, both work with SHIFTIN or SHIFTOUT, as appropriate. Both are synchronously serial accessed chips. SERIN/SEROUT is for asynchronous serial accessing.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 11/15/2005 2:08:13 AM GMT
  • lfreezelfreeze Posts: 174
    edited 2005-11-15 12:48
    Thanks for the responses.....Let me describe in a little more detail what I am attempting to do....

    1.···· load a byte of data· (from an external source) bit by clocked bit into the 595

    2.···· store this data for x amount of time.

    3.··· ·using the stamp to control the output, read out the data (shiftin) ·as a byte into the stamp

    4.··· using the stamp, read the· byte of data and take various actions based on the value of the data

    I· thought the 595 would work as the data sheet describes it functionality· as (8-bit serial in, serial or parallel out)

    I can get the 595 to work using its parallel output, but my objective is to limit the amount of stamp pins needed

    to read the data, and simplify the wiring. I don't have much experience with this and feel frustrated at my inability

    to make it work, suggestions are really welcome and appreciated.

    Larry,
  • NewzedNewzed Posts: 2,503
    edited 2005-11-15 13:00
    Connect the output of the 595 to the inputs of a 74HC165.· The 165 is parallel in, serial out.· You can read the incoming byte·with 3 Stamp I/Os.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2005-11-15 13:16
    OK,·Mr Freeze,

    Help us to help you -- by posting what you have.

    It seems to me that you could effect a serial output from the 74595's Q7 (pin 7 -- or by taking inverted data from pin 9) output by clocking through the bits.· That is, once you have your "8", then Q7 becomes the 1st bit "out" (FIFO'ing: first in, first out), succeeding bits will shift over/through on succeeding CLOCKs.· So,·at the end of 7 CLOCKs further, the last bit of your original "8" will be at Q7.

    N.B.,
    • /OE (pin 13) must be LO
    • /SRCLR (pin 10) must be HI.

    You'll need to be mindful that·in the process of transferring these bits out, the shift register·will be·taking bits in behind·them, too.
  • lfreezelfreeze Posts: 174
    edited 2005-11-15 19:07
    Thanks everyone..... After looking at the options, I will purchase some 74hc165's and interface the 595 to it.

    It will acomplish the objective of using fewer stamp pins as compared to connecting the 595 in parallel mode to

    the stamp. It will also give me some additional control as I can store the data in the 165 and control the data going

    into the stamp via the 165 clock
Sign In or Register to comment.