Count down timer for my soccer club

Wendy

Joined Mar 24, 2008
23,797
To keep the record straight, I have corrected my drawings:

Actually, you are incorrect in this case. It does not matter, and it simplifies making PCBs. A LM393 is a open collector, which means there is no connection what so ever to Vcc. The entire side of the chip is grounded, which is easy to implement.

You have added an extra part that has absolutely no benefit, none what so ever. By my definition, a flawed design.

I do it routinely with this chip.
 

Thread Starter

chrischrischris

Joined Feb 18, 2012
317
Bill, I didn't really know about grounding of the LM393. Thanks for clarifying.

A couple of questions again if I may trouble you:

1. Instead of the TIP105 PNP Darlington you suggested, can I used a TIP147? The 105 only handles 8A, I need to handle 11A and the 147 can handle 20A.

2. The 10KΩ variable resistor for the 555 in the circuit above I believe changes the frequency (Hz). Can I just replace this with a fixed resistor? Can you point me to where I can find forumula to calculate the Hz based on the 2 resistors and capacitor?

3. I understand that the combination of the LDR and the 1MΩ variable resistor in the PWM circuit affects the pulse width and I suppose minimum and maximum pulse duration. Again, could you point me to a formula that I can use to calculate this pulse width.

Sorry for all the questions.
 

Wendy

Joined Mar 24, 2008
23,797
OK, understand I'm answering from work, so I can't research it as much as I would like.

1. I'll get back with you, if you have the datasheet you can save me some time by attaching it, otherwise I have to look it up when I get home.

2. Yes, but if you are using 5V for the 555 I need to use a different circuit. Sorry about that. It isn't that different.

3. The pulse width is completely variable. All you are doing is setting set points. Minimum brightness vs. max.
 
Last edited:

Thread Starter

chrischrischris

Joined Feb 18, 2012
317
Bill, data sheet attached for the TIP147:

View attachment tip147.pdf

5V with the 555 - I sort of guessed that some values would need to be changed since not based on 12V any more.

With the pulse width, does it start by the leds being totally off when set to minimum because the transistor has a 0.7V minimum before it leds current flow through CE? Should I add a 0.7V via a resistor to the base as well, so it doesn't switch off totally? Again guessing here. And I do want this to also go 100% bright.

PS. I guess with this circuit I could have ignored using resistors in my led displays - I could have simply relied on the PWM circuit. However, I suppose there would be a chance then of accidentally over powering the leds during testing.
 

Wendy

Joined Mar 24, 2008
23,797
PWM does not replace resistors. I have seen other people make that mistake. Resistors set the maximum current, while PWM allows for proportional control, hard to do any other way with LEDs. So yes, you will always need resistors with this kind of circuit and LEDs.

If you look up my tutorial on 555 Hysteretic Oscillators that particular oscillator quits around 5V, but not to worry, I'll show you a different one when I get home.

The new transistor is fine. It is why we like to show where we are on the profile, different parts of the world have access to different parts.
 

Wendy

Joined Mar 24, 2008
23,797
OK, you can go one of two paths. A CMOS 555 (such as a 7555 or TLC555, there are others) will work at 5VDC (they can go as low as 2VDC). A CMOS 555 is very close to a regular 555 in many ways, but have much lower drive. This doesn't matter in this application.

The other way is this circuit...



This from My Cookbook, which is located in Bill's Index.

I'm not sure what you want your switching frequency to be, so I am arbitrarily picking 5Khz. You want R1 to be as low as you can safely go, so I am (arbitrarily) selecting 1KΩ for R2 and 0.01 for C1.

Give this set up R2 calculates out to be 27KΩ. C2 is a filter cap, it doesn't matter much.

The triangle wave is taken off of pin 2 & 6, same as the other oscillator.
 
Last edited:

Thread Starter

chrischrischris

Joined Feb 18, 2012
317
Bill,
I'm still a little confused on the 555 / LM393 / LDR combination for the PWM circuit. Working on it all day.

I used your cookbook for a few 555 circuits as well as online circuits. Found a good online calculator:

http://www.csgnetwork.com/ne555timer2calc.html

Is this theory correct?... Frequency of 30Hz just flickers (I found 100Hz also did). So should be at least 1KHz. You suggested 5KHz for safety margin.

