Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: cjcj on Mar 15, 2015, 01:34 am

Title: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 15, 2015, 01:34 am
Hi.
I'm a bit new to Arduino and have a question on a project I'm doing.  I created a project out of discrete components and now am trying to replicate it to code so that I can have more flexibility and simplify the electronics.

I've written code for a minute/second timer (mm:ss) via 4 off 7 segment displays.  To minimize outputs, I've multiplexed the displays.  Seems to work ok so far.  I'm now trying to incorporate an LDR in the circuitry to control the intensity (darker at night and lighter during the day).

I've tried reading the LDR signal and feeding it to the commons in the mutiplex.  Doesn't work properly.  Is this because I'm using CC digits?  Should they instead by CA?  If so, in the short term, is there an easy way of re-coding to use my CC digits.  Attached is the code.  Part of the code (that I tried to alter) is as follows:

Code: [Select]

  if(stepMultiplex == 1 && (currentMillis - previousMillis) >= delayMp) {
    digitalWrite(commons [0],B);
    previousMillis=currentMillis;
    sevenSegWrite_1(sec_ones);
    digitalWrite(commons [3],A);
    stepMultiplex=2;

Tried to change to:
Code: [Select]

  if(stepMultiplex == 1 && (currentMillis - previousMillis) >= delayMp) {
    digitalWrite(commons [0],B);
    previousMillis=currentMillis;
    sevenSegWrite_1(sec_ones);
    digitalWrite(commons [3],dValue);  // where dValue is the mapped analog value from the LDR
    stepMultiplex=2;
Title: Re: LDR with 7 seg display and PWM output
Post by: UKHeliBob on Mar 15, 2015, 01:22 pm
Quote
Doesn't work properly.
What does it do that is wrong ?  Does it work predictably if you set the value variable to a fixed number rather than calculating it ?  Have you tried printing the value variable and if so what range of values do you get ?  How is the LDR wired ?
Title: Re: LDR with 7 seg display and PWM output
Post by: Paul__B on Mar 15, 2015, 10:19 pm
Need to read the "How to Post (http://forum.arduino.cc/index.php/topic,148850.0.html)".

All of it.

Seriously!
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 16, 2015, 11:37 am
What does it do that is wrong ?  Does it work predictably if you set the value variable to a fixed number rather than calculating it ?  Have you tried printing the value variable and if so what range of values do you get ?  How is the LDR wired ?
Need to read the "How to Post (http://forum.arduino.cc/index.php/topic,148850.0.html)".

All of it.

Seriously!

Need to read the "How to Post (http://forum.arduino.cc/index.php/topic,148850.0.html)".

All of it.

Seriously!

Thanks Paul for that link and sorry - first time user in this forum.  I'll use it in future.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 16, 2015, 11:58 am
What does it do that is wrong ?  Does it work predictably if you set the value variable to a fixed number rather than calculating it ?  Have you tried printing the value variable and if so what range of values do you get ?  How is the LDR wired ?
Hi HeliBob.  Late yesterday I realized that my 7 segment digits being common cathode require a ground.  I was trying to feed the converted analog signal (between 0 and 255) to these pins.  So I replaced the digits with anode type, swapped the high and lows in the code and it started to work.  It was a bit dim, but I assume I need to constrain the analog values.  Sorry, I've been stumped for a week!

Can I just ask another question.  Am I approaching this the right way?  To minimize outputs I'm multiplexing via the commons of the digits delaying using the millis function.  Then to alter the intensity I'm using an LDR.  Ultimately I want to convert this to large LED sign run on 24V which will be run outdoors.
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 16, 2015, 09:53 pm
Hi,

Late yesterday I realized that my 7 segment digits being common cathode require a ground.  I was trying to feed the converted analog signal (between 0 and 255) to these pins.  So I replaced the digits with anode type, swapped the high and lows in the code and it started to work.
Assuming you mean you were connecting a pwm output to the common connection on the display, swapping the common cathode display for a common anode one can't be the reason it started working. Either type should work equally well.

Can I just ask another question.  Am I approaching this the right way?  To minimize outputs I'm multiplexing via the commons of the digits delaying using the millis function.  Then to alter the intensity I'm using an LDR.  Ultimately I want to convert this to large LED sign run on 24V which will be run outdoors.
For outdoor use you want to avoid multiplexing. It will be difficult enough to get them bright enough and multiplexing will make it much more difficult. Use common anode displays and drive each digit with a tpic6c595 high-current shift register.

Also, higher voltages will not give you any advantage if you are using manufactured displays. They must not be subjected to any voltage higher than their specification, or they will be damaged. For maximum brightness you need maximum current, but within the specification.

If you are making your own displays from individual leds, you can use many leds in series so that your 24V supply is appropriate.

Paul
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 17, 2015, 10:12 pm
Assuming you mean you were connecting a pwm output...
For outdoor use you want to avoid multiplexing...
Paul
Hi Paul.
Thanks for the reply.  It might therefore be that my resistance to the digits is not correct as it works for the anode (that end up dimming) but not for the cathode - that just stay bright.  I'll measure them tonight.

The digits that I'll be using outdoors are about 400 x 250 with LEDs connected in series and parallel with resistors to suit 24V.  It's just that these displays (a scoreboard) are driven by discrete components and I now what to drive it via code (for greater flexibility - and serviceability!).  The LEDs I bought from OS are quite bright and I'm even dimming them a bit during the day - hence I though multiplexing should work.  I might have to therefore test one before I go too far.

These are common anode.  I've fiddled with a small shift register a bit.  Why do you say this is a better way to go?  Chris.
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 17, 2015, 11:38 pm
Chris, I'm not sure I understand your question.

Multiplexing will reduce the average current in your digits to one half or one quarter compared to without. Reducing to one quarter current will aproximately half the apparent brightness.

My reason for recommending common anode is that this enables you to use the tpic6c595 shift registers I was describing.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 18, 2015, 10:28 pm
Multiplexing will reduce the average current... apparent brightness.

My reason for recommending common anode is that this enables you to use the tpic6c595 shift registers I was describing.
Sorry for the confusion.  History:  I made a sign (scoreboard) that has 15 large displays.  Each 7 segment digit is made up of an average 7 leds in series (with a 330 ohm resistor each) x 8 rows in parallel.  I'm currently running each LED somewhere between 12 to 15mA only in full daylight (given these are fairly bright units).  The total current draw per segment ends up either 120mA or 780mA.  These are being driven by discrete components - the leds via ULN2003's.  LED forward voltage is 2.7V.  Overall, max of 11.7Amps to run all digits if displaying "8" on each.

Now that I've found "Arduino", I've fallen in love!  I want to convert it to programming.  I will have to change the drivers, but I'm just trying to work out the "easiest" way for me to do the programming, use existing Arduino boards with whatever drivers I need.  But before that, I need to look at basics - yes as you said the display will be dimmer with multiplexing.

At this stage my idea is to drive only 4 of the digits with one Arduino Uno board, mulitiplexing only 4 digits.  This will 1/4 the intensity I think, if I give the same current (i.e. end result of 12 to 15mA each LED).  However, I "think" I can increase the current to 4 times as much (48 to 60mA?) as they are only on a quarter of the time.  Is this correct?  Would this give the same intensity?

Then comes the dimming during night time.  Is my suggestion of an LDR the way to go?
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 19, 2015, 12:19 am
Multiplexing 4 digits can be done two ways. First way is to light 2 digits, then the other 2. This gives a multiplex ratio of 1:2 or 50% because any digit is lit for 50% of the time. Second way is to light the first digit, then the second, then third and finally fourth digit. Multiplex ratio 1:4 or 25% because any digit is lit for 25% of the time. I assume you are suggesting the 1:4 ratio.

The level of brightness depends on the average current each led gets. To maintain the original brightness while changing to a 1:4 multiplex means that the instantaneous/peak current needs to be 4 times higher than it was without multiplexing.

The human eye is not linear. Half the average current does not look half as bright. One quarter of the average current will look around half as bright, very roughly speaking.

Your ldr idea should be ok. If using shift registers, they normally have an Output Enable pin. You can connect that to a pwm output on the arduino to dim the displays. If driving the displays with arduino pins, connect a separate pwm pin to each digit's common connection. Just be careful that the ldr is shielded from the light coming from the displays themselves, or wierd stuff will happen!
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 19, 2015, 09:55 am
Paul thank you so much for you time and patience.
Yes, I am considering the option of 1:4 ratio.  The spec sheet for the LEDs I have suggests a peak forward current of 50mA.  Is it safe to push it to this limit in the 1:4 ratio, or should I be dropping it even further (if the intensity is still ok)?

I see what you mean about non - linear.  That's why from 20mA to 12mA I can't really see too much difference.  I never knew why.

Yes I did connect a separate pwm pin to each digit common.  I'm not too confident however using a shift register.  I'll do more homework on this then maybe ask you some more questions down the track once I've studied up on it (if that's ok).
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 19, 2015, 05:02 pm
Hi, on better quality data sheets for leds, it will give a duty cycle and maximum pulse length to go along with that peak current figure. E.g. max continuous current 30mA, peak current 150mA with a 1:10 duty cycle and 1ms max pulse. In other words you can go up to 150mA but only for 1ms out of every 10ms. This limit of a 1ms pulse prevents the led getting too hot, and the 9ms before the next pulse allow it to cool again. In your design, the duty cycle (=multiplex ratio) is 1:4, so you can't go as high as that max, even for 1ms. Does your data sheet give any info about max pulse and duty cycles for that peak current? If not, well... its up to you. The leds might seem ok at 50mA but you might be shortening their life.

My shift register suggestion could be your "plan B" if the leds are not bright enough with the 1:4 multiplex. You would replace your uln2803 with a tpic6c595 or tpic6b595 shift register for each digit. Common anodes connected direct to 24V, then dim them by connecting the Output enable pins of all 4 shift regs to an arduino pwm output. No multiplexing, so you maintain your 12 to 15mA.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 19, 2015, 09:57 pm
Hi Paul.  I bought 8000 odd LEDs directly from a company in China.  They did send me a spec sheet at the time.  There is a mention of pulse width, but I don't understand it - something about "Ifp Conditions : Pulse Width < 10ms < 1/10".  Please see attached.

So the shift registers are in a way an extension of the arduino board pins (so that each pin can be individually wired rather than multiplexing).  I'll do some "googling" to see this setup.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 22, 2015, 11:22 am
I did end up being able to dim the common cathode with an LDR by changing the code as follows:
Code: [Select]

  if(stepMultiplex == 1 && (currentMillis - previousMillis) >= delayMp) {
    digitalWrite(commons [0],B);  // Turn off the previous digit once time expires
    previousMillis=currentMillis;
    sevenSegWrite_1(sec_ones);
    analogWrite(commons [3],dValue);  // Turn on the sec_one digit
    stepMultiplex=2;

Above I set B to HIGH.  To use the analogue value I change "digitalWrite" to "analogWrite".
To get the common anode working, the above also worked.

I'm now trying to work out how to work out the brightest I can make these (withing safety).  I cant however put everthing together as I don't understand the numbers.  The facts I have:



I really don't know how to apply the 1/10 duty cycle, 0.1ms pulse width and 160mA above and how the LDR affects this.  Can someone please explain it to me or point me to suitable link (as I can't find it clearly explained).
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 22, 2015, 06:20 pm
So, just let me check, we are now talking about driving these 0.5" 7 seg 4 digit displays directly with Arduino pins? No uln2803 like with the larger displays you began the thread with?

If so, the limiting factor will be the Arduino pins connected to the common anodes/cathodes. Max current should be 40mA for any output, but not continuous, or the Arduino's life may be shortened. You are multplexing 4 digits, so that max current will be on for 2ms off for 6ms for any one of those outputs, so not continuous.

40mA on the common anode/cathode means only 5.7mA per segment, when that digit is lit. With a 1:4 multiplex that corresponds to only 1.4mA per segment on average. May not be very bright, but see what you think of it.

So driving with the Arduino alone gets you nowhere near the max brightness of the display.

To increase the current to the display means using some transistors on those common anode/cathode pins. The limiting factor then becomes the overall current limit for the atmega328 or whatever chip your Arduino has. For atmega328 it is around 200mA. That limits us to around 7mA on average for each segment. Much better than 1.4mA, but still a long way from the max current for the display.

To reach the max current of the display segments, transistors will be needed on both anodes and cathodes.
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 23, 2015, 01:03 am
Hi, I will write a longer explanation for you, hopefully tomorrow. For now, do not run your display with 20R series resistors. You may damage the Arduino.

Paul
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 23, 2015, 09:16 am
Yes, given I can now see the displays change intensity, before I move onto my larger project (large digits), I want to first breadboard the smaller 0.5" 7 segment displays and understand them fully before moving on.

So if looking at a single digit, I connect a current limiting resistor to each segment - based on R=V/I = (5-2.5)/0.02 = 125 ohms.  The 5V supply I connect directly to the anode pin.

I assume for full brightness, each digit should be delivered around 20mA.  As you said in an earlier explanation, when multiplexing 4 digits, the "average current" to each is a 1/4.  I don't understand why.  Is it not still 20mA per digit and only on for 1/4 of the time?  I do however understand the "time on" is only a quarter and this results as you said to probably closer to 1/2 the intensity.

So would the aim be to increase the current to 4 x 20mA (if possible) to get back to full brightness?

I understand not blowing up the arduino and using transistors - I'll do that next.  But what I don't understand is how to push the digits to the suggested max 1/10 duty cycle & 0.1ms pulse width.  I think as I said I'm running at 1/4 duty cycle.  So from the digits specs is this correct:

If specifications say 160mA max at 1/10 duty cycle @ 0.1ms pulse width, then mine run at 80mA could be:

=>160/2 mA at (1/10)/2 @ 0.1ms
=> 80mA at 1/5 @ 0.1ms
=> 80mA at 1/4 @ (0.1)x1.25ms
=> 80mA at 1/4 @ 0.125ms

If this is by any chance correct, now I understand the 1/4 duty cycle.  But how do I achieve a 0.125ms on value for each digit (in multiplexing).  The millis only works at a minimum of 1ms (1/1000th second).  The above 125ms is an 1/8 of that.  This would be 125microseconds.  I'm confused.  I'd appreciate your help here.
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 23, 2015, 11:41 am
As you said in an earlier explanation, when multiplexing 4 digits, the "average current" to each is a 1/4.  I don't understand why.  Is it not still 20mA per digit and only on for 1/4 of the time?
Exactly, yes. The current is 20mA for 1/4 of the time and zero for the other 3/4, so 5mA on average. Its the average that determines the brightness.

So would the aim be to increase the current to 4 x 20mA (if possible) to get back to full brightness?

But what I don't understand is how to push the digits to the suggested max 1/10 duty cycle & 0.1ms pulse width.
I don't think you neccessarily want to do that. It won't give maximum brightness. 160mA at 1/10 duty cycle is only 16mA on average. You are aiming for 20mA average.

So from the digits specs is this correct:

If specifications say 160mA max at 1/10 duty cycle @ 0.1ms pulse width, then mine run at 80mA could be:

=>160/2 mA at (1/10)/2 @ 0.1ms
=> 80mA at 1/5 @ 0.1ms
=> 80mA at 1/4 @ (0.1)x1.25ms
=> 80mA at 1/4 @ 0.125ms

Short answer is I don't know if your calculations give an answer that is safe for the leds. Most led data sheets give a max continuous current and a max current for a specified pulse width and duty cycle. Most don't show a graph or give a formula that tells us the max current for other duty cycles and pulse widths. What else if anything does your data sheet give? Can you post a link to it?

But how do I achieve a 0.125ms on value for each digit (in multiplexing).  The millis only works at a minimum of 1ms (1/1000th second).  The above 125ms is an 1/8 of that.  This would be 125microseconds.  
Yes, that would be awkward to achieve. There is micros() (http://arduino.cc/en/Reference/Micros) but it seems overkill to get what you want.

Maybe someone on the forum with more experience can explain how to calculate the max safe current for these leds with a 1/4 duty cycle and a pulse width of, say 1ms.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 23, 2015, 10:39 pm
I don't think you neccessarily want to do that. It won't give maximum brightness. 160mA at 1/10 duty cycle is only 16mA on average. You are aiming for 20mA average.
In this case, even if the digits end up at 16mA rather than 20mA, that would be fine.  It would probably be hardly noticeable.  What I therefore am not clear on, is the calculation and yes if someone could answer that, I'd appreciate it.  My calculation is:

Data sheet says max 160mA at 1/10 duty cycle at 0.1ms pulse width, so  is this correct:
160mA : 1/10 dc : 0.1 pw, is the same as...
 80mA : 1/5 dc   : 0.1 pw, which is the same as...
 80mA : 1/4 dc   : 0.08 pw
 (Sorry, different to my previous calculation).

If 0.08ms pulse width is correct, how is this achieved in arduino code when cycling.  Do I specify the delay duration in micros?

Ps.  The link to the data sheet for these 7 segment displays is in this thread, post #12.


Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 23, 2015, 11:19 pm
The link to the data sheet for these 7 segment displays is in this thread, post #12.
No, I think that's the DS for the 8000 round leds you bought from China, not the 0.5" 4-digit display...
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 24, 2015, 09:14 am
No, I think that's the DS for the 8000 round leds you bought from China, not the 0.5" 4-digit display...
Oops, I'm so sorry.  I'll attach the link to the 7 segment display in this reply.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 25, 2015, 09:57 am
Hi.

I'm wondering if someone can still answer my question above - I think it may have got lost in the thread.

There is a specification sheet attached in the note above for common cathode 7 segment digits I'm experimenting with.  I'm trying to multiplex 4 digits and attain near max (safe) brightness.  The spec sheets says the digits can go to 160mA max at 1/10 duty cycle and 0.1ms pulse width.  I'm trying to convert this to my 4 digits (hence 1/4 duty cycle).

As each digit can be 20mA max, then to get this cycling 4 digits it should be around 4 x 20mA = 80mA (I think).

Interpolating the spec sheet figures, would this be the equivalent then of 80mA peak at 1/4 duty cycle and 0.08ms pulse width?

If so, how do you do a delay of 0.08ms.  Does this mean I have to do delays between each common 80uS?
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 26, 2015, 10:33 am
Can someone please answer this ...

I've done a bit more reading of related threads and still haven't resolved my dilemma, so I've tried to do this graphically.

Can someone please tell me if my thinking is correct for working out max intensity I can push a 7 segment display based on peak forward current, duty cycle and pulse width (also refer attached specification sheet for this display).  I'm really stuck...


(http://forum.arduino.cc/index.php?action=dlattach;topic=308365.0;attach=120073)

(http://forum.arduino.cc/index.php?action=dlattach;topic=308365.0;attach=120075)

(http://forum.arduino.cc/index.php?action=dlattach;topic=308365.0;attach=120077)

(http://forum.arduino.cc/index.php?action=dlattach;topic=308365.0;attach=120079)
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 26, 2015, 01:24 pm
No one's answering me  :'( ...
In my experience of this forum, the most likely reason is that no-one here knows.

Can someone please tell me if my thinking is correct for working out max intensity I can push a 7 segment display based on peak forward current, duty cycle and pulse width (also refer attached specification sheet for this display).  I'm really stuck...
I'm not sure you are even asking the right question.

I would phrase the question like this:

"We know the max continuous current is 30mA.
We know the max current is 160mA with pulse width 0.1ms and 1/10 duty cycle
What is the max current at pulse width 2ms and 1/4 duty cycle?"

And one answer you might get from the forum would be "if maximum brightness is really so important, don't multiplex".

I think its all to do with heat dissipation. The higher the current, the faster you are heating the leds. The temperature they reach depends on the length of the pulse, what temperature they were at the start of the pulse, and how fast they loose heat during the pulse. The temperature at the start of the pulse depends on what rate they cool. The rate at which they cool depends on the temperature at any instant. Its all horribly complicated.

But every time the led heats up and cools again, it looses a tiny part of its life. The hotter it gets, the larger that part of life is lost.

My advice would be that if you are building something for you own use, you can afford to push the limits. If you are designing something to be mass-manufactured and sold, you have to be much more conservative if you can't get a definitive answer to your question.

If it were me, I would go to maybe double the max continuous current with a 2ms pulse and 1/4 duty cycle, and be prepared for the possible consequences, but take comfort in the knowledge that the manufacturer's data sheet figures will be conservative.
Title: Re: LDR with 7 seg display and PWM output
Post by: CrossRoads on Mar 26, 2015, 02:27 pm
If you exceed this on-time and current
Peak Forward Current [1] 160 mA
1. 1/10 Duty Cycle, 0.1ms Pulse Width.

you will burn the parts out.
If you want 20mA all the time, use daisy chained, high current shift registers, TPIC6C595 or TPIC6B595. Can then use them for higher voltage (multiple LEDS/segment) with a larger display as well.

Also makes the coding easier - just shift out 4 bytes whenever you need the display updated.
I'd use SPI for that:
Code: [Select]

// time for a display update?
digitalWrite (latchPin, LOW); // RCLK from SS on pin 10
for (x=0; x<4; x=x+1){
SPI.transfer(displayData[x]); // data from MOSI pin 11, SRCLK from SCK on pin 13
}
digitalWrite (latchPin, HIGH); // SS on pin 10

If you are sending font characters, can pull data from a look up table
Code: [Select]

// time for a display update?
digitalWrite (latchPin, LOW); // RCLK from SS on pin 10
for (x=0; x<4; x=x+1){
SPI.transfer(fontArray[displayData[x]]); // data from MOSI pin 11, SRCLK from SCK on pin 13
}
digitalWrite (latchPin, HIGH); // SS on pin 10

Code: [Select]

byte fontArray[] = {
0b00111111, // 0, with 1 = segment on, DP-g-f-e-d-c-b-a
0b00000110, // 1        a
0b01011011, // 2    f        b
0b01001111, // 3        g
:                            e        c
:                                d         dp
0b01101111, // 9
0b01110111, // A
: // etc.
};
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 26, 2015, 02:50 pm
This  (http://bryanduxbury.com/2013/12/02/over-driving-leds-for-brightness/)may be of interest, although it doesn't really answer my version of your question.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 27, 2015, 08:53 am
Paul, thanks for re-wording my question- yes it wasn't clear.

Your absolutely right about that if I want bright, consider not multiplexing.  Originally I just used a heap of outputs, but then I learnt about multiplexing, so that seemed to work well for saving pins.  However the compromise is dimmer display.  You have a valid point that if I want the digits to last, the lower the current the better.  This is therefore more academic exercise.  I'll do some experimenting.

Your link to bryanduxbury yes is relevant and I already read it last week.  This is what I'm trying and I think I have enough info to experiment.

Crossroads, I do agree that the way forward on my ultimate project is with shift registers for the reasons both you and Paul outlined.

I will soon need some help with my 24v common anode digits and driving them with shift registers (and MOSFETS).  I might start up another thread when I'm up to that.  Thanks guys. :)
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 27, 2015, 11:11 am
24v common anode digits and driving them with shift registers (and MOSFETS)
Before you purchase components, work out the current the digits will draw. The tpic6*595 shift registers have built-in mosfets, so as long as the current is within their capability, you can keep the circuit really simple. Wiring lots of leds in series with 24V supply should help keep the current down.

tpic6c595: 100mA per segment
tpic6b595: 150mA per segment
tpic6595: 250mA per segment
tpic6a595: 350mA per segment

Note: these chips can only sink this current, they cannot source any current.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 27, 2015, 12:12 pm
Thanks Paul.  Yes, I definately will check currents before hand.  You did mention earlier also about using the  tpic6c595 high-current shift registers.  In - built mosfets - excellent.  Before I order anything, I'll run through the specs with you if that's ok.

Right now I'm just experimenting with multiplexing single LEDs, checking strobing and currents.  I'm finding it just flickers at 50Hz, but stops at 60.  So I assume 100Hz would be safe.  I read somewhere that it should be 1000Hz

I've attached a sheet that I drew up earlier outlining how my 24V 7 segment displays are setup along with current draw, etc.  From your notes above, I assume I will use tpic6b595's?  I would assume then that I'd be using 2 of these per 4 digits. (ultimately I have 15 digits - timer, clock, home score, away score and temperature).
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 27, 2015, 02:32 pm
I've attached a sheet that I drew up earlier outlining how my 24V 7 segment displays are setup along with current draw, etc.  From your notes above, I assume I will use tpic6b595's?  I would assume then that I'd be using 2 of these per 4 digits. (ultimately I have 15 digits - timer, clock, home score, away score and temperature).
You forgot the attachment!

If not multiplexing you will need one shift register per digit. If multiplexing, one for every 2, 4 or perhaps even 8 digits, but you know the penalty for doing that. Also if multiplexing, you will need some high-side p-channel mosfets with high-current capacity, along with something to drive the mosfets (e.g Arduino pins + pnp transistors, or an extra tpic chip).

Bob (CrossRoads) is the real expert in these chips. He may even have a suitable product you could use.
Title: Re: LDR with 7 seg display and PWM output
Post by: CrossRoads on Mar 27, 2015, 02:40 pm
I have a board that has a '328P set up like an Uno, with offboard USB/Serial adapter, and 12  shift registers for driving large high voltage displays based on LED strips with built-in current limit resistors.
Could be expanded to 15 digits and add in current limit resistors for 7-segment displays.
http://www.crossroadsfencing.com/BobuinoRev17/ (http://www.crossroadsfencing.com/BobuinoRev17/)
(http://www.crossroadsfencing.com/BobuinoRev17/12_digit_driver_board.jpg)
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 27, 2015, 02:45 pm
Sorry about attachment.  I've added it here.  Please do take a look at it.

I took a quick look at the chip (tpic6b595) before - I think I had multiplexing on the brain, hence I assumed it was for 2 digits.  Yes, 8 drains, so 1 digit.  I'll new quite a few of these, but if it saves a stack of MOSFETs, it'll be worth it.

I'd be happy for Bobs help with these chips.
Title: Re: LDR with 7 seg display and PWM output
Post by: CrossRoads on Mar 27, 2015, 03:11 pm
Yes, TPIC6B595 can handle these currents:
Segments A, D & G = 7 x 8 (rows) of LEDs = 8x15 = 120mA each
Segments B, C, E & F = 7 x 7 (rows) of LEDs = 105mA each

Need one shift register per digit.

15 digits, daisy chain them all and send out 15 bytes when an update is needed.
I often use a data array to hold the value, 0 to 9, for each digit, and a font look up array to map the value to the needed segments.
Code: [Select]

byte dataArray[15]; // 15 bytes holding 0-9 for each digit, time, score, period, whatever

byte fontArray[] = {
0b00111111, // 0, with  DP-g-f-e-d-c-b-a, 1 = segment on
0b00000110, // 1       a
etc.                        f       b
0b01101111, // 9       g
};                          e      c
                                 d     DP

// time for an update?
digitlalWrite (ssPin, LOW); // D10 to RCLK pin, D11 to Ser data, D13 to SRCLK
for (x=0; x<15; x=x+1){
SPI.transfer (fontArray[dataArray[x]]);
}
digitlalWrite (ssPin, HIGH);  // outputs updated on this rising edge
// MRCLR tied High, OE/ tied Low, or to a PWM pin for brightness control
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 28, 2015, 12:35 am
Thanks for that info Bob and I like the look of your board - I'll aim to make mine similar.  I'm feeling more confident now and getting excited for my build!  I've found the following:

Sorry but I now have a few more questions if I can:


Sorry for the zillion questions, but I'm just learning and this is a big challenge for me.
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 28, 2015, 12:41 am
One Arduino will be fine - Uno/Nano/Pro Mini as you like. You will only need 3 pins to run all 15 shift registers.

If you want to "roll you own" arduino, you could use an atmega328 and regulator circuit. But a Nano for example comes with built-in usb for easy re-programming and a regulator to provide it with 5V (just be careful not to use much current from the 5V supply, or the built-in regulator could overheat, given the 24V input voltage).

You can buy very cheap ir remotes and sensor kits for Arduino on eBay. Also you can find ds3231 rtc modules which have a built-in temperature sensor.

ir remote kit (http://www.ebay.co.uk/itm/New-Infrared-IR-Wireless-Remote-Control-Module-Kits-for-Arduino-/271719947271?pt=LH_DefaultDomain_3&hash=item3f43c55c07)

rtc with temperature sensor (http://www.ebay.co.uk/itm/DS3231-AT24C32-Memory-Module-For-Arduino-IIC-Precision-RTC-Real-Time-Clock-/400624291795?pt=LH_DefaultDomain_3&hash=item5d47118fd3)

For dimming, you can use an ldr connected to an analog input, and connect an Arduino pwm output to the "OE" pins on the shift registers.

Title: Re: LDR with 7 seg display and PWM output
Post by: CrossRoads on Mar 28, 2015, 01:21 am
cjcj, your first 2 links won't open for me.
You can do all 15 digits in one sketch.
Standalono arduino is simple - you can see the parts:
16 MHz crystal, 22pF caps, 0.1uF cap, 10K resistor.
I add ICSP header for bootloading as an Uno, or for Upload Using Programmer after bootloading (bootloading also sets fuses); add FTDI header if you want serial access for debugging (recommended!) and serial downloading after bootloading.

Can read relay closures the same as button presses:
Code: [Select]

pinMode (pinX, INPUT_PULLUP);

if (digitalRead(pinX) == LOW){
// relay closure connects pin to Gnd
// advance a score or something
}


5V supply - how much current is expected? Maybe 5V linear regulator (78005 type), maybe 5V switching regulator from a higher input voltage source, such as
http://www.digikey.com/product-detail/en/OKI-78SR-5%2F1.5-W36-C/811-2196-5-ND/2259781

Use PWM to control brightness, determine value from 255 (full dim) to 0 (full bright) however you'd like, as PaulRB indicated.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 28, 2015, 04:00 am
Bob, I've tried to fix the first link with a "longer" web address, but couldn't change the 2nd.  Plan B - I've attached a PDF of them both.

Once I've done the code for the 5 functions, I will therefore try to combine them.

Paul - 3 pins to run all 15 registers - thats fantastic, I had no idea I could.  Not sure how to do that yet, but I'll start by taking small steps.  I know that the arduino is all setup with the 5V supply, USB, etc as you say, but I am "tempted" to consider creating that circuitry as well in my board (as Bob suggested).  But again, that will come later.

I did buy an RF trasmitter / receiver module earlier this year to experiment with (link here (http://www.ebay.com.au/itm/315Mhz-Wireless-RF-Transmitter-Receiver-Link-Kit-Module-for-Arduino-ARM-MCU-WL-/400572503417?hash=item5d43fb5579&_uhb=1)), but your link with keypad is brilliant.

I also did buy the DS3231 AT24C32 clock (link here (http://www.ebay.co.uk/itm/DS3231-AT24C32-Memory-Module-For-Arduino-IIC-Precision-RTC-Real-Time-Clock-/400624291795?pt=LH_DefaultDomain_3&hash=item5d47118fd3)).  Just received a battery for it last week, but haven't tried it yet.  I did however write code in a sketch to run my  clock - and I was so proud of doing it.  Is it better I use this module?  Isn't that sort of cheating and relying on pre made components!  And I didn't know it did temperature too - excellent - another bit of research for me / homework.

Dimming - OE pins - also excellent.  This is all sounding so promising.  Chris.
Title: Re: LDR with 7 seg display and PWM output
Post by: CrossRoads on Mar 28, 2015, 06:35 am
$2.30 per part - you guys down under get hosed on prices.
Same for me is $1.74
http://www.digikey.com/product-search/en?pv69=80&k=tpic6b595&mnonly=0&newproducts=0&ColumnSort=0&page=1&quantity=0&ptm=0&fid=0&pageSize=25

Quote
3 pins to run all 15 registers - thats fantastic, I had no idea I could.  Not sure how to do that yet,
Did you look at the code I posted in #32?
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 28, 2015, 09:08 am
Did you look at the code I posted in #32?
I did read it, however I assumed that each register "linked" but needed at least 3 to 4 wires each. 
As for the code, I'm not too hot at the moment reading code.  I loosely understand what you've written in principle, however I have to actually write this up and apply it in context to fully understand it.  I'll order the shift registers, mock up 15 small led displays with it, then write the code to learn how to do it.

Below for instance is an example of the code I've written for a MM:SS timer.  You'll look at it and think it's quite long winded.  But self taught, so far it's the best I can do.

Code: [Select]

/* COMMON ANODE TIMER (with start, pause and reset):
   This Arduino code drives 4 separate 7 segment common ANODE LED displays
   Via a pushbutton switch, it starts a timer display from 00:00
   (mm:ss) to 59:59.  The button also pauses the timer.
   Holding the button in for greater than 2 seconds resets
   There is a built-in debounce to limit bouncing of pulses via the pushbutton.
   Includes an LDR to control the intensity of the digits
   Create by Chris in Feb 2015
*/

//--------------------------------------------------------------------------------------------

int A = 1;                   // Set to 0 (LOW) for common cathode.  Set to 1 for common anode digits
int B = 0;                   // Set to 1 (HIGH) for common cathode.  Set to 0 for common anode digits
int ldrIn = 14;              // Analog input pin A0.  Attach to first leg of LDR and 10K to GND
int aValue = 0;               // A variable used in controlling the light intensity value
int dValue = 0;               // A variable used in controlling the light intensity value

int buttonChange = 15;       // Analog in pin (A1) used to pause, restart and reset timer
                             // Other end of led to GND via a 10K resistor
int state = LOW;             // The current state of the output pin
int reading;                 // The current reading of the input pin
int previous = HIGH;         // The previous reading from the input pin
int check = 0;               // Used to pause the clock when the button is preassed - whilst reset
int delayMp = 2;             // Used to delay the muliplexing
int sec_ones = 0;            // Used to indicate what number the digit is set to
int sec_tens = 0;            // Used to increment the tens unit
int min_ones = 0;            // Used to increment the min_ones units
int min_tens = 0;            // Used to increment the min_tens units
long time1 = 0;              // Used in delaying for debouncing of pushbutton
long time2 = 0;              // Used in delaying the increment clock time
long secondMicro = 996000;   // One second increment clock time
long debounce = 500;         // Debounce time - longer than usual so it works for me
unsigned long currentMillis = 0;  //
unsigned long previousMillis = 0; //
int stepMultiplex = 1;       // Variable used to step through each segment
int reset = 2000;            // Duration required for button press to reset time
int firstTime = 1;           // Used in recording button press duration
unsigned long startTime = 0; // Used in recording button press duration
unsigned long pressTime = 0; // Used in recording button press duration


// the following array is used to define each led common
byte commons [4] = {6,9,10,11};   // pins to each digit common (these are PWM outputs)

// the following array is used to define each led segment for number 0 to 9
byte sevenSegmentPin[7] = {2,3,4,5,7,8,12};
byte sevenSegment[10][7] = {
  {B,B,B,B,B,B,A},    // this is 0
  {A,B,B,A,A,A,A},    // this is 1
  {B,B,A,B,B,A,B},    // this is 2
  {B,B,B,B,A,A,B},    // this is 3
  {A,B,B,A,A,B,B},    // this is 4
  {B,A,B,B,A,B,B},    // this is 5
  {B,A,B,B,B,B,B},    // this is 6
  {B,B,B,A,A,A,A},    // this is 7
  {B,B,B,B,B,B,B},    // this is 8
  {B,B,B,A,A,B,B},    // this is 9
}; 


void setup()  //--------------------------------------------------
{
  Serial.begin(9600);
  for (byte i=0; i<7; i++)
  pinMode(sevenSegmentPin[i],OUTPUT); // this sets pins 2,3,4,5,6,8 and 12 as outputs

  for(byte i=0; i<4; i++)
  pinMode(commons[i], OUTPUT);         // this sets pins 6,9, 10 and 11 as outputs

  for (byte i=0; i<7; i++) {
    digitalWrite(sevenSegmentPin[i], sevenSegment[0][i]); // this sets pins 2,3,4,5,6 and 8 as 0
  }
}

// This is code for displaying the incremental digit for the "sec_ones"
void sevenSegWrite_1(byte sec_ones) {
  for (byte i=0; i<7; i++) {
    digitalWrite(sevenSegmentPin[i], sevenSegment[sec_ones][i]);
  }
}

// This is code for displaying the incremental digit for the "sec_tens"
void sevenSegWrite_2(byte sec_tens) {
  for (byte i=0; i<7; i++) {
    digitalWrite(sevenSegmentPin[i], sevenSegment[sec_tens][i]);
  }
}

// This is code for displaying the incremental digit for the "min_ones"
void sevenSegWrite_3(byte min_ones) {
  for (byte i=0; i<7; i++) {
    digitalWrite(sevenSegmentPin[i], sevenSegment[min_ones][i]);
  }
}

// This is code for displaying the incremental digit for the "min_tens"
void sevenSegWrite_4(byte min_tens) {
  for (byte i=0; i<7; i++) {
    digitalWrite(sevenSegmentPin[i], sevenSegment[min_tens][i]);
  }
}


void loop()  //--------------------------------------------------
{
  aValue = analogRead(ldrIn);              // Read the LDR analogue value on analog pin and
                                          // store the value between 0 and 1023
//  Serial.print("0l to 1023 value = ");
//  Serial.println(aValue);
  aValue = constrain (aValue, 20, 300);   // Constrain the value between 900 and 1010
  dValue = map (aValue, 20, 300, 0, 255); // The digital pin outputs values from 0 to 255
                                          // so convert the value received in the above line
 
  reading = digitalRead(buttonChange); // Check the state of the button
  currentMillis = millis();            // Set variable for multiplexing timing

 
// Used to toggle starting and pausing the clock...

if (reading == HIGH && previous == LOW && millis() - time1 > debounce) {
    if (state == HIGH) {
      state = LOW;
      time1 = millis ();
    }
    else {
      state = HIGH;
      time1 = millis();
    }
  }
  previous = reading;


// Used to check if the button is pressed long enough to reset the time

 if (reading == HIGH) {
   if (firstTime == 1) {
     startTime = millis();
     firstTime = 0;
   }
   pressTime = millis () - startTime;
 }
 else if (firstTime == 0) {
   firstTime = 1;
 }
 
 if (pressTime > 2000) {
    state = LOW;
    sec_ones=0;
    sec_tens=0;
    min_ones=0;
    min_tens=0;
    time1 = 0;
 }
 
//-------------------------------------------------------------------

  if(stepMultiplex == 1 && (currentMillis - previousMillis) >= delayMp) {
    digitalWrite(commons [0],B);  // Turn off the previous digit once time expires
    previousMillis=currentMillis;
    sevenSegWrite_1(sec_ones);
    analogWrite(commons [3],dValue);  // Turn on the sec_one digit
    stepMultiplex=2;
  }
 
  if(stepMultiplex == 2 && (currentMillis - previousMillis) >= delayMp) {
    digitalWrite(commons [3],B);  // Turn off the previous digit once time expires
    previousMillis=currentMillis;
    sevenSegWrite_2(sec_tens);
    analogWrite(commons [2],dValue);  // Turn on the sec_tens digit
    stepMultiplex=3;
  }
   
  if(stepMultiplex == 3 && (currentMillis - previousMillis) >= delayMp) {
    digitalWrite(commons [2],B);  // Turn off the previous digit once time expires
    previousMillis=currentMillis;
    sevenSegWrite_3(min_ones);
    analogWrite(commons [1],dValue);  // Turn on the min_one digit
    stepMultiplex=4;
  }

  if(stepMultiplex == 4 && (currentMillis - previousMillis) >= delayMp) {
    digitalWrite(commons [1],B);  // Turn off the previous digit once time expires
    previousMillis=currentMillis;
    sevenSegWrite_4(min_tens);
    analogWrite(commons [0],dValue);  // Turn on the min_tens digit
    stepMultiplex=1;
  }

//  The next few lines are used to advance the clock
 
  if (micros() - time2 > secondMicro && state == HIGH) {
    check=1;                            //this is used to pause the clock while the button is pressed
    if (check == 1 & reading == LOW) {
      sec_ones++;
      check=0;
    }
   
    if(sec_ones >9) {
      sec_ones=0;
      sec_tens++;
    }
   
    if(sec_tens>5) {
      sec_tens=0;
      min_ones++;
    }
   
    if(min_ones>9) {
      min_ones=0;
      min_tens++;
    }
   
    if(min_tens>5) {
      sec_ones=0;
      sec_tens=0;
      min_ones=0;
      min_tens=0;
    }
    time2 = micros();
  }
}
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 28, 2015, 09:50 am
I also did buy the DS3231 AT24C32 clock...  I did however write code in a sketch to run my  clock - and I was so proud of doing it.  Is it better I use this module?  Isn't that sort of cheating and relying on pre made components!
Why get a dog and bark yourself? The RTC module has several important advantages over using the Arduino as a clock. It will be much more accurate over long term, Arduino will probably loose/gain several mintues per day, vs several minutes per year with ds3231. RTC has battery back-up, so doesn't need re-setting every time Arduino is powered up/reset.
I'll order the shift registers, mock up 15 small led displays with it, then write the code to learn how to do it.
Make sure to buy common-anode individual/single-digit 7-seg displays for your mock-up. You won't be able to use multi-digit displays without multiplexing them, and that wouldn't be an accurate mock-up of your final curcuit.
Below for instance is an example of the code I've written for a MM:SS timer.  You'll look at it and think it's quite long winded.  But self taught, so far it's the best I can do.
Its good that you are practising your coding skills, but little of that code will be suitable for your project. You won't be multiplexing, you will be using shift registers and an RTC connected to the i2c bus. For now, better to spend your time getting the code for that RTC module working. Just send the output to serial monitor for now.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 28, 2015, 12:35 pm
You are right.  I already noticed I had to fiddle with microseconds in order to get the time accurate'sh.  At least I learnt something with my code.  As for the battery backup - yes, I didn't think of that.

I've already got small 7 segment common anode digits (10 at this stage, so I'll order another 1/2 dozen).

I do realize the multiplexing is out the window now.  Again - good practice and I'm learning heaps.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 29, 2015, 03:56 pm
$2.30 per part - you guys down under get hosed on prices.  Same for me is $1.74
Bob, could you check this LINK (http://www.ebay.com/itm/5pcs-TPIC6B595N-TPIC6B595-POWER-LOGIC-8-BIT-SHIFT-IC/171378975450?_trksid=p5411.c100167.m2940&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D20140131123730%26meid%3D1e1a8f2b2bf74b9dae1b382bb3c570db%26pid%3D100167%26rk%3D9%26rkt%3D15%26sd%3D181458475492) for shift registers on ebay.  Do you think I should trust them?

Title: Re: LDR with 7 seg display and PWM output
Post by: CrossRoads on Mar 29, 2015, 05:29 pm
Up to you. I don't trust anything on e-bay. I only by electronics from actual distributors.
If this is just for personal use, that's different.  I deliver a lot of what I buy, so I buy from known good suppliers.
I also can't live with 3-4 week delivery time.

As for the code:
have an array of elements that you will shift out.
Code: [Select]

dataArray[] = {
leftScoreTens,
leftScoreOnes,
rightScoreTens,
rightScoreOnes,
minutesTens,
minutesOnes,
secondsTens,
secondsOnes,
tenths,
//etc
};

Then send the data to the shift registers
Code: [Select]

digitalWrite (ssPin, LOW); // connects to RCLK
for (x=0; x<15; x=x+1){
SPI.transfer (fontArray[dataArray[x]]); // look up font mapping and send it out for data at location x in dataArray
}
digitalWrite (ssPin, HIGH); // connects to RCLK, outputs update on this rising edge.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 29, 2015, 11:12 pm
Up to you. I don't trust anything on e-bay....If this is just for personal use, that's different... I buy from known good suppliers...I also can't live with 3-4 week delivery time.
The 3 to 4 weeks is a pain, but in my it will take me a while to do this project.  In my previous large project I did use ebay components alot of the time, except for anything high powered like the TPIC6B595s.  Yes, this is not for "personal" use, so I might just order 15 of from a local suppler (rs components) and some "spares only" from ebay.  This way I can start breadboarding earlier.

Thanks for all the snipits of code.  They will come in handy when I get my PICs and start coding.

For now, better to spend your time getting the code for that RTC module working. Just send the output to serial monitor for now.
I did try my RTC, the only problem was that it was labelled on the ebay website as "DS3231", however I was sent a "DS1307" (no temperature on it).  The $2 lost on this module is not the problem - only the 3-4 week waiting again!  I connected it and tried some code anyway - time works well (but I've read the earlier DS1307 looses too much time as it is heat affected).  New module on order.

Time for me to read some posts on shift registers and do some more practice...
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 29, 2015, 11:40 pm
it was labelled on the ebay website as "DS3231", however I was sent a "DS1307"
On eBay? I hope you opened a dispute!
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 30, 2015, 08:58 am
On eBay? I hope you opened a dispute!
I did write back to the seller saying "what tha".  Interested to see what he does.  If I have to return the unit, it'll probably cost me between $5 to $10.  Some seller are just dishonest!
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 30, 2015, 10:23 am
I expect they will send you a replacement, rather than risk a dispute case or poor feedback. Question is do they understand difference between ds1307 and ds3231, if they are one of those bazar-type vendors that sell false nails and clothes that no self respecting woman would be seen wearing in public except on a hen night!
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 30, 2015, 10:33 am
Yes, your right.  Not sure if they understand the difference either.  I just had a reply from "Alice" and I had no idea what her reply ways so I wrote back in simpler english - "You send me wrong part.  Please send me right part = DS3231 NOT".  It makes me laugh.  But at the same time I ordered another unit for about $2 from someone else - "Plan B".
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 30, 2015, 12:14 pm
You mean alice1101983 (http://www.ebay.co.uk/usr/alice1101983?_trksid=p2053788.m1543.l2754)? They run the TxHang shop. I was recommended them by another forum member and have used them a couple of times without a problem.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 30, 2015, 01:29 pm
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 30, 2015, 04:54 pm
  • The Arduino generates binary code - 8 bits / 1 byte (i.e. 00010000) to depict a 7 segment digit number
  • This info is sent in serial (via a single line) to the shift register - pin 3 (SER IN)?
  • Each bit is sent/received 1 at a time and shoves the next spot in the register until all 8 are filled up (received)
  • To snapshot this, via the Arduino, "latch" is changed from Low to High  - this is pin 12 (RCL) or the register
  • This flip causes the bits to be copied to each of register output pins (drain0 to drain7)
  • This then repeats replacing the bits in the shift register

Now, to cascade, is this correct?
  • All the 15 drain0's are connected together, and all 15 drain1's, are connected together etc, etc
  • All 15 latch pins are connected together - pin 12?
  • All 15 clock pins are connected together - pin 13?
  • To "shunt?" the 8 bits down from the first register to the next and next, pin 18 (SER OUT) is connected to pin 3 (SER IN) of the next register, and so on
  • Common anodes (in my case) are connected directly to 24V
  • The arduino PWM signal is connected to all the output enable pins (G) - pin 9 of each register
  • The arduino sends out 15 bytes at a time which fill each of the 15 shift registers

That all looks correct.

So does this mean that 15 bytes of info are sent by the arduino ever microsecond or so, hence any change in 8-bit is displayed immediately in the 7 segment displays so 100 duty cycle?
No, your sketch only sends the data when you want to change something. So for example if you were displaying the time as hh:mm you would only need to update once per minute.

And does it also mean that the dimming all the displays is controlled by a PWM signal from the Arduino to pin 9 of every shift register which essentially essentially creates a sort of duty cycle/pulse width?
Yes, your sketch can set the level with analogWrite(), again, only when it needs to change.

Maybe a question for Bob - other than the 15 shift registers, 20 pin IC sockets and 0.1uF caps for each register, is there any other basic components that I need to get started for this test?
For your small 7-seg displays, probably be ok, maybe add a 10uF for each display. For your large displays, some much larger caps, maybe 1000uF per digit.
Title: Re: LDR with 7 seg display and PWM output
Post by: CrossRoads on Mar 30, 2015, 05:01 pm
All devices receive clock and latch in parallel.
1st device gets Serial data from processor, it's Serial Out goes to Serial In on next chip.
Example:
http://www.crossroadsfencing.com/BobuinoRev17/ (http://www.crossroadsfencing.com/BobuinoRev17/)
(http://www.crossroadsfencing.com/BobuinoRev17/12digit_2relay_drive_sch.png)
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 30, 2015, 09:13 pm
Quote
All the 15 drain0's are connected together, and all 15 drain1's, are connected together etc, etc
Oh, that's wrong. Each drain is connected to a separate segment cathode.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 31, 2015, 12:57 am
You mean alice1101983 (http://www.ebay.co.uk/usr/alice1101983?_trksid=p2053788.m1543.l2754)? They run the TxHang shop.
Yes.  What a coincidence.  It was exactly the same person / company.
No, your sketch only sends the data when you want to change something. So for example if you were displaying the time as hh:mm you would only need to update once per minute
Yes, of course.  That makes sense.
For your small 7-seg displays, probably be ok, maybe add a 10uF for each display. For your large displays, some much larger caps, maybe 1000uF per digit.
Is that right?  I "thought" that each IC needs a 0.1uF capacitor as close to the Vcc as possible and ground in order to stop any resilient "noise".

All devices receive clock and latch in parallel.
1st device gets Serial data from processor, it's Serial Out goes to Serial In on next chip.  Example...
Yes, now that's starting to make sense.  Your link to the sketch now also is making sense.  So am I now understanding this correctly.  Your post #30 that shows a circuit board, is essentially exactly what I need (expect I need an extra 3 shift registers, plus having to connect my PWM signal?
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 31, 2015, 07:45 am
Quote
I "thought" that each IC needs a 0.1uF capacitor as close to the Vcc as possible and ground in order to stop any resilient "noise".
Correct, you need those too. The larger caps are to smooth the sudden demand spikes when large currents are switched, such as your led segments. You might get away with minimal or no caps for your small prototype, depending how good your power supply is and how far away the chips are from it. But with your large displays and the long power lines you will probably have in the final build of the project, lots of large caps spread around would be a very good idea.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Mar 31, 2015, 09:54 am
I suppose then these are to replace the 0.1uF.  So do I put them next to each shift register (15 in total), and maybe 35V, 1000uF?
Title: Re: LDR with 7 seg display and PWM output
Post by: PaulRB on Mar 31, 2015, 11:14 am
I mean you need (or might need) both. Definitely a 0.1uF decoupling cap for each chip (accross 5V & ground), plus (maybe) a larger cap to smooth the high-current switching (accross 24V & ground - check cap's voltage rating is adequate). With your small displays, maybe not needed at all. For the large displays, maybe 1000uF per display is overkill. I'm not sure how to estimate that, maybe Bob has some advice.
Title: Re: LDR with 7 seg display and PWM output
Post by: cjcj on Apr 01, 2015, 10:40 pm
All devices receive clock and latch in parallel.
1st device gets Serial data from processor, it's Serial Out goes to Serial In on next chip.
Bob,
So am I now understanding this correctly.  Your post #30 that shows a circuit board, is essentially exactly what I need (expect I need an extra 3 shift registers, plus having to connect my PWM signal?  And yes, any ideas on the number and placement of caps as suggested above?