Author Topic: LED to indicate Arduino is running  (Read 8045 times)

0 Members and 1 Guest are viewing this topic.

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
LED to indicate Arduino is running
« on: October 12, 2014, 11:05:26 pm »
From time to time I'll have an Arduino lock-up.  In the past if I wanted to check for a lock-up I setup a heartbeat LED which will blink when the Arduino is running.  If the program hangs, the LED will stop blinking.  I have a project now where I want the LED to stay on continuously if the sketch is running and turn off if the Arduino locks-up.  I was thinking I could still have a heartbeat output, but instead of going directly into an LED, it would go into a little circuit which controls the LED. The circuit would look for the heartbeat and if it didn't see a heartbeat, the LED would turn off. I don't know how to build a circuit that would do this. Any suggestions?
 

Offline suicidaleggroll

  • Super Contributor
  • ***
  • Posts: 1453
  • Country: us
Re: LED to indicate Arduino is running
« Reply #1 on: October 12, 2014, 11:15:19 pm »
How have you controlled the heartbeat in the past?  What if the Arduino locks up while the output is high instead of low?  Doesn't Arduino have a watchdog timer?

I've never used an Arduino, is locking up really that common?  It seems like a fundamental problem that should be fixed, rather than jumping through hoops trying to implement some kind of signal to tell you when it's screwing up.  Maybe if it's that big of an issue you should use a different (aka: more reliable) platform?

I can think of a lot of ways to accomplish this, but it all seems like a roundabout way to notify the user of a problem that should never happen in the first place.
« Last Edit: October 12, 2014, 11:17:35 pm by suicidaleggroll »
 

Offline ludzinc

  • Supporter
  • ****
  • Posts: 506
  • Country: au
    • My Misadventures In Engineering
Re: LED to indicate Arduino is running
« Reply #2 on: October 12, 2014, 11:17:33 pm »
Just use the output to retrigger a monostable multivibrator.

Typically a 555 is used for this, amongst other options.

See here:  http://www.eleinmec.com/article.asp?4
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: LED to indicate Arduino is running
« Reply #3 on: October 12, 2014, 11:22:48 pm »
How have you controlled the heartbeat in the past?  What if the Arduino locks up while the output is high instead of low?  Doesn't Arduino have a watchdog timer?

I've never used an Arduino, is locking up really that common?  It seems like a fundamental problem that should be fixed, rather than jumping through hoops trying to implement some kind of signal to tell you when it's screwing up.  Maybe if it's that big of an issue you should use a different (aka: more reliable) platform?

If the LED stops blinking I don't care if the output is high or low, I'll see that it stops blinking.  It's doesn't happen much, I think the Arduino is pretty reliable.  I've seen it generally happen with some sort of communication problem, like with Ethernet or I2C, and also with a memory problem.  Like a string was too long or it ran out of memory. 

Watchdog timer works on some Arduinos and not others - I think it depends on the bootloader.  One problem with watchdog is it kind-of hides the problem.  The Arduino could be hanging and rebooting and I wouldn't know it.




 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: LED to indicate Arduino is running
« Reply #4 on: October 12, 2014, 11:24:37 pm »
Just use the output to retrigger a monostable multivibrator.

Typically a 555 is used for this, amongst other options.

See here:  http://www.eleinmec.com/article.asp?4

Thanks, I'll check that out.  I figured a 555 would probably be involved one way or another.
 

Offline suicidaleggroll

  • Super Contributor
  • ***
  • Posts: 1453
  • Country: us
Re: LED to indicate Arduino is running
« Reply #5 on: October 12, 2014, 11:27:32 pm »
Just use the output to retrigger a monostable multivibrator.

Typically a 555 is used for this, amongst other options.

See here:  http://www.eleinmec.com/article.asp?4

Thanks, I'll check that out.  I figured a 555 would probably be involved one way or another.

Remember the comment I made about it failing high or low.  You don't want a solution that counts in one state and resets in another, you need a solution that counts in steady state (high or low) and resets on transitions.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6202
  • Country: us
Re: LED to indicate Arduino is running
« Reply #6 on: October 12, 2014, 11:30:16 pm »
You want a ''retrigerable" and  "edge triggered" monostable, like this one (there are many others)

http://www.nxp.com/documents/data_sheet/74LVC1G123.pdf
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: LED to indicate Arduino is running
« Reply #7 on: October 13, 2014, 01:15:09 am »
Thanks for all the help.  I just built this circuit with a 555 timer and it looks like it should do what I need.
http://www.doctronics.co.uk/555.htm#retriggering
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: LED to indicate Arduino is running
« Reply #8 on: October 13, 2014, 02:32:12 am »
...turn off if the Arduino locks-up.
Isn't that a bit indeterminate?  If it locks up - putting a LED toggle conveniently in the (buggy) lock-up code may be harder than it appears (why not fix the code?) !

Or put your LED toggle somewhere within the main loop(), perhaps with a divider to make it 'visible'... say 5Hz or whatever.  Then you'll see when the loop has become 'locked-up'.  Perhaps even using an interrupt & counter to restart or break out of your code (a-la watchdog style).

