Discussion in "8051 Discussion Forum" started by    DavesGarage    Nov 14, 2009.
Fri Dec 25 2009, 11:17 AM
#11
ya right...i read the description for the TCON register.it says TF flag Cleared by hardware when processor vectors to interrupt routine....so can we use just RET instead of RETI as flag gets cleared automatically??.....
Sat Dec 26 2009, 07:54 AM
#12
No.

When you vector to an interrupt service routine, the micro will automatically push critical registers onto the stack, including the PSW. It's a little more involved than just a jump, which does none of this.

When you execute a RET instruction, you just restore the PSW - You don't restore any of of the registers that were pushed onto the stack.

Executing the RETI instruction does this for you...

I suggest you read from the 8052 bible books about what happens during an interrupt, and what the differences are between RET and RETI.

Hope this helps,
 ammi_paranjpe like this.
Sat Dec 26 2009, 09:31 AM
#13
thanx dave for ur help......i'll surely read from d buk u mentioned to get ma concepts more cleared.....
Sun Dec 27 2009, 08:41 AM
#14
You are welcome
Sat Apr 09 2016, 02:57 AM
#15
Hi Forum Members,

I have question(s). I have to create 1 sec to 10 sec for Timer Interrupt and switch on eight relays .

while continuously monitoring Temperature , Voltage , Pressure . 10 Relays should ON or OFF between
1 sec to 10 sec as Set by the user accordingly, to maintain the Temperature , Voltage , Pressure .

The Problem is that the Program should not exhibits large delay .. 1 sec to 10 sec . Relays should ON or OFF independently while printing the data on LCD .

Will your logic work for me . I am working on PIC16F72


--
Kr



[ Edited Sat Apr 09 2016, 03:00 AM ]
Sat Apr 09 2016, 05:26 PM
#16
Unfortunately Dave has not been in for a while, so I will try to answer your question.
The basic idea of a timer causing an interrupt will work well for you.

It it was me... I would turn the relay on and set a count during the main loop.
Each relay has its own count.

In the interrupt .. once every few milliseconds, count down the relay count.
When it hits 0, turn off the relay.

The method works for any micro with a timer that can generate an interrupt,
which is any still in use.
 Karan123 like this.
Tue Apr 12 2016, 08:15 AM
#17
Thanks ExperimenterUK,


Let me update you. Please see below code. I have to create delay between 1 sec to 10 sec with simple loops ( while, for etc. ) and switch on/off 10 relays.

When code is reached at ControlVoltageRelay(); the system stops for 10sec for each relay.
Similar thing happen on other Control Functions . My Application don't want this . The System will behave like hang while processing relay function.

I need Voltage,Temp,Pressure keeping scrolling on LCD or any output device and Relay should on/off independently without exhibiting any the delay .

I know i have to use Timer Interrupts for that (may be similar is Dave said) . But don't know how .

Please send me on code template or basic overview if you can on any micro controller .

Thanks in advances
 

while(1)
{
ReadVolage() ;
ControlVoltageRelay();
delay();
Readtemp() ;
ControltempRelay();
delay();
ReadPressure() ;
ControlPressureRelay();
delay();
}
void ControlPressureRelay()
{ 
    if(Pressure < P_RANGE)
          RELAY1= ON ;
   Delay10SecondswithLoop() ;
    if(Pressure < P_RANGE)
          RELAY2= ON
Delay10SecondswithLoop() ;
   if(Pressure < P_RANGE)
          RELAY3= ON
Delay10SecondswithLoop() ;
    if(Pressure < P_RANGE)
          RELAY4= ON
Delay10SecondswithLoop() ;
///////////////////
    if(Pressure>
 P_RANGE)
          RELAY1= ON
Delay10SecondswithLoop() ;
   if(Pressure >
P_RANGE)
          RELAY2= ON
Delay10SecondswithLoop() ;
    if(Pressure >
 P_RANGE)
          RELAY3 = ON
Delay10SecondswithLoop() ;
    if(Pressure >
 P_RANGE)
          RELAY4 = ON
Delay10SecondswithLoop() ;
}
ControlVoltageRelay()
{
    if(Voltage < P_RANGE)
          RELAY5= ON
Delay5SecondswithLoop() ;
   if(Voltage < P_RANGE)
          RELAY6= ON
Delay5SecondswithLoop() ;
    if(Voltage < P_RANGE)
          RELAY7= ON
Delay5SecondswithLoop() ;
    if(Voltage < P_RANGE)
          RELAY8= ON
Delay5SecondswithLoop() ;
///////////////////
    if(Voltage >
 P_RANGE)
                RELAY8= ON
Delay3SecondswithLoop() ;
   if(Voltage >
P_RANGE)
          RELAY6= ON
Delay3SecondswithLoop() ;
    if(Voltage >
 P_RANGE)
          RELAY7= ON
Delay3SecondswithLoop() ;
    if(Voltage >
 P_RANGE)
          RELAY8 = ON
Delaywith3SecondswithLoop() ;
}
ControltempRelay()
{
         if(temperature < T_RANGE)
          RELAY5= ON
Delay3SecondswithLoop() ;
       if(temperature  < T_RANGE)
          RELAY6= ON
Delay3SecondswithLoop() ;
        if(temperature  >
 T_RANGE)
          RELAY5= ON
Delay3SecondswithLoop() ;
        if(temperature  >
 T_RANGE)
          RELAY6= ON
Delay3SecondswithLoop() ;
}

Tue Apr 12 2016, 05:18 PM
#18
Which compiler are you using ?
Wed Apr 13 2016, 01:20 AM
#19
Thanks,

MPLAB v8.83 and MPLAB XC8 V.21 . You can give demo on any complier .

--
Karan
Thu Apr 14 2016, 01:13 AM
#20
Hello

@ExperimenterUK Any Update from your side

--
Karan

Get Social

Information

Powered by e107 Forum System

Conversation

Mon Oct 21 2019, 08:46 AM
charmdatemru
cooking
Sun Oct 13 2019, 02:02 AM
Aline Hutchinson
Hey there,
ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
ExperimenterUK
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
BUSTER123
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.

Downloads

Comments

ilylily07
Tue Oct 15 2019, 04:32 PM
hientran123
Tue Oct 15 2019, 02:27 AM
Sat Oct 05 2019, 02:38 PM
zexalo
Thu Oct 03 2019, 09:53 AM
thanhle12345
Thu Oct 03 2019, 07:37 AM
ramon_vsc
Fri Sep 20 2019, 04:53 PM
youssoufba
Thu Sep 19 2019, 11:57 AM
Taiphan000
Tue Sep 17 2019, 04:21 AM

Online

Guests: 48, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38097
Newest member: ilylily07
Forum Activity
wimac Avatar
Posted By wimac
Mon Oct 21 2019, 09:18 AM
I’ve been following this thread and looking at the...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 03:09 PM
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 03:02 PM
sir, when i on display ,sometime 3rd display is no...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 02:53 PM
sir, when i on display ,sometime 3rd display is no...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 20 2019, 12:21 AM
Your code seems okay on my simulationTry my code o...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 20 2019, 12:21 AM
Your code seems okay on my simulationTry my code o...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sat Oct 19 2019, 07:13 PM
please find video attachment. 3rd & 4th displa...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sat Oct 19 2019, 07:05 PM
sir, 3rd and 4th dot matrix display flickering, ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Oct 18 2019, 09:18 PM
Hopefully you understand some of the program.Which...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Thu Oct 17 2019, 09:38 PM