Looking for suggestions for a blinking led object or method
Don M
Posts: 1,652
In my latest project I'd like to utilize an led indicator (or maybe several) to indicate various modes or status of operation. I know how to blink an led in a repeat loop but how do I go about blinking an led (or leds) without having the repeat loop tied into the Main repeat loop? Do I need to have it run in its own cog and then pass parameters to it?
An example might be to indicate if an SD card is mounted and open. Or if data was being written to an SD card. One indication might be a solid on light whereas the writing mode might be a flashing mode. If there were an error maybe a predefined series of flashes to indicate the fault, etc....
Any suggestions or examples welcome.
Thanks.
Don
An example might be to indicate if an SD card is mounted and open. Or if data was being written to an SD card. One indication might be a solid on light whereas the writing mode might be a flashing mode. If there were an error maybe a predefined series of flashes to indicate the fault, etc....
Any suggestions or examples welcome.
Thanks.
Don
Comments
You could blink the LED using the NCO counter in PWM mode.
Once started the NCO runs independently until changed.
Note! Each cog has 2 of these.
Duane J
App Notes/AN001 Propeller P8X32A Counters
And "NCO" = "Numerically Controlled Oscillator".
A really cool effect is to put a slightly different frequency in the 2 counters and have both output on the same pin.
Now the LED will slowly fade on and off.
Duane J
My homework for this morning...
Thanks for your suggestion.
I did a Google search on the forum and came up with a MultiCogTwinkleDemo from Duane Degn, Rick Post and Kye. I ran that on the Quickstart board and while it is neat it's not quite what I was looking for. That's what gave me the initial idea that I maybe needed to run it (my method) in it's own cog.
I have an object that will flash any number of LEDs at any rate for as many times as you want but it does use a cog.
I think the object I just linked to is better than the "twinkle demo" one (though I don't remember what the twinkle one does).
You can find source code is in the Demo folder of the Propeller Tool install.
You can find the PE kit in the Propeller Tool Help menu.
It works pretty slick however I am wondering why I need the "repeat". Your initial comment- "Once started the NCO runs independently until changed" had me thinking that it would run without a repeat. Unless my program is wrong somehow. I don't understand.
@Duane Degn- That is exactly what I was looking for! Thanks for that.
Of course, you'll need to define a stack (16 longs is plenty) and create a variable that you will set (0 = off). Launch like this:
The code shown blinks the code every 2 seconds but is easy to adjust.
For my professional projects I tend to use two pins and a Red-Green LED with a bicolor driver (I wrote about this in my Nuts & Volts column). The bicolor driver allows me to do color coded single and dual-color blinking. It's very effective. That driver, of course, is written in PASM
Do you remember which issue / column in N & V? I'll have a look at that.
Edit: I found it. Column #1 July 2009...