VCO recommendation

Thread Starter

sirch2

Joined Jan 21, 2013
1,037
I am looking for a simple circuit that gives a voltage controlled oscillator to Flash an LED.

I have an output from an instrumentation amp and I would ideally like the LED to be off at around 300mV and then flash with increasing speed as the Vout from the instrumentation amp goes up so that the LED appears to be fully on around 3V. This is running from a 6V supply. I would like the LED on duration to be short but just enough to notice (I guess around 50 to 100ms) and at 300mV have it flash about once per second or so.

Obviously this could be done in lots of ways, including with an MCU, but it is an add-on to an existing project and I would ideally like it to be low cost, low power and low component count (not asking for a lot am I). Hence I have been looking at 555s and while there are a lot of circuits out there I am not sure that a 555 is the best option.

So is there a better VCO or should I just go with a 555?
 

wayneh

Joined Sep 9, 2010
17,496
You can get about a 4X frequency range using the control pin (#5) of the 555. You could use an op-amp to convert your input to a rail-to-rail voltage on pin 5.

So for instance you could have 1Hz at 300mV (0V on pin 5) and 4Hz at max (Vcc on pin 5). Not exactly the change you were looking for, but not bad.

I would note that your ability to discern one frequency from another probably goes down above 10Hz or so.
 

AnalogKid

Joined Aug 1, 2013
10,987
Starting with the back end first, a retriggerable monostable gives you a constant 50 ms or 100 ms pulse for the LED, and the pulses get closer and closer together as the driving clock increases in frequency. Eventually the clock period is shorter than the monostable period, the monostable is constantly retriggered before it times out, and the LED is on solid. All of this fits in half of an LM339 with three Rs and one C, it will run on anything from 5V to 15V, and you get an open-collector LED driver for free.

The front end is the VCO. AN LM566 comes to mind, although I've never used one at such low frequencies. Since there are two sections of the LM339 looking for work...

Going all analog, another 1/4 LM339 as a non-inverting Howland current pump creates a constant current for charging a timing capacitor. The capacitor charges more quickly as the control voltage increases. The reference input is biased above GND with a Shottkey diode to disable charging below 300 mV input.

Note that there is a linear - not exponential - relationship between input voltage and charging current. Should make your visual indicator more useful by preventing frequency compreession as the control voltage increases.

The last 1/4 LM339 compares the capacitor voltage to a fixed divider to drive the retriggerable section.

ak

Note: No TTL, PICs, Arduinos, or 555's were harmed in the writing of this response.
 

AnalogKid

Joined Aug 1, 2013
10,987
That was fun, but I might be working too hard. The 555's control pin input probably will not give you the range you want. But you can tie the IA voltage (through a voltage follower buffer and scaling resistor) to the 555 discharge pin in the standard astable circuit to modulate the waveform period. The output would have a (mostly) constant low state and variable high state. It would not go to a DC output at high IA output voltage, but the freq would be high enough for retinal delay to make the LED look like it's on steadily.

ak
 

Thread Starter

sirch2

Joined Jan 21, 2013
1,037
Thanks guys, I was unsure how much variation the control pin of a 555 would give me, so thanks for answering that.

I might well prototype AnalogKid's second suggestion and see how it goes.

THE_RB - plus £25 for the programmer ;-)
 

THE_RB

Joined Feb 11, 2008
5,438
Someone that does electronics these days and does not have a programmer is like someone who does not have a soldering iron; Very poorly equipped.
;)

If you were (poorly equipped) you could do it with a dual comparator IC and possibly still make it within the specs for low cost and low power consumption.

One comparator would basically be a monostable making the fast LED on period, then the cap discharges slowly during the off period. When the cap discharges lower than
the control voltage (0.3v to 3v) the second comparator detects that and fires the first comparator again.

It's like using two 555s, but in one 8 pin IC, and the individual comparators are easier to configure than 555s because they don't have the internal voltage divider resistors that 555s have.
 

AnalogKid

Joined Aug 1, 2013
10,987
Someone that does electronics these days and does not have a programmer is like someone who does not have a soldering iron; Very poorly equipped.
;)
<Where oh where to begin... How about...>

In a world with over 1000 different switching power supply control IC's in current production, what kind of bozo would design one from scratch with all discrete components?

http://www.romanblack.com/smps/smps.htm

I mean, like, dude, like, everyone knows the right way is with a PIC. The code is free right there on their site!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ak
 

Thread Starter

sirch2

Joined Jan 21, 2013
1,037
I do have a programmer, just not a PIC one :p

And as I indicated this is a bit of a nice-to-have on an existing project, so something that could be done with a handful of stock components in an evening was what I was aiming for, I know you are going to say that you could write a program to do this in an evening but I know it would take me a few days to climb the appropriate learning curve...
 

wayneh

Joined Sep 9, 2010
17,496
One way to get a good effect might be to leave the frequency alone at, say, 5Hz, but vary the duty cycle, ie. PWM. If you look at the PWM circuit in Figure 10.4 of Bill's blog on this forum, you see that you control the pulse width by the reference voltage provided to the comparator. You could replace the reference with your signal.

The 555's timing cap charging and discharging in that circuit goes between 1/3 and 2/3 of Vcc. For instance between 2V and 4V on a 6V supply. So to make this work you'd need a circuit that maps your 0.3-3V into 2-4V (or whatever is appropriate for your Vcc). This would give 0-100% PWM. I know this could be done with an op-amp but maybe there's something simpler that would be good enough for this application.
 

AnalogKid

