|
|
View previous topic :: View next topic |
Author |
Message |
Markdem
Joined: 24 Jun 2005 Posts: 206
|
Relay making PIC stop |
Posted: Wed Mar 28, 2007 4:54 pm |
|
|
Hi All, i have tried to make a light conntroller that is controled using MIDI commands. It all works very well, but when i connect anything to the relays, eg to the 240VAC side, the PIC will stop about 2 sec later. Nothing happends if i unplug the light. I have tried to use diffrent devices on the 240 side, but it does not help.
The only thing that i can tell is it must be somewhere between when the PIC recived that data, and when i try to decode it, as PIN_E0 will be on when it stops.
The relays are powered off a diffrent power supply, and are connected via a darlington array.
Can anyone see why this may be happening??
Thanks, Mark
Code: |
#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN,NOBROWNOUT
#use delay(clock=48000000)
#use rs232(baud=31250, BITS=8, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define USB_CON_SENSE_PIN PIN_D1
#include <STDLIB>
#include <usb_cdc.h>
int1 MIDIDataIN;
int BeatStep, i, Loutput, Qcount;
int MIDImsg;
int BeatMask[35];
#int_rda
void MIDIBeatIn()
{
MIDIDataIN = 1;
output_low(PIN_E0);
MIDImsg = getc();
}
void SettingDownload()
{
disable_interrupts(INT_RDA);
printf(usb_cdc_putc,"200\n");
for(i=0;i<32;i++) //get Beat Masks from host
{
BeatMask[i] = get_int_usb();
}
printf(usb_cdc_putc,"200\n");
BeatStep = 0;
enable_interrupts(INT_RDA);
}
void main()
{
delay_ms(100);
BeatStep = 0;
MIDIDataIN = 0;
QCount = 0;
for(i=0;i<32;i++)
{
BeatMask[i] = 0;
}
usb_init_cs();
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
while(1)
{
usb_task();
if (usb_cdc_kbhit())
{
switch(get_int_usb())
{
case 200:
SettingDownload();
break;
case 201:
for(i=0;i<32>= 24) //Has 24 clocks gone, meaning that is is a beat
{
printf(usb_cdc_putc,"BEAT!!\r\n"); /////Testing
QCount = 0;
loutput = BeatMask[BeatStep];
output_b(Loutput);
if(BeatStep >= 31)
{
BeatStep = 0;
}
else
{
BeatStep++;
}
}
}
output_high(PIN_E0);
}
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Markdem
Joined: 24 Jun 2005 Posts: 206
|
|
Posted: Wed Mar 28, 2007 5:41 pm |
|
|
Thanks PCM, i forgot to say that i have back emf diodes installed |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Mar 29, 2007 7:38 am |
|
|
How much current does your relay's coil require for pull-in and also for hold?
How are you driving the coil? Direct from the pin (generally bad idea) or with some kind of buffer? _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Mar 29, 2007 1:58 pm |
|
|
It sounds like the PIC works as long as nothing is connected to the contacts of the relays, but a load on the relay contacts makes the PIC stop. In that case the problem is not on the coil side of the relay. I would look at the proximity of the 240VAC wiring to the PIC, and maybe add some snubber caps to the relay contacts. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|
|
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
|