Heartbeat LED


Closed Thread
Results 1 to 6 of 6

Thread: Heartbeat LED

  1. #1
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151

    Default Heartbeat LED

    I am asking for opinions on how others setup and use a LED to blink periodically to show the system is up and working.

    Usuallly I just use a counter in a loop and toggle the LED based on bits in the counter, however, that does not always work well when the program spins waiting on an input.

    I am thinking about setting up a timer and set the LED to the overflow?

    How do some of you guys do it?
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

  2. #2
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default A greatHeartbeat!

    Hey-
    I did a better search on this and the 'older' forum and located DT's ASM interrupt used for the heartbeat. No overhead and it works just great with inputs that wait on a keypad.
    It works great!

    Thanks Darrell!
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Well, having an LED beat to a timer overflow in an interrupt is not a heartbeat at all. It will not tell you if your code is hung or has malfunctioned. All it will tell you is that the interrupt system is functioning. Its a false assurance at best. Similar logic also applies to resetting the watchdog timer within an interrupt. Don't do it in the interrupt is what I can advise. You would want your code to restart if ever it gets hung. You do not want it to falsely clear the watchdog timer and assure you that all is well when it's obviously not.

    The best place for such code is in the mainline where your program spends most of its time. If there are other sections in code where you wait for input, it may be a good idea to replicate the code there too. I use a technique where the timer interrupt increments a byte sized counter. The D7 bit of the counter is copied to the Hearbeat Led. If it stops, it means either the timer interrupt has stopped(malfunction) or the program is hung(malfunction). The first one could mean you have shut off the timer or its interrupt. The second one definitely is a malfunction.

  4. #4
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Thanks!

    Your approach is clearly better for the reasons mentioned.

    I will foll around with this notion and see what happens.

    Regards.
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

  5. #5
    Join Date
    Oct 2005
    Location
    Pinckney, Michigan
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    I like to use a different approach.

    I have a one-shot connected to a flashing LED. If the one-shot is allowed to expire the led will flash. If your software "tickles" the one-shot every pass through the main loop, the one-shot remains re-triggered, and the LED remains off.

    This way your LED flashes only if your program stops working.

  6. #6
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Interesting

    That approach is interesting, and it would solve the internal issues of just blindly working at the code level.

    I could use a comparitor to check for the voltage level, and use it with the one-shot for a 'fault' indication as well.......

    Thanks for the info. This shows me there really are many different ways to skin a heartbeat <grin>.
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

Similar Threads

  1. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  2. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  3. For next loop using: Led var Byte
    By quester in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th March 2008, 10:16
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. can't even flash an LED
    By bruno333 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2005, 13:27

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts