555 one shot, constant output? - Page 1
Forum section: electronics / beginners

author: Infraviolet
author_rank: Super Contributor
timestamp: May 02, 2022, 10:02:58 pm
content: I'm trying to use a 555 to process a signal. I have an incoming sine wave oscillating about 2.5V. Whenever I see a negative "peak" I want to send my output high, and I want it to stay high constantly across multiple peaks, only dropping low again when a negative peak is not seen for many wave periods. It is my understanding that the monostable 55 is triggered only by negative peaks, not positive ones.I am trying to produce a constant logic high whenever the sine wave is bigger than some certain amplitude, and a logic low when it is below this amplitude. Later on I'll try to do hysteresis regarding those amplitudes, but for now simply outputting high when the wave amplitude is strong and low when the amplitude is small about 2.5V is fine. I am ofcourse also perfectly happy to have logic low output for large amplitudes and logic high for small amplitudes if that is easier.I have set up a voltage divider on the 555's pin 5 to give a level for how low I wanted this negative peak to be, and have the rest of the 555 set up in monostable mode, the trouble is that when a large enough wave is incoming the output pulses low despite the wave being constant. I had set the RC time constant for the 555 to be rather longer than several wave periods, but every several wave periods I still get this output drop. It seems the 555 is insisting in this mode on having a period of negative output before it is willing to be retriggered, hence I can't get a constant high output while the wave is present.Thanks

author: Infraviolet
author_rank: Super Contributor
timestamp: May 02, 2022, 11:21:18 pm
content: I seem to have possibly solved the first part of this, by running a diode from the higher voltage end of the cap on the 555's pin 6 with the cathode going to the 555's pin 2 where the input sine wave enters. Output now stays high constantly so long as an incoming wave with a sufficient amplitude is present, then drops low after an RC time constant when the wave stops arriving.But I'm not sure whether the hysteresis I'd hoped to build in is even possible with use of 555s? Can there be any way to make the 555's output go high for input waves above some amplitude and go low at a different amplitude? Right now if the wave amplitude is at a threshold level I get an output waveform randomly shifting between high and low, is there a way with a 555 to modify this so I can have hysteresis based on the wave's amplitude, or am I going to have to switch to another method? 555's are useful as I have a lot to hand.

author: YurkshireLad
author_rank: Frequent Contributor
timestamp: May 02, 2022, 11:42:02 pm
content: I'm really a beginner here, so apologies if I misunderstood your requirements. What about thishttps://www.falstad.com/circuit/e-555missing.html

author: Zero999
author_rank: Super Contributor
timestamp: May 03, 2022, 09:02:18 am
content: The typical monostable 555 circuit can't be triggered, until the delay has finished. What you're looking for is a retriggerable monostable.

author: Ian.M
author_rank: Super Contributor
timestamp: May 03, 2022, 10:18:29 am
content: Your problem is you are trying to do too much with a single 555. Use two, one as a comparator to generate a pulse if your signal amplitude is over the required threshold, and the other as a missing pulse detector to produce the required steady state output. Attached is a LTspice sim of one way to do that.N.B. the first 555 must be Trigger dominant (i.e. if both Threshold (high) and Trigger (low) are active, Trigger 'wins' and the output goes high). Genuine NE555 chips are, some 'clones' are not.The R4:R3 potential divider biases Trigger to 55% of CV. The internal divider provides a reference for Trigger of 50% of CV, so the signal on the Trigger pin must be greater than 10% of CV pk-pk to pulse the output high. With a 9V supply, that's about 0.6V. The R1:R2 divider reduces the input signal amplitude such that it needs over approx 2.5V to pulse. The second 555 is connected as a monostable with an external discharge transistor, and its R7.C3 time constant needs to be adjusted to suit the min. input signal frequency, and the speed of response required.However using 555s is a horrible way to do this and it would make far more sense to use a dual OPAMP or dual comparator, with one half thresholding the signal and the other as the missing pulse detector monostable.

author: Infraviolet
author_rank: Super Contributor
timestamp: May 04, 2022, 10:53:26 pm
content: Thanks for that. I've had some other ideas too now, about multi-stage ways to do it. Can I just check, and searching doesn't seem very helpful for this, nor does the TI NE555 datasheet make it obvious, when using a 555 as a schmitt trigger, does using the contol pin, pin 5, let you adjust the reference voltage about which it triggers? Does applying a potential divider between Vcc and Gnd to pin 5 let you alter both the upper and lower thresholds at once? I would need them to be more like V_low=3V and V_high=4V on a 5V supply, rather than being centred about 2.5V. Is there an equation for how V_low and V_high will vary with the voltage one applies to pin 5?

author: Ian.M
author_rank: Super Contributor
timestamp: May 04, 2022, 11:07:26 pm
content: I'm not using THRESHOLD, as CV cant be set low enough to make the hysteresis range workable, due to the headroom needed for the PNP quasi-darlington TRIGGER comparator load. The upper threshold (THRESHOLD comparator reference) is CV, and the lower one (TRIGGER comparator reference) is approx. CV/2 depending on how well matched the lower polysilicon resistors in the CV divider chain are.

