PIC Resetting

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

keejay
Flowcode v5 User
Posts: 110
Joined: Tue Jul 23, 2013 10:02 am
Been thanked: 14 times
Contact:

PIC Resetting

Postby keejay » Fri Mar 13, 2015 2:38 pm

Hi all,

I apologise in advance if this is not the correct place to bring this up (as it's not quite a FC6 problem), but I thought that due to the frequency that this issue seems to rear it's head, it might be worth a discussion. I have a FC program that switches 4 relays depending on some variables. These relays in turn, switch on ac electric motors (220v apprx 500W each x 4 motors). When the program runs without the motors connected (just switching the relays on their own) all is perfect. When the motors are connected, the PIC resets every so often and even the 16x4LCD gets corrupted quiet often. This happens mostly when the motors are switched off.

I've tried to disable the MCLR option with config buts, but even so, the PIC still resets when I push the set button, so this doesn't seem to have worked?

The PIC is an PIC18F46k22.

I have got 1000uF caps on the power supply lines
100nF ceramics across the PIC power pins (directly across them)
100nF and 1000uF across the LCD power pins

Does anyone have any advice/ideas what can be done in order to stop this resetting behaviour.

Thanks guys...

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8476
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2433 times
Been thanked: 3487 times
Contact:

Re: PIC Resetting

Postby medelec35 » Fri Mar 13, 2015 2:54 pm

Sounds like when the motor is switched off the relay contacts are arcing, causing interference on the microcontroller supply line.
This interference/ringing will cause voltage on supply line to drop and cause MCU to reset (brown out).
Interference will be too fast for a meter or LED to pick up.
You should be able to scope it.
You could try using X type capacitor, mains contact suppressor (0.1UFcap , 100R resisotor) across relay contacts.
Maybe a suitable VDR will help?
Obviously there must be extreme caution to avoid mains shocks and wrong components fitted that could go with a bang or catch fire

Has the relay coil got a reversed biased diode connected across it?

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: PIC Resetting

Postby hyperion007 » Fri Mar 13, 2015 4:40 pm

Do you have flyback protection diodes across the relay coils? Have you considered using optocouplers and thus isolating the PIC side from the relay side? You should also have a capacitor connected to the MCLR pin if you are using the MCLR that is (do not have the capacitor connected to MCLR when you are programming the PIC only when you are running the application)

keejay
Flowcode v5 User
Posts: 110
Joined: Tue Jul 23, 2013 10:02 am
Been thanked: 14 times
Contact:

Re: PIC Resetting

Postby keejay » Fri Mar 13, 2015 10:07 pm

I am interfacing to the motors with this board:

http://www.amazon.com/SunFounder-Channe ... r+5v+relay

It has opto-coupled inputs and I have a 400V MOV across the relay contacts as well.

Confusion reigns...

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8476
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2433 times
Been thanked: 3487 times
Contact:

Re: PIC Resetting

Postby medelec35 » Sat Mar 14, 2015 9:23 pm

Hi,
I also had the dreaded microcontroller reset.
From personal experience I found capacitor across relay contacts was more effective than MOV when powering a diverter valve.
Not sure if will be as effective with a more powerful motor or not?
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1099
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 453 times
Been thanked: 503 times
Contact:

Re: PIC Resetting

Postby Steve001 » Sat Mar 14, 2015 9:33 pm

maybe one of these across your relay contact would help

http://uk.rs-online.com/web/p/rc-networ ... s/0209241/

Steve
Success always occurs in private and failure in full view.

keejay
Flowcode v5 User
Posts: 110
Joined: Tue Jul 23, 2013 10:02 am
Been thanked: 14 times
Contact:

Re: PIC Resetting

Postby keejay » Mon Mar 16, 2015 4:58 pm

Thanks. Ill give that a try. I'm also going to try using the zero crossing triac switch method to avoid the EMI.