FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Forum index » Electronix » design
Microchip and Relay Interaction Problems
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
Author Message
Mark
electronics forum Guru


Joined: 03 May 2005
Posts: 329

PostPosted: Thu Jul 20, 2006 9:26 pm    Post subject: Re: Microchip and Relay Interaction Problems Reply with quote

Quote:
2. Does the problem happen without any load on the relay?


I agree...

step 1 is to detemrine if the problem occurs with the relay COIL
connected, but the relay CONTACTS disconnected. Then we know where the
plroblem is...

Mark
Back to top
john jardine
electronics forum Guru Wannabe


Joined: 23 Apr 2005
Posts: 233

PostPosted: Thu Jul 20, 2006 8:46 pm    Post subject: Re: Microchip and Relay Interaction Problems Reply with quote

"Angora" <pjvdwest@sun.ac.za> wrote in message
news:1153413431.635514.284380@m73g2000cwd.googlegroups.com...
Quote:
Hello All

[...]

Stick a 1000uF across the micro power pins. Feed the relay straight from the

battery and not via that diode.
john
Back to top
Gary Reichlinger
electronics forum beginner


Joined: 03 Mar 2006
Posts: 5

PostPosted: Thu Jul 20, 2006 6:23 pm    Post subject: Re: Microchip and Relay Interaction Problems Reply with quote

On 20 Jul 2006 09:37:11 -0700, "Angora" <pjvdwest@sun.ac.za> wrote:

Typical relay coil current usage (when relay is on)
Quote:
is between 50 and 70 mA. Maximum current that flows through switches is
around 50mA.

Why not just use the mosfet to drive the load? This may require
a different mosfet depending on your circuit, but you would eliminate
the inductive problems present in a relay.
Back to top
Spehro Pefhany
electronics forum Guru


Joined: 01 May 2005
Posts: 2326

PostPosted: Thu Jul 20, 2006 5:44 pm    Post subject: Re: Microchip and Relay Interaction Problems Reply with quote

On 20 Jul 2006 09:37:11 -0700, the renowned "Angora"
<pjvdwest@sun.ac.za> wrote:

<long story deleted>

1. What kind of reset circuit are you using? If the on-chip BOR is
being used, what is Vbot? If BODLEVEL is 1, then the chip can reset
at as high as 4.5V Vdd. (4.0V typical).

2. Does the problem happen without any load on the relay?

3. Is there series gate resistor on the MOSFET?

4. What kind of supply bypassing do you have on the ATMEGA16?

5. How about the layout? Did you have controlled separate current
paths for the relay coil current and load current? How about
a ground plane under the micro?


Best regards,
Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@interlog.com Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
Back to top
Bob Eldred
electronics forum Guru Wannabe


Joined: 05 May 2005
Posts: 154

PostPosted: Thu Jul 20, 2006 5:25 pm    Post subject: Re: Microchip and Relay Interaction Problems Reply with quote

"Angora" <pjvdwest@sun.ac.za> wrote in message
news:1153413431.635514.284380@m73g2000cwd.googlegroups.com...
Quote:
Hello All

My problem defies solving. Ive been stuck on it for two months now and
I hope that you can help me out. This will be a lengthy post.

Here is my circuit (and component) discription:

1) Microchip type: ATMEL ATMEGA16. Surface mount. Commercial package.

2) Supply voltage: 6V. Unregulated, but powered by batteries. A diode
allows sufficient voltage to drop before I connect it to the chip.
(diode in series with supply). During battery usage, voltage of
batteries do drop, but it does not matter here. Chip can still work to
4.5V min.

3) Relay type: 5V relay, PDIP package, no protection diode, 2-form,
non-latching. I have added my own diode (for back-EMF). The relay is
driven through a MOSFET. The MCU switches on the relay by writing out a
high to the mosfet gate, which in turn switches on the relay. At the
moment I have a 10 ohm resistor in series with the relay coil and the
6V battery supply. Typical relay coil current usage (when relay is on)
is between 50 and 70 mA. Maximum current that flows through switches is
around 50mA. The relay can handle voltages over and beyond the battery
supply. It can also still function to voltages of around 4V.

