View previous topic :: View next topic |
Author |
Message |
jtgoulart
Joined: 13 Feb 2007 Posts: 10
|
Problem in coupling pic-relay |
Posted: Fri Feb 16, 2007 10:18 am |
|
|
I have been trying to connect a font in the pic to activate an relay. The objective is to make an air pump turn on and off in a regular time (on aprox 5 min and off aprox 20min), but the time precision isn't really important.
However I am having some problems, the pump doesn't follow the desired program. I Would like to know if somebody has nay idea of what is going on. Thanks for the attention.
the program:
----------------bomba675.h-----------
#include <12F675.h>
#device adc=8
#use delay(clock=4000000)
#fuses XT,NOWDT,NOMCLR,NOPROTECT
-------------------------------------
---------------bomba675.c------------
#include "C:\Otavio Gomes\PIC\Bomba de ar\bomba675.h"
#ROM 0x3ff = {0x3480}
int i;
void main() {
setup_adc_ports(no_analogs);
setup_adc(ADC_OFF);
setup_counters(RTCC_INTERNAL,RTCC_DIV_4);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while (true){
output_high(PIN_A0); //pin bomba high
output_low(PIN_A2); //pin led low
for (i=1;i<=6;i++)
{delay_ms(60000);}
output_low(PIN_A0); //pin bomba low
output_high(PIN_A2); //pin led high
for (i=1;i<=24;i++)
{delay_ms(60000);}}}
------------------------------------ |
|
|
Ttelmah Guest
|
|
Posted: Fri Feb 16, 2007 10:30 am |
|
|
What are you using as an oscillator to drive the PIC?. You have a #ROM line, which suggests you feel you need to load the internal calibration value (needed if this has been erased, and you want to run the internal oscillator), but you are running with the fuse 'XT', which implies an external oscillator. How is the relay connected?. As soon as you start driving devices like relays/coils, you need to be very careful about clamping the overshoot when the device is switched off in particular.
Best Wishes |
|
|
jtgoulart
Joined: 13 Feb 2007 Posts: 10
|
|
Posted: Sat Feb 17, 2007 11:31 am |
|
|
Ttelmah wrote: | What are you using as an oscillator to drive the PIC?. You have a #ROM line, which suggests you feel you need to load the internal calibration value (needed if this has been erased, and you want to run the internal oscillator), but you are running with the fuse 'XT', which implies an external oscillator. How is the relay connected?. As soon as you start driving devices like relays/coils, you need to be very careful about clamping the overshoot when the device is switched off in particular.
Best Wishes |
I am using the internal oscillator. I already think about the overshoot, then I connected the relay with a diode. Look the project:
the project is at: http://e-mesmo.fotos.net.br/album2/photo.html |
|
|
jtgoulart
Joined: 13 Feb 2007 Posts: 10
|
|
Posted: Sat Feb 17, 2007 11:48 am |
|
|
I hope you understand my rough draft... |
|
|
Ttelmah Guest
|
|
Posted: Sat Feb 17, 2007 4:01 pm |
|
|
The circuit is hard to understand. However some comments apply.
Your fuse setting is wrong. To use the internal oscillator, you want the oscillator fuse INTRC, or INTRC_IO.
What is the nature of the protection diode?. You may be suprised at what a high peak current rating this needs. Also what sort of recovery time specification has it got?. Do you know the inductance of the relay coil?.
Consider having a pull down resistor on the pin feeding the transistors. A large value like 1MR. Otherwise, there many be problems when the pin is programmed as an input, when the chip wakes up.
I'd get rid of the BC337. You are already using a Darlington transistor, with a current gain of about 1000*, and this is uneccessary.
What supression is on the 5v supply?. You want something like a 0.1uF ceramic capacitor, as close to the PIC as possible, as well as any other supply smoothing.
Best Wishes |
|
|
jtgoulart
Joined: 13 Feb 2007 Posts: 10
|
|
Posted: Mon Feb 19, 2007 10:50 am |
|
|
The wrong in the ocillator isn't important. It's a trick.
The diode is used to prevent a return of the current . I'm using a diode NI4004. I don't know the indutance of the relay coil...
I go to think about the pull down resistor.
Well, the 5v supply are 4 batteries associates in series. |
|
|
Ttelmah Guest
|
|
Posted: Mon Feb 19, 2007 1:03 pm |
|
|
What supression have you got across the batteries?. You want something like perhaps a 100uF electrolytic, and a small ceramic capacitor close to the PIC.
Best Wishes |
|
|
jtgoulart
Joined: 13 Feb 2007 Posts: 10
|
|
Posted: Mon Feb 19, 2007 1:46 pm |
|
|
I'm using nothing this... |
|
|
Ttelmah Guest
|
|
Posted: Tue Feb 20, 2007 5:11 am |
|
|
Seriously, this is _necessary_. Especially the small cap close to the chip.
Best Wishes |
|
|
jtgoulart
Joined: 13 Feb 2007 Posts: 10
|
|
Posted: Wed Feb 21, 2007 11:42 am |
|
|
Ttelmah wrote: | Seriously, this is _necessary_. Especially the small cap close to the chip.
|
Ok, I made it. But the problem continues... |
|
|
jtgoulat Guest
|
|
Posted: Sat Feb 24, 2007 10:39 am |
|
|
Well, if somebody haven't other idea, I thanks the help. But I continue with the problem, then I will go to test a new pic. |
|
|
|