SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By jayjay
#12326
Hello Guys

I have a simple relay circuit which has a strange behaviour. A 12V relay is controlled by a HCS12 MCU and when there is no load on the relay, the toggling of the relay works fine, however when a 12V load is connected to the relay, after a few itteration of toggling the MCU hangs.

The relay schematic is here http://www.cap.com.sg/misc/relay.jpg

I though it could be insufficient current and have verified that the current requirements of the MCU + Load is ok, I have also added filtering caps to eliminate unwanted spikes. Even with the changes, the relay works ok for a while and about 5 mins the MCU just hangs. Any ideas?

Thanks.
Jay
By Kuroi Kenjin
#12328
What is with the R15? I don't think you need it, and you might also want to reduce your base resistor. Philba has a few good comments on how to pick the base resistor. Assuming you're MCU is outputting 5V:

Ib = (5 - 0.7)/R

Ic = Ib * Hfe (check data sheet for Hfe values, pick lowest one since transistor will be in saturation)

if you follow through the calculations, you might find that this collector current is close to the relay's coil current or just under.

You also mentioned a filtering cap. Where is the filtering cap? Contact side, coil side, or on as MCU power bypass? Also, specify what you mean by the MCU haning? Is it doing other things that also just stop?
By jayjay
#12329
Hello Kuroi,

Thanks for the c omments, I will recalculate to adjust the resistor values.

>You also mentioned a filtering cap. Where is the filtering cap? Contact side, coil side, or on as MCU power bypass?

on contact side as well as on the main MCU power bypass.

>Also, specify what you mean by the MCU haning? Is it doing other things that also just stop?

Normally the MCU reads in serial data and based on a command set, it either displays some info on a LCD or turns on/off the relays. I have tested the LCD commands individually and they work fine, I have tested the relay on/off commands and they work fine to as long as I dont have any load connected to it. When a load is connected, the program runs for a few iteration and then the MCU just stops responding. It does not do any of the other things untill manually reset.

When the relay is loaded, this hanging seems to have no fixed pattern, sometimes this happens after 10 iteration and sometimes after 50 iteration, etc. Hence I am thinking could it be that some peak voltage flows back into the MCU i/o pin and caused to go nuts?

Thanks
Jay
By Philba
#12331
since it's an MCU hanging problem, I'd look at the power supply circuit. Do you derive the MCU power from the same source as 12V. What are the relay NO/NC contacts hooked up to? is it drawing from the same power supply as the MCU? It may be power supply transients. I would isolate the 12V supply from the MCU supply.

The Base-Emitter resistor is pretty low. I'd make it at least 100K or higher. You are dividing the voltqage out of the MUC to 1/2. Fortunately, that is still enough for the BC846

an aside, am I the only one that thinks the eagle relay symbol is butt ugly?
By jayjay
#12333
Hi Philba

The main supply is a well regulated 12V brick, this forms the 12V supply rail on the PCB and also powers the MCU's 5V lines thru a 7805 regulator (with caps added).

COM2 normally has 12V, when turned on, NO1 becomes 12V, which powers a small color LCD backlight.

I will try a higher resistor value for the B-E.

Thanks
Jay
By Philba
#12337
I have seen this kind of problem when one supply feeds both digital logic and inductive loads (like motors or relays). You will see a lot of trash on the power line from the motors and at startup, they can pull down the 12V rail, no matter how well regulated.

I would try putting a series diode between your 12V supply and the 7805. Then add a largish cap after the diode, before the 7805. This will give your circuit some transient load protection and prevent the 12V load from draining the transient suppression cap.

of course, I am assuming you have moved potential noise sources away from the digital logic, bypassed all your chips and so on. noise could cause similar problems.

By the way, a relay for a backlight led seems, well, kind of overkill. What kind of current does it draw?