Author Topic: Converting square wave to voltage dependant on the frequency  (Read 1277 times)

0 Members and 1 Guest are viewing this topic.

Offline ELS122Topic starter

  • Frequent Contributor
  • **
  • Posts: 936
  • Country: 00
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 more

or is there a good reason I didn't really find any viable solution on google ;D
 

Offline SuzyC

  • Frequent Contributor
  • **
  • Posts: 812
Re: Converting square wave to voltage dependant on the frequency
« Reply #1 on: June 29, 2021, 07:06:15 pm »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13076
Re: Converting square wave to voltage dependant on the frequency
« Reply #2 on: June 29, 2021, 07:12:37 pm »
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 . ..
« Last Edit: June 29, 2021, 07:16:16 pm by Ian.M »
 

Online TimFox

  • Super Contributor
  • ***
  • Posts: 8366
  • Country: us
  • Retired, now restoring antique test equipment
Re: Converting square wave to voltage dependant on the frequency
« Reply #3 on: June 29, 2021, 07:21:07 pm »
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 by
I = 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 capacitor C, and there is a scale expansion that sends a switchable standard current into the meter circuit to partially null out the current.
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: gb
Re: Converting square wave to voltage dependant on the frequency
« Reply #4 on: July 01, 2021, 06:20:22 am »
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.

I 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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13076
Re: Converting square wave to voltage dependant on the frequency
« Reply #5 on: July 01, 2021, 07:02:36 am »
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.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17117
  • Country: us
  • DavidH
Re: Converting square wave to voltage dependant on the frequency
« Reply #6 on: July 02, 2021, 02:37:44 am »
or is there a good reason I didn't really find any viable solution on google ;D

The 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf