555 timer in Astable mode, first pulse problem. - Page 1
Forum section: electronics / beginners

author: Heisen
author_rank: Contributor
timestamp: January 31, 2023, 04:14:42 am
content: Hi everyone,I have my 555 timer configured in astable mode outputing 1hz square wave. Following is the circuit that I am using.But with a small change, I have the reset pin of the 555 timer connected to a debounced push button, which connects it to either VCC or GND. I want to start and stop the square wave with the push button.The output waveformyellowlooks fine. Thebluewaveform is of the charge/discharge capacitor.Here comes the trouble, when I release the push button the output turns off immediately as expected but when I push the button to start the output, the timing of the first pulse is longer then the rest due to the completely discharged timing capacitor.Any idea how to fix this glitch?Thanks.

author: Ian.M
author_rank: Super Contributor
timestamp: January 31, 2023, 07:09:57 am
content: That's tricky. The best option is not to use a 555. E.g. if you use a CD4060 with a high enough RC clock frequency (i.e. take the output from Q7 or higher Qn), the first cycle error (after you take RST low to release it) will be negligible.However if you must, you can get there by precharging the 555's timing capacitor to 1/3 Vcc when Reset releases. The easiest way to do that is to split it into three equal capacitors, two in parallel to Gnd and the other to your Reset signal source, which must be a stiff push-pull output. See attached LTspice sim.N.B. a CMOS 555 doesn't need that BJT + diodes circuit to get a 50% duty cycle - simply drive the timing resistor from the Output

author: ledtester
author_rank: Super Contributor
timestamp: January 31, 2023, 12:04:52 pm
content: Quote from: Ian.M on January 31, 2023, 07:09:57 amYou can find this approach on the Falstad simulator:https://falstad.com/circuit/circuitjs.htmlGo to the Circuits menu -> 555 Timer Chip -> Square Wave GeneratorThat schematic has a 1M pull-up on the threshold/trigger node -- is that needed?

author: Ian.M
author_rank: Super Contributor
timestamp: January 31, 2023, 12:27:53 pm
content: I doubt it - it seems to start OK without it. However it may be a tweak to square up the duty cycle for a 555 that doesn't quite have a rail-to-rail output.Try thisFalstad version of my gated circuit.N.B. Falstad is *NOT* a Berkley SPICE based simulator and can give very misleading results. So can various SPICEs, but usually less often + there are more customisation options to avoid or minimise non-physical behaviours.Edit: Corrected error with gate signal swing - see Ledtester's comment below.

author: shapirus
author_rank: Super Contributor
timestamp: January 31, 2023, 12:30:14 pm
content: What if you invert the output and use the low cycle halves as high? This will of course need ANDing with the button's level to prevent getting high output when the timer is off. This will however introduce a delay before getting first high on the resulting output, not sure if it's acceptable for your application.

author: Zero999
author_rank: Super Contributor
timestamp: January 31, 2023, 12:39:24 pm
content: Quote from: Heisen on January 31, 2023, 04:14:42 amThe problem is C starts at 0V, yet it only discharges to1/3VCC, so the first pulse is always longer.Halve the value of C and add another capacitor, with the same value, between pin 6 and your switch. The two capacitors form a divider, so the voltage starts will always start at1/2VCC, when the switch is connects to VCC. The disadvantage of this is, charging capacitors is hard on the switch, so you can add a low value resistor (try 47R) in series with the switch and the capacitors, to limit the surge.EDIT:I stand corrected by IanB. The capacitor voltage should start at1/3for the first output pulse to be high for the same length of time as the others.

author: Ian.M
author_rank: Super Contributor
timestamp: January 31, 2023, 12:50:16 pm
content: No. You want it to start at Vcc/3 not Vcc/2 otherwise you'll get a shortened first pulse. Use 1/3:2/3 (of existing Tc) capacitor values to fix that and you've basically got my circuit.

author: ledtester
author_rank: Super Contributor
timestamp: January 31, 2023, 01:09:26 pm
content: Quote from: Ian.M on January 31, 2023, 12:27:53 pmThe square wave generator is bi-polar. Perhaps you want max voltage = 5V with a 5V offset?

