View previous topic :: View next topic |
Author |
Message |
matheuslps
Joined: 29 Sep 2010 Posts: 73 Location: Brazil
|
Multiple 74595 at different rates (each one separately) |
Posted: Tue Feb 19, 2013 8:18 pm |
|
|
I am using 4 74595 chips and the default CCS library. Each one have his duty. Example: 1 control 8 cathodes from 7-segment display. Another one control the 7-segments inputs, ABCDEFG. The other two make other tasks. I can make it work like this (the default way):
Code: | while (TRUE)
{
if (p1) //every 500mS
{
mask[0] = seg[n]; //Call the array digit for 7-segment
write_expanded_outputs(mask);
n++;
p1 = 0;
}
} |
But I have 4 two-digit 7-segment display. So, in total I have 8 cathodes to control. easy, right? Just use the other 74595 and shift through the cathodes. So I need to do this two tasks at different rates. Maybe call the digit routine every 500ms and the cathodes routine every 30ms, something like this.
Well, I tried to make a timer interrupt and call the write_expanded_outputs command inside there. But I do not know how will I call the write_expanded_outputs command for an specific mask.
Let me explain:
I have arrays that holds my output states like ABCDEFG outputs, cathode var and etc.
I know that write_expanded_outputs is a destroyable command, so I created a mask[] variable to hold the others arrays...OK
My variable mask[] length is 4: mask[4]. So I decided for now:
mask[0] ---> one duty
mask[1] ---> 7 segment input, ABCDEF
mask[2] ---> another task
mask[3] ----> cathode shifting, just a 0b00000001 and:
Code: | rotate_left( &cathodes, 1);
mask[3] = cathodes; |
So how can I use the write_expanded_outputs command to output a specific mask[] ? If I can do it, I can call them at different rates. I will need that. I tried:
Code: | write_expanded_outputs(&mask[3]); |
No luck.
Sorry for bad english mistakes.
Thanks.
Last edited by matheuslps on Wed Feb 20, 2013 8:20 pm; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Feb 20, 2013 5:29 am |
|
|
For multiplexed displays, it's usual to control both cathodes and anodes at the same rate.
Show us how you've got everything connected. That way we all can see what you're trying to do.
Mike
EDIT. ASCII art will do. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19383
|
|
Posted: Wed Feb 20, 2013 8:55 am |
|
|
Or, just use a sub multiple of the same rates.
So single routine at (say) 50mSec. Every call updates one cathode position. Every eighth call, when the cathode loops back to zero, also updates one anode position.
You want the updates to be _synchronous_ to one another, or you will get beating problems, so you don't want separate timers.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
matheuslps
Joined: 29 Sep 2010 Posts: 73 Location: Brazil
|
|
Posted: Wed Feb 20, 2013 12:29 pm |
|
|
I get the idea that both of you posted.
But my question is not direct to the displays.
I think that the 74595.C library can control the number n of chips at the same time. BUT I want to control each 74595 separately.
Every time I use the command:
write_expanded_outputs(mask);
The library writes on all the chips.
P.S: The circuit for the displays:
http://img.photobucket.com/albums/v222/ahhh/circuit_displays_test.png
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19383
|
|
Posted: Wed Feb 20, 2013 12:39 pm |
|
|
There are two ways of doing this. In the first, the chips are cascaded. Like this, you need to change the line in the driver, to say how many chips you have, and physically cascade them. Then all chips are always accessed.
Alternatively, use a second set of I/O lines, and have two drivers. On the second, change the name of the write_expanded_outputs call to (say) write_expanded_outputs2, and set the second driver to use the second set of I/O lines. The drivers are then completely separate.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
matheuslps
Joined: 29 Sep 2010 Posts: 73 Location: Brazil
|
|
Posted: Wed Feb 20, 2013 1:03 pm |
|
|
Quote: | Alternatively, use a second set of I/O lines, and have two drivers. |
Well, for now this is the best shot. Like Mike Walne said, it's usual to control both cathodes and anodes at the same rate. In this way I can use 2 74595 and one routine.
For the other two 74595's I will create another 2 calls. I will spend 9 I/O lines from my PIC...
Well, I have the 9 lines free. Lets make it work....
Coding now......
Thanks again. |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Feb 20, 2013 1:56 pm |
|
|
Quote: |
use a second set of I/O lines
|
A way that i have controlled multiple SPI devices ( as that is what a '595 IS)
combines ALL shift_clock and all IN_data in parallel and to
THEN
individually toggle the Register_L/S ( load_shift) control. Then you never have to shift more than 8 bits.
Up to 8 595's can be so controlled with 3 pic lines and a HC238. |
|
![](templates/subSilver/images/spacer.gif) |
matheuslps
Joined: 29 Sep 2010 Posts: 73 Location: Brazil
|
|
Posted: Wed Feb 20, 2013 2:47 pm |
|
|
@asmboy, I got your idea, but I read the 74HC238 and this chips has 3 i/o input. If I use it, i will need 3 lines for it and 2 lines for the 74HC595. Right?
bye |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Feb 20, 2013 2:55 pm |
|
|
You need one extra a chip enable line for the 238
if using 8 '495s but the 2 chip combo will give the fastest possible updates to any of the 8 '595's using EITHER the hardware SPI features of the pic - (fastest) or the bit-banging method ( slower) of the example driver file.
The R clock selector MUX means you never output
more than a single SPI byte or 8 bit banged 'bits' of I/O -
Only TWO port masked operations needed for rclock can select and deselect a 595 chip ( if one of 7 '238 outs '0' address used as idle ).
I am a big believer in using extra chips to improve performance, and on the lookout for new ways to do that. |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Feb 20, 2013 3:42 pm |
|
|
Your schematic has only served to confuse me.
1) Schematic has to be worked on to show the connections.
2) The PNP drivers (as shown) MUST be ANODE drivers NOT cathode as you state.
3) There appears to be no current limiting to the PNP bases.
4) Are you using common ANODE or common CATHODE displays?
Please clarify
Mike
EDIT You seem to be in the process of changing your approach.
Let us know when you firm up on a decision. |
|
![](templates/subSilver/images/spacer.gif) |
matheuslps
Joined: 29 Sep 2010 Posts: 73 Location: Brazil
|
|
Posted: Wed Feb 20, 2013 8:11 pm |
|
|
@Mike Walne
Sorry, I reviewed the link that I posted and it was wrong. I will not change that file to not break the topic dinamic. But did another one.
Quote: | 1) Schematic has to be worked on to show the connections. |
Sure. Made another one. Below....
Quote: | 2) The PNP drivers (as shown) MUST be ANODE drivers NOT cathode as you state. |
My mistake. Typo error. The correct is ANODES.
Quote: | ) There appears to be no current limiting to the PNP bases. |
yes! Corrected.
Quote: | Are you using common ANODE or common CATHODE displays? |
Common CATHODE!
And yes, I am changing the approach. I have some pins free, so for now I will use Ttelmah's sugestion and make 3 different calls.
The asmboy's sugestion is valid but I do not have HC238 to test. I am ordering some online (7 days to arrive).
The new circuit (Part of it. There are some other tasks)
EDIT: Folks from photobucket are messing things aroung this days. Sometimes I post a DIRECT LINK and it is redirected to the main site. OR this is a problem with new version 19 from Firefox
http://img.photobucket.com/albums/v222/ahhh/circuit_test_display_595_2.png
I think that i did not forget anything on the circuit.... I know that this forum is not a circuit forum. But you all helped a lot.
EDIT:
I will use Mike Walne's sugestion to call anodes and cathodes at the same time. I thought better and is the logic better way :d
Lets code... Calvin Harris - Sweet Nothing (feat. Florence Welch)
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Thu Feb 21, 2013 9:25 am |
|
|
When you code, bear in mind the sequence needs to go something like:-
1) Turn ALL cathodes OFF.
2) Set up Anodes for next digit.
3) Turn on cathode for appropriate digit.
4) Wait for fixed time interval.
5) Loop back to 1.
You'll get ghosting if you don't turn OFF all cathodes whilst changing the anodes.
Mike |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19383
|
|
Posted: Thu Feb 21, 2013 9:54 am |
|
|
The data pins, can be the same in each copy of the driver. You only need a different select line.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
matheuslps
Joined: 29 Sep 2010 Posts: 73 Location: Brazil
|
|
Posted: Thu Feb 21, 2013 12:33 pm |
|
|
@Mike Walne, Thanks for that tip. I did not know that.
@Ttelmah, Quote: | You only need a different select line. |
Select line will be pin 13, (!OE), right?
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Thu Feb 21, 2013 6:10 pm |
|
|
To get maximum brightness you need to spend as little time as possible with the display turned OFF.
I don't have '595s, but I can see two possible tricks.
1) Use the OE pin to disable the O/Ps rather then transmitting new data.
2) Whilst the display is turned ON, send the data for the next digit, but wait until its needed before latching to the O/Ps.
Mike |
|
![](templates/subSilver/images/spacer.gif) |
|