4) Reasons for relay: I am designing an automatic measurement devicve.
The device runs from batteries, which means I need to limit any current
usage to an absolute minimum. In order to do this, I have decided to
use a relay to switch on power to external component when a measurement
is required and to switch it off again when the measurements are done.
This limits power consumption to that which the AMTEL uses, which is
typically around 400uA during off time. Relay effectively switches
positive and negative 6V supply (from batteries) to op-amp rails during
switching. Op-amp rails are switched to ground when off.

5) Microchip program details: A "cold boot" start by setting up all MCU
peripherals (port uses, initial states, etc), then switching on the
relay. After all of this, it goes to a infinite loop (while(1) loop).
In this loop, it checks if serial comms are being requested. If so, it
waits until a switch is pulled. If not, it proceeds to measure using
the A/D ports. These ports are connected to the op-amps mentioned
before. After a few measurements are taken, the chip stores the results
in an external EEPROM, checks that all interrupts have been serviced,
then commands the relay to switch off. It then goes into sleep mode.
The only way to come out from this sleep mode is via an timer
interrupt. A 32kHz crystal is used in an asynchronous timer, which
remains on during sleep mode, causing an interrupt on overflow. After
exiting sleepmode (every 8 seconds in my case), the chip checks if
another measurement needs to be done (a counter is checked). If not, it
goes back to sleep. If so, it switches the relay back on, then proceeds
with the whole cycle again. (In other words, all of the actions
mentioned here take place within the while(1) loop).

6) External chips: OP-AMPS are LM358's. (Dual package. . .surface
mount).
External EEPROM is ATMEL's SPI type (AT25320A)
Serial port connected via maxim RS323 chip.

Ok, I hope thats all the detail. Much of the programming and external
setups are not given here, since that will require a mini-report.
However, I hope that this will enable you to identify my problem (if
you can). If not, feel free to request more information.

Here is my problem (at last). My program manages to do everything is is
supposed to do, right up to the point where the relay switches ON (the
time it switches back on in the infinite loop). What happens is that my
program suddenly restarts, right after the command to switch on the
relay. NO code following this command gets executed. However. . .this
does not happen every single time. There are times when the relay
switches on and the MCU goes on as normal. Nothing strange happens
after "relay off" commands, neither do it get the problem if the single
code that switches on the mosfet (to the relay) is removed. In other
word, the program cycle, all timer interrupts and sleep mode do not
seem to give me this "glitch".

To make the problem more complex, I built a prototype circuit where,
when I removed code to write out debugging words via serial port, the
glitch seemed to go away (so I blamed stack overflow problems).
However, when I made a PCB and programmed the exact code (from the
prototype) on this new circuit, the problem returned. The only
differences between my PCB and the prototype circuit are the op-amps
(LM358 instead of the quad LM324) and, of course, layout. However, all
the connections and the rest of the chips used in both circuits are the
same.

Finally, I have catered for switch bounce etc. during on times by
programming in delays etc. The problem persists. I have decoupling
capacitors at every chip (although my power supply is strictly non-AC
in nature) and a few big uF ones for the whole circuitboard.

Thanks a lot. Hope it all makes sense.

If I read your problem correctly it sounds like turning on the MOSFET resets
the processor. This could happen if the FET pulls the power rail down
sending the processor into a restart mode. Once restarted the port driving
the FET is is returned to its off condition. Here are a few things to look
for: Be sure the processor is bypassed with a cap, .1 uF or so right at its
power and ground terminals. You mention this but it is unclear. The ring off
diode across the relay could be in backwards. The relay or diode could be
shorted or the diode breaking down if it is the wrong type or faulty. The
FET could be oscillating. Place a 100 ohm resistor in series with the gate
to the port. I read your description but an actual schematic would be
helpful. Good luck.
Bob
Back to top
John Popelish
electronics forum Guru


