Square wave signal to a fixed pulse width signal - Page 1
Forum section: electronics / beginners

author: pman92
author_rank: Contributor
timestamp: February 23, 2022, 08:55:38 am
content: Hey guys,I have a working circuit that uses a MOSFET and an inductor that is "charged up" (if that's the correct terminology) / saturated and then switched off. The resulting voltage spike from the inductor is used as a signal to drive an older style automotive tachometer. The circuit receives a square wave input that is always 50% duty cycle (but varies frequency from a few hertz to probably no more than 1 or 2 kHz).At lower frequency's the inductor spends most of its time switched on pointlessly. It is already fully saturated, but current continues to flow through it until the next edge of the square wave, pointlessly wasting current and generating heat.I would like to be able to use the square wave signal to generate another square wave signal, which has the same frequency, but a fixed / shorter time when it is high. Essentially a signal with a variable duty cycle to only remain high for long enough to saturate the inductor and then switch low. I could use that signal to drive the MOSFET gate and eliminate the inductor being switched on for the excessive amount of time.I'm figuring I'll use some resistor/capacitor arrangement (with correct values for the desired amount of on/high time) along with a comparator or logic gate to compare that "slow changing" voltage to some other fixed voltage and produce the required output. However I'm not exactly sure how to approach it.It is not important if the new signal is out of phase (it can be high when the old signal is low). It also doesn't matter if its triggered on the rising or falling edge. However it is important that the new signal doesn't bounce between off/on at the transitions. A simple solution with the fewest number of components would also be preferred.Thanks in advance for any advice.Cheers

author: Terry Bites
author_rank: Super Contributor
timestamp: February 23, 2022, 10:13:33 am
content: What you need is a (non retriggerable) monostable- it gives a fixed pulse width output independently of the input pulse width. A 555 (related to the 666) will work here.Replace the switch in this circuit with your mosfet.https://www.electronics-tutorials.ws/wp-content/uploads/2018/05/waveforms-tim38.gif

author: Benta
author_rank: Super Contributor
timestamp: February 23, 2022, 11:23:48 am
content: A better choice would be MC14538.But yes, an edge-triggered, non-retriggerable monostable is the way to go.

author: Damianos
author_rank: Frequent Contributor
timestamp: February 23, 2022, 11:10:03 pm
content: If the main goal is the minimum number of components, then just put a capacitor in series with the square wave signal. Assuming that there is a resistor, between gate and source of the MOSFET, it will make a differentiator, that produces short pulses at each edge of the input signal. This may increase the heating of the transistor due to the slow falling of the voltage. This can be solved by using a Schmitt trigger circuit to make the pulse orthogonal.A differentiator is also needed at the input of the proposed "555" circuit. [EDIT: because the trigger signal must be of shorter duration than the output]A proper solution (I think so) will be a circuit that detects the current limit and resets the operation, waiting for the next pulse. But this may be a little more complicated.

author: pman92
author_rank: Contributor
timestamp: February 24, 2022, 09:07:26 am
content: Thanks guys.I've decided I'll go with the series capacitor option to reduce the number of components and limit complexity.I've calculated (and checked with the scope) that the inductor only takes 200uS to saturate, so even at the fastest frequency I think I'll ever need its much faster than required.I'm already using an inverter gate/schmitt trigger elsewhere, so if I can use another one of them the same that would mean I don't need any new types of components.I've come up with a proposed circuit (see picture). I decided I need to add a series resistor before the capacitor to limit the current in/out of the microcontroller (which is supplying the square wave). I decided on 470R as I'm already using one elsewhere and it seemed like an appropriate value (approx 10mA current at 5v).I have found the switching threshold voltages for positive/negative going transitions in the Schmitt trigger/inverter gate datasheet. Obviously there will be a bit of pulse length variation depending on how the schmitt trigger performs (temperature etc.), but working with the min/max values specified I'm sure I can find something that works (it doesn't matter if its on too long as I have plenty of time to work with).I'm at a bit of a loss on how to calculate the capacitor and resistor values connected the inverter gate input, so as to create the desired pulse length. I'm familiar with calculating the RC time constant, but the additional 470 ohm current limiting resistor on the other side of the capacitor confuses me. How do you calculate the time constant when you have resistors on both sides of the capacitor? I'll probably just try a heap of different values until I find something that works, but it would be nice to know how to calculate it as well.Cheers

author: ledtester
author_rank: Super Contributor
timestamp: February 25, 2022, 03:56:20 am
content: Quote from: pman92 on February 24, 2022, 09:07:26 amI presume the 470R is to prevent excess current from entering/draining through the mcu pin. But I don't think you have to worry about it in this case because the R connected to the 5V rail will limit both charging and discharging current.In any case, I think you could swamp out the effect of the 470R if you use a large enough resistor value. The basic formula is 0.7RC or 0.8RC depending on who you ask -- so there's already a fudge factor involved. Then using the chart below you can quickly assess your RC options. My feeling is that if you pick an R in the 100's of K then the 470R isn't really going to affect the timing.http://www.n5dux.com/ham/files/pdf/Working%20With%20Monostable%20Multivibrators.pdf

author: Damianos
author_rank: Frequent Contributor
timestamp: February 26, 2022, 01:34:44 am
content: When the input is in low state the capacitor is charged to 5V, then, when the input rises, the two voltages add up (Vc+Vpulse)! To protect the input of the IC put also a diode from it's input to the 5V and keep your proposed series resistor.EDIT: Check also if the Schmitt trigger can drive the transistor fast enough (both data sheets are needed).

author: ledtester
author_rank: Super Contributor
timestamp: February 27, 2022, 12:41:16 am
content: Quote from: Damianos on February 26, 2022, 01:34:44 amThat's a good point especially since the inverter is an AHC device.In researching this issue I learned that unlike other CMOS logic families the AHC family does not have a positive clamp diode on its inputs. In fact, there is this specific warning in the AHC Designer's Guide (page 14):QuoteIn an app note Maxim suggests using a Schmitt-trigger buffer from the LVC family:I suppose an LVC inverter could also be used.Given that the microcontroller is essentially irreplaceable, it might be a good idea to further isolate its output from the edge detector circuit with another buffer/inverter.AHC/AHCT Designer’s Guide - September 1998https://www.ti.com/lit/ml/scla013d/scla013d.pdfAdding Edge-Sensitive Transition Detection to GPIO Devices - Maxim App Note 4634https://pdfserv.maximintegrated.com/en/an/AN4634.pdf