Why does duty cycle affect frequency in this 555 based circuit? - Page 1
Forum section: electronics / beginners

author: raw_circuits
author_rank: Contributor
timestamp: June 07, 2017, 10:18:05 pm
content: Hello all. I've lurked for a long while but am coming out of the shadows to ask a question about a 555 circuit. I've been around long enough to know about the 55.5kHz "easter egg"but I have a different issue.I have implemented a circuit like thisonethat uses steering diodes to allow for a variable duty cycle controlled by a pot (P2). I breadboarded the circuit using a CMOS 555 powered at 12 volts via a bench supply. Everything appears to work correctly. Changing the common pot P1 varies the frequency and changing P2 varies the duty cycle (I've designed it to run at about 60Hz).However, I am a bit surprised to see that changing the duty cycle also changes the frequency. I thought thatTh = .0.693 * Rc * CandTl = 0.693 * Rd * Cwhere Rc is the resistance during the charge cycle and Rd is the resistance during the discharge cycle. The total cycle time then would beT = Th + TlIf I "move" some resitance from Rc to Rd via P2 it seems to me that the total cycle time should remain unchanged.In the circuit I builtRc = R1 + P1 + (1 - k) * P2andRd = R1 + P1 + (1 + k) * P2where k is the position of pot P2 and varies from 0 to 1. So varying P2 "moves" resistance from Rc to Rd and vice versa.Obviously I'm missing something and my math is wrong since my Oscilloscope measurements tell me that varying P2 also changes the frequency.I would be very grateful if someone could enlighten me.

author: danadak
author_rank: Super Contributor
timestamp: June 08, 2017, 01:55:41 am
content: The freq does not change if Ra + 2 x Rb does not change.Regards, Dana.

author: raw_circuits
author_rank: Contributor
timestamp: June 08, 2017, 02:55:56 pm
content: Thanks for your reply, but that is my point exactly. According to the MATH as I know it, the duty cycle should not change. My observations of an actual circuit, however, contradict that.

author: Neilm
author_rank: Super Contributor
timestamp: June 08, 2017, 07:10:53 pm
content: You mentioned that you have breadboarded this. It could easily be some parasitics on the layout that are interferring with timing. Could you post a pictur of it?

author: raw_circuits
author_rank: Contributor
timestamp: June 08, 2017, 07:56:04 pm
content: Attached is a picture of the breadboarded circuit. Note that I have tried using bypass caps from pin 1 to 8 and pin 5 to ground. They didn't make any difference (and it's a little easier to see what's going on without them).Discharge is connected to the center of the 200k pot. Steering diodes connect that to a 50K pot for frequency. That pot is connected to the timing cap (.1uF), trigger, and threshold.

author: ali6x944
author_rank: Frequent Contributor
timestamp: June 08, 2017, 08:36:46 pm
content: Quote from: Neilm on June 08, 2017, 07:10:53 pmMaybe due to the type of timer u r using, NE555 have much higher trigger current of 0.5 to 2 uA compared to the tlc555 with its astonishing 10 to 75 pA, but this is unlikely in my opinion ...

author: danadak
author_rank: Super Contributor
timestamp: June 08, 2017, 09:02:51 pm
content: QuoteIf you move resistance Rdelta from Ra to Rb, in order to keep Ra + 2 x Rb the same,thenLet Ra + 2 x Rb = K(Ra - Radelta) + 2(Rb + Rrbdelta) = K = Ra - Radelta +2Rb +2RrbdeltaTherefore Rrbdelta = [K - Ra _+ Radelta - 2Rb] / 2 = (K –K + Radelta) / 2Rrbdelta = Radelta / 2Example if Ra = 1K, Rb = 2K, then K = 5KIf I drop Ra by .2K to .8K then I have to add .1K to RbTherefore .8K +2 X 2.1k = 5KWhat happens to DC.....Originally = (1K + 2K) / (1K + 4K ) = 60%New DC = (.8K + 2.1K) / (.8K + 4.2K) = 2.9K/ 5.0K = 58%So Rrbdelta = Radelta / 2 should keep freq the same.Regards, Dana.PS : I had too much time on my hands

author: raw_circuits
author_rank: Contributor
timestamp: June 08, 2017, 09:49:37 pm
content: Thanks again Dana but unless I am mistaken the steering diodes in the circuit I am using changes that equation slightly. What I expect is that I haveTH = 0.693 * (Ra + n * Rb) * CTL = 0.693 * (Ra + (1 - n) * Rb) * CWherenis the position of pot R2 (200K in my circuit) and varies from 0 to 1. SoT = TH + TL= 0.693 * (Ra + n * Rb) * C + 0.693 * (Ra + (1 - n) * Rb) * C= 0.693 * C * (Ra + n * Rb + Ra + (1 - n) * Rb)= 0.693 * C * (2 * Ra + Rb * (n + 1 - n))= 0.693 * C * (2 * Ra + Rb)Hence the period (and thus frequency) should be independent of the position of pot Rb.Simulating in LTSpice seems to support this (see attached). I used fix resistors rather than a pot in LTSpice. In the LTSpice schematic R2 and R3 make up the pot. I can swap the two values (simulating moving the pot center arm from one side to the other) and the duty cycle changes as I would expect but frequency changes very little (about 1Hz in the current configuration).However, in my actual circuit the frequency changes significantly with the duty cycle. In the attached screen captures from my scope you can see the frequency varies from 64.10 Hz to 78.74 Hz as I vary R2 from a 3k/195k split (as measured with my multimeter) to a 195k/3k split.

author: onlooker
author_rank: Frequent Contributor
timestamp: June 09, 2017, 03:48:52 am
content: Maybe, your 2 diodes are not matching. Swap the two and see anything changes.A side point is: 0.693 needs correction for the diodes. 0.693 is from ln(2). Now, it is ln((V+* 2/3 - 0.7)/(V+/3 - 0.7)). The 0.7s are for the voltage drop on the diode.

author: raw_circuits
author_rank: Contributor
timestamp: June 09, 2017, 10:52:05 pm
content: Quote from: onlooker on June 09, 2017, 03:48:52 amThis certainly seems plausible - these are two unknown diodes from a junk pile. I did test them on a multimeter and found they both had a voltage drop of about .7 volts. I've swapped them out for two more unknown diodes each with a voltage drop of about .6 volts and there is no difference.

author: raw_circuits
author_rank: Contributor
timestamp: June 10, 2017, 01:01:58 am
content: One more data point: The frequency varies with supply voltage. At 5V I'm getting 43.48Hz with .1uF and about 150K resistance. At 12V that goes to 58.48 without any changes to the circuit. This is true in my variable duty cycle circuit and in the more "traditional" configuration with fixed resistors.Is this to be expected? In theory (as I understand it) the frequency shouldn't change with supply voltage since trigger and threshold are set relative to Vcc (1/3 and 2/3).

author: MK14
author_rank: Super Contributor
timestamp: June 10, 2017, 01:52:55 am
content: Quote from: raw_circuits on June 10, 2017, 01:01:58 amA quick look at your photograph of the circuit, seems to show a disc ceramic capacitor, used as the timing element. These exhibit significant changes of capacitance with temperature, voltage and other factors. Hence the change in frequency of your 555 circuit.http://www.murata.com/en-eu/support/faqs/products/capacitor/mlcc/char/0005

author: onlooker
author_rank: Frequent Contributor
timestamp: June 10, 2017, 02:33:10 am
content: Period = a x (Rc+Rd)C.with diodes, a = ln((V+* 2/3 - 0.7)/(V+/3 - 0.7)). [no longer a = 0.693]Since you got a frequency ratio of ~0.75 for V+= 5v and 12v. It corresponds to a voltage drop of ~0.85v on each diode. That is, the 0.7 used for calculating "a" above should be 0.85.0.85v is a little too high for a normal diode. But the discharge pin may remain a few hundred mV about ground during discharging. This can be "equivalent" to have the voltage drop of each diode raised 100 mV or so from 0.7v to 0.85v for a simplistic view. (Though, the real equivalent is to add the whole discharge pin voltage to the voltage drop of the discharge diode.)If I read your pictures correctly, I think this discharge pin voltage also contributes to the period change when you turned P2 since the effect lengthens only the discharge interval. Though, it seems it can't cause the change as large as you saw.Showing us the waveforms of different pins of 555 should help to see these effects or other possible causes in details.

author: raw_circuits
author_rank: Contributor
timestamp: June 10, 2017, 11:15:41 pm
content: Quote from: MK14 on June 10, 2017, 01:52:55 amThis is interesting and new to me. I've attempted to measure the capacitor at two different voltages. Check me to see if I have done this correctly. I put resistor (21k) in series with the capacitor and ran a 40Hz square wave through the circuit. I probed across the circuit (to see the square wave) and at junction between the resistor and cap (to see the voltage across the cap). I used the scope's cursors to measure from the start of the rising edge of the square wave to the point at which the capacitor reached .63V.With a 3 volt PP square wave I measured the time at 2.4ms. If I have done my math right that puts the capacitance at about .11428uF.With a 10 volt PP square wave I measured the time at 2.36ms. If I have done my math right that puts the capacitance at about .11238uF.At .11428uF and 150K ohms I would expect a frequency of about 58.33Hz. At .11238uF and 150K ohms I would expect a frequency of about 59.32Hz. So it definitely introduces some error, but on the order of about 2% or less. The differences I am measuring are an order of magnitude larger. Assuming of course that I have done my measuring and math correctly.Have I analyzed this correctly?

author: raw_circuits
author_rank: Contributor
timestamp: June 10, 2017, 11:54:27 pm
content: Sorry to split this and my previous reply into two posts - I couldn't figure out how to quote two messages and so I took the easy way out.Quote from: onlooker on June 10, 2017, 02:33:10 amI don't understand this. Not disagreeing - I just literally don't understand. The cap is charging to 2/3 Vcc and discharging to 1/3 Vcc as it should. See the attached screen captures (this is at Vcc = 12 volts). The cap is connected directly to Threshold and Trigger. The frequency swing is about 11% here even at a constant supply voltage.

author: MK14
author_rank: Super Contributor
timestamp: June 11, 2017, 12:38:56 am
content: Quote from: raw_circuits on June 10, 2017, 11:15:41 pmI think you have analysed it correctly, as I can't see anything wrong, when I read through it. 2% is not that much of a variation, when you were experiencing a considerably higher frequency variation with supply voltage.I've noticed it is NOT an original 555, but a CMOS equivalent one. Did you buy it on Ebay/China or does it come from a mainstream/reliable supplier, such as Digikey/Mouser etc ?I.e. If it was from Ebay/China, it could be substandard/faulty/fake/bad and hence cause your frequency variations (but if your scope confirms the threshold is remaining 1/3 and 2/3, then I guess it is NOT too bad, anyway).Quick messing with a similar circuit to yours with LTSpice, seems to show approximately an 11% frequency variation (because of the diodes), between 5V and 12V. So I still don't know why you got something more like a 34% variation over that voltage range.Quote from: onlooker on June 10, 2017, 02:33:10 amIn principal I agree with you. The diodes will cause a significant variation with supply voltage, which seems to be about 11% (5V to 12V), when I messed around with it in LTSpice.I just originally thought it was mainly because of the timing capacitance's variation with voltage, but that seems to have been mostly ruled out now.

author: raw_circuits
author_rank: Contributor
timestamp: June 11, 2017, 12:57:45 am
content: Quote from: MK14 on June 11, 2017, 12:38:56 amIt would be from a reputable source, likely Mouser or at worst Fry's. It's ancient though - been around for a while. I'll get a new one to test with but it will likely be several days.I really appreciate all the help. This is a good learning exercise for me.

author: floobydust
author_rank: Super Contributor
timestamp: June 11, 2017, 01:11:55 am
content: I suggest having a power supply bypass capacitor.Your diodes look like zener diodes. Check their part number.

author: MK14
author_rank: Super Contributor
timestamp: June 11, 2017, 01:13:26 am
content: Quote from: raw_circuits on June 11, 2017, 12:57:45 amThat is a good idea (trying a different/new one). In all probability, it won't make any difference (based on other, similar threads), but it is nice to eliminate that source of error.In general CMOS parts are more susceptible to damage, from ESD (static) and overvoltaging than some other types (bipolar), but the modern ones are much improved compared to the ancient ones, which were notoriously easily damageable (the original ones tended to have NO protection at all).You just had to look at them funny, and they would breaktl;drThe CMOS version of your 555 may have got inadvertently damaged somewhere along the line, so it is nice to eliminate it as a source of the errors, even if it is only a 10 or 20% chance.

author: MK14
author_rank: Super Contributor
timestamp: June 11, 2017, 01:44:46 am
content: Quote from: floobydust on June 11, 2017, 01:11:55 amNow you mention it, they do look a bit odd. That would/could explain the strange larger than expected variation in frequency with supply voltage, so well worth checking out.If that is the case (they are zeners or something), well spotted

author: onlooker
author_rank: Frequent Contributor
timestamp: June 11, 2017, 02:49:37 am
content: Quote1).the multiplier to RC is,a=ln(start_voltage_cross_resistor/end_voltage_cross_resistor)Or simply,a=ln(resistor_voltage_ratio_at_2_time_points)With the diode, the flip of 555 still occurs at the voltages of the capacitor reach 1/3 x V+and 2/3 x V+, but the corresponding voltages over the resistor will need to subtract the voltage drop on the diode to calculate the "a" constant.2).Thanks for the waveform pictures. It will be helpful to show the waveform of the discharge pin together with the other waveforms of yours. The purpose is to see how close it is driving to the ground. LT datasheet gives 300mV max.With your newer smaller frequency variation (53.2HZ@14.9% and 59.2Hz@80.5%). A relatively bad saturation voltage of the discharge pin may explain it. In fact, for such cases, the problem can be compensated by adding a Schottky diode in series with the diode on the charging path (or better to also change all the diodes to Schottky).On the other hand, your output pin (?yellow) was very close to the ground when low. You may try to use the output pin to drive charging and discharging (google helps) and to see if it works better .