Even better, you can update a global variable at various places in your code, and oly when the crash timer fires - read that variable to see the most recent place the variable was updated (i.e. most recent updated value from your code).
Don't ask a question if you aren't willing to listen to the answer.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6202
  • Country: us
Re: LED to indicate Arduino is running
« Reply #9 on: October 13, 2014, 04:56:15 am »
Thanks for all the help.  I just built this circuit with a 555 timer and it looks like it should do what I need.
http://www.doctronics.co.uk/555.htm#retriggering

If your MCU will get stuck in the trigger state the LED will stay on.  This is why you want an edge triggered monostable.
 

Offline kolbep

  • Frequent Contributor
  • **
  • Posts: 598
  • Country: za
    • ShoutingElectronics.com
Re: LED to indicate Arduino is running
« Reply #10 on: October 13, 2014, 05:54:57 am »
Enable the WDT, and possibly BOR,
then have code at the start of the program, that if, when it starts up, it detects that it was a WDT reset or BOR (anything really except for normal powerup), if it does see the flag, then light up a LED to let you know it locked and was restarted.

Although, I am more used to PICS, so I do not know what functionality like that the Arduino has.
====================================
www.ShoutingElectronics.com Don't just talk about Electronics, SHOUT ABOUT IT! Electronics Blog Site and Youtube Channel
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: LED to indicate Arduino is running
« Reply #11 on: October 13, 2014, 11:54:29 am »
Thanks for all the help.  I just built this circuit with a 555 timer and it looks like it should do what I need.
http://www.doctronics.co.uk/555.htm#retriggering

If your MCU will get stuck in the trigger state the LED will stay on.  This is why you want an edge triggered monostable.

Good point.  Thanks.
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: LED to indicate Arduino is running
« Reply #12 on: October 13, 2014, 12:06:54 pm »
Enable the WDT, and possibly BOR,
then have code at the start of the program, that if, when it starts up, it detects that it was a WDT reset or BOR (anything really except for normal powerup), if it does see the flag, then light up a LED to let you know it locked and was restarted.

Although, I am more used to PICS, so I do not know what functionality like that the Arduino has.

What's BOR?  I'm not sure if there's a way for the Arduino to know it restarted from a timeout; I'll check for this on the Arduino forum, maybe there's a way.

BTW - I haven't event done the programming for this project yet, so I it may never hang-up.  I'm just trying to anticipate problems.  It's my first project using RS-485 communication (Arduino is receiving only, no sending). 
 
 

Offline ozwolf

  • Regular Contributor
  • *
  • Posts: 166
  • Country: au
Re: LED to indicate Arduino is running
« Reply #13 on: October 13, 2014, 12:15:43 pm »
Why not try one of these from Freetronics?

http://www.freetronics.com/products/watchdog-timer-module#.VDvBDqEcSt8

Documentation says that the module will actually blip the reset line if Arduino locks up.
I reject your reality and substitute my own.
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: LED to indicate Arduino is running
« Reply #14 on: October 13, 2014, 12:22:05 pm »
Why not try one of these from Freetronics?

http://www.freetronics.com/products/watchdog-timer-module#.VDvBDqEcSt8

Documentation says that the module will actually blip the reset line if Arduino locks up.

That would work.  I see in the schematic it uses a 555.  Is this an edge-triggered monostable circuit or something different? 
 

Online Kjelt

  • Super Contributor
  • ***
  • Posts: 6485
  • Country: nl
Re: LED to indicate Arduino is running
« Reply #15 on: October 13, 2014, 12:54:06 pm »
Try to find out where the uC hangs, if it is for instance I2C than it could be that one of the I2C chips "hangs" the bus. In that case you can try to reset that chip or clear the bus by transmitting some I2C CLK signals. If that still does not help you should reboot the whole pcb. In any case it is better to first try to recover from an error and determine exactly what causes the error.
 

Offline ozwolf

  • Regular Contributor
  • *
  • Posts: 166
  • Country: au
Re: LED to indicate Arduino is running
« Reply #16 on: October 13, 2014, 12:57:45 pm »
Why not try one of these from Freetronics?

http://www.freetronics.com/products/watchdog-timer-module#.VDvBDqEcSt8

Documentation says that the module will actually blip the reset line if Arduino locks up.

That would work.  I see in the schematic it uses a 555.  Is this an edge-triggered monostable circuit or something different?

Have a read of the Quickstart Guide and you will note that the module requires your code (sample code in Guide) to blip an I/O pin (connected to IN) at intervals < default 5 mins or optional 1 minute.  So all you're doing is resetting the 555 module before it has a chance to time out and fire the OUT which is connected to your RESET pin on microcontroller.

I haven't used this module myself, as I'm happy with using the Timer ISR routine on the Arduino to flash the LED on pin D13 at 1/2 second intervals.  My logic being that if the Arduino is locked up the Timer ISR will fail as well.  However, my method will not RESET automatically like the Watchdog Timer Module does.
I reject your reality and substitute my own.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: LED to indicate Arduino is running
« Reply #17 on: October 13, 2014, 06:36:37 pm »
...logic being that if the Arduino is locked up the Timer ISR will fail as well...
Not strictly true. (Sorry Oz!)
If your code is in a 'deadly embrace' loop - the ISR will continue to fire - with the LED blinking happily while the code does nothing...!

