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 CCS Technical Support

Microcontroller Resets automatically.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

Microcontroller Resets automatically.
PostPosted: Fri Nov 25, 2016 9:53 am     Reply with quote

Hi ALL,

I have a strange issue with my microntrollers. It resets automatically when something (inductive load) is turned on or off.

My setup would be as follows.

I have a sine wave UPS and I use it 12V battery to power up the pic microcontroller. Obviously I use 7805 regulator with ample filter capacitors.

Everything works normally almost 95% time, but the other 5% is like crazy. The Microcontroller will just reset and do nothing as all the variables pre-coded to the modbus registers are lost.


I don't know how to attach the circuit here.


Please help me out.

Devil Crying or Very sad Crying or Very sad Crying or Very sad Crying or Very sad
_________________
Regards,
Devil
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Nov 25, 2016 10:05 am     Reply with quote

OK, 3 possiblities...
..EMI to me is ANY 'signal' that is NOT wanted...
so..

1) if the PIC is controlling the 'inductive load', the load is not properly designed for EMI supression...

2)the UPS is the source of the EMI, and so is not properly designed.

3) your PIC power supply/PCB/ I-O designs are allowing EMI to reset the PIC
3a) can be coming through the 'wires'
3b) could be airborne.

You need to figure out WHERE the source of the EMI is coming from THEN take appropriate action

I used to design systems in one of the worst possible environments( Optical Emission Spectrometers) and could accurately see 1mv changes on 32 , 16 bit ADC channels so I KNOW it is possible to suppress 'EMI'.

Haven't seen schematics or pictures of the hardware but it can be fixed !!

Jay
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

How to upload the schematic
PostPosted: Fri Nov 25, 2016 10:13 am     Reply with quote

Ok,

1) UPS is professionally built one.
2) The Pic does not drive an inductive load.
3) The pic resets when a 1/2 HP motor starts or stops.
4) The motor is not driven by UPS and It is attached to a different Line.

Can you please let me know any reading materials on how to handle EMI. How to measure it / how to check it?

I have 0.1uf cap in the supply close to the PIC which is not displayed in the schematic.


_________________
Regards,
Devil
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Fri Nov 25, 2016 10:34 am     Reply with quote

I see a remarkable 'lack' of any high frequency decoupling.
Large electrolytic capacitors have almost no effect on frequencies in the MHz range. For a circuit like that, there should be perhaps a minimum 4* 0.1uF ceramic capacitors. One close to the regulator, one by each of the pairs of power pins on the PIC (close to these), and one by the transistors.

Program all the unused pins (A1 to A4, B0 to B5, and C0 to C3), as outputs, and drive them low (A4 does not have a pull up transistor).

Proper RF test kit is expensive. Get a MW radio with a ferrite antenna. Detune it. Do you hear extra noise when the motor starts?. If so you can use the ferrite to work out 'direction'.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Nov 25, 2016 11:45 am     Reply with quote

OK, with the new information...
1) can you test with a battery ONLY going to the PCB? NOT the UPS battery, in fact disconnect 100% of the wiring to the UPS.

With this test, if the PIC resets, then the EMI is probably airborne. Possible cures include a) EMI suppression on the motor b) LOTS of caps as Mr T has said. .1, .001, .01 ceramics will help. These need to be real close to the PIC. As well the 7805 needs them BOTH on input and output.

The *MCLR may need some 'help' as well.

Other things...
Is the project in a solid aluminum case or just a poly plastic unit ?

The RS485 lines may need EMI suppression as well....

Also the FET output lines....

If the EMI is airborne, you need to use caps, ferrites, chokes, R-C networks at EVERY point that could be an antenna.
Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 25, 2016 12:40 pm     Reply with quote

Can you clarify:

1. Is the motor attached to your PIC board in any way ? (including
through a cable, or an intermediary board, etc.)

2. Is the motor an air conditioning motor in another room, or some such,
that just randomly goes on and off during the day ? In other words, is
the motor completely unrelated to your project ?

3. If it's an air conditioning or heater blower motor, etc., what is the
amperage of this motor ? Can you confirm that it's connected to your
AC line power for the building ?
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

Thanks for your response.
PostPosted: Fri Nov 25, 2016 7:01 pm     Reply with quote

PCM programmer wrote:
Can you clarify:

1. Is the motor attached to your PIC board in any way ? (including
through a cable, or an intermediary board, etc.)

2. Is the motor an air conditioning motor in another room, or some such,
that just randomly goes on and off during the day ? In other words, is
the motor completely unrelated to your project ?

3. If it's an air conditioning or heater blower motor, etc., what is the
amperage of this motor ? Can you confirm that it's connected to your
AC line power for the building ?


1) NO - Separate Electrical Line
2) The motor sits outside at least 20 meters away. It runs a pressure pump and has nothing to do with this circuit.
3) Its rated 2 Amps

Mr T and Jay Thanks let me throw a bunch of caps at the places you told me and try this out.
_________________
Regards,
Devil
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Fri Nov 25, 2016 11:26 pm     Reply with quote

