VCO recommendation

Discussion in 'The Projects Forum' started by sirch2, Apr 9, 2014.

  1. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    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?
     
  2. Jony130

    AAC Fanatic!

    Feb 17, 2009
    3,957
    1,097
    Maybe CD4046 will do the job.
     
  3. wayneh

    Expert

    Sep 9, 2010
    12,090
    3,027
    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.
     
  4. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,516
    1,246
    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.
     
  5. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,516
    1,246
    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
     
  6. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    A cheap 8 pin PIC, a resistor and a LED. And some code. ;)
     
  7. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    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 ;-)
     
  8. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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.
     
  9. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,516
    1,246
    <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
     
  10. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    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...
     
  11. wayneh

    Expert

    Sep 9, 2010
    12,090
    3,027
    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.
     
  12. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,516
    1,246
    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
     
  13. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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. ;)
     
  14. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    This is pretty much the whole MikroC code for a 8-pin PIC 12F675, but is untested and probably needs more PIC port setups;

    Code ( (Unknown Language)):
    1.  
    2. unsigned int volts;
    3.  
    4. TRISGPIO = 0b00000001;   // GP1 = LED, GP0 = ADC
    5.  
    6. while(1)
    7. {
    8.   GPIO.F1 = 1;           // LED on
    9.   Delay_mS(50);
    10.   GPIO.F1 = 0;           // LED off again
    11.  
    12.   // 0.3v = ADC 61, 3.0v = ADC 614, (range = 553 counts)
    13.   volts = ADC_read(0);   // read voltage on ADC pin AN0
    14.  
    15.   // this inverts the ADC value so 0.3v = 553 and 3.0v = 0.
    16.   volts = (553 - (volts-61));
    17.  
    18.   // LED off delay; 0.3v = 1.106 seconds, 3.0v = 0 seconds
    19.   VDelay_mS(volts*2);  
    20. }
    21.  
    Took about 5 minutes. :)

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

    Distinguished Member

    Aug 1, 2013
    4,516
    1,246
    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
     
  16. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    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.
     
  17. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    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?

    Code ( (Unknown Language)):
    1.  
    2. #include <stdio.h>
    3. #include <stdlib.h>
    4. #include <xc.h>
    5.  
    6. // CONFIG
    7. #pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
    8. #pragma config PWRTE = OFF      // Power-up Timer Enable (PWRT disabled)
    9. #pragma config MCLRE = ON       // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
    10. #pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
    11. #pragma config CPD = OFF
    12. #pragma config BOREN = OFF      // Brown-out Reset Enable (Brown-out Reset disabled)
    13. #pragma config FOSC = INTRCIO  // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
    14.  
    15. #define _XTAL_FREQ 4000000
    16.  
    17.  
    18. void delay_ms(unsigned int milliseconds) {
    19.     unsigned int ms = milliseconds;
    20.     while (ms-- > 0) {
    21.         __delay_ms(1);
    22.     }
    23. }
    24.  
    25.  
    26. /*
    27. *
    28. */
    29. void main(void) {
    30.  
    31.     unsigned int adcVal;
    32.  
    33.     TRISIO = 0b00000001; // GP1 = LED, GP0 = ADC
    34.     ANSEL = ADCS1 | ANS0; //ACD Osc/32; Pin 0
    35.     ADCON0 = 0x00;
    36.     ADCON0 = ADON | ADFM; //Start the ADC, right justified, Vdd ref=0
    37.     CMCON = 0x07;
    38.     VRCON = 0x00;
    39.  
    40.     while (1) {
    41.         GPIObits.GP1 = 1; // LED on
    42.         __delay_ms(100);
    43.         GPIObits.GP1 = 0; // LED off again
    44.         //__delay_ms(500);
    45.        
    46.         GO_nDONE = 1; //Enable
    47.         while (GO_nDONE); //Wait for ADC to complete
    48.  
    49.         adcVal = ((ADRESH << 8) + ADRESL);
    50.         // this inverts the ADC value so 0.3v = 553 and 3.0v = 0.
    51.         // 0.3v = ADC 61, 3.0v = ADC 614, (range = 553 counts)
    52.         adcVal = (553 - (adcVal - 61));
    53.  
    54.         delay_ms(adcVal);
    55.     }
    56.  
    57. }
    58.  
     
  18. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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);

    Code ( (Unknown Language)):
    1.  
    2. while (1)
    3.     {
    4.         while (GO_nDONE); //Wait for ADC to complete
    5.         adcVal = ((ADRESH << 8) + ADRESL);
    6.  
    7.         if(adcVal >= 512) GPIObits.GP1 = 1; // LED on
    8.         else              GPIObits.GP1 = 0; // LED off
    9.     }
    10. }
    That will show you the pot, ADC and LED are all working ok.
    :)
     
  19. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    I'll give that a try later
     
  20. wayneh

    Expert

    Sep 9, 2010
    12,090
    3,027
    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.
     
Loading...