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.

[51] Relay interface with 8051

Status
Not open for further replies.

hirenn

Full Member level 1
Joined
Jul 12, 2014
Messages
96
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
703
Hi

I want to build a project with relay,switch and 8051

my logic is as below

- when pressed Switch Start Relay
- wait for pulse 60 seconds,
- if pulse there withing 60 sec then continuous on relay,
if no pulse then wait another 60 sec
- after 120 second if no pulse then make relay off and again check for switch pressed

thanks
 

xenos

Full Member level 4
Joined
May 9, 2015
Messages
212
Helped
82
Reputation
164
Reaction score
81
Trophy points
28
Location
127.0.0.1
Activity points
1,182
Hi

I want to build a project with relay,switch and 8051
...
thanks
Thanks for sharing this with us!
:-D

ps. you obviously forgot to tell what your problem is...
 

hirenn

Full Member level 1
Joined
Jul 12, 2014
Messages
96
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
703
Hi !

my problem is i dont know how to do this logic . . .

thanks
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
524
Trophy points
1,393
Activity points
0
If there is pulse between 60 and 120 second ? Where does the pulse come from ? Is it actually a pulse or some low to high transition which remains in high state after transmission ?

Edit: If pulse is detected between 60 and 120 sec then Relay is turned ON ?
 
Last edited:

Surender Reddy

Full Member level 2
Joined
Jan 28, 2012
Messages
130
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Location
Bangalore, India
Activity points
2,189
Use interrupt concept for detecting pulse, update the timer value with 60. Decrement the timer value in the while loop, when the timer goes zero switch off the relay.
 
  • Like
Reactions: hirenn

    hirenn

    Points: 2
    Helpful Answer Positive Rating

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
524
Trophy points
1,393
Activity points
0
I can do this but if you can use PIC18F458.

Here is the Keil C51 Code for AT89C51. INT0 is switch and button not pressed state is high. Button has to be pressed and released. Pulse has to go high and then low.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <REGx51.h>
 
#define ON 1
#define OFF 0
 
sbit RELAY = P1^0;
 
char myFlags = 0, count = 0, waitCounter = 0;
 
char pulseDetectedFlag = 0;
 
void ex0_isr (void) interrupt 0 {
     EX0 = 0;     
     EX1 = 1;     
     TR1 = 1;
}
 
void ex1_isr (void) interrupt 2 {
 
     if(waitCounter == 0) {
          RELAY = ON;        //Continuous ON
 
          ET1 = 1;
          IT1 = 0;
          EX1 = 0;
          
          TMOD = 0x10;
          TH1 = 0x27;
          TL1 = 0xFD;
          TR1 = 0;
          
          waitCounter = 0;
     }
     else if(waitCounter == 1) {
          RELAY = ON;        //Pulse between 60 and 120 sec
 
     }
 
     pulseDetectedFlag = 1;
}
 
void timer1_isr (void) interrupt 4 {
 
        TF1 = 0;
        TH1 = 0x27;
        TL1 = 0xFD;
          
        if(++count == 100) {
             count = 0;
             waitCounter++;
             if(waitCounter == 2) {
                    if(pulseDetectedFlag == 0) {
                            RELAY = OFF;
                            
                            EX0 = 1;                            
                            EX1 = 0;                            
                            TR1 = 0;
                    }
             }
 
        }
     
        TF1 = 0;
 
}
 
void main() {
 
    P0 = 0x00;
    P1 = 0x00;
    P2 = 0x00;
    P3 = 0x0C;
 
        EX0 = 1;
    IT0 = 0;
    EA = 1;
    
        while(1);
 
}



118267d1433876868-relay_control.png
 

Attachments

  • Relay Control.rar
    59.4 KB · Views: 3
  • relay_control.png
    relay_control.png
    27.7 KB · Views: 12
Last edited:
  • Like
Reactions: hirenn

    hirenn

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top