CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Door Access Application?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chingB



Joined: 29 Dec 2003
Posts: 81

View user's profile Send private message

Door Access Application?
PostPosted: Tue Mar 09, 2004 4:47 pm     Reply with quote

Hi,

I have access application and I put a micro-switch such that when the door is open it will closed. How can I monitor the door if it is open for 20seconds it sound an alarm?

Would it be possible to use interrupt?


Thanx
asjad



Joined: 09 Mar 2004
Posts: 52
Location: Greater Manchester - UK

View user's profile Send private message

Door switch
PostPosted: Tue Mar 09, 2004 4:53 pm     Reply with quote

You could use an external interrupt, which could start timer 0.

After say 10 seconds had elaspsed on the timer0. you could sound an alarm

Hope this helps!!
_________________
Best Regards
chingB



Joined: 29 Dec 2003
Posts: 81

View user's profile Send private message

Re: Door switch
PostPosted: Tue Mar 09, 2004 5:10 pm     Reply with quote

asjad wrote:
You could use an external interrupt, which could start timer 0.

After say 10 seconds had elaspsed on the timer0. you could sound an alarm

Hope this helps!!


Is this algorithm will do the job or maybe share some tips and suggestions to improve this code.

Code:

#int_ext2
ext2_isr(){
   flag=1;
   doortmr=0;
   int2if=0;
}

main(){

   intedg2=1;
   int2if=0;
   enable_interrupts(int_ext2);
   enbale_interrupts(global);

   while(1){
      if (bit_test(PORTA,2) && (doortmr>=20))
         sound_alarm(ON);
      if (!bit_test(PORTA,2) && flag){
         sound_alarm(OFF); flag=0;
      }
   }
}


Thank u.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group