This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

using external interrupt

Hi
I am using ultra sonic sensors to detect any obstacle and i have connected their response to extenal interrupt0 of 8051. The problem is the sensors are very sensitive they trigger the interrupt even if there is an object very far.
I want that external interrupt should trigger if it gets contineous pulse from sensors for 1 second. (I think it is called debounce operation). Is their any way i can do this.
Thanks for your help

Parents
  • In my opinion you need to re-think your approach. If the sensor sees an object too far away, it will still see the object after 1 sec delay. You might want to consider a hardware approach external to the MCU. It can be as simple as a RC filter with a variable resistor and capacitor.
    Also, some of the 8051 family have built-in camparators and DACs so you can set the compare threshold and feed the comparator output back into the interrupt input. With the DAC, you can scale the input sensitivity.
    However, if your input is really just noise and not a true object sense, then the debounce you suggested might be a better approch.
    Have you put an oscillscope on the sensor out and determined if the sense level is a true sensor detection or noise.?
    Bradford

Reply
  • In my opinion you need to re-think your approach. If the sensor sees an object too far away, it will still see the object after 1 sec delay. You might want to consider a hardware approach external to the MCU. It can be as simple as a RC filter with a variable resistor and capacitor.
    Also, some of the 8051 family have built-in camparators and DACs so you can set the compare threshold and feed the comparator output back into the interrupt input. With the DAC, you can scale the input sensitivity.
    However, if your input is really just noise and not a true object sense, then the debounce you suggested might be a better approch.
    Have you put an oscillscope on the sensor out and determined if the sense level is a true sensor detection or noise.?
    Bradford

Children
  • the commonh method is to start a timer at the same time as the output pulse. when the input pulse is detected stop the timer: time * k = distance.

    Erik

  • Yes you are right my input is normally just noise(on off on off i mean it is falsely triggered) but when an object really comes in the way then they trigger for some time(off for some time(active low). I want to feed that input to external interrupt pin that stays active for some time.
    so i want to program controller in such a way that if it sees an input active for some time at external interrupt then it should perform desired action. hope you understand me.

  • You could use a timer to generate a regular interrupt at a suitable frequency (say 100Hz) and poll the input from your sensor in the timer interrupt service routine. If the input is active for 100 consecutive polls you would be pretty sure you were seeing a real object rather than noise.

  • I agree that the issue here seems to be more fundamental than the microcontroller. Have you ever read about pulsed(range finding) radar or sonar? A lot of work is done to remove clutter from the return signal. The detection is synchronous and gating the transmitter and then later the receiver allows range discrimination based on gate delay time. If you're using a CW transmitter( more appropriate for doppler radar) and the receiver is continuously active it means that at any moment you are looking at a signal which contains information from a continuum of ranges.

  • THanks for your reply
    i have solved my problem with this timer technique.