Fire protection system & interrupt

Thread Starter

aspirea5745

Joined Apr 17, 2019
99
In the code, system is doing so many tasks such as controlling house lights, running the motor, monitoring temperature, controlling AC ans doing number of task's

C:
 main(void)

{
     /* initialize all devices */
      initialize ();
 
     /*routine to Control House Light */
      Control_House_Light();
   
     /*routine to run Motor */
          Motor_Run ();
 
     /* routine to monitor temperature */
      monitor_temperature();
   
     /* and so many task */
}

  /*System is required to be switched off all devices when fire alarm is activated */
  /* call the interrupt service routine if fire detected */

interrupt
{
    /* When fire sensor is activate switched off all devices */
     switch_off_Devices ();
    Turn_On _Buzzer ();
}
Do you think I really need interrupt to switch off all devices or I should write code in side the main function ?
 

MrChips

Joined Oct 2, 2009
30,801
Any program can run entirely in the main( ) loop without the need for interrupts.
The advantage of using interrupts is priority processing and response time.

If your main program is in a wait loop or executing a time consuming process it may take some time to respond to an alarm condition. With the use of interrupts the alarm condition takes priority and is serviced with minimum delay.
 

Thread Starter

aspirea5745

Joined Apr 17, 2019
99
Any program can run entirely in the main( ) loop without the need for interrupts.
The advantage of using interrupts is priority processing and response time.
Nothing important then the safety so My first priority would be safety.
It seems I am correct because I am doing high priority task in interrupt service routine

I think I can set another interrupt to monitor locker get lock continuously. if it's open more then 5 minutes , activate siren
 

Thread Starter

aspirea5745

Joined Apr 17, 2019
99
Timer interrupt I am telling you what I understand by the timer interrupt

For example When it comes to security checkpoints at airports. Passengers bag move one by one on conveyor to check surgical metal ... bags are screened by metal detectors and or scanners.

It may be big problem as point of security if metal detector fails to check surgical metal due to some reason

System has to do two tasks
1. Detect surgical metal
2. check metal detector continuously it's working or not

I think second task is my first priority I would set timer interrupt for 1 second to check metal detector is working or not

Do you really think timer interrupt required for second situations ?

C:
  Metal detector ()
   {
       if ( surgical metal detected)
         {
             ring the buzzer);
         }
        
       else
        {
            (pass the beg in collection bin );
        }
      
  void main (void)

  {
      Metal detector ();
      count begs ();
    
      NTask ();
  }   
    check metal detector at every second wather it's working or not
    timer interrupt ()
    {
        if (Ouput of metal detector is high )
          
          ( it's okay metal detector is working );
      
        else
            (alert to secuirty  :metal detector is not working )
    }
 

MrChips

Joined Oct 2, 2009
30,801
One goal of computer systems is to perform certain tasks in a timely fashion.
The question becomes, "What is the meaning of timely?"
Computer code can execute in microseconds or sub-microseconds. If the program loop can complete all processes in a specified time frame, x milliseconds, seconds, minutes, etc. then there is not need for interrupts.

Therefore, if your maximum allowable response time is, say 100ms for example, then most computer systems today can meet that specification without the need for interrupts.
 

Thread Starter

aspirea5745

Joined Apr 17, 2019
99
If the program loop can complete all processes in a specified time frame, x milliseconds, seconds, minutes, etc. then there is not need for interrupts.
I gave you two examples of interrupts. first for hardware interrupt and second for timer interrupt

You explained interrupts use and when interrupt could be useful. What is your opinion. Do you really think I have used interrupt correctly in my example ?
 

michael8

Joined Jan 11, 2015
414
Watch out.. Suppose your main loop is in progress of turning something on, it's decided to but
hasn't yet turned it on. Now the fire interrupt hits and the interrupt routine turns everything off.
On the return from interrupt your main routine will continue running and turn that something
on....
 

Thread Starter

aspirea5745

Joined Apr 17, 2019
99
@MrChips and @michael8 Both of you are ignoring my example. You explained interrupts use and when interrupt could be useful.

I gave two examples for hardware and timer interrupt and I wanted you to check and to tell me whether it is right or wrong for interrupt. I am asking because it possible I am be wrong or may be missing something.

If I am wrong then will you give your own example for hardware and software interrupt
 
ISRs nned to respond to the interrupt and in our case for the most part schedule a priority and a response to be done later ter the ISR exits.

lets say
Fire sensor
panic Push button
Turn of local alarm after 5 minutes
Exit delay start
Exit delay stop

panic probably has first priority in that mess.
If you should increment every priority 0 even and decrement it when serviced, you have a way inside your normal loop to continue servicing the high priority events. Maybe use different stacks and stack pointers for each of the priorities.
 
Top