Shop OBEX P1 Docs P2 Docs Learn Events
VCO as ADC — Parallax Forums

VCO as ADC

deSilvadeSilva Posts: 2,967
edited 2008-02-28 08:53 in Propeller 1
Common request here in this forum have to do with ADC. In addition to complex devices to be addressed by parallel or serial (SPI or I2C) protocols, there is the low cost variation of PWM.

Voltage controlled oscillators (VCO) are a special kind of PWM generators, easy to read and terribly low cost:
Some CMOS ICs have a VERY broad range for voltage supply. As the threshold for Schmitt trigger inputs is rather proportional to that and also proportional to the frequency when used as an RC oscillator, this is a most ingenous way to simply measure higher(!) voltages (upto 15 V). For details see the link, to be varied according to your and the Propeller's needs.
www.discovercircuits.com/PDF-FILES/4584vco.pdf
«1

Comments

  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-16 06:05
    I've thought about doing just this. I figure, the oscillation is fairly constant under a constant voltage, and if it's fairly linear, one could just read the frequency of the oscillator, and determine the voltage based on it. Cheap way to do it. I'm sure the number of bits would be pretty good considering it is the propeller counting the ticks, which is very accurate.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-16 09:48
    Caveats: It is certainly not so linear (see annotation in the link) and needs a table/interpolation in software. Also the bandwidth is limited, and it might even be susceptible to resonance...

    But many times people just want to measure their battery voltage or such....

    As a CMOS chip configured for 1 to 10 kHz it has very little current consumption, but of course it needs more than a megohms resistor network...
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-16 09:57
    deSilva said...
    megohms resistor network...

    Wouldn't this make it susceptible to noise? Even just thermal noise in the resistors?
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-16 11:36
    Generally this is true; more so with carbon based resistors which were common formerly. As they do not cost much more - and SMDs anyway - metall resistors are more used nowadays, which show a much better behaviour.

    Nevertheless ADC accuracy is determined by MANY CAUSES and needs a specific analysis with respect to noise, linearity, drifts, local temperature effects in every single case. For the hobyist there is rarely a true improvement in quality when changing from 8-bit converters to more bits smile.gif
  • AribaAriba Posts: 2,685
    edited 2008-02-16 17:50
    A better VCO solution is the CMOS 4046, it has a very linear VCO configurable with a C and 1..2 R. Because it is a PLL IC you have also a Phasecomparator, or an XOR Gate for free. The HC-versions can produce frequencies up to 30 MHz, ideal for a Prop.

    But I don't think that this solution is easier and cheeper than a SigmaDelta ADC. An advantage of the VCO solution can be that you don't need a seperate Cog for slow frequencies and low sample rates (just measure the pulslength on time).

    Andy
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-16 18:00
    The great advantage of a VCO solution is you can do the conversion next to the (remote) sensor! The connection line to the procesor is very uncritical as FM is very noise resistant. Another advantage is that you need no special voltage supply but tap the sensor!
  • TubularTubular Posts: 4,646
    edited 2008-02-16 18:21
    Analog Devices also have an interesting chip - the AD7400. Not strictly a VCO but the reading method would be similar (count the number of 1's in a time bucket rather than the number of clock transitions)

    The AD7400 reads a +/- 200mv analog signal and outputs its data as a 'density of ones' at a fixed output bitrate of 10 Mhz

    Advantages I see are 1) it offers full isolation 2) single wire input per channel 3) trade off sampling rate vs accuracy just by changing the length of the time bucket

    Not quite sure what to use it for but its certainly a different chip from the norm!
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-16 18:38
    Tubular said...
    Not quite sure what to use it for but its certainly a different chip from the norm!
    Not really.. It's a most ordinary delta-sigma modulator with a prohibitive price tag. But it is very precise, no question...
    ----
    Edit: Well, you can boost its output and connect it to a set of loudspeakers smile.gif

    Post Edited (deSilva) : 2/17/2008 3:54:53 AM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-17 04:02
    The 4046 is really versatile... Should be looked at by people learning how a PLL works.. Using just the VCO is absolutely fine for a quarter only smile.gif
    The standard CMOS versions however might not exceed 100kHz @3.3V
    The HC is more expensive...

    But they need a precise supply voltage to be precise - this is the beauty of the solution in my OP: It does not smile.gif
    The 4584 costs also around a quarter...
  • rjo_rjo_ Posts: 1,825
    edited 2008-02-17 04:29
    deSilva,

    Love the topic... have a lot of questions, but I'm sure they will get answered without me having to ask[noparse]:)[/noparse]

    I've been approaching the whole area of ADC very gingerly... I have the very vague impression that if I get the right instrument amplifier and actually know what it is doing, the ADC problems will magically disappear[noparse]:)[/noparse]

    This is a little OT, but I for one wish that you would put all of your best work and ideas into a package... sort of an advanced education kit... include a dozen of your favorite chips, a little code and a healthy dose of your enthusiasm. You could probably get the chips as samples and sell them for a modest profit.

    Then rather than saying a polite thank you, we could show our appreciation by ordering one of your packages... and learn whatever it is you are interested in teaching... what a deal[noparse]:)[/noparse]

    Rich
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-17 05:16
    smile.gif So this is also OT...
    Thank you Rich, but it will not be that easy. However I am thinking in that direction from time to time...
    I have looked through the excellent Parallax books for the Basic Stamps...
    There is nothing like that for the Propeller!
    Also - and no offence intended! - some of those books are a little bit "Don't ask - just do it." This especially avoids an easy switch to the Propeller for the unexprienced reader... And of course they are centered around Parallax products...

    In my impression the number of "Propeller-Newbies" is growing now. Some of them do the most extraordinary things and spend a lot of money for useless parts...

    They are looking for "boards"... But they do not need a board.... They need some basic instructions, starting with Ohm's Law and "What's in a repeat loop?" and "How to cut wires with a wire cutter" smile.gif

    The Propeller is a most extraordinary device - as we all know. It works best with nothing but caps and resistors around it. But it also interfaces with more complex devices... But be aware that this is not what it is created for... It is created for to DO all the things those external complex devices do.

    This however needs understanding WHAT that is in the first place....
    There are limits however (CAN, Ethernet,..) Or have a look into a modern Flash-ADC... You either buy it, or you don't smile.gif

    But there is an intermediate level... "Well, I know how to connect LEDs, I can even multiplex a 7-segment display, and I send serial data to my PC by a self programmed VerySimpleSerial. What now?"

    Yes, I see what you mean...
  • TubularTubular Posts: 4,646
    edited 2008-02-17 09:20
    How about a Flashing LED as an ADC?

    Some of these have a beautifully linear voltage vs flash frequency characteristic.

    Slow, obviously, but should do for battery level measurement (~3 to 15v). And has a built in 'status' feature...
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-17 09:37
    I think they work EXACTLY as the proposed circuit smile.gif
  • rjo_rjo_ Posts: 1,825
    edited 2008-02-17 17:50
    You might consider something like "the Chip of the Month Club." You could have regular subscribers and do what interests you most[noparse]:)[/noparse]

    Thanks again for all of your submissions... a Herculean effort!
  • DroneDrone Posts: 433
    edited 2008-02-17 18:29
    Let's not forget the venerable 555 timer that can be configured as a Voltage to frequency converter (VCO) as well as a voltage to pulse-width converter. Then there's also the discrete Programmable Unijunction Transistor (PUT) device (typically in a TO-92 package) that can act as a relaxation oscillator to convert voltage to frequency (2N6027/8). There are many op-amp circuits that do V/F etc. Retriggable monostable multivibrators (one-shots) can do a lot too in this area. For higher frequency, low-cost VCO's built with a BJT or FET oscillator with a varactor diode to tune it may work, sample the zero-crossings coming back with a timer-driven ASM routine (Hmmm....)

    Tubular... Very innovative suggestion: Flashing LEDs. It never occurred to me that there would be (as you said), "Some of these have a beautifully linear voltage vs flash frequency characteristic." Do you have any measured data and/or suggested part numbers? A flashing LED as ADC would not only provide A to D but the frequency of flashing may be useful as a front panel display if the flash frequency changes significantly over the voltage range of interest. I agree with you that flasing LEDs may be slow as an A/D, but that's ok for many apps.

    Rgds, David
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-17 18:53
    CMOS versions of the 555 are fine: e.g. ICM7555. They are very similar to the VCO in the the 4046. A comparison might be highly interesting! Of course their frequency does not depend on the supply voltage, as I erroniously implied some postings above...

    The "voltage control" in 7555 works against 66 kOhms = 50µA, sinking a similar current as the original proposition as well as in the 4046 case....
  • TubularTubular Posts: 4,646
    edited 2008-02-18 00:49
    @ Drone, the one I have tested is a Kingbright L36BSRD-B. I'll post results in a new thread once I figure out how to dump waveforms off this cro (digital cam shot is looking likely at this point)
  • TubularTubular Posts: 4,646
    edited 2008-02-18 00:54
    Is anyone building DeSilva's 4584 circuit so we can get some qualitative / quantitative data on performance and stability?
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-18 07:25
    I can give some preliminary results, also from a 7555, during the week. People having a 74HC14 can use that too, but with a limited voltage range upto - say - 8 V. A voltage devider < 10k can be used for the supply voltage as well, this however loads the signal source... Conditioning of the signal is needed when the square wave amplitude drops below 2V, which however should not happen as it will not work for such low supply voltage... For protecting the Propeller a 47k series resistor is needed, or a (flexible) CMOS level shifter

    Post Edited (deSilva) : 2/18/2008 7:39:06 AM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-26 00:11
    How deep a thread can hide in a few days...
    Well, this works fine with the 4584; there is no need for additional signal conditioning, except a 100k serial resistor for higher voltage.

    The chip works down to 2.2 Volts, delivering a convenient 2V signal for the Prop.

    I took 470k/1nF for the oscillator (but 2M2 and 22p will do as well..) This gave 500 Hz for 2Volts and 6kHz for 8 Volts. Current usage was 300µA corresponding to 20kOhms which is not high-impedance but acceptable for many usages...

    It must be calibrated of course and I have no idea how large the variance between chips might be ...
    Determining the period of the signal is simple and 6kHz have a nominal resolution of > 12 bits smile.gif

    Note that the signal is no longer symmetric at lower voltages, so high and low level must either be added to find the period or you count from riosing egde to rising egde..)

    I just connected 4 inputs to ground and used just one gate for the oscillator and one for buffering.

    The 14 pin case is a little bit bulky, but for 50 cents (chip, 2 resistors, 1 cap) this is really nice.

    Note: One should add a low pass filter at the input = power supply to reduce the danger of unwanted oscillation. As 2Volts gave a 500 Hz signal, this needs a larger cap... so it might be better to increase the signal frequency (say x10 with a 100p cap)

    Post Edited (deSilva) : 2/26/2008 12:17:02 AM GMT
  • Brian LBrian L Posts: 60
    edited 2008-02-26 00:38
    How good is the temperature stability of a VCO of this type? I like this idea and I'm thinking about using it on a portable device that might be indoors at room temperature one moment, and then outside on a cold winter day the next. I already know that the analog sensor and it's associated bridge circuit have temperature issues that have to be dealt with, but after that's taken care of, will the VCO also vary it's freq with temperature change, assuming the input signal remained constant?
  • TubularTubular Posts: 4,646
    edited 2008-02-26 03:34
    deSilva, many thanks for those results. It certainly looks very encouraging and I love the simplicity. If you're getting away with 2 gates - even better. I wonder if there is a smaller package available. Also does the supply current vary linearly with Vin?

    Brian L I think the temperature stability is probably "the issue" with the vco's. An NP0 rated capacitor will certainly help. The flashing LEDs have a similar issue (but more due to self heating which does even out quickly). It may be possible to have a dummy vco connected to the well regulated 3v3 supply to factor out temp effects using the prop to calculate the required compensation.

    I haven't had time to do detailed temp checks on the flashing LEDs but will post the initial results as soon as I work out how
  • VIRANDVIRAND Posts: 656
    edited 2008-02-26 20:35
    You can get an accurate ADC good enough for audio input with an op amp or comparator;
    you put sawtooth waves in one input and analog to measure in the other and the output is PWM,
    so simply count the pulse-widths (not the frequency which doesn't change).
    Good sawtooth waves can be made with a constant current source and a capacitor and a transistor
    to discharge it after it's full. An LM555 can also be used very simply as the whole sawtooth wave generator.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-02-26 21:59
    Due to rise- and fall-time distortions in a long cable, analog-to-PWM output would not be as accurate as analog-to-frequency output in those circumstances. OTOH, PWM is less susceptible to temperature change and the frequency variations that might result, since the relative pulse widths are independent of frequency.

    -Phil
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-26 22:53
    I am just compiling a list of dvices and feature criteria for low-cost ADC solutions... Threshold for competition is $1 (incl. VAT) equivalent to 70 Euro Cents! There will be some testing needed to get an idea of "general quality"... Luckily I succeded to retrieve my misplaced cooling spray for a quick check smile.gif

    A colleague offered me a 74VHC14 as an alternative which should reduce the input current downto 30µA, equivalent to 100k input resistanc! We'll see...

    A simple slope converter as described by Virand will even work for multiple channels (with a 4x comparator). This however will be the limit for SSI solutions, as the next step (channel multiplexer) will exceed the budget smile.gif

    Note that all principles of ADC depend on DAC pus comparator. The reconstruction of the DAC time basis in the Propeller works more reliable for PWM than for V/F, as Phil described. This is not unexpected, as PWM has two degrees of freedom (period and duty cycle)
  • TubularTubular Posts: 4,646
    edited 2008-02-27 02:21
    Would it be possible to use the Schmitt VCO as a keypad Mux? For those standard 4 row 3 col telephone keypads - a different series resistor for each row, added to a different series one for each column. Net effect 12 separate tones. Would need to keep drift under control.

    Also following Virand's suggestion how bad would a "slowish" prop generated sawtooth be? With a long long reset period to drive it back towards gnd.

    I've found quite a few dual schmitts in 6 pin packages. Surface mount but for 6 pins this should be ok.
  • VIRANDVIRAND Posts: 656
    edited 2008-02-27 21:14
    If you have a telephone keypad that outputs DTMF, you can rectify and filter the tones
    to get a single low frequency beat tone that's readable without ADC.

    You can also read a keypad with well chosen resistors on it as you suggested.

    Speaking of slow prop generated sawtooth, it should be excellent to generate the sawtooth with the Prop
    using PWM output and an R/C filter, if well chosen it shouldn't take long to fall back to ground. Should look
    perfect on an oscilloscope. The RC time constant should be just enough to turn the flat looking PWM out into
    a nice smooth diagonal line by holding the energy of the pulses up for just over one PWM duty cycle.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-02-27 22:05
    For a sawtooth output, the return to ground can be accelerated by an additional output that drives a MOSFET to short the filter cap to ground.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-02-28 04:03
    The latest EDN arrived today. FWIW, it includes a Design Idea that uses a 555, along with an op amp to form a V->F converter for measuring negative voltages. I say "FWIW", simply because the output at 0V is 0Hz, which certainly doesn't help acquisition speed any! And, well, it is for negative voltages, which I guess some folks have to measure.

    -Phil

    (Why did I even post this?)
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-28 08:53
    Negative voltage is an interesting feature... As the input powers the Schmitt-trigger lowcost V/F converter you can of cause interchange the connections, so it works from -2 to -18V WRT Propeller GND.
    To see the signal it has to be decoupled by a cap and pushed up to around 2V by a pair of resistors, as you know it from every audio transistor amplifier..

    Now also adding an input low pass we need:
    - inverter chip
    - 5 resistors (or 4 and 1 diode)
    - 3 caps

    Still "lowcost" but SOME parts smile.gif
Sign In or Register to comment.