multiple 74hc595 devices
Archiver
Posts: 46,084
Any code examples of how to communicate to multiple 74hc595 devices?
I want to turn on 48 LEDs one at a time in sequence until all 48 LEDs
are on, then turn them off, then start all over. I'll use 6 595s but
right now I have three linked. All RCK and SRCK lines are tied
together and the first serout is connected to the second device serin
(pin 9-to-14) and the second to the third.
Thanks,
Guy
I want to turn on 48 LEDs one at a time in sequence until all 48 LEDs
are on, then turn them off, then start all over. I'll use 6 595s but
right now I have three linked. All RCK and SRCK lines are tied
together and the first serout is connected to the second device serin
(pin 9-to-14) and the second to the third.
Thanks,
Guy
Comments
in the number of bits you want to get to. In other words if you want to
read the second 8 bits from the second 595 shift in 16 bits (with the \16
modifier). I am not sure what the limit is on number of bits to shift but
if it is smaller than 48 then you will need to do it in a loop and store the
first bits until you get all the ones you need. Sounds like a pain but
remember the chip is guaranteed to shift releabily up to 30 Mhz so you won't
be wasting much time..
Ok, I just looked, you can shift in up to 16 bits at a time, so simply
shift in 16, store them and repeat that 2 more times to get all 48 bits.
Depending on which chip you are using it will shift in at about 42 Khz which
is pretty fast.
Mike B.
P.S. Every where I said "shift in", replace it with shift out ! I'll
always get the LS165 and LS595 mixed up but the functions are identical in
operation.
. mb
Original Message
From: "digital_interior" <guyb@m...>
To: <basicstamps@yahoogroups.com>
Sent: Wednesday, September 04, 2002 9:57 AM
Subject: [noparse][[/noparse]basicstamps] multiple 74hc595 devices
> Any code examples of how to communicate to multiple 74hc595 devices?
> I want to turn on 48 LEDs one at a time in sequence until all 48 LEDs
> are on, then turn them off, then start all over. I'll use 6 595s but
> right now I have three linked. All RCK and SRCK lines are tied
> together and the first serout is connected to the second device serin
> (pin 9-to-14) and the second to the third.
>
> Thanks,
> Guy
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
together; data goes from the Stamp and daisy-chains through. Simple. If you
have this setup:
[noparse][[/noparse]Stamp]-->[noparse][[/noparse]A]-->[noparse][[/noparse]B]-->[noparse][[/noparse]C]-->[noparse][[/noparse]D]-->[noparse][[/noparse]E]-->[noparse][[/noparse]F]
... you need to make sure that you shift the data for unit F out first. The
data for unit E will push it along, and so-forth until the data for unit A
has been shifted out. At that point, you would pulse the latch pin(s) to
move the new data to the outputs.
So, your output commands will look like this:
SHIFTOUT dPin, cPin, MSBFirst, [noparse][[/noparse]unitF, unitE, unitD, unitC, unitB, unitA]
PULSOUT Latch, 5
Hope this helps.
-- Jon Williams
-- Parallax
In a message dated 9/4/02 5:08:48 PM Central Daylight Time, w6ffc@p...
writes:
> Guy I'll check to make sure, but I think it is simply a matter of shifting
> in the number of bits you want to get to. In other words if you want to
> read the second 8 bits from the second 595 shift in 16 bits (with the \16
> modifier). I am not sure what the limit is on number of bits to shift but
> if it is smaller than 48 then you will need to do it in a loop and store the
> first bits until you get all the ones you need. Sounds like a pain but
> remember the chip is guaranteed to shift releabily up to 30 Mhz so you won't
> be wasting much time..
>
> Ok, I just looked, you can shift in up to 16 bits at a time, so simply
> shift in 16, store them and repeat that 2 more times to get all 48 bits.
> Depending on which chip you are using it will shift in at about 42 Khz which
> is pretty fast.
>
> Mike B.
>
> P.S. Every where I said "shift in", replace it with shift out ! I'll
> always get the LS165 and LS595 mixed up but the functions are identical in
> operation.
> . mb
>
>
Original Message
> From: "digital_interior" <guyb@m...>
> To: <basicstamps@yahoogroups.com>
> Sent: Wednesday, September 04, 2002 9:57 AM
> Subject: [noparse][[/noparse]basicstamps] multiple 74hc595 devices
>
>
> > Any code examples of how to communicate to multiple 74hc595 devices?
> > I want to turn on 48 LEDs one at a time in sequence until all 48 LEDs
> > are on, then turn them off, then start all over. I'll use 6 595s but
> > right now I have three linked. All RCK and SRCK lines are tied
> > together and the first serout is connected to the second device serin
> > (pin 9-to-14) and the second to the third.
> >
> > Thanks,
> > Guy
> >
>
[noparse][[/noparse]Non-text portions of this message have been removed]
and the serial data from the stamp to "A" out of "A" to "B" out
of "B" to "C". I can shift out 16 bits of data MSBfirst to the device
chain and get correct results on the devices "A" and "B". What is
happening is device "C" seems to be getting that same data as "A".
Device "C" outputs are a copy of "A".
Then I tried shifting out 8 bits of data to the device chain and
again the same, device "C" was displaying output status identical
to "A" and Device "B" was idle (no output change).
What are your thoughts?
Guy
--- In basicstamps@y..., jonwms@a... wrote:
> It's not tough to use multiple '595s. Connect the clock and latch
lines
> together; data goes from the Stamp and daisy-chains through.
Simple. If you
> have this setup:
>
> [noparse][[/noparse]Stamp]-->[noparse][[/noparse]A]-->[noparse][[/noparse]B]-->[noparse][[/noparse]C]-->[noparse][[/noparse]D]-->[noparse][[/noparse]E]-->[noparse][[/noparse]F]
>
> ... you need to make sure that you shift the data for unit F out
first. The
> data for unit E will push it along, and so-forth until the data for
unit A
> has been shifted out. At that point, you would pulse the latch pin
(s) to
> move the new data to the outputs.
>
> So, your output commands will look like this:
>
> SHIFTOUT dPin, cPin, MSBFirst, [noparse][[/noparse]unitF, unitE, unitD, unitC,
unitB, unitA]
> PULSOUT Latch, 5
>
> Hope this helps.
>
> -- Jon Williams
> -- Parallax
>
>
> In a message dated 9/4/02 5:08:48 PM Central Daylight Time,
w6ffc@p...
> writes:
>
>
> > Guy I'll check to make sure, but I think it is simply a matter of
shifting
> > in the number of bits you want to get to. In other words if you
want to
> > read the second 8 bits from the second 595 shift in 16 bits (with
the \16
> > modifier). I am not sure what the limit is on number of bits to
shift but
> > if it is smaller than 48 then you will need to do it in a loop
and store the
> > first bits until you get all the ones you need. Sounds like a
pain but
> > remember the chip is guaranteed to shift releabily up to 30 Mhz
so you won't
> > be wasting much time..
> >
> > Ok, I just looked, you can shift in up to 16 bits at a time, so
simply
> > shift in 16, store them and repeat that 2 more times to get all
48 bits.
> > Depending on which chip you are using it will shift in at about
42 Khz which
> > is pretty fast.
> >
> > Mike B.
> >
> > P.S. Every where I said "shift in", replace it with shift
out ! I'll
> > always get the LS165 and LS595 mixed up but the functions are
identical in
> > operation.
> > . mb
> >
> >
Original Message
> > From: "digital_interior" <guyb@m...>
> > To: <basicstamps@y...>
> > Sent: Wednesday, September 04, 2002 9:57 AM
> > Subject: [noparse][[/noparse]basicstamps] multiple 74hc595 devices
> >
> >
> > > Any code examples of how to communicate to multiple 74hc595
devices?
> > > I want to turn on 48 LEDs one at a time in sequence until all
48 LEDs
> > > are on, then turn them off, then start all over. I'll use 6
595s but
> > > right now I have three linked. All RCK and SRCK lines are tied
> > > together and the first serout is connected to the second device
serin
> > > (pin 9-to-14) and the second to the third.
> > >
> > > Thanks,
> > > Guy
> > >
> >
>
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
It depends on how you are writing your code. For
example, if you have three 595's strung together, the
end of your SHIFTOUT command could have
[noparse][[/noparse]128\8,0\16]which would turn on (or off) the last
output of the last 595 in the chain.
Hope this helps
Chuck
--- digital_interior <guyb@m...> wrote:
> I do have the units connected with clock and latch
> going to all three
> and the serial data from the stamp to "A" out of "A"
> to "B" out
> of "B" to "C". I can shift out 16 bits of data
> MSBfirst to the device
> chain and get correct results on the devices "A" and
> "B". What is
> happening is device "C" seems to be getting that
> same data as "A".
> Device "C" outputs are a copy of "A".
>
> Then I tried shifting out 8 bits of data to the
> device chain and
> again the same, device "C" was displaying output
> status identical
> to "A" and Device "B" was idle (no output change).
>
> What are your thoughts?
> Guy
>
> --- In basicstamps@y..., jonwms@a... wrote:
> > It's not tough to use multiple '595s. Connect the
> clock and latch
> lines
> > together; data goes from the Stamp and
> daisy-chains through.
> Simple. If you
> > have this setup:
> >
> > [noparse][[/noparse]Stamp]-->[noparse][[/noparse]A]-->[noparse][[/noparse]B]-->[noparse][[/noparse]C]-->[noparse][[/noparse]D]-->[noparse][[/noparse]E]-->[noparse][[/noparse]F]
> >
> > ... you need to make sure that you shift the data
> for unit F out
> first. The
> > data for unit E will push it along, and so-forth
> until the data for
> unit A
> > has been shifted out. At that point, you would
> pulse the latch pin
> (s) to
> > move the new data to the outputs.
> >
> > So, your output commands will look like this:
> >
> > SHIFTOUT dPin, cPin, MSBFirst, [noparse][[/noparse]unitF, unitE,
> unitD, unitC,
> unitB, unitA]
> > PULSOUT Latch, 5
> >
> > Hope this helps.
> >
> > -- Jon Williams
> > -- Parallax
> >
> >
> > In a message dated 9/4/02 5:08:48 PM Central
> Daylight Time,
> w6ffc@p...
> > writes:
> >
> >
> > > Guy I'll check to make sure, but I think it is
> simply a matter of
> shifting
> > > in the number of bits you want to get to. In
> other words if you
> want to
> > > read the second 8 bits from the second 595 shift
> in 16 bits (with
> the \16
> > > modifier). I am not sure what the limit is on
> number of bits to
> shift but
> > > if it is smaller than 48 then you will need to
> do it in a loop
> and store the
> > > first bits until you get all the ones you need.
> Sounds like a
> pain but
> > > remember the chip is guaranteed to shift
> releabily up to 30 Mhz
> so you won't
> > > be wasting much time..
> > >
> > > Ok, I just looked, you can shift in up to 16
> bits at a time, so
> simply
> > > shift in 16, store them and repeat that 2 more
> times to get all
> 48 bits.
> > > Depending on which chip you are using it will
> shift in at about
> 42 Khz which
> > > is pretty fast.
> > >
> > > Mike B.
> > >
> > > P.S. Every where I said "shift in", replace
> it with shift
> out ! I'll
> > > always get the LS165 and LS595 mixed up but the
> functions are
> identical in
> > > operation.
> > > . mb
> > >
> > >
Original Message
> > > From: "digital_interior" <guyb@m...>
> > > To: <basicstamps@y...>
> > > Sent: Wednesday, September 04, 2002 9:57 AM
> > > Subject: [noparse][[/noparse]basicstamps] multiple 74hc595 devices
> > >
> > >
> > > > Any code examples of how to communicate to
> multiple 74hc595
> devices?
> > > > I want to turn on 48 LEDs one at a time in
> sequence until all
> 48 LEDs
> > > > are on, then turn them off, then start all
> over. I'll use 6
> 595s but
> > > > right now I have three linked. All RCK and
> SRCK lines are tied
> > > > together and the first serout is connected to
> the second device
> serin
> > > > (pin 9-to-14) and the second to the third.
> > > >
> > > > Thanks,
> > > > Guy
> > > >
> > >
> >
> >
> >
> >
> > [noparse][[/noparse]Non-text portions of this message have been
> removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
bits to fill your devices. If you have three devices, you should shift 24
bits (three bytes, one per 595) and then latch the outputs.
I would suggest using byte variables for your 595 data -- it will be easier
for you to do testing with by using specific values (output patterns) and
testing your output subroutine.
-- Jon Williams
In a message dated 9/4/02 8:19:20 PM Central Daylight Time, guyb@m...
writes:
> I do have the units connected with clock and latch going to all three
> and the serial data from the stamp to "A" out of "A" to "B" out
> of "B" to "C". I can shift out 16 bits of data MSBfirst to the device
> chain and get correct results on the devices "A" and "B". What is
> happening is device "C" seems to be getting that same data as "A".
> Device "C" outputs are a copy of "A".
>
> Then I tried shifting out 8 bits of data to the device chain and
> again the same, device "C" was displaying output status identical
> to "A" and Device "B" was idle (no output change).
>
> What are your thoughts?
>
[noparse][[/noparse]Non-text portions of this message have been removed]
Thanks for all the help. See if this makes any sense to you guys:
I took all the suggestions, reviewed and tweaked my code last night.
In my case what I did was indeed to break up my data into "word" size
variables (16-bit blocks of data for each pair of 595s in the chain,
a pair represents the 16-bits). So, with my 4 595 devices I only
needed to deal with two 16-bit, "word" size variables. Then
sent/shifted these variables out in the reverse order (last pair of
devices first). I suppose if I broke out my data into "byte" size
variables (8-bit blocks of data for each individual 595 in the chain)
I would then send/shift out these 8-bit variables in the reverse
order of each device in the chain, needing four 8-bit "byte" size
variables.
Now I'm off to get more 595 devices for my prototyping.
Thanks again.
Guy
--- In basicstamps@y..., jonwms@a... wrote:
> I think you're latching the outputs before you should and not
shifting enough
> bits to fill your devices. If you have three devices, you should
shift 24
> bits (three bytes, one per 595) and then latch the outputs.
>
> I would suggest using byte variables for your 595 data -- it will
be easier
> for you to do testing with by using specific values (output
patterns) and
> testing your output subroutine.
>
> -- Jon Williams
>
>
> In a message dated 9/4/02 8:19:20 PM Central Daylight Time,
guyb@m...
> writes:
>
>
> > I do have the units connected with clock and latch going to all
three
> > and the serial data from the stamp to "A" out of "A" to "B" out
> > of "B" to "C". I can shift out 16 bits of data MSBfirst to the
device
> > chain and get correct results on the devices "A" and "B". What is
> > happening is device "C" seems to be getting that same data
as "A".
> > Device "C" outputs are a copy of "A".
> >
> > Then I tried shifting out 8 bits of data to the device chain and
> > again the same, device "C" was displaying output status identical
> > to "A" and Device "B" was idle (no output change).
> >
> > What are your thoughts?
> >
>
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
guyb@m... writes:
> Now I'm off to get more 595 devices for my prototyping.
>
For Guy
Did you know you can do what you want with 2 595's ?
48 LEDs can be handled by a 6 x 8 matrix.
For example, connect 8 LEDs to Qh on the first chip. Connect the ground lead
of one LED to Qh on the second chip, the next LED to Qg, the next to Qf, and
so on. Then write
start
low latch
pulsout dout, clk, lsbfirst, [noparse][[/noparse]%11111110] 'turns on first LED
pulsout dout, clk, lsbfirst, [noparse][[/noparse]%00000001]
pulsout latch, 10
low latch
pause 500
low latch
shiftout dout, clk, lsbfirst, [noparse][[/noparse]%111111100] 'turns on 2nd LED
shiftout dout, clk, lsbfirst, [noparse][[/noparse]%00000001]
pulsout latch, 10
low latch
pause 500
and so on for the next 6 LEDs
goto start
I'm sure you can figure out the programming for the 8 LEDs connected to Qg,
Qf, and so on. When you get thru there will be 8 LEDs on Qa thru Qh, and one
the second chip 8 LEDs to Qh thruQc.
Also, did you know you can use decimal numbers instead of binary ?
Shiftout dout, clk, lsbfirst, [noparse][[/noparse]253]
is the same as
shiftout dout, clk, lsbfirst, [noparse][[/noparse]%11111101]
and a lot less typing.
Sid Weaver - W4EKQ
< < < <
Christmas is coming
Remember - Fumpus tegit .
[noparse][[/noparse]Non-text portions of this message have been removed]