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.

Relay chattering problem at system start-up

Status
Not open for further replies.

sush

Member level 4
Joined
Aug 24, 2005
Messages
78
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
1,946
hi,

I'm almost new to micro-controllers. I made this small project to switch on&off a
relay using 89c51, and Push-button. I've installed both switch and relay on port0.
and also added pullup resistors. The system is working fine, but, my problem is,
whenever i switch on the system the relay switches on and off for a fraction of a
second, how can i eliminate this one time chattering of relay? i tried adding a
condensor at the base of transistor, the chattering stopd but when i need to push
the switch to on the system the relay takes some time to switch on. I'm sending both diagram and code, please help!!!

every help would be appriciated, Thanks.

Code:
;***************************************************************************

#INCLUDE "8051EQU.INC"          ;include predefined constants
;
;**************************************************************************

; RESET                         ;reset routine

   .ORG   0H                    ;locate routine at 00H
    AJMP   START                ;jump to START 
;
;**************************************************************************
;
; INTERRUPTS  (not used)        ;place interrupt routines at appropriate
                                ;memory locations
   .ORG   03H                   ;external interrupt 0
    RETI
   .ORG   0BH                   ;timer 0 interrupt
    RETI
   .ORG   13H                   ;external interrupt 1
    RETI
   .ORG   1BH                   ;timer 1 interrupt
    RETI
   .ORG   23H                   ;serial port interrupt
    RETI
   .ORG   25H                   ;locate beginning of rest of program
;
;**************************************************************************
;
INITIALIZE:                     ;set up control registers
;
    MOV   TCON,#00H
    MOV   TMOD,#00H
    MOV   PSW,#00H             
    MOV   IE,#00H               ;disable interrupts
    RET
;
;**************************************************************************

;**************************************************************************
;
START:                         
   	ACALL INITIALIZE           
LOOP:                          
	JB P0.1, LOOP
HERE:
	JNB P0.1, HERE		;WAIT FOR KEY RELEASE
	CPL P0.2
   	AJMP LOOP
.END
 

Re: Relay problem

You may have switch bounce problems ..
Try to add delays to both loops:

Loop:
JB P0.1, Loop
CALL Delay (≈50-100ms)
JB P0.1, Loop

Here:
JNB P0.1, Here
CALL Delay (≈50-100ms)
JNB P0.1, Here

CPL P0.2
SJMP Loop


Also, connect 100µF+100nF bypass capacitors between +5V and 0V, add 10nF-100nF capacitor betwwen P0.1 and GND .. and try again ..


Regards,
IanP

PS, if you need a DELAY subroutine here is an example:

Firstly replace:
MOV TMOD,#11H ;both timers in 16-bit mode
MOV TCON,#00H ;stop both timers
in INITIALIZE ..

;------------------------------------------------------------------------
; 0.1 SECOND DELAY ROUTINE AT 12 MHz SPPED
; {TR0(50ms) + TR1(50ms)} x R7(01) = 0.1 secOND delay
;------------------------------------------------------------------------
DELAY:
MOV R7,#COUNT ;load R7 for loop repeat counter

DLOOP:
MOV TL0,#LOW(FIFTY) ;load low byte for 50ms
MOV TH0,#HIGH(FIFTY);load high byte
MOV TL1,#LOW(FIFTY) ;load low byte for 50ms
MOV TH1,#HIGH(FIFTY);load high byte

SETB TR0 ;start timer TR0 for 50 milli seconds
JNB TF0,$ ;wait until TRO flag is set
CLR TR0 ;stop timer TR0
CLR TF0 ;clear TR0 flag bit

SETB TR1 ;start timer TR0 for 50 milli seconds
JNB TF1,$ ;wait until TRO flag is set
CLR TR1 ;stop timer TR0
CLR TR0 ;clear TR0 flag bit
DJNZ R7,DLOOP ;decrement and check R7 for loop repeat

RET
 

Relay problem

I really appritiate the efforts u took to reply to my question. First of all there's no problem of key debounce. my problem is, when i switch on the system (micro-controller) the relay activates for a second and then switches off, help me for that.

and also i tried adding a 100uf+100nF capacitor, i even tried adding 10uf tantalum
capacitor, a 100nf very near to pin 40 of 89c51......but none of them worked out.
 

Re: Relay problem

Bear in mind that on power-on (reset) all ports are loaded with "FFh" what means that the relay will be energized as soon as you apply power to the micro ..
As the very first instruction of your code try:

CLR P0.2 ..

Regards,
IanP
 

Re: Relay problem

I don't check if it's a software problem. But, you use a BC547 transistor, and you don't say anything about what kind of relay you used. BC546/BC547/BC548 transistors gain (hfe) are dependents of how much current drops from collector to emiter. First, base resistor must be lower 1K or less. I recomend that change the transistor to a BC337 is more stable the gain at high currents (up to 800mA).

:arrow:
 

Relay problem

I dont know PIC , in other mciros ports are tristate at POR. If said is true (port are set to 0xff at PORT) problem can be solved as :
- discard circuitity connected to P0.2
- use PNP BJT transistor as - emitter connected to +5V
collector to relay , base to P0.2 through 4.7 K. Another end of relay connected to ground with parallel diode (katod to ground )
- changes in software as - output logical 0 to switch relay ON in program


if ports are set to tristate at POR you should :
- cut 10 kOhm connected between P0.2 and +5V
- connect 10 kOhm to BC547's base and other end of resistor to ground.

Also , your reset delay is too long - t~ 100 msec . Dont know what is recommended for PIC but you could decrease capacitor value to acceptable reset delay .
 

Relay problem

it is the problem with higgh voltage appearing at the port of 8051.it is better to compliment ur out put logic.
try it,
wth gluck sabu
 

Re: Relay problem

Check the attachment. This is the perfect result for you. i fully agree to what "artem" said. Right "Ianp" ???
 
Re: Relay problem

Hi sush:

Where is your decoupling capacitor?

Hope this helps.
 

Relay problem

Thanks Pont de Pedra for replying. i tried that. small value capacitor didn't helped and if i use higher value there comes up a delay in switch on/off of relay.
 

Re: Relay problem

I mean a 100nF (for instance) between ground and Vcc close to the uControler pins.
That is (in DIL package) pin 20(-) and pin 40 (+), not in the output pins.

Regardds.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top