Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Controlling relays fluctuate when the value is changed, why?

Status
Not open for further replies.

john2020

Full Member level 5
Joined
Nov 13, 2005
Messages
292
Helped
12
Reputation
24
Reaction score
8
Trophy points
1,298
Activity points
4,911
controlling relays

hi all,

i m controllring 8 relays using 373 latch connected with microcontroller
89c51. but when i ever i change the value at the port of microcontroller,
the relays fluctuate
why is it so? and what is the solution.

regards
john
 

Re: controlling relays

Hi John!
Can you post the code that you are using to switch on/off the relays.
I think the problem you are taking about has something to do with the way you are modifying the port output e.g if all the relays are turned on and you want to turn off just one relay by sending logic 0 to that port pin then the C code should be like this

P1 = P1&0XFE;(Relay connected to P1.0 is turned off.
on the other hand if all the relays are turned off and you want to turn on just one relay then the code will be
P1 = P1|0X01;
I have assumed that the relays are connected to P1.
Regards.
 

Re: controlling relays

use transistor between 373/573 output and relay.
not drive directly.
 

controlling relays

You're not disabling the enable bit when you're updateing the latch, you're probably catching pin propogation delay from your micro controller. Turn the 373's enable pin off, update the latch, then re-enable it. Think of the enable bit as a master clock for the update of the individual bits of the latch. It has to be enabled ONLY during a known phase of ALL the inputs. Make sure you read the sheet for the EXACT version of the 373 that you're using to make sure you're waiting the proper amount of time after the last bit is updated to when it's in a known state and when it's propgated through the input circuitry of the latch before you trigger the enable.
 

Re: controlling relays

I can't see any advantage in using 373 latch between microcontroller port and relays .. You have to employ 8 pins anyhow ..
Why cant you drive relays directly:
(microcontroller pin)-->(resistor)-->(transystor)-->(relay)
Regards,
IanP
 

controlling relays

Dear John
It is better for u to use a separate buffer for modifing P1 port.like this
p1_buf=p1_buf|0x01; for turn on
p1_buf=p1_bus&0xFE for turnoff

P1=p1_buf;
active latch enable

If you use c compiller, you can use sbit command to
define a bit of memory

bdata char p1_buf;
sbit relay_1=p1_buf^0;
sbit relay_2=p1_buf^1;
relay_1=0 or 1;
relay_2=0 or 1;
P1=p1_buf;
active latch enable

All PLCs use memory image like above.

NOTE: Check Interupt Routine that you used.they may change your port too.

:idea: 7404 is an open collctor buffer u can use it for drive your relay.
Regards
 

Re: controlling relays

dear jhon,
i think you mean that buffer dosn't save the last output from micro-controller that's because you need keep pin 11 (LE) down to store data, if pin 11(LE) is 1 or not connected, latch output=input as abuffer

Added after 2 minutes:

latch
 

Re: controlling relays

hi all,

thanks specially for shafee and smxx for their suggestions,ideas.

bye
john
 

controlling relays

i fully agree with IanP u can add a small condenser at the base of the transistor to reduce the chattering of the relay

regards
 

Re: controlling relays

hi smxx,

could you elaborate on your idea about that , it is better for u to use a separate buffer for modifing P1 port?


regards
john
 

controlling relays

hi john2020
Assume I have to change P1.0 =0 (relay 1) and P1.1=1 (relay 2).

/****************/

Direct Modification
I can define bits of port P1 directly

sbit relay1=P1^0; define bit 0 of Port P1 as relay 1
sbit relay2=P1^1; define bit 1 of Port P1 as relay 2

relay_1=0; " bit 0 of P1"
relay_2=1; " bit 1 of P1"

/**************************************/

Indirect Modification
I define a buffer p1_buf for modify port P1.

bdata char p1_buf; bit addresable char
sbit relay_1=p1_buf^0; define bit 0 as relay_1
sbit relay_2=p1_buf^1; define bit 1 as relay_2



p1_buf =P1; "make a mirror for port P1"
relay_1=0; " bit 0 of P1_buf=0"
relay_2=1; " bit 1 of P1_buf=1"

P1=p1_buf; out p1_buffer to P1
active latch enable

In application that used interrupt it may an interrupt
occur bitween bit 0 an bit 1 modifing in Direct Modification.
 

Re: controlling relays

hi smxx

can you tell me why have you assumed to change P1.0 =0 (relay 1) and P1.1=1 (relay 2)?
 

controlling relays

hi john
I edit my above poste . I assumed ...
what is the problem?!!!
 

Re: controlling relays

hi smxx

i just asked to clarify,whether is there any specific reason for your assumption,nothing more.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top