View previous topic :: View next topic |
Author |
Message |
spilz
Joined: 30 Jan 2012 Posts: 220
|
16F690 and MCLR_FROM_RUN |
Posted: Wed Apr 05, 2017 1:25 am |
|
|
Hello,
I'm working on a project to control spots light.
My board and my software works well when the spot is not connected, but when it's connected and change the state of the relay, sometimes the PIC16F690 reset, and the reset cause is 27, so MCLR_FROM_RUN.
What means MCLR_FROM_RUN ?
What can cause this reset ?
I try to add capacitors on the power line but it does not solve the issue ...
Thanks for your help.
regards
my code :
Code: | #include <16F690.h>
#device ADC=10
#FUSES NOMCLR,NOWDT //No Watch Dog Timer
#FUSES BROWNOUT // brownout reset
#use delay(crystal = 20 MHz)
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A0,bits=8,restart_wdt,errors,TIMEOUT = 100,stream = RS232_PICKIT2)
// carte Spot RFM69
#define LED_PIN pin_c0
#define RELAY_PIN pin_b7
#define LED(x) output_bit(LED_PIN,x)
#define LED_on output_high(LED_PIN)
#define LED_off output_low(LED_PIN)
#define RELAY(x) output_bit(RELAY_PIN,!x)
#define RELAY_ON output_low(RELAY_PIN)
#define RELAY_OFF output_high(RELAY_PIN)
#define ON 1
#define OFF 0
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8); // 4MHz : 524 ms overflow
setup_wdt(WDT_OFF);
LED_on;
//TODO: User Code
fprintf(RS232_PICKIT2,"Spot RFM69 %u\r\n",RESTART_CAUSE());
fprintf(RS232_PICKIT2,__DATE__);
fputc(' ',RS232_PICKIT2);
fprintf(RS232_PICKIT2,__TIME__);
fprintf(RS232_PICKIT2,"\r\n");
LED_off;
while(true){
fprintf(RS232_PICKIT2,"ON\r\n");
relay(ON);
delay_ms(2000);
fprintf(RS232_PICKIT2,"OFF\r\n");
relay(OFF);
delay_ms(2000);
}
reset_cpu();
}
|
|
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Wed Apr 05, 2017 3:02 am |
|
|
Hi spilz
I don't know what is MCLR_FROM_RUN, but I have a few questions:
* You have a diode across the relay (or maybe the relay have an internal one?)
* How you drive the relay?
* Is the relay power supply same as the PIC?
Best wishes
Joe |
|
|
spilz
Joined: 30 Jan 2012 Posts: 220
|
|
Posted: Wed Apr 05, 2017 3:26 am |
|
|
hi,
There is a diode across the relay.
I drive the relay through a transistor 2N2222.
Yes the relay has the same power supply as the PIC.
The relay works well, the issue comes from the reset of the PIC.
I tried to power the board from another power supply, I still have the issue... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Wed Apr 05, 2017 7:34 am |
|
|
MCLR from run, does mean the processor is being spiked by something.
What smoothing do you have immediately adjacent to the PIC?.
What connection do you have to the MCLR pin?.
(I know you have 'NOMCLR', but the pin is still able to reset the PIC if it is taken to the wrong voltage).... |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Wed Apr 05, 2017 7:42 am |
|
|
I'm not sure about the Microchip programmers (don't own any), but the CCS programmers can function with a 4.7k pullup on /MCLR to Vcc. If your pullup on the /MCLR line is rather high, you can quite safely lower it to 4.7k, which will help your reset issue. As someone else has already mentioned, your relay needs a flyback diode, and the PIC line driving the transistor which in turn drives the relay could use some protection as well, such as a 0.1uF ceramic cap, and a TVS wouldn't hurt. A TVS on your Vcc rail, close to the relay drive, would also help. |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Wed Apr 05, 2017 7:53 am |
|
|
Also if the spot light are an AC device and high power the relay contacts will need to have arc suppression. Been bitten by that one before so switch to zero crossing triacs.
Regards |
|
|
spilz
Joined: 30 Jan 2012 Posts: 220
|
|
Posted: Wed Apr 05, 2017 7:58 am |
|
|
Ttelmah :
Close to the pic, there is the light spot, (which is a cheap one, with a poor 220v AC to 6V AC transformer and halogen lamp).
I tried to connect the MCLR pin to VCC with a jumper, but it does not solve the problem :(
What can cause a MCLR_FROM_RUN ?
Set MCLR pin to ground ?
A wrong address ?
newguy:
My relay has already a flyback diode.
what is a TVS ?
I tried to use a relay board with optocoupler isolation, I still have the issue.
For information:
Sometimes, when the relay turn On or Off the spot, the screen of my computer (2 feet near the spot) freezes or reset.
I tried to use an external power, the problem was not solved. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Wed Apr 05, 2017 8:08 am |
|
|
TVS: transient voltage suppressor.
If cycling the spotlight is also glitching a computer monitor, you have pretty serious noise/EMI issues. As someone else mentioned, you need to use a TRIAC or a solid state relay (SSR - which usually has some form of TRIAC or similar in it). The spotlight is drawing such high current that if you attempt to turn it off while the AC waveform isn't zero, you're going to get a very significant inductive "kick" back onto the mains from the spotlight/cord. You need to switch off your AC load (the spotlight) at the zero crossing of the mains voltage, which will minimize your inductive "kick" and any EMI associated with cutting off an AC load at something other than the zero crossing. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Wed Apr 05, 2017 11:11 am |
|
|
Quote: |
Close to the pic, there is the light spot, (which is a cheap one, with a poor 220v AC to 6V AC transformer and halogen lamp).
|
I'm asking what smoothing components you have actually attached by the PIC.
The PIC _at absolute minimum_ requires a 0.1uF HF rated capacitor as close as possible to each of it's supply pins, and some larger reservoir capacitor nearby.
You have major problems with whatever you are using to supply the PIC. It _needs_ significant smoothing to maintain it's supply.... |
|
|
spilz
Joined: 30 Jan 2012 Posts: 220
|
|
Posted: Wed Apr 05, 2017 2:04 pm |
|
|
^^ sorry for my misunderstanding (bad English)
Actually using a solid state relay seems to solve the problem...
I will draw a new pcb and test it.
I will add a 0.1uF as close as possible.
I'm using G3MB-202P 5v but my board only have 3.3V.
On my prototype board it works, someone has experimented with this component ?
Is it just luck that it works ?
Thanks for your help.
Spilz |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Wed Apr 05, 2017 6:09 pm |
|
|
Just a general comment
that SSR is only rated for 2 amps so be sure your halogen lamp doesn't draw more than that.
In stage lighting, you normally 'preheat' the lamps by injecting a small current, not enough to see but to warm the filament, this reduces the thermal shock and destroying expensive lamps.
Be very careful !! 220 volts at 2 amps can kill you....
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Thu Apr 06, 2017 12:07 am |
|
|
The G3MB-202P, was listed as 'not for use in new designs', over five years ago.... "Discontinuation planned for April, 2010". They are still being sold, but are intended as replacements for old equipment.
Also at the very least you should be using the version with an internal snubber.
That it is operating, is 'luck'. The minimum 'guaranteed' operating voltage, is 4v. Like most things though there is a margin, and the version you have is 'just' working. What series resistor are you using?. I'd suspect you are using a smaller one than specified?.
Get something like a Panasonic AQG22124. Same current rating, same package. Has the built in snubber, and operates down to 1.5v. However if you are actually intending to operate even close to it's rating, then look at getting a version with a higher current rating. |
|
|
spilz
Joined: 30 Jan 2012 Posts: 220
|
|
|
spilz
Joined: 30 Jan 2012 Posts: 220
|
|
Posted: Thu Apr 06, 2017 3:41 am |
|
|
It's for a personal project, and I already have 30 x G3MB-202P 5v.
to solve the possibility of issue with 3.3v, I think using a step up 5v regulator just for pin + of the G3MB-202P |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Thu Apr 06, 2017 4:58 am |
|
|
Another alternative is to make your own SSR. Using a zerocross optocoupler, a triac, an LED and 2 resistors you get a self indicating SSR. I refer you to an article ...http://electronicdesign.com/analog/solid-state-relay-features-load-indicator... published back in 2004. Just be sure to choose a TRIAC that is rated for your 220V and load current. I was driving 6 of them from a single VF opamp back then, and it still works today. |
|
|
|