author: Zero999
author_rank: Super Contributor
timestamp: May 05, 2022, 08:52:56 am
content: Quote from: Infraviolet on May 04, 2022, 10:53:26 pmIn case you're interested, there are other, arguably better, ways to do this. The 74HC123, or microcontroller spring to mind. I would choose the latter, because it's cheaper and I already know enough about the 555 but am still learning micros. I've recently written asimple programwhich could do this, with a few changes.

author: Terry Bites
author_rank: Super Contributor
timestamp: May 05, 2022, 06:35:02 pm
content: By negative you mean a signal going from a one +Ve level to a lower one. Not actually below 0V?The 555 is not retriggerable as you know. But there are some fudges, eghttp://sam.electroastro.pagesperso-orange.fr/dossiers/555/redec.gifMuch more suited to this task is a CD4538 or similar Monostable.You might want to trawl through some data sheets on watchdog timers.555s are like marmite.... (UK only remark)

author: Infraviolet
author_rank: Super Contributor
timestamp: May 05, 2022, 09:38:48 pm
content: Thanks, I could do it trivially with a microcontroller, but I've been trying to learn some use of more discrete electronics here. And I've been trying to work with very generic chips, the kinds that come from many manufacturers and are less affected by the chip crisis.That samelectroastro page is good, when you use google translate, it is the trick I found for retriggerability and works nicely, but yes, it looks like 555's aren't suited to the task I am needing to solve. There's some hope with op-amps though by the look of it.First an op amp and a diode as a peak detector with relatively quick fall off, that gives a roughly DC signal, slightly wiggly, from 2.5V to 5V, depending on the sine wave's amplitude. Then another op amp looks to be able to serve as a comparator where custom positions for the lower and upper thresholds can be set by selecting resistors around it.

author: Zero999
author_rank: Super Contributor
timestamp: May 07, 2022, 05:58:35 am
content: It sounds like you're looking for a pulse extender, rather than a monostable. A dual comparator will do the job.

author: ledtester
author_rank: Super Contributor
timestamp: May 07, 2022, 03:18:52 pm
content: Quote from: Zero999 on May 07, 2022, 05:58:35 amHi Zero999 - a question about the pulse stretcher circuit...When I run it in ltspice it shows an initial output pulse on power on. I'm wondering if that happens in real life and if there's a way to prevent it.Attached are my ltspice files.

author: Zero999
author_rank: Super Contributor
timestamp: May 07, 2022, 04:09:39 pm
content: Move C1 to be in parallel with R5.

author: ledtester
author_rank: Super Contributor
timestamp: May 07, 2022, 05:09:03 pm
content: Quote from: Zero999 on May 07, 2022, 04:09:39 pmThat's the R5 in my schematic which is R3 in yours, right? (I should have kept the same component ids)

author: Zero999
author_rank: Super Contributor
timestamp: May 08, 2022, 10:32:53 am
content: Quote from: ledtester on May 07, 2022, 05:09:03 pmYes.And here's my MCU version, which also has the issue of triggering on power on, which I put down to the fact I built it on a breadboard. A fix would be to add a delay at the start with the output low.Code:/** File: main.c** Created on 8 May 2022, 21:45*/// XC8 Compiler// Extends a pulse by 60ms.// GP0 = AC in// GP1 = output//// PIC12F509 Configuration Bit Settings#pragma config OSC = IntRC // Oscillator Selection bits (internal RC oscillator)#pragma config WDT = OFF // Watchdog Timer Enable bit (WDT disabled)#pragma config CP = OFF // Code Protection bit (Code protection off)#pragma config MCLRE = OFF // GP3/MCLR Pin Function Select bit (GP3/MCLR pin function is digital input, MCLR internally tied to VDD)// #pragma config statements should precede project file includes.// Use project enums instead of #define for ON and OFF.#define _XTAL_FREQ 4000000 // oscillator frequency for _delay()#define sGPIObits (*(GPIObits_t * volatile)&sGPIO) // shadow port structure#define MASKIN(reg,mask,x) ((reg = (mask & x)|(~mask & reg))) // mask macro to select which bits to keep. Not thread safe but smaller.//#define MASKIN(reg,mask,x) (reg^=(reg^(x))&(mask)) // mask macro. Slightly larger binary code, but thread safe.// pin definitions#define trigger GPIObits.GP0#define trigger_s sGPIObits.GP0 // shadow trigger 1#define output sGPIObits.GP1#define time_out 234 // 60ms#define TRIS_set 0b111101#include <xc.h>#include <stdint.h>volatile unsigned char sGPIO = 0; // shadow register__bit triggered = 0;void main(void) {OPTION = 0b11010111; // configure Timer0://-1------ disable weak pull-ups//--0----- timer mode (T0CS = 0)//----0--- pre scaler assigned to Timer0 (PSA = 0)//-----111 pre scaler = 256 (pre scaler = 111)// -> increment every 256usTRIS = TRIS_set; // configure TRISfor (;;){GPIO = sGPIO;if (!trigger_s || !triggered || TMR0 >= time_out) // not triggered, trigger is low, or timer exceeds time out.{TMR0 = 0;triggered = 0;}if (triggered || !trigger_s)output = 1;else output = 0;while (!TMR0) // wait for a bit to make the edge detection more reliable.{}if (!trigger_s && trigger) triggered = 1; // set trigger if positive edge detected.MASKIN (sGPIO,TRIS_set,GPIO);}return;}