HeartBeat Monitor (so you can tell if the Propeller is still alive)
Genetix
Posts: 1,754
in Propeller 1
I was trying to run a program earlier today and it did nothing so I wasn't even sure if my Propeller was alive or dead.
At work one of the controller boards has several microcontrollers on it, and aptly named 'Heartbeat Monitors' are attached to each.
It's just an LED with a current-limiting resistors attached to one of the I/O pins.
The Propeller Activity boards and Flip modules have LEDs on P26 and P27 that could be used for this.
I could waste a Cog running a Blinker program, but maybe someone has a more elegant solution.
I am using my QuickStart at the moment, but I also have an Activity and Demo board.
Comments
Try running a simple LED blink program at RCFAST clock. If that works your PLL may have been damaged.
Publison,
I verified that my QuickStart works with JonnyMac's QuickStart Demo - works perfectly!
This program I was testing was supposed to send messages to the screen but I saw absolutely nothing.
I tried programming the Propeller and reseting it and still nothing.
A HeartBeat Monitor would at least tell me that my Propeller programmed and is running a program.
It's something that I thought would be usefull to add to Propeller programs as a sanity check; It's my program not my Propeller.
If my program doesn't do what it's supposed to then I know it's not the Propeller.
I could even change the blink rate each time I make changes to the program.
Time to post your program so we can look at it.
I have a Quickstart on hand to test.
What about using a counter ?
NCO mode could work well- check the example on page 4 of the Counters AppNote : https://www.parallax.com/package/an001-propeller-p8x32a-counters/
Set APIN to the LED pin on your board.
Publison,
I finally got it to work.
Stupid me forgot to call Main from my starting Init method..... DOH!
VonSzarvas,
The program I was playing with used both counters, but not at the same time so I could do that.
I was curious to try that code snippet, so grabbed a FLiP module. I use the LEDs quite a bit for diagnostics, but never thought to use a counter. Never really had a need, but it's a neat idea and I'm sure I'll use this the next time I write a driver for something. Setting the frqa rate is so simple!
I'll drop what I tried here for future reference!!
Cool Beans!
VonSzarvas,
I don't who came up with that scheme but it seemed like a clever idea so I thought I would put it to use.
Seeing as both the Flip and PAB has 2 LEDs, you could be clever and make it pattern similar to a real heartbeat.
Atdiy (is that correct?) would know how it should look.
VonSzarvas,
How did you come up with that Rate of 27?
It seems to blink slower than once a second and I would like to be able to change it as I make program changes.
TOGGLE_RATE = 27 ' (4,294,967,296 / clkfreq) / 2
It won't be super accurate as that value is rounded to the nearest integer, and you will see the cumulative period error (rounding error) increase over time. I don't know how to correct for that yet, but I can try to explain the math....
The counter mode toggles each time the counter overflows.
The counter max is a 32-bit integer. So we divide that maximum integer by our clock frequency to figure out how many clock ticks are needed to overflow the 32-bit counter (at the code clock frequency).
The max counter at 32-bit is 2^32 (= 4,294,967,296)
Our clock frequency "clqfreq" depends, but in my code I was using 80 MHz (= 80,000,000)
We know that our clqfreq equates to a 1 second period, and I remember it like this :
clqfreq is the total number of clock ticks in 1 second, and the period of 1 clock tick of the Propeller is 12.5ns
80,000,000 clock ticks * 12.5ns = 1,000,000,000ns (= 1 second)
So the counter math is :
4,294,967,296 / 80,000,000 = 53.6870912
Which means at 80 MHz clock freq, the counter will overflow after 53.6870912 lots of 80 MHz clock ticks.
We divide that by 2, because we are toggling the LED in two states (on/off) within the 1 second period :
53.6870912 / 2 = 26.8435456
And then I rounded that result up to 27.
Edit: Perhaps that formula in the code comment needs brackets... just adding them now!