The extra caps are essential to start. You may also find that your 10k pullup on /MCLR may be too big - that may be need to be reduced to 4.7k. Also, how long is the line/connection from your ICD header to the PIC itself? How close is the /MCLR pullup to the PIC?
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Sat Nov 26, 2016 2:38 am     Reply with quote

"Throw a bunch of caps"... :(

Wrong attitude. These need to be good high frequency type (polyester, polystyrene or ceramic), and need to have really good low impedance connections to the tracks.

We haven't queried the actual layout of the board. How is it grounded?. What do the FET's drive?. How long is the connection to the LDR?. How long are the other connections?. What type of wire is used?. Do any of these connections connect to other kit?. If so how is this grounded?.
One very likely possibility is a 'ground loop', where another piece of kit is also grounded, or connects to a different ground, and when the motor starts there is a potential difference between the two grounding points....

Also you haven't mentioned my comment about switching the undriven pins to outputs. General rule, is that you must never have an 'input' pin sitting 'open' (undriven). All unused inputs should have a pull-up (or pull down) resistor on them. On the PIC (fortunately), we can reprogram the pins as outputs, but a floating input, is a really easy way of making any circuit unreliable....
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

Mr T - Answers for you.
PostPosted: Sun Nov 27, 2016 12:07 am     Reply with quote

The circuit is grounded with the ground pin on the wall socket.

LDR is soldered on to the board. 2cms in length.

Fets drive 2 LEDs (1 for camera focus light) other one is the flash itself 10W LED.

Mr T,

Quote:
One very likely possibility is a 'ground loop', where another piece of kit is also grounded, or connects to a different ground, and when the motor starts there is a potential difference between the two grounding points....


Seems like this might be the problem. Remember the circuit is powered by the UPS battery. UPS is isolated from heavy loads such as motors, freezers and washers.

I have set all unused pins as outputs but not tied to the ground with a resistor. I might have to redesign the board to accommodate the resistors.

I think this would become a cool project for photographers... Smile
_________________
Regards,
Devil
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Sun Nov 27, 2016 3:10 am     Reply with quote

Hmm.

Are you sure that the bottom pin of the UPS battery is itself grounded?. I'm not sure you will find this always to be the case. Then however even if it is, the ground for your circuit should go to the ground point in the UPS that the battery is grounded to. Currently (not actually a pun, though it could be...), you are creating a potential ground loop, especially if the UPS does activate at all. If this happens the UPS becomes the 'power source', not the mains. Is this an off-line UPS, or an online type?. You may find that at the instant the motor starts the UPS is actually acting for a few mains cycles.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Nov 27, 2016 6:39 am     Reply with quote

You really should do the 'battery only' test (NOT the UPS battery btw), totally isolate the product from all AC sources.
Mr T's 'ground loop' sounds likely to be the cause.
But....
without those correct caps.....airborne EMI can (WILL) reset the PIC, cause 'weird' ADC readings, etc.

also... not all UPS's ARE Uninterruptable ! The monster I have here (has 'car battery' inside) has a 'dead' period of maybe 1/4 second between AC fail and battery switch over. JUST enough that a loaded PC will crash...

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Sun Nov 27, 2016 12:00 pm     Reply with quote

That is where offline types win totally.
ON these the UPS runs continuously and the mains charges the batteries. This is why they are a lot more money, but are worthwhile for anything where a power 'glitch' cannot be tolerated.
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

OFfline UPS
PostPosted: Mon Nov 28, 2016 11:43 am     Reply with quote

Ttelmah wrote:
That is where offline types win totally.
ON these the UPS runs continuously and the mains charges the batteries. This is why they are a lot more money, but are worthwhile for anything where a power 'glitch' cannot be tolerated.


I am not sure what kind of a UPS it is, its 850VA powered by a 12V 110ah battery. I never had my PC, Servers, modems, routers or any of my IT stuffs reboot when power goes down.

I added the following
2 X 0.1 caps -> 7805 input and output
2 X 0.01 caps -> 7805 input and output.
1 X 0.1 cap -> MCLR and Ground.


Jay,

I could not buy a 12V battery as today is Sunday and also a month end,
(Running short on funds.) Will buy a new battery on 1st DEC 2016. will keep you posted.

By the way, I managed to fry 3 of my Max485 ICs.
I think the above mentioned capacitors took care of the resetting problem, but I pushed the testing to a whole new level by routing my RS485 twisted pair and mixed it with 220V AC wires and near to an old fluorescent tublelight choke.

Do you have any Idea why the MAX485 would short out? GND and VCC will be connected once it gets fried.

Laughing
_________________
Regards,
Devil
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Mon Nov 28, 2016 12:42 pm     Reply with quote

Look again at what I said:

"one by each of the pairs of power pins on the PIC (close to these), and one by the transistors. "

Have a look at a PC motherboard.

You will see loads of electrolytic capacitors in the PSU, and loads of ceramic compactors here, but also one or two ceramics right adjacent to every IC round the board.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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