Converting square wave to voltage dependant on the frequency - Page 1
Forum section: electronics / beginners

author: Deactivated-1
author_rank: Frequent Contributor
timestamp: June 29, 2021, 06:49:25 pm
content: I don't have any LM2917 lying around, wonder if I can just do this without one. I need it for a shift light, the signal is 0-12volts with the frequency being 1hz = 1 rotation of the engine crankshaft, basically I need to turn on a light when the input is at ~100 hz or moreor is there a good reason I didn't really find any viable solution on google

author: SuzyC
author_rank: Frequent Contributor
timestamp: June 29, 2021, 07:06:15 pm
content: If your square waves are really square and always the same amplitude p-p, use a differentiator to feed into a rectifier and integrate the rectified result with a capacitor.The voltage at the output of this circuit will be directly proportional to the input frequency.Verbal Schematic:for instance Sq-Wave from CMOS Hex-InV ->1 nF cap--->(cathode sw diode anode to ground)+2nd diode, anode switching diode--->cathode switching diode to 10uF and 100k res to Gnd--->Bottom of 10uF to ground. Output is positive of 10uF capacitor. You can use a LM393 comparator to detect the voltage corresponding to the frequency you've decided to take action.

author: Ian.M
author_rank: Super Contributor
timestamp: June 29, 2021, 07:12:37 pm
content: As you have only asked for detecting if the crankshaft signal is over or under 100Hz, one way of doing it is to use a dual retriggerable monostable. The first section should be set up to be triggered by an edge of your crankshaft signal, with period 10ms. It will pulse if the input is under 100Hz, and remain steady at higher speeds. The second section is triggered from the first and has a period of a bit over 10ms. If its input is pulsing (<100Hz) it will stay active, but when its input stops pulsing, it will time out and go to its inactive state. A single chip solution using a dual monostable from 74xx series (or successors)or 4000 series logic families, or even using a NE556 + a couple of transistors would be possible.Another option would be a low pin count MCU programmed to time the interval between input pulses, which would be a much better choice if multiple outputs with different trigger speeds are required, or if you want different speed setpoints for shifting down vs shifting up . ..

author: TimFox
author_rank: Super Contributor
timestamp: June 29, 2021, 07:21:07 pm
content: With respect to SuzyC's reply, try googling "charge pump".My classic General Radio 1142A analog frequency meter does exactly this: squaring the input waveform, then coupling the square wave through a capacitor to a rectifier and current meter. The current is given byI=Q/t=C V f, so the square wave must have a constant amplitude.In the 1142A, the frequency range is selected by switching the capacitorC, and there is a scale expansion that sends a switchable standard current into the meter circuit to partially null out the current.

author: eblc1388
author_rank: Frequent Contributor
timestamp: July 01, 2021, 06:20:22 am
content: Quote from: Ian.M on June 29, 2021, 07:12:37 pmI notice a problem about the period of the second monostable. Its input(from the output of first mono) is still pulsing even if the crank shaft frequency approaching zero. The second mono will time out unless it has a very long period.

author: Ian.M
author_rank: Super Contributor
timestamp: July 01, 2021, 07:02:36 am
content: Good point. Yes, the second stage is going to need a significantly longer period, such that it doesn't time out between pulses at idle speed. Piston engines rarely have an idle speed under 600 RPM, so 100ms period would be appropriate. That's only a tenth of a second delay, which is probably tolerable for an indicator for human observation.An alternative strategy with much less lag would be to use a monostable and a dual D type flipflop. One D flipflop would be used to divide the input frequency by two to guarantee a squarewave. The monostable would be triggered on the rising edge of f_in/2, and its /Q output would be used to clock the other flipflop at the end of its 10ms period, which would sample f_in/2. If f_in<100Hz, it will capture logic high, and if 100Hz<f_in<200Hz it will capture logic low. Additional logic to keep the output low above 200Hz is unlikely to be needed as most piston engines redline below 12000 RPM.

author: David Hess
author_rank: Super Contributor
timestamp: July 02, 2021, 02:37:44 am
content: Quote from: ELS122 on June 29, 2021, 06:49:25 pmThe good reason is that the search term to look for is "charge pump", which is the common way to convert frequency to voltage with reasonable accuracy. It is commonly used for exactly the applications you are interested in and can be done with just a couple transistors.