Pump controller using atmega128 going wrong due to EMI

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I have just put together a Pump controller system which consists of a 3 24VAC contactors and the avr atmega128 circuitry. Basically when the Pump controller receives a signal to start the pump, based on the water levels in the tanks the appropriate pump should be turned on by the contactor.

 

the problem i am facing is when the Contactor turns ON or OFF(mostly when turned off), the uC goes crazy. I get a partial hung up system or there is all garbage on the LCD. The system has to be reset.

 

The easiest solution i could think of was to enable the Watchdog timer. But that does not help too. The system does not reset. not sure if its a coding problem.

 

pasted the code if you feel it a watchdog code issue

void wdt_setup() 
{
  wdt_disable();
  wdt_enable(WDTO_2S);
}

 

 

in main:

 

.
.
wdt_setup();
.
.

 

in a timer function

 

ISR(TIMER0_COMP_vect)
{
    \\ISR is called every 1ms
TCCR0 &= ~(1 << WGM01);
wdt_reset();
.
.
.

 

any suggestions? 

 

if i disconnect the contactors the systems is perfect so i am pretty sure its because of the noisy environment

 

Would love to hear some advice.

 

Rodney Almeida

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

You need to fix your PCB design, to increase the noise immunity - such things as supply filtering, transient suppressors, etc.

Leon Heller G1HSM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rodney_alm wrote:
The easiest solution (sic) i could think of was to enable the Watchdog

A Watchdog doesn't solve the problem - it just lets the system recover after a problem has occurred!

 

As leon_heller says, you need to fix the problems in your design - so that it is not susceptible to this interference...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Where do we start?
It is next to useless putting the watchdog reset in an isr- even if the stack has gone west, the isr will most likely execute. See my tutorial on multitasking in the tutorial section. You kick the watchdog in the main loop. If a function hangs, then the loop won't execute and the watchdog doesn't get kicked. Nevertheless, the watchdog doesn't solve the problem.

As Leon points out, your design leaves much to be desired. A sprinkling of varistors across the coils and contacts of your contactors might help a bit.
Your inputs are via a flat cable - any RC filtering here?

Be careful how you route your wiring. Keep low voltage stuff away from switched loads.

Really, why did you just not get a micro PLC?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

an update!

 

Thanks Leon, awneil & Kartman,

 

I did realise that emi would be an issue was designing the board, hence i had created a hatch pattern copper pour on the bottom layer. It just hit me that the copper pours were isolated, so i connected the copper pour islands to ground and immediately everything seems ok. i still have a lot more testing to be pretty sure.

 

Kartman - your right putting the watchdog reset in the isr is indeed pointless. will modify my code accordingly.

 

Thanks, 

 

Rodney Almeida

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rod, i think you'll need a bit more than a cross hatch pattern on the pcb - that is meant to minimise radiation. Your problem is susceptance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Disable the pump power to see if the resets were coming from contactor coil as opposed to pickup from the pump power circuit.  If so energize the contactor from a battery to determine whether it is EMI from the drive loop or back EMF from the coil. Unless you have a large loop antenna, its probably back EMF when the current to the coil is interrupted. That  can be controlled with diodes or capacitors. -> your grounding fix may have increased the capacitance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It sounds to me like the contactor coil back emf is the issue, in fact I would bet the farm on it, looking at the picture there is nothing to handle this

 

For AC coils you can fit an RC snubber, you can calculate the values of R and C with simple methods (Ohms law) an MOV is probably better though, if it were me I would fit both because its not much cost, think of the snubber as protecting the MOV

 

If it were me I would also fit some suppression on the PCB just as suggested