AT89C2051 trigering relay problem

H

Haris

Guest
I'm trying to interface AT89C2051 mcu with a relay that inturn should
switch a 12V NC output.

AT89C2051
_____
5V________ | |
| | |
12V______ | | |
| | | |
| | | |
| | |_____|
| | |P1.7
| | |
| | |
5V NC NO | | \
| | | | | /
| | | | | / 10K Resistor
) | | | | \
( -- -- | | |
) / | | |
( / | | |
| Relay | | | |B
| | | | _
| |______| | / \ E |
|_____________________/ \_________||
|||
Transistor ||
| GND


The problem is that if device (EM lock) is connected, MCU will hang
after 1 day. I am saying that it hang since PC connected to it using
serial port unable to receive or send signal.

If the device is not connected, it works fine. At this point (and in
mydesperation to explain this) I thought that somehow the relay 12V
output is giving interference to the MCU. Since the relay is normally
open, the 12V current is there almost all the time.

Any idea?

Thanks in advance
 
Terry,

There is one think I would like u too clarify

Secondly, look at your "gnd" connection. I would twist gnd, P1.7 and +5V
together, and connect them all up at the micro (put the 10k there).
What do you, mean by twist. Is it like having this three wire traced
close together in parallel on the PCB? And where should I put the 10k
resistor?

--ChEeRs
--Haris
 
Regulator
========
My understanding on Dave and Terry comment is that I need to put a
regulator circuit between the adaptor (wall wart) and my MCU (and the
rest of the circuit)

And not to forget the free wheeling dioed.

So the modified circuit should be

---------------
| Regulator |
5V_____| circuit |________ VCC
| | using 78(L)05 | |
| --------------- |
| |
| V?? (what do |
| call this?) |
|________ |
| | AT89C2051
| | _____
| | | |
| | | |
| 12V______ | | |
| | | | |
| | |--|VCC |
| | | |_____|
| | | |P1.7
| | | |
| | | |
| | | /
| | | \
| NC NO | | \
_____| | | | | /
| | | | | | / 10K Resistor
K | ) | | | | \
_|_ ( -- -- | | |
/ \ ) / | | |
----- ( / | | |
A | | Relay | | | |B
|_____| | | | _|_
| |______| | / \ E |
|____________________/ \_________||
|||
Transistor ||
| GND


Next is thing I'm not sure about
================================

Dave write
-------------------------------------------------------------------------

I would also add a resostor from the port pin to ground, to assure
that the
transistor turns OFF, when the port pin is tristated, like during
reset.

-------------------------------------------------------------------------

This make above circuit into

---------------
| Regulator |
5V_____| circuit |________ VCC
| | using 78(L)05 | |
| --------------- |
| |
| V?? (what do |
| call this?) |
|________ |
| | AT89C2051
| | _____
| | | |
| | | |
| 12V______ | | |
| | | | |
| | |--|VCC |
| | | |_____|
| | | |P1.7 |
| | | | ||
| | | |_____/\ /\_____|||
| | | | \/ |||| GND
| | | | 10K Resistor |||
| NC NO | | | |
_____| | | | | |
| | | | | | |
K | ) | | | | |
_|_ ( -- -- | | |
/ \ ) / | | |
----- ( / | | |
A | | Relay | | | |B
|_____| | | | _|_
| |______| | / \ E |
|____________________/ \_________||
|||
Transistor ||
| GND


Bypassing
=========
I got the idea that bypassing is some kind of capacitor use to filter
out spike. Correct me if I'm wrong here. Hell, I got a lot of
braindead cell at the moment. The question is now (at least for me) is
where to put the 100nF capacitor. My guess is:

1. At the atmel VCC pin

VCC AT89C2051
| _____
| | |
| | |
| | |
| 100nF | |
|--||- -|VCC |
| |_____|
2. Between 12V and | |P1.7
the relay output | |
100nF | |
12V----||--+ | |
| | |
| | |
3. Before the | | |
coil | | |
| | |
100nF | | |
V?? ---||----+ | | |
| | | |
| | | |
| NC NO | | |
_____| | | | | |
| | | | | | |
K | ) | | | | |
_|_ ( -- -- | | |
/ \ ) / | | |
----- ( / | | |
A | | Relay | | | |B
|_____| | | | _|_
| |______| / \ E |
|______________________________/ \_________||
|||
Transistor ||
| GND



End Note
========
In the past two weeks I have change from using regulator to a type of
power supply that have regulator inside. Not surprisingly I got a
stable working circuit. This sort of conform with what we have
discussed here.

And multimeter reading across the adapter is about 5.4 V. Multimeter
reading across the power supply is about 5 V.

Thanks everyone for all the help. Though i got this feeling that there
is still lot to come.

--ChEeRs
--Haris
 

Welcome to EDABoard.com

Sponsor

Back
Top