Is the aim of the 555 in the circuit shown earlier therefore to get a frequency of say 5KHz, and high duty cycle (say above 95%)? The cycle then needs to alter to dim the leds - via resistance.

If so, then what does the LM393 in combination with the LDR do? Is this altering the duty cycle somehow? If not, could the LDR simply replace one of the 2 resistors to alter the duty cycle? Can I say set C1 to 0.47uF, R1 to 1K and vary R2 from 10Ω to 10KΩ? This alters the duty cycle between 99% and 52%, and the frequency between 3KΩ and 146Ω.

PS. On a second note, in the circuit you showed earlier (figure 5.3 from your blog), you've shown C1 as a normal cap. I think it should it be electrolytic. And in your last note above, you suggested C1 to be 0.01uF. This doesn't existing in electrolytic does it? Could you confirm R1, R2 and C1 so I can test it out.

Lastly, shouldn't it be the square wave (pin 3) that I use. Why is it pin 2?

Sorry for the zillion questions.
 

Wendy

Joined Mar 24, 2008
23,797
Chris, don't apologize for asking questions. I may not have the answers, but someone around here does.

Base PWM frequency is not that important, unless it causes an undesirable effect like flicker. If you get the base frequency too close to other frequencies it can cause beating. So once you find somewhere where it doesn't interfere then you can ignore it.

Your calculator works well enough, just remember to keep R1 a low value (I suggested a 1KΩ resistor). This type of oscillator will work the entire voltage range of the 555, unlike the one I used.

When we need true digital operation, such as a clock, Pin 3 on a 555 is normally the output. However, we needed a triangle wave, and it so happens the 555 produces something very close elsewhere in the circuit. What the 555 produces is often referred to as a sawtooth. It works well enough to use though. So we tap into an area that is not normally an output and use the wave form. The only catch is we have to tap into it very lightly. Since a comparator has a high impedance input it meets this simple requirement.

Looking at the Figure 5.3 for reference, it shows this.



The comparator (LM393) compares the voltages on the two inputs, and comes out with a digital output according to which voltage is bigger. If the - input is larger, the output is low. If the + input is larger, the output is one (high voltage).

These chips use an open collector output, they simply open up when the output is high. There are many digital circuits that do this. So adding R8 allows the output to really go high, as in a true digital output.

This in turn drives Q1, which turns the LED on/off.

The thing to remember is pin 5 of U2a is a voltage input. It compares the input voltage with the instantaneous voltage of pin 6, which is always changing. The result is a PWM signal that can go 0% to 100%. 0% and 100% are both pure DC, the carrier is gone, and they are either ground or Vcc.

Another article I've written (for the book) on PWM is here.

Pulse Width Modulation

The drawing to pay attention to is this one, it shows how a sine wave is converted into a PWM signal. Your use is simple, a DC voltage that represents light intensity outside.



You will note the output changes states when the triangle wave voltage crosses the sine wave signal. A simple comparator function.

Instead of the resistor network R4-R6, which is just a simple voltage divider, you have replace it with the LDR circuit, a different voltage divider. In both cases the voltage divider just makes a DC voltage that the comparator can use (in conjunction with the triangle wave) to make a PWM signal.


About driving LEDs

You are getting confused between what PWM does and what the resistors for the LEDs do. I have seen this before, you are not alone.

A LED with no current limiting resistor is a short on the power supply, and will burn up. So we add a resistor to keep the current in limit and the LED within specification. Even if the circuit is on 1% of the time it still needs controlled current for that 1% of the time it is on, or it will slowly burn up.

PWM controls the amount of time an LED is on.

The LED resistor controls the amount of current through the LED while it is on.

Both are needed, as they are doing separate jobs.


Why that particular %?

You need to remember we don't care what the numbers are, just how they make your display looks. So if the specific numbers happen to be 52% it isn't important, it is what works to make the display look correct. It is an empirical approach, but it works.


C1, Electrolytic or not?

In this case it doesn't matter what C1 is, it will work the same either way. Generally, smaller caps are not electrolytics. They don't need to be, we can build them just fine without using a electrolyte. They tend to be better parts for it, higher frequency response, and other issues.

The reason large caps use an electrolytic is it allows you to make the parts smaller. In basic physics if you trying to build a 100µF cap by using nothing but plate area it would be huge. Electrolyte amplifies the capacitance. This is incorrect, but I think of it in similar terms to a battery electrolyte. The reality is the physics is totally different between the two, but it is how I conceptualize it.

Electrolytic caps are not as good as regular caps. They leak a little (conduct current). In some circuits it can make a major difference, but in many it is no big deal. They also have a frequency response, which may or not be important. When using them for power supply filters you will often see both used side by side to take advantage of the best characteristics of both.
 
Last edited:

Thread Starter

chrischrischris

Joined Feb 18, 2012
317
So this is what I understand. In theory what I need to achieve is to pick components that set the 555 to produce a suitable visual frequency. That makes sense now.

Then rather than the square wave, we tap into the saw tooth triangular wave at pin 6. The comparator then compares the voltage difference between pin 6 and the voltage received through the resistor/LDR setup. This is used in combination with the pull up resistor to turns the leds fully on or off at the set frequency.

The result is a PWM signal that can go 0% to 100%. 0% and 100% are both pure DC, the carrier is gone, and they are either ground or Vcc.
This is where I get lost. The square wave pulse that is then sent to the leds has an "on time" and an "off time" (duty cycle?). How does the comparator change the duty cycle. Doesn't it simply signal Q1 to be fully on or off?
 

Wendy

Joined Mar 24, 2008
23,797
99.9% or 0.01% duty cycles will have very tiny spikes, almost invisible and practically non-existent. When you have 100% the the voltage on the comparator is now over the triangle voltage, it never turns off. If the input voltage is under the voltages of the triangle wave it never turns on. Completely off or completely on is 0% and 100%.

We are not required to have the carrier, it is a convenience to a goal. If you want the light on full time the circuit will do it.
 

Thread Starter

chrischrischris

Joined Feb 18, 2012
317
Bill, I think I'm on a different wavelength - excuse the pun! I don't get it.

When I wave my hand over the LDR, the LEDs change intensity. How?

I thought the intensity is changed by the duration of the "on" time as compared to the duration of the "off" time (in each Hz pulse). Eg, if Q1 is on for 3/4 of a cycle and off for 1/4, then the intensity is at 75% full brightness. If however it is off for 3/4 and on for 1/4, then it is at 25% brightness. If this is true, how is the comparitor and LDR doing this?
 

Wendy

Joined Mar 24, 2008
23,797
Monitor the voltage going to pin 5 of the comparator, this voltage is created by the LDR and the resistors.

The LDR is a variable resistor, it is a Light Dependent Resistor. So it is part of a voltage divider circuit when combined with its other resistors.

A voltage divider makes new voltages depending on the ratios of the resistances.

This voltage is feed into the PWM circuit, which converts voltage in into % PWM out.

When you wave your hand over it, you are casting a shadow, which is a variation in light level.

:D Bet you've been up a while.
 

Thread Starter

chrischrischris

Joined Feb 18, 2012
317
Yes, I think I have been up too long.

I assumed the 555 created the PWM.
So I'm missing a crutial link still.

I do understand the voltage via the LDR. I understand the LM393 compares this to pin 6 and gives out some sort of signal in its pin 7.

When you say the voltage is fed into the PWM circuit, which part is the actual PWM circuit. Is it the LM393? Is this the guy that creates the %PWM? When the voltage from pin 6 and the LDR are compared by the LM, what does it do with that?
 

Wendy

Joined Mar 24, 2008
23,797
The 555 does not create the PWM in this circuit. It creates the triangle wave, a crucial component.

The comparator creates the PWM, along with R8. But it needs the triangle wave to do this.

U2a and the 555 together make a voltage to PWM convertor.
 

Thread Starter

chrischrischris

Joined Feb 18, 2012
317
OK, I think I've got it now...

  • The 555 creates a square wave on pin 3, and also a "saw tooth" wave on pin 6
  • The comparator (LM393) outputs on pin 7 based on voltage difference between pin 5 and 6
  • The reference voltage into pin 5 comes from the LDR
  • The pulsing voltage comes from pin 6 of the 555
  • When input voltage is higher than reference - current flows out of pin 7
  • The duty cycle changes based on the diagram below
(the higher the reference voltage, the smaller the duty cycle).

Could you please confirm if this is correct?



LM393 output.jpg
 
Last edited:
Top