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

ExperimenterUK
Thu Mar 14 2019, 08:44 PM
We don't send code,but you can ask for help in the 8051 forum
Thu Mar 14 2019, 11:00 AM
Jui Sanjay Kapare
Hello sir, I want code of interfacing DS18B20 with 8051.plz send the code as early as possible
ExperimenterUK
Mon Jan 07 2019, 03:31 AM
@REVOCATUS please post in the AVR forum
Mon Dec 24 2018, 09:25 AM
REVOCATUS MATEMU
sorry I mean referee boards for player substitution
Mon Dec 24 2018, 09:24 AM
REVOCATUS MATEMU
hi am.looking how to build referee by using Atmega 328 and its codes
Sat Dec 15 2018, 01:45 PM
Arslan ayoub
Hii ,, can I get the simulation of numeric keypad lock on proteus
ExperimenterUK
Mon Dec 03 2018, 05:17 PM
Please post questions in the forum. The chat box is for chat
Mon Dec 03 2018, 06:43 AM
help!me!
help! I don't understand busy flag!
Sun Dec 02 2018, 08:01 PM
ile
hello
Mon Nov 12 2018, 05:58 AM
Pavan_user
i have seen your replica of I2C programming using AT89C51 but i am unable to understand the "ack_bit" variable usage ...looks like it is always 1...can you elaborate how acknowledgment is working....

Downloads

Comments

tutu10
Tue Mar 12 2019, 07:11 AM
Raj243
Fri Mar 08 2019, 02:08 AM
bharatsb
Thu Mar 07 2019, 04:34 PM
Yass7
Thu Mar 07 2019, 03:55 PM
mashabed
Mon Mar 04 2019, 11:08 PM
AccelMotion
Tue Feb 26 2019, 06:06 PM
turbovps
Mon Feb 25 2019, 06:26 AM
the_Doker
Thu Feb 14 2019, 02:21 PM

Online

Guests: 37, Members: 0 ...

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

Members: 38052
Newest member: tutu10
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Mar 22 2019, 09:10 PM
Using the external interrupt on pin B0 is the best...
Ansh12 Avatar
Posted By Ansh12
Fri Mar 22 2019, 03:45 PM
I have pic16f877a and MPLABX8 and I want to count ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Mar 13 2019, 02:32 AM
HiI looked at" Atmel AVR042: AVR Design Considera...
tutu10 Avatar
Posted By tutu10
Tue Mar 12 2019, 07:13 AM
Hi...My firmware upgradable code lock seems to be ...
Yass7 Avatar
Posted By Yass7
Sat Mar 09 2019, 12:52 AM
It's exactly that ! it's my teacher who asked me t...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Mar 09 2019, 12:27 AM
As I understand it, you want to use a P89LPC952 /...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Mar 09 2019, 12:21 AM
After you get the string what do you want to do wi...
bharatsb Avatar
Posted By bharatsb
Thu Mar 07 2019, 04:40 PM
help me to write code for 8051 to receive string ...
Yass7 Avatar
Posted By Yass7
Thu Mar 07 2019, 03:59 PM
Hello everyone,here I made a 3-axis CNC with 3 ste...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Jan 26 2019, 07:19 PM
Yes that helps a lot.At first sight I can't see th...