author: Ian.M
author_rank: Super Contributor
timestamp: January 31, 2023, 01:14:44 pm
content: OOPS!!! Thanks. It still sorta works in simulation as the doubled swing drives the timing node to 2/3 VCC, so it outputs a runt pulse then starts properly after a discharge half-cycle but its certain to cause problems and maybe even blow the chip in real life.As I have fixed the link above, but believe in eating the crow I've cooked, here's the bad version:https://tinyurl.com/2d3zbn3f

author: Zero999
author_rank: Super Contributor
timestamp: January 31, 2023, 02:38:15 pm
content: Quote from: Ian.M on January 31, 2023, 12:50:16 pmYes, you're right. Starting at1/2VCCis no good.Another way is to use a potential divider to bias the other side of the capacitor, with a potential divider.50% duty cycle can be achieved by putting a resistor of 42.3% of the value of the pull-up in series with the discharge pin.

author: Heisen
author_rank: Contributor
timestamp: January 31, 2023, 02:45:38 pm
content: Quote from: Ian.M on January 31, 2023, 07:09:57 amOkay, I didn't have CD4060 so I ordered it, I also looked for CMOS version of 555 timer but it was not available in DIP version anywhere on local sites in my area.In the meantime while the part arrives, I'll try other combinations with the NE555 and post results.This circuit is a sort of test jig for testing another circuits that I am making, the requirement is 1Hz square wave is needed at different voltage levels (12v roughly, 4.7v, 2.7v) on the push of the button, I went with 555 timer because it works up to 15v VCC, with zener diodes on the output I can get the 1Hz square wave in the other voltage levels.But now observing that the first pulse is a problem with 555 timer. I can't try the circuit shown by Ian.M because I don't have CMOS 555.The CD4060 looks promising, hope it works with 32.768kHz crystal but I have to use two CD4060, first divide by 7 and then divide by 8 to get 1Hz. Hmmn lets see, I'll post soon.

author: Heisen
author_rank: Contributor
timestamp: January 31, 2023, 02:49:03 pm
content: Quote from: Zero999 on January 31, 2023, 02:38:15 pmThanks, I'll try this and post back.

author: Ian.M
author_rank: Super Contributor
timestamp: January 31, 2023, 02:52:51 pm
content: Try splitting the capacitor as per my circuit in your NE555 NPN + 2 diodes circuit. The capacitive divider to start from 1/3 Vcc on the rising edge of /RESET, is independent of the 50% duty cycle mod. If your switch can handle approx 200mA and is SPDT between Vcc and Gnd, you can omit the MOSFETs like the Falstad version. Keep the 22 ohm resistor or it will kill your switch.While a CD4060 *can* be used with a 32.768KHz watch crystal, LF 'tuning fork' crystals are rather fussy about drive levels and you'll probably have an interesting time getting it to work.Personally I'd use a MCU to generate the timing and a level shifter to make the output pulse bigger. What sort of level shifter is the big question - which depends on what risetime you need and how much current the pulse output must source and/or sink.

author: Heisen
author_rank: Contributor
timestamp: January 31, 2023, 03:41:13 pm
content: Quote from: Ian.M on January 31, 2023, 02:52:51 pmI tried this and it works beautifully except my frequency is not 1Hz most likely it some mistake on my part, working on it.

author: shapirus
author_rank: Super Contributor
timestamp: January 31, 2023, 03:43:45 pm
content: Quote from: Heisen on January 31, 2023, 03:41:13 pmBut first pulse is still a little bit longer than the following, I'm pretty certain that I see it even without cursors :)

author: Heisen
author_rank: Contributor
timestamp: January 31, 2023, 03:53:20 pm
content: Quote from: shapirus on January 31, 2023, 03:43:45 pmYes it is off little bit, but the idea worked, much better than before, I'll come to it once I fix my frequency first.

author: Ian.M
author_rank: Super Contributor
timestamp: January 31, 2023, 04:04:09 pm
content: Trim Rt to suit. I made no particular effort to get it right in the sim, and your circuit doesn't drive Rt rail-to-rail so it will be wrong anyway. In your circuit, it will also be supply voltage dependent.

author: Zero999
author_rank: Super Contributor
timestamp: January 31, 2023, 06:25:19 pm
content: Quote from: Heisen on January 31, 2023, 02:49:03 pmIt can be applied to the circuit attached to the original post. Note I removed one of the diodes which isn't needed.