Joined: 29 Apr 2005
Posts: 1601

PostPosted: Thu Jul 20, 2006 4:57 pm    Post subject: Re: Microchip and Relay Interaction Problems Reply with quote

Angora wrote:
(snip description)
Quote:
Here is my problem (at last). My program manages to do everything is is
supposed to do, right up to the point where the relay switches ON (the
time it switches back on in the infinite loop). What happens is that my
program suddenly restarts, right after the command to switch on the
relay. NO code following this command gets executed. However. . .this
does not happen every single time. There are times when the relay
switches on and the MCU goes on as normal. Nothing strange happens
after "relay off" commands, neither do it get the problem if the single
code that switches on the mosfet (to the relay) is removed. In other
word, the program cycle, all timer interrupts and sleep mode do not
seem to give me this "glitch".

Sounds to me that the relay turn on pulse momentarily dips the battery
voltage low enough to reset the processor. I would look at bypassing
(both at the processor, and also at the point where the mosfer and
relay coil connect to the supply. The relay should have its own
bypass capacitor that is big enough to pull the relay in (bounce the
contacts closed), momentarily, all by itself. You may need to add a
ferrite bead on a lead (or other small inductance between he positive
rail feeding this capacitor and relay coil) to let this bypass sag a
bit, so it can supply current, without also sagging the battery voltage.

Quote:
To make the problem more complex, I built a prototype circuit where,
when I removed code to write out debugging words via serial port, the
glitch seemed to go away (so I blamed stack overflow problems).
However, when I made a PCB and programmed the exact code (from the
prototype) on this new circuit, the problem returned. The only
differences between my PCB and the prototype circuit are the op-amps
(LM358 instead of the quad LM324) and, of course, layout. However, all
the connections and the rest of the chips used in both circuits are the
same.

Make sure the relay coil current does not go past the micro, in its
way to and from the battery. You don't want the trace resistive and
inductive drops included in the micro supply voltage.

Quote:
Finally, I have catered for switch bounce etc. during on times by
programming in delays etc. The problem persists. I have decoupling
capacitors at every chip (although my power supply is strictly non-AC
in nature) and a few big uF ones for the whole circuitboard.

The exact location of those big capacitors are important. Remember
that you can't get any current from a capacitor, unless you allow its
voltage to change.

Quote:
Thanks a lot. Hope it all makes sense.
Back to top
Angora
electronics forum beginner


Joined: 20 Jul 2006
Posts: 1

PostPosted: Thu Jul 20, 2006 4:37 pm    Post subject: Microchip and Relay Interaction Problems Reply with quote

Hello All

My problem defies solving. Ive been stuck on it for two months now and
I hope that you can help me out. This will be a lengthy post.

Here is my circuit (and component) discription:

1) Microchip type: ATMEL ATMEGA16. Surface mount. Commercial package.

2) Supply voltage: 6V. Unregulated, but powered by batteries. A diode
allows sufficient voltage to drop before I connect it to the chip.
(diode in series with supply). During battery usage, voltage of
batteries do drop, but it does not matter here. Chip can still work to
4.5V min.

3) Relay type: 5V relay, PDIP package, no protection diode, 2-form,
non-latching. I have added my own diode (for back-EMF). The relay is
driven through a MOSFET. The MCU switches on the relay by writing out a
high to the mosfet gate, which in turn switches on the relay. At the
moment I have a 10 ohm resistor in series with the relay coil and the
6V battery supply. Typical relay coil current usage (when relay is on)
is between 50 and 70 mA. Maximum current that flows through switches is
around 50mA. The relay can handle voltages over and beyond the battery
supply. It can also still function to voltages of around 4V.

4) Reasons for relay: I am designing an automatic measurement devicve.
The device runs from batteries, which means I need to limit any current
usage to an absolute minimum. In order to do this, I have decided to
use a relay to switch on power to external component when a measurement
is required and to switch it off again when the measurements are done.
This limits power consumption to that which the AMTEL uses, which is
typically around 400uA during off time. Relay effectively switches
positive and negative 6V supply (from batteries) to op-amp rails during
switching. Op-amp rails are switched to ground when off.

