1

I am making a moving robot that will be autonomous in many respects. However if something goes wrong I want to be able to use a remote to push a button and it stop in its tracks no matter what function its in. My understanding is that interrupts can do that. The official site I did not find to be helpful. Any ideas? Or if the scheduler library would be of use.

1

An interrupt can not always stop the code, although that is almost always the case. Certainly having an interrupt based kill switch would be better than a "regular code" polled one, which would still be better than nothing. If possible I would feel safest with a cut-power-to-the-whole-thing style safety switch.

Many functions that have sensitive timing constrains disable interrupts while they are active. It is rare for any of these to take a noticable amount of time, but it is possible that a bug in an interrupt dissabled function or another interrupt function could cause it to block and in that case your stop switch wouldn't work. rare, but possible.

I suppose you could turn on the chip watchdog timer, have a regular timer based interrupt reset the watchdog timer at a certain interval, and have your interrupt safety switch enabled. Then if interrupts ever stopped firing for too long the chip would reset itself. Checkout AVR132: Using the Enhanced Watchdog Timer. I've never used the watchdog myself, but it exists for a reason.

I don't have enough experience with a scheduler system to know if they would be helpful.

| improve this answer | |
  • 1
    Is there an overview of arduino functions that disable interrupts for a (short) period? Anyway, watchdog-timer would be the most professional way to handle this. Though you should try to handle the it and only reset when needed. Then make sure the robot won't move after a reset. And that it's easy to see when it has resetted (so you know it was due the WDT). I would reset the watch-dog timer in software though, because if your main code dead-locks, the timer interrupts might still work and reset the WDT. But an interrupt will do well generally. Don't use too much code that disables interrupts? – Paul Apr 17 '15 at 12:36
  • A clear overview of intterupts was what I was looking for although I appreciate advice given. – NULL Apr 17 '15 at 18:31
0

If you are using an arduino uno, pin 2 and 3 are the hardware interrupt pins. You may send rising , falling, high or low signals to these pins using a Bluetooth module (for eg). Say for eg when you press the remote switch, Bluetooth gets a low signal and triggers an interrupt. If the output of Bluetooth is connected to pin 2, then in the setup you have to declare

attachInterrupt(0, stoprobo, LOW);  

And in the function stoprobo, you can write the code to stop your robot.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.