author: Heisen
author_rank: Contributor
timestamp: February 09, 2023, 02:35:36 pm
content: Hi, everyone.I found one more solution on another forum. To fix the first cycle of the 555 timer in astable mode you just need 3 components, 2 resistor voltage divider and a diode, preferable schottky diode. I am unsure about the exact theory behind this but it works. This doesn't need any change to your already configured timing resistors and capacitor.The voltage divider through the diode will pre charge the capacitor close to 1/3 VCC. To compensate the voltage drop of D1, R5 can be adjusted, if R5 becomes too big the circuit doesn't work, it can also be omitted completely but then the capacitor will pre charge only to (1/3VCC minus the voltage drop of D1).After trying many solutions on breadboard including this one, the first pulse can not be exactly matched to the rest of the pulses, it will always be slightly longer, but this makes it less noticeable.I hope it helps.

author: BillyO
author_rank: Super Contributor
timestamp: February 09, 2023, 03:35:01 pm
content: Why not just use a microcontroller? Some are nearly as cheap as a (real) 555 these days and you can get precise results very quickly. It seems a shame to waste all the time that have already spent on solving this problem. You could have done this in 10 minutes with even a simple PICAXE 08M2 with only adding a push button and resistor.Anyway, looks like you are getting close. Maybe only a few more hours of work.

author: Heisen
author_rank: Contributor
timestamp: February 09, 2023, 04:05:24 pm
content: Quote from: BillyO on February 09, 2023, 03:35:01 pmI thought I could do it in hardware but realized quickly that this is tricky and microcontroller is the right way to go. But then one thing led to another, pain became pleasure and here we are.

author: BlackICE
author_rank: Regular Contributor
timestamp: February 11, 2023, 01:50:43 am
content: Decades ago I used the 555 timers and 556 timers. But nowadays I would just program Atmega 328p and have it output whatever waveform I want. A little more expensive but easier to do and for low frequencies works fine. You don't care about the exact frequency you can use the internal oscillator and save on the parts count. Besides the 555 isn't that stable anyway.

author: Ian.M
author_rank: Super Contributor
timestamp: February 12, 2023, 05:42:36 pm
content: Where a 555 still wins is when you need a quick and dirty coarse tolerance delay, or repeating pulse signal in a nom. 12V system. To get there with a MCU, you need to regulate the 12V down to 5V or 3.3V to power the MCU, then level-shift the output back up to a 12V swing.

author: Laurencewilliams
author_rank: Newbie
timestamp: February 12, 2023, 05:49:18 pm
content: Quote from: Ian.M on February 12, 2023, 05:42:36 pmHi! Yes, that's correct. The 555 timer is a versatile and low-cost solution for generating simple delay and repeating pulse signals in a nominal 12V system. Its simplicity and low cost make it a popular choice for hobby and educational projects.The level shifting requirement is one of the challenges in using a microcontroller (MCU) in such a system. The 555 timer doesn't have this requirement, and its output can be directly connected to a load. On the other hand, MCUs offer greater versatility and programmability, allowing for more complex signal generation and processing.Ultimately, the choice between a 555 timer and an MCU for a particular application depends on the requirements and trade-offs of the specific application, such as cost, complexity, accuracy, versatility, and power consumption.

author: Ian.M
author_rank: Super Contributor
timestamp: February 12, 2023, 05:58:21 pm
content: Is anyone aware of a '555 replacement' ATtiny breakout board with the regulator and output level shifters? Preferably readily available from the usual far East suppliers . . .

author: Zero999
author_rank: Super Contributor
timestamp: February 12, 2023, 06:06:58 pm
content: The CD4504 can be used as a level shifter, but it has a low current output and is a bit overkill if all you need is one channel.https://www.ti.com/lit/ds/symlink/cd4504b.pdf

author: Ian.M
author_rank: Super Contributor
timestamp: February 12, 2023, 07:28:30 pm
content: Yes, that's a bit on the weak side, even if you buffer it with a BJT emitter follower complimentary pair. IMHO something closer to the ~200mA source/sink capability of the original 555 would be more useful. Maybe there's a MOSFET driver that could be abused to handle that without excessive voltage drop.