e.g: http://www.pcmag.com/encyclopedia/term/41017/deadly-embrace
Don't ask a question if you aren't willing to listen to the answer.
 

Offline firewalker

  • Super Contributor
  • ***
  • Posts: 2450
  • Country: gr
Re: LED to indicate Arduino is running
« Reply #18 on: October 13, 2014, 08:00:19 pm »
Why don't you use the watchdog included to the AVR chip? If there is a lockup it will reset the chip, and will flip a register bit. Using that bit you can later hard reset the chip (if needed).

Alexander.
Become a realist, stay a dreamer.

 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: LED to indicate Arduino is running
« Reply #19 on: October 13, 2014, 08:11:50 pm »
Why don't you use the watchdog included to the AVR chip? If there is a lockup it will reset the chip, and will flip a register bit. Using that bit you can later hard reset the chip (if needed).

Alexander.
I just found out about the register bit the watch dog timer resets.  I might use a WDT instead.
 

Offline kolbep

  • Frequent Contributor
  • **
  • Posts: 598
  • Country: za
    • ShoutingElectronics.com
Re: LED to indicate Arduino is running
« Reply #20 on: October 13, 2014, 08:27:46 pm »
BOR = brown out reset.
the micro ia held in reset until the supply voltage exceeds a settable limit.

That way if the battery goes flat, or the powersupply gives a low voltage, then the Micro does not behave eratically.
====================================
www.ShoutingElectronics.com Don't just talk about Electronics, SHOUT ABOUT IT! Electronics Blog Site and Youtube Channel
 

Offline SevenLeggedSheep

  • Newbie
  • Posts: 5
Re: LED to indicate Arduino is running
« Reply #21 on: October 14, 2014, 04:27:14 am »
Feed your "running" pulse into C48. Take the output (Arduino OK) from R122.

Change R111 and C47 to your requirements, this circuit is designed to provide lockup indication for a PIC very quickly.

It's only a simple enhancement to a very standard 555 heartbeat circuit, and it works reliably.

HTH
 

Offline ozwolf

  • Regular Contributor
  • *
  • Posts: 166
  • Country: au
Re: LED to indicate Arduino is running
« Reply #22 on: October 14, 2014, 10:46:10 am »
...logic being that if the Arduino is locked up the Timer ISR will fail as well...
Not strictly true. (Sorry Oz!)
If your code is in a 'deadly embrace' loop - the ISR will continue to fire - with the LED blinking happily while the code does nothing...!

e.g: http://www.pcmag.com/encyclopedia/term/41017/deadly-embrace

That's why I like this forum.  Always an opportunity to learn.  You're right.  Searching "arduino watchdog timer" on Google, throws up quite a few good examples and solutions.  Didn't even know there was an on-board WDT.
I reject your reality and substitute my own.
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 10020
  • Country: nz
Re: LED to indicate Arduino is running
« Reply #23 on: October 14, 2014, 10:57:45 am »
From time to time I'll have an Arduino lock-up.  In the past if I wanted to check for a lock-up I setup a heartbeat LED which will blink when the Arduino is running.  If the program hangs, the LED will stop blinking.  I have a project now where I want the LED to stay on continuously if the sketch is running and turn off if the Arduino locks-up.

i have a simple idea, no need for a 555.
Generate some high frequency pulses/AC with the mcu (ideally in software and not using a hw timer). Coupled that signal to a LED through an appropriately sized capacitor.

If the mcu is running current will flow through the cap and light the LED up, if the mcu stops the switching stops and the cap will blocks DC so LED=off

You can use Xc = 1/(2 pi F C)  to calculate the reactance in ohms of a cap at a set frequency.
« Last Edit: October 14, 2014, 11:03:26 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Online richard.cs

  • Super Contributor
  • ***
  • Posts: 1192
  • Country: gb
  • Electronics engineer from Southampton, UK.
    • Random stuff I've built (mostly non-electronic and fairly dated).
Re: LED to indicate Arduino is running
« Reply #24 on: October 14, 2014, 11:14:45 am »
i have a simple idea, no need for a 555.
Generate some high frequency pulses/AC with the mcu (ideally in software and not using a hw timer). Coupled that signal to a LED through an appropriately sized capacitor.

If the mcu is running current will flow through the cap and light the LED up, if the mcu stops the switching stops and the cap will blocks DC so LED=off

You can use Xc = 1/(2 pi F C)  to calculate the reactance in ohms of a cap at a set frequency.

^ This.

You'll need a diode in antiparallel with the LED or you'll just pump the anode down negative and it'll turn off. Given you're hitting it with squarewaves I would still include some series resistance with the LED, maybe make that the dominant thing limiting the current and make the capacitor reactance small in comparison. If you wanted a low frequency you could make the capacitor large and then have a second capacitor that holds the LED on during the off cycle.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf