CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem in coupling pic-relay

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jtgoulart



Joined: 13 Feb 2007
Posts: 10

View user's profile Send private message

Problem in coupling pic-relay
PostPosted: Fri Feb 16, 2007 10:18 am     Reply with quote

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







PostPosted: Fri Feb 16, 2007 10:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Feb 17, 2007 11:31 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Feb 17, 2007 11:48 am     Reply with quote

I hope you understand my rough draft...
Ttelmah
Guest







PostPosted: Sat Feb 17, 2007 4:01 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 19, 2007 10:50 am     Reply with quote

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







PostPosted: Mon Feb 19, 2007 1:03 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 19, 2007 1:46 pm     Reply with quote

I'm using nothing this...
Ttelmah
Guest







PostPosted: Tue Feb 20, 2007 5:11 am     Reply with quote

Seriously, this is _necessary_. Especially the small cap close to the chip.

Best Wishes
jtgoulart



Joined: 13 Feb 2007
Posts: 10

View user's profile Send private message

PostPosted: Wed Feb 21, 2007 11:42 am     Reply with quote

Ttelmah wrote:
Seriously, this is _necessary_. Especially the small cap close to the chip.



Ok, I made it. But the problem continues...
jtgoulat
Guest







PostPosted: Sat Feb 24, 2007 10:39 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group