Joined Aug 1, 2013
10,987
I modelled a couple of different flavors of the 555 idea in #5, and could not get it to behave well, not counting the part where it never goes beyond 50/50 duty cycle. So I'm back to the quad opamp or quad comparator version in #4. It has the most promise because the current pump can have gain, and turn a 10:1 input voltage range into a 20:1 or 30:1 frequency range.

ak
 

THE_RB

Joined Feb 11, 2008
5,438
<Where oh where to begin... How about...>

In a world with over 1000 different switching power supply control IC's in current production, what kind of bozo would design one from scratch with all discrete components?

http://www.romanblack.com/smps/smps.htm
...
You made me chuckle.

The answer is; the kind of bozo that sees an Everest and says; What the hell, I'm in the mood to see if I can climb that silly thing".

But as far as comparisons go, I didn't go to a forum and say; "Tell me how to make a 5v SMPS buck regulator AND it can't use an IC".

Asking for help implies that you want someone with more wisdom than you to provide a solution for you. And the person with more wisdom may very well suggest that you use a chip, or even a microcontroller chip. ;)
 

THE_RB

Joined Feb 11, 2008
5,438
I do have a programmer, just not a PIC one :p

And as I indicated this is a bit of a nice-to-have on an existing project, so something that could be done with a handful of stock components in an evening was what I was aiming for, I know you are going to say that you could write a program to do this in an evening but I know it would take me a few days to climb the appropriate learning curve...
This is pretty much the whole MikroC code for a 8-pin PIC 12F675, but is untested and probably needs more PIC port setups;

Rich (BB code):
unsigned int volts;

TRISGPIO = 0b00000001;   // GP1 = LED, GP0 = ADC

while(1)
{
  GPIO.F1 = 1;           // LED on
  Delay_mS(50);
  GPIO.F1 = 0;           // LED off again

  // 0.3v = ADC 61, 3.0v = ADC 614, (range = 553 counts)
  volts = ADC_read(0);   // read voltage on ADC pin AN0

  // this inverts the ADC value so 0.3v = 553 and 3.0v = 0.
  volts = (553 - (volts-61)); 

  // LED off delay; 0.3v = 1.106 seconds, 3.0v = 0 seconds
  VDelay_mS(volts*2);   
}
Took about 5 minutes. :)

(note) It does not include protection for cases where the input voltage is <0.3v or >3.0v.
 

AnalogKid

Joined Aug 1, 2013
10,987
Chuckle is good.

It also does not include the PIC port setups (as you said), something I routinely struggle with. I know it is a generic part and they can sell it into a gazillion different applications because the pins are so setup-able, but it does slow down the casual user and intimidate the beginner.

It also does not include the years of familiarity with C it took to be able to whip up that code in 5 minutes, which I think is more to the point.

ak

ps. I dub thee GPOP - Grand Protagonist Of PIC
 

Thread Starter

sirch2

Joined Jan 21, 2013
1,037
Thanks again guys, I haven't yet had time to do much with any of these ideas but wayneh's suggestion now looks like the front-runner.
 

Thread Starter

sirch2

Joined Jan 21, 2013
1,037
I finally got around to having a go at using a PIC for this, but it doesn't work probably due to not configuring the ADC properly. Here's the code I have for a PIC12f675. Any ideas?

Rich (BB code):
#include <stdio.h>
#include <stdlib.h>
#include <xc.h>

// CONFIG
#pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = ON       // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
#pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF
#pragma config BOREN = OFF      // Brown-out Reset Enable (Brown-out Reset disabled)
#pragma config FOSC = INTRCIO  // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)

#define _XTAL_FREQ 4000000
 

void delay_ms(unsigned int milliseconds) {
    unsigned int ms = milliseconds;
    while (ms-- > 0) {
        __delay_ms(1);
    }
}


/*
*
*/
void main(void) {

    unsigned int adcVal;

    TRISIO = 0b00000001; // GP1 = LED, GP0 = ADC
    ANSEL = ADCS1 | ANS0; //ACD Osc/32; Pin 0
    ADCON0 = 0x00;
    ADCON0 = ADON | ADFM; //Start the ADC, right justified, Vdd ref=0
    CMCON = 0x07;
    VRCON = 0x00;

    while (1) {
        GPIObits.GP1 = 1; // LED on
        __delay_ms(100);
        GPIObits.GP1 = 0; // LED off again
        //__delay_ms(500);
        
        GO_nDONE = 1; //Enable
        while (GO_nDONE); //Wait for ADC to complete

        adcVal = ((ADRESH << 8) + ADRESL);
        // this inverts the ADC value so 0.3v = 553 and 3.0v = 0.
        // 0.3v = ADC 61, 3.0v = ADC 614, (range = 553 counts)
        adcVal = (553 - (adcVal - 61));

        delay_ms(adcVal);
    }

}
 

THE_RB

Joined Feb 11, 2008
5,438
A good test with ADCs is to read the ADC pin and light a LED if the ADC reading is > half way (ie is >512);

Rich (BB code):
while (1) 
    {
        while (GO_nDONE); //Wait for ADC to complete
        adcVal = ((ADRESH << 8) + ADRESL);

        if(adcVal >= 512) GPIObits.GP1 = 1; // LED on
        else              GPIObits.GP1 = 0; // LED off
    }
}
That will show you the pot, ADC and LED are all working ok.
:)
 

wayneh

Joined Sep 9, 2010
17,496
I finally got around to having a go at using a PIC for this...
Just curious - did you abandon the "old fashioned" approach, or did you try it without success? Learning the PIC is probably a better use of your time, so I completely understand if you skipped the other.
 
Top