5) Microchip program details: A "cold boot" start by setting up all MCU
peripherals (port uses, initial states, etc), then switching on the
relay. After all of this, it goes to a infinite loop (while(1) loop).
In this loop, it checks if serial comms are being requested. If so, it
waits until a switch is pulled. If not, it proceeds to measure using
the A/D ports. These ports are connected to the op-amps mentioned
before. After a few measurements are taken, the chip stores the results
in an external EEPROM, checks that all interrupts have been serviced,
then commands the relay to switch off. It then goes into sleep mode.
The only way to come out from this sleep mode is via an timer
interrupt. A 32kHz crystal is used in an asynchronous timer, which
remains on during sleep mode, causing an interrupt on overflow. After
exiting sleepmode (every 8 seconds in my case), the chip checks if
another measurement needs to be done (a counter is checked). If not, it
goes back to sleep. If so, it switches the relay back on, then proceeds
with the whole cycle again. (In other words, all of the actions
mentioned here take place within the while(1) loop).

6) External chips: OP-AMPS are LM358's. (Dual package. . .surface
mount).
External EEPROM is ATMEL's SPI type (AT25320A)
Serial port connected via maxim RS323 chip.

Ok, I hope thats all the detail. Much of the programming and external
setups are not given here, since that will require a mini-report.
However, I hope that this will enable you to identify my problem (if
you can). If not, feel free to request more information.

Here is my problem (at last). My program manages to do everything is is
supposed to do, right up to the point where the relay switches ON (the
time it switches back on in the infinite loop). What happens is that my
program suddenly restarts, right after the command to switch on the
relay. NO code following this command gets executed. However. . .this
does not happen every single time. There are times when the relay
switches on and the MCU goes on as normal. Nothing strange happens
after "relay off" commands, neither do it get the problem if the single
code that switches on the mosfet (to the relay) is removed. In other
word, the program cycle, all timer interrupts and sleep mode do not
seem to give me this "glitch".

To make the problem more complex, I built a prototype circuit where,
when I removed code to write out debugging words via serial port, the
glitch seemed to go away (so I blamed stack overflow problems).
However, when I made a PCB and programmed the exact code (from the
prototype) on this new circuit, the problem returned. The only
differences between my PCB and the prototype circuit are the op-amps
(LM358 instead of the quad LM324) and, of course, layout. However, all
the connections and the rest of the chips used in both circuits are the
same.

Finally, I have catered for switch bounce etc. during on times by
programming in delays etc. The problem persists. I have decoupling
capacitors at every chip (although my power supply is strictly non-AC
in nature) and a few big uF ones for the whole circuitboard.

Thanks a lot. Hope it all makes sense.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
The time now is Thu Jun 21, 2018 2:59 am | All times are GMT
Forum index » Electronix » design
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts SONY STR D650Z problems BR3ND3L Repair 0 Tue Apr 07, 2009 10:21 am
No new posts Mitsubishi CS-27EX1 Relay? P/N? Where to Buy? Rod Repair 0 Fri Jul 21, 2006 11:34 am
No new posts relay john carson Repair 5 Wed Jul 19, 2006 6:10 pm
No new posts GeneXproTools 4.0 - GEP modeling tools for Math and Boole... Candida Ferreira design 1 Tue Jul 18, 2006 10:52 am
No new posts GeneXproTools 4.0 - GEP modeling tools for Math and Boole... Candida Ferreira Misc 1 Tue Jul 18, 2006 10:52 am

Copyright © 2004-2005 DeniX Solutions SRL
Other DeniX Solutions sites: Unix/Linux blog |  Unix/Linux documentation |  Unix/Linux forums |  Medicine forum |  Science forum  |  Send and track newsletters


Powered by phpBB © 2001, 2005 phpBB Group