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.

PIC12F629 comparator_internal Vref

Status
Not open for further replies.

Mat22

New Member
Hello,

please look attachment. My questions:
1. Can I connect directly AC source to CIN- pin (0.11V) and can this PIC recognise this very low voltage?
2. I would like to turn on LED when voltage (internal Vref) is > 0,05 V? Can I set Vref as 0,05 V?

thanks
 

Attachments

  • Design1 - Schematic.pdf
    11.5 KB · Views: 261
Hello,

please look attachment. My questions:
1. Can I connect directly AC source to CIN- pin (0.11V) and can this PIC recognise this very low voltage?
2. I would like to turn on LED when voltage (internal Vref) is > 0,05 V? Can I set Vref as 0,05 V?

thanks

hi,
I would add a low value resistor in series with the CIN pin, say 1K.

The PIC's internal diodes will not be turned on with such a low voltage as 0.11Vac, but the 1K will limit the input current should the CIN voltage ever exceed approx 0.5V.

Look at page 35, Section 6 of the 12F629 datasheet for the comparator.
The values at which the Vref can be set are in internally fixed discrete steps, choose the Vref that suits your App.

E.

EDIT:
With a +5V supply the lowest you can get for Vref is Vdd/24= 0.2V
You could use an external OPA to raise the 0.11Vac to a higher voltage.
 

Attachments

  • AAesp02.gif
    AAesp02.gif
    7.9 KB · Views: 270
Last edited:
can this PIC recognise this very low voltage
Not sure of the question.
Common mode voltage. See data sheet.
Old comparators (not in your micro) the inputs do not work well near the supply voltages. It is typical for a comparator to have a input range from slightly below the (-) supply to {(+) supply-3 volts}. (with a 0 and 12V supply the inputs do not function above 9 volts) OR (below -0.5 volts)
There are R-R input parts that can work from -supply to +supply.
The data sheet on the 12F629:
"Vcm min=0 max=Vdd-1.5V"
With a 5V supply it will work if both voltages are with in 0 to 3.5 volts range. (it probably work if one of the inputs is in that range) If inputs are 2V and 4V it will work.

"Vos=+/-5mV typical +/-10mV max. The offset voltage is typically 5mV. So if you think a input is at 1.000 volts the part might see it as 1.005 or 0.995 volts. If you are looking at very small voltages that error might get you. You are looking at 50mV and the part could be 5mV off. (10mV max)
 
Hello,

I have decided to work with minimal voltage 3,125 V AC (can I use AC voltage on comparator input?).
With:
VRR=1 and VR3 ... VR0 = 1111 (15) with a VDD of 5V the Vref will be (15/24)*5 = 3,125V.
I have made a code but I am stuck :(
Code:
/ * Project name:
     Detect low voltage
 * Description:
     When voltage is detected LED blinks
 * Test configuration:
     MCU:             PIC12F629
     Dev.Board:       EasyPIC5
     Oscillator:      04.0000 MHz, Internal
     SW:              mikroC PRO for PIC
 */
unsigned char i;
bit oldstate;                       // Old state flag
void main() {
OSCCAL = 0b11111100;                   // calibrate internal osilator 4 MHz
CMCON = 0b00000100;                 // CIN- analog, Internal VRef
TRISIO = 0b00000010;                     // gp2 = output
VRCON  = 0b10101111;                   // sets Vref
do {
     if (CMCON.cout == 1)            // if cmcon.cout=1 blink a led, else set led off, if the voltage is higher them 3,125  V blink a led
       {
        gpio.F2 =1;
        delay_ms(500);
        gpio.F2 = 0;
        delay_ms(500);
       }
     } while(1);
   }
 
Ok, I have adapted the code and it works. I have tried it on my protoboard:

Code:
* Project name:
     Detect low voltage
 * Description:
     When voltage is detected LED blinks
 * Test configuration:
     MCU:             PIC12F629
     Dev.Board:       EasyPIC5
     Oscillator:      04.0000 MHz, Internal
     SW:              mikroC PRO for PIC
 */
unsigned char i;
bit oldstate;                       // Old state flag
void main() {
OSCCAL = 0b11111101;                   // calibrate internal osilator 4 MHz
CMCON = 0b00000100;                 // CIN- analog, Internal VRef
TRISIO = 0b00000010;                     // gp2 = output
VRCON  = 0b10100001;                   // sets Vref
 gpio.F2 = 0;
do {
     if (CMCON.COUT == 0)            // if cmcon.cout=0 blink a led, else set led off
       {
        gpio.F2 =1;
        delay_ms(500);
        gpio.F2 = 0;
        delay_ms(500);
       }
    }  while(1);
     }
if cmcon.cout=0 blink a led, else set led off
As long this AC signal is applied LED is blinking, otherwise is OFF.
This AC signal will be ON for short period of time - like a impulse and it will turn OFF.
How can I change code to blink a LED constantly after impulse goes OFF?

thanks
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top