# Frequency to voltage conversion

#### john green

##### Member
I have a project that requires the monitoring and using a data logger to record, among other easier parameters, any change in the speed of ten dc motors over a test period of some weeks.

The motors have encoders but though recording such square waves directly is quick and easy, this does not present a very user friendly solution when it comes to reading or monitoring the speed. A much more appropriate option for a clear and easy to read graphical presentation is to converting the encoder frequency to an analogue voltage.

I realise I can do this with off-the-shelf hardware but I am wondering whether there is an effective PICAXE way of achieving the same effect.

The encoder output is a clean square wave (hall effect switch) and in the order of 80Hz at the correct running speed. The motor speed is 400rpm and it would be preferable to be able to measure this to the nearest couple of rpm - so a resolution of 0.025 volts on a 5 volt range.

#### Buzby

##### Senior Member
Capturing signals at 80Hz is quite easy with Picaxe, and there are lots of options with what do with the captured signal.

By measuring the length of each transistion of the square wave it is easy to calculate RPM. To keep the software simple, I would use a Picaxe per channel, which could then output a 0-5v for the speed, and a digital ( LED or buzzer maybe ) to indicate speed errors.

Unfortunately, the DAC on Picaxe is very poor resolution, [EDIT only 8-bit, 256 levels, i.e 0.0195v per step at 5v, only 5-bit, 32 levels, i.e 0.156v per step at 5v, nowhere near enough to give the results you need. ] Sorry, I don't know why I said the DAC was 8-bit. Must have been a Senior Moment.

One possible solution is to use the DAC to indicate the measured error, not the actual speed. This will give much greater resolution, as the full 5v range will now cover, say, -10rpm to +10rpm.

Another solution is to generate a PWM signal into a simple R/C filter. This would give the required analogue resolution, but it would be very dependant on the target load. A buffer circuit would be needed to handle this.

Cheers,

Buzby

Last edited:

#### AllyCat

##### Senior Member
Hi,
A much more appropriate option for a clear and easy to read graphical presentation is to converting the encoder frequency to an analogue voltage.
What do you plan to do with the "analogue voltage" when you've generated it? Most displays and storage devices are (now) likely to be digitally-based.
Unfortunately, the DAC on Picaxe is very poor resolution, only 8-bit, 256 levels, i.e 0.0195v per step at 5v, not quite enough to give the results you need.
Which PIcaxe is that, most have only a 5-bit DAC (32 levels) with an output impedance of up to 40 kohms? But, as said above, a PWM output can be low-pass filtered to give up to 1024 voltage levels with a much lower source resistance/impedance than the PICaxe's DAC. Typically use a resistor between about 1k and 10k and a capacitor to give an appropriate time constant for the frequency and acceptable output ripple. One issue is that the amplitude of the output pulse waveform needs to be regulated/stabilised. However, I devised a compensation method using CALIBADC10 some years ago, documented in threads HERE and HERE.

Another method to convert frequency directly to a voltage is simply to use the encoder output edges (positive or negative) to trigger a traditional "Monostable (multivibrator)" circuit such as a 555 timer (or a PICaxe) followed by a low-pass filter. The duration of the monostable's pulse is chosen to be somewhat less than the shortest triggering period (and the monostable's recovery time), but again the amplitude of the square wave must be stabilised to give an accurate DAC output.

Cheers, Alan.

Last edited:

#### fernando_g

##### Senior Member

You could use a LM331.

Figure 18 on the data sheet I have used to convert the tachometer pulses from a small Wilesco steam engine to drive an analog meter.
I wanted the analog meter to maintain that vintage look.

Last edited:

#### Attachments

• 761.8 KB Views: 15
• 129.9 KB Views: 14

#### john green

##### Member
Thank you all for those replies.

The purpose of the planned tests is to observe comparisons between different set ups of the same equipment and this entails recording a number of other parameters that are easy to work with in analogue rather than digital form. I have and use Pico data loggers these being very adequate for such tasks and which require low voltage analogue inputs.

Reflecting upon Buzby's thought of using the measured error, I did think about using that over a limited speed range and use an error flag to stop the test running if the speed wanders too far from the optimum values given that if there is any great change, this will indicate a fault that will have to be investigated.

While pondering the possibilities I went for a rummage through some boxes of older stuff and found some LM2907 frequency to voltage converters that have not seen the light of day for at least 30 years although these are still very easily available to buy. Looking at the results of a bit of testing, I think these will be my solution for this particular job. I will however also now have to have a look at the LM331.

That's a nice looking set up Fernando - and you know what Erco? I've got that very book by Forrest Mimms too!

#### fernando_g

##### Senior Member
The IPhone picture size is enormous and this forum limits the image size. The photo is significantly cropped, it shows less than 25% of the total setup. Missing are the boiler and stack, all the bands and pulleys driving several mechanical loads, and a pair of lights powered by the generator.
All from this little engine!