Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Cheapskates voltage to frequency converter

Status
Not open for further replies.

fourtytwo

Active Member
Hi all,

Been banging my head thinking about how to do a cheap reasonably linear VFC for measuring isolated solar panel voltages, the frequency output could be coupled optically, through a capacitor or by transformer (to name a few). Of course there are also isolation amplifiers but I don't want to break the piggy bank!

First off I came up with a 555 circuit using current mirrors but the latter was the problem as RS only sell them in silly quantities and the design called for both pnp & npn.

Later I looked at chips like the LM331 but put off by the prices.

Then I thought of the ubiquitous Microchip PIC, the problem is not so much the ADC (pays your money gets your resolution) but how to get the frequency out of it particularly if you want more than 8 bit resolution (that I do). There is no clock output from any timers and the PWM isn't exactly designed for frequency jumps (more duty changes). The SPI interface looks promising but limited to 8 bit resolution, the UART bit rate generator however can be put in 16 bit mode with a 16 bit synchronized load even in an 8 bit processor. By using this interface in synchronous master mode the clock comes out of a pin Aaahhhh.

The only downside is the BRG is reset on every load, meaning the interval between loads needs to be several clock cycles for the receiver to be able to synchronize.

The cost, if I use a PIC16L/F1782 I have used before ~£1.80, this has a 10bit ADC.

Please if someone has a favorite low cost single supply VFC tell me as I have searched everywhere..........
Comments including your nuts because xyz welcome :)

PS I would have tagged on the end of the other threads on VFC's but there all closed due to age.
 
How about just a 555 astable fed from a stabilised supply, with the "charging" resistor being high value and direct from the variable input voltage?

That should give a frequency in proportion to the voltage, I reckon?
 
How about just a 555 astable fed from a stabilised supply, with the "charging" resistor being high value and direct from the variable input voltage?

That should give a frequency in proportion to the voltage, I reckon?
Absolutely right but rather non-linear, this could of course be compensated by an mpu look up table at the other end but hard to get 10 bit resolution maybe. Perhaps I should give it a go in the simulator :)
Hmm KISS principle again, visually seems to work just as well without the current mirrors o_O Thankyou :)
Ahh the fly in the ointment, without the current mirrors it doesnt work when vin <= 2/3rds vcc :(
 
Last edited:
Why mess about with VFC? - just measure it with a microcontroller (the 18F27K42 has a 12 bit one - seeing as I've just confused myself by transferring it's value to a 10 bit PWM) and send it as some kind of serial data, even radio?.
 
Why mess about with VFC? - just measure it with a microcontroller (the 18F27K42 has a 12 bit one - seeing as I've just confused myself by transferring it's value to a 10 bit PWM) and send it as some kind of serial data, even radio?.
YUP that was the solution I originally envisaged after trying other routes, however quite willing to try any suggestions I had not thought of, that's why I posted.
 
If you want a near infinitely variable frequency out of a PIC, use the output compare unit.

Use an integer or 16 bit variable to keep running total and another 16 bit int for the period value, with the output compare set in toggle mode.

Each time a compare event happens, add the period to the total and write the new total to the compare register.

It's a 32 MHz device and that only takes a few cycles; it should be able to run as fast as you could possibly need.
 
If you want a near infinitely variable frequency out of a PIC, use the output compare unit.

Use an integer or 16 bit variable to keep running total and another 16 bit int for the period value, with the output compare set in toggle mode.

Each time a compare event happens, add the period to the total and write the new total to the compare register.

It's a 32 MHz device and that only takes a few cycles; it should be able to run as fast as you could possibly need.
Much better then the UART BRG, still 16 bit in 8 bit devices, thank you :) BUT there might be some flies as software intervention is required, I want to run low power and interrupt latency would cause jitter I see as the software has to reload the timer for the next cycle, if auto trigger is set to make this happen automatically it disables the o/p pin for some crazy reason, utopia doesn't exist sadly
 
Last edited:
Here's a 555 VFC that uses a Howland current pump circuit to give a linear charging current versus input voltage:

1613683297760.png
 
Last edited:
Here's a 555 VFC that uses a Howland current pump circuit to give a linear charging current versus input voltage:
That does it for me! replace unobtainium transistor pairs with a simple r-r op-amp! Many thanks indeed, fixes all those nasty PIC problems and it's low power (given a cmos 555) :)
 
Just a thought, but wouldn't a PWM modulator circuit be better than VFC for your purpose?
You just have to average the voltage of the PWM signal to recover the modulating voltage.
 
Or you can beg for one of these and I will gladly send one.
I have a box full and don't know what to do with them. 0.01% linearity sounds like a lot of precision for a cheapskate. Also, they require a +/-12 to +/-15V supply.
Edit: And I didn't see your single sup request.
 
Or you can beg for one of these and I will gladly send one.
Sounds like one of those for the transmitter and one from the receiver should work well.
 
Just a thought, but wouldn't a PWM modulator circuit be better than VFC for your purpose?
You just have to average the voltage of the PWM signal to recover the modulating voltage.
I considered bias distortion across the isolation bridge extremely likely and I laughingly thought a VFC would be simpler.
 
I considered bias distortion across the isolation bridge extremely likely
What is "bias distortion"?
What "bridge"?
I would use an opto-isolator to couple the signal.
As long as the isolator transmits the PWM signal (which can be a relatively low frequency in your case) with reasonable fidelity, then I don't see a problem.
 
Bias as in distorted mark-space ratio
Bridge as in isolation
An opto-isolator is what I am trying first although the drive current is challenging in a low power design.

I don't see any particular reason to favor PWM but then we all make choices according to our experience and perhaps hidden nuances of the application.
ATM in simulation I have this circuit working from 3 to 40V self-powered and consuming <8mA, I hope to improve on that in bench testing.

Thank you and everybody else for there help :)
 
The PICs have 16bit timers and pre-scalers and can achieve frequency output protocols that are way beyond the 10- or 12-bit ADC on board.
 
Bias as in distorted mark-space ratio
should not be a particular problem with PWM.
An opto-isolator is what I am trying first although the drive current is challenging in a low power design.
You are measuring solar panel voltage which, I assume generates a significant amount of power, so why is power a concern?
 
The PICs have 16bit timers and pre-scalers and can achieve frequency output protocols that are way beyond the 10- or 12-bit ADC on board.
But the problem was getting the frequency out of the wretched thing! Not easy without glitches on change as discussed around post #7

should not be a particular problem with PWM.
You are measuring solar panel voltage which, I assume generates a significant amount of power, so why is power a concern?
Bias distortion is a concern with PWM as any non-linearity in bias distortion will directly contribute to non-linearity in the measurement.
Power is a concern because of the power supply for the measuring unit, I chose linear to avoid high value expensive inductors hence with a <=40V input every mA counts!
 
But the problem was getting the frequency out of the wretched thing! Not easy without glitches on change as discussed around post #7

No, no. The 16-bit timer/counter is hardware and doesn't rely on code other than to set it up. You can also use the PWM to set the PWM period (not frequency) to nearly any frequency you want as a 16-bit range. You can also slow/speed system clock to increase dynamic range or to tune dynamic range. The PWM period can be set in a buffer register and activated at the next period start so there is no clutch related t code as viewed by the receiver. The max delay of most recently read ADC value until output as a frequency would be a few clock cycles (millionths of a second) and then wait for the current PWM period to finish (about 1/10,000 second).
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top