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 small question

Status
Not open for further replies.

Mat22

New Member
Hello,
what is the best way of "reading" if the voltage is present or not? I have connected +5V to GPO and where this voltage drops to 0V I want to turn on LED on GP2. I can do it with comparator on GP1, is there better way of doing this?

thanks
 
hi,
How have you connected +5v to GP0.? is it via a resistor.

E
 
I did not connected it yet, I am only thinking how to do it :)

As you know the 629 does not have ADC input on GP0, so I assume that you have set it as an Input pin.?

Do want to to internally 'test' GP0 as well as turn on the GP1 pin.
Whats the purpose of the project.?
 
I would like to test the presence of 230 V AC power supply over tranformer 230/6 V AC, then rectifier it to 5 V DC. When this voltage is present nothing happens.
When this voltage is not present I would like to turn on reley on one of remainig ports (I have made small DC/AC conveter before some time and now with small PIC12F629 I want to do "smart" turning on and off, I want to do UPS device). Now I have reley - 230 VAC with 2 changeover contacts. When the power supply is On (230 V AC) the coil of reley is energised and on output we have power supply from electrical grid, and when there is break in power supply coil is not enegised and load have power supply from DC/AC converter. This coil - it is not good to be energised all the time, maybe there is better solution.
 
Have you considered powering the coil of a 5Vdc relay directly from the transformer/rectifier ?

When the rectified 5Vdc is present the 5V relay is energized and its off when the 220V/5V fails.
 
You'll need a smoothing cap to maintain a logic 1 between mains waveforms.
If not a relay then you could connect the 6v through a1k resistor to the pic's ip, might also be a good idea to connect a 1n4148 diode from the i/p to the + supply, with the cathode connected to the + supply.
 
Have you considered powering the coil of a 5Vdc relay directly from the transformer/rectifier ?

When the rectified 5Vdc is present the 5V relay is energized and its off when the 220V/5V fails.

I think that better idea is to power 5 VDC relay from battery of UPS system which supplies DC/AC converter (it is 12 V battery, 100 Ah capacity, I will put one 7805 and I have stable 5VDC power supply for my changeover system even in case when there is no power supply from the grid).
 
hi,
That would give you a back up supply of 5Vdc for your PIC.
Lets know what you decide.
 
How come 100ah, maybe your powering something else too.
If your using more than a few ma at 5v then I'd suggest a switching version of the 7805 to save power.
 
Hello,
I have made circuit board (schema is in attachment). It works like this:
  1. When the voltage from the power grid is present pump for central heating system is powered from the grid. It uses N/C contacts on 5V relay.
  2. When voltage from power grid is not present, PIC12F629 turn on 5V relay and in this case the pump is powered with DC/AC converter. When the power from power grid restores, pump is powered over power grid again
I have write several lines of C code for PIC12F629 and everything works except one thing, I have made mistake somowhere and I need help from you to see where I have made an error.
When the PIC turns on relay everything is OK, on relay coil there is 4,7 V and LED is ON, but when I turn on power from power grid I can hear that relay is OFF and LED emits very low level of light. There is 0,5 V on relay coil. Please look attachment. I have to connect 0 V from 7805 from car battery to 0 V from 7805 from transformer.
How can I solve this situtation?

thanks
 

Attachments

  • Shema.png
    Shema.png
    19.4 KB · Views: 188
You have the 7805 on the right backwards.

Edit, you also haven't said what the problem is. It sounds like it's working correctly.

Mike.
 
Thanks Mike,

it is only mistake only on schema, I have connected it in good way on my protoboard,
 
There should be nearly nothing across the relay when its de-energised.
Does your code drive the output pin for the relay to 0, or does it go high impedance?
Try a 10k from base to emmitter on the transistor to ensure it turns off.
Also put an led on the output of the mains powered dc supply, the mains transformer will be happier with a little load on it rather than just the 10k.
 
Last edited:
If the LED is lighting at all then the pic pin must be going high for a short period. The 0.5V you are seeing is the average voltage, can you use a scope to look at it? Also, the lack of decoupling capacitors and powering the relay through the 7805 could be causing a continual reset. Can you power the relay from the 12V supply?

Edit, you might want to post your code as the problem might be there.

Mike.
 
just a quick one - did you disable the comparator?
 
If the LED is lighting at all then the pic pin must be going high for a short period. The 0.5V you are seeing is the average voltage, can you use a scope to look at it? Also, the lack of decoupling capacitors and powering the relay through the 7805 could be causing a continual reset. Can you power the relay from the 12V supply?
I don not have scope now. I have changed 5V relay with 12V and I have the same problem (with 12V relay and voltage from the grid, I have 1,2 V on relay in off state.

Code:
/* Project name:
     Detect low voltage
* Description:
     When voltage is detected LED blinks
* Test configuration:
     MCU:             PIC12F629
     Dev.Board:       EasyPIC4
     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  = 0b10101111;                   // sets Vref
gpio.F2 = 0;
do {
     if (CMCON.COUT == 1)
       {
        gpio.F2 = 1;
       }
             else
         {
        gpio.F2 = 0;
     }

    }  while(1);
     }
just a quick one - did you disable the comparator?

No I use comparator to "read" if the voltage from grid is present or not
 
Try clearing GPIO before you change triss and if that fixes it then your pic is resetting.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top