author: raw_circuits
author_rank: Contributor
timestamp: June 11, 2017, 04:04:50 am
content: The yellow trace in the previous scope captures was indeed output. The attached captures here show the cap and discharge.

author: danadak
author_rank: Super Contributor
timestamp: June 11, 2017, 10:32:56 am
content: Another way of doing this, with more precision is to use a PSOC.See attached screenshot. You could use a 2 turn, 5 turn, 10 turnpot in this design to produce more resolution.The design has no external components except for the pot, and bypasscaps for the PSOC Vdd pin.With ~ 20 lines of code you can have a more repeatable stable accurate solutionto the problem. And tons of other capability on the same part/chip.Just a thought.Regards, Dana.

author: onlooker
author_rank: Frequent Contributor
timestamp: June 11, 2017, 02:46:39 pm
content: Quote from: raw_circuits on June 11, 2017, 04:04:50 amLet us 1st list some numbers from your waveforms:(assuming the scope is in calibration)1). The flip voltages on the capacitor are not really at 1/3*V+=4V and 2/3*V+=8V. They are about3.8V(4-0.15)=3.85V and (8-0.2) = 7.8 V.2). The 1st picture (duty=13.30%) shows the saturation voltage of the discharge pin is about 360 mV for the most part.Now we can calculate the "a" values for the charging and discharging paths:--For charging,a=ln([7.8-0.7]/[3.8-0.7]) = 0.8287Correction: need to use voltage ratio on the charging resistor and with more accurate numbersa=ln([8.15-0.7]/[4.2-0.7]) = 0.755--For discharging,a=([7.8-0.7-0.36]/[3.8-0.7-0.36]) = 0.900a=([7.8-0.7-0.36]/[3.85-0.7-0.36]) = 0.882Edited below:That is, the frequency ratio for duty=100% vs duty=0% is 0.882/0.755 = 1.17, or a 17% increase from duty=0%. After correct for your waveforms that have duty=80% and 13.3%, the 17% becomes about 15%, which is close to the 11% you observed as a 1st order approximation.A simple sensitivity calculation indicates that a parameter (flip Vs, discharge saturation, diode v drop) change of 100mV can cause 0.4% to 2.6% change in the frequency variation between duty=100% and 0%.Using more accurate measured discharge saturation voltage and the capacitor flip voltage should give a number matching better with the observed 11%.

author: floobydust
author_rank: Super Contributor
timestamp: June 12, 2017, 07:50:57 pm
content: I say they are Motorola zeners, 1N52xx parts. I have a bunch. Never seen ordinary diodes in silver case.All this math here...

author: raw_circuits
author_rank: Contributor
timestamp: June 13, 2017, 06:16:35 pm
content: Thanks to all for your help and your patience. I believe I am slowly beginning to grasp the math. I've attempted to work through the equations from KVL. I think I have worked out the charge circuit but I haven't quite got the discharge side down - I haven't had much time to focus on it in the last few days. And trying to recall differential equations from 30 years ago... ouch.

author: MK14
author_rank: Super Contributor
timestamp: June 13, 2017, 06:27:57 pm
content: Quote from: raw_circuits on June 13, 2017, 06:16:35 pmA number of people have said they think you have accidentally put in zeners instead of diodes, in your breadboard circuit.If so, then that can easily explain the problems with the timings being wrong (at different voltages) etc.

author: StillTrying
author_rank: Super Contributor
timestamp: June 13, 2017, 07:36:24 pm
content: The scope pics in Replies#14 and #21 show the correct voltages and no zener diode action.Of course you could put a scope channel on each side of a diode and see the 0.65V conduction voltage.

author: MK14
author_rank: Super Contributor
timestamp: June 13, 2017, 07:56:54 pm
content: Quote from: StillTrying on June 13, 2017, 07:36:24 pmThey do appear to. But when the OP experienced the wrong/unexpected frequencies (which may not be on the scope pictures we have), maybe the pot/trimmer position(s) were changed and the possible zeners, were influencing the situation ?I'd prefer to clarify the situation, rather than take lots of assumptions.So far, I can't see any schematic (of EXACTLY what he did), we have a picture, which might have completely different components to what we were expecting, and the scope traces may have been taken under different settings, to what he was complaining about.tl;drI would prefer to have solid facts, rather than lots of unknowns.