Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/27/10 14:17
Modified:
  01/27/10 14:29

Read: times


 
#172756 - use of interrupts
Responding to: ???'s previous message
no this would not be a problem at all. The main program code is reading information from a CAN bus, and displaying this information on a screen, using no interrupts, so i see no reason for not using an external interrupt pin

5-6ms is an eternity? This is what I thought, perhaps my oscilloscope trace is incorrect. The code I was using was to simply test the hardware I had just interfaced with. the code I was using was something along the lines of: (i am excluding a lot of congiuration etc here, but as i said, the program was working fine when physically simulating the movement of the actuator slowly)
within main loop:
sbit LED1 = P3^4;    //LED on board
sbit SW1 = P1^7;     //Switch to begin the movement of actuator
sbit FValve = P3^5;  //Valve opened to begin movement of the actuator via CO2
sbit FSensor = P1^6; //Sensor at position actuator should not move past

if (SW1==0) // has been pressed
{
  while (FSensor==1) //FSensor is the sensor at the position 
                     //i want to stop the actuator moving past
  {
  LED1=1;            //turn on LED
  FValve=0;          //turn on valve
  } //end while

} // end if

else
{
LED1=0;              //turn off LED
FValve=1;            //turn off Valve
}


 


Hang on, by writing this post I have figured out why it does not appear to read the sensor. They do say, explain it to the teddy. (Sorry I have used you as a teddy haha)

I think its because the switched is still depressed. I did not think about this when excited by the working interfacing electronics and deciding to just plug the micro in and give it a try!

A new question:
what is the best way in code, to run the "movement" part of the code (i.e open valve, close valve when sensor activated), and to not rerun this code until the button is released. Would it be to set a flag bit that is only cleared once the button released, and only call the code to open and close the valve, if the button is being pressed and the flag bit clear.

OR would you reccomend calling the code via an edge triggered interrupt (with correct hardware debouncing?)

Cheers for all the replies, regards, Joel

List of 10 messages in thread
TopicAuthorDate
Sensor Problems            01/01/70 00:00      
   milliseconds?            01/01/70 00:00      
      I wonder too ...            01/01/70 00:00      
         use of interrupts            01/01/70 00:00      
            Remember state            01/01/70 00:00      
      To (almost) quote Star Trek:            01/01/70 00:00      
         Counter            01/01/70 00:00      
   re-think code            01/01/70 00:00      
   Weeelll if you have to            01/01/70 00:00      
      misnamed device            01/01/70 00:00      

Back to Subject List