LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Blink LED N times

Oh, boy, another chance to teach!  Call me "Socrates" (not Ishmael) -- I'm going to ask questions.

 

But first -- have you been around the Forums enough (i.e. have you read other posts from beginners such as yourself) and seen the pleas from people posting Helpful Responses to not use Frames and Sequence structures?  You absolutely do not need them if you do a little thinking first ...

  • You created a Counter that starts at 1 and increments by 1 every time your For loop executes a loop.  Good, you understand Shift Registers.  Here's a Quiz -- do you see that little symbol of "i" inside a Blue (color is significant in LabVIEW!) box in the lower left hand corner?  Do you know what values it takes?  Do you see that you don't need your Counter at all?
  • You have a Dbl called "Number of Flashes" wired to the "N" input of the For Loop.  Did you notice that the "N" is Blue?  Color is significant!  Do you see the little red dot where the Orange (Color is significant!) wire meets the Blue N?  That's called a "coercion dot", and means that LabVIEW is changing your Dbl to an Integer (in this case).
  • Am I correct that a "Flash", to you, means an "On-Off-On" (or "Off-On-Off") sequence, i.e. the LED changes state twice?
    • I'm indenting here because I want to discuss what happens in a Flash.  Let's say the LED is Off.  What happens?  It turns On, waits a bit, then turns Off, waits a bit.
    • How much does it wait?  Let's say you have a frequency at which you want the LED to flash.  How do you convert Frequency to an "On-Off-On" (or "Off-On-Off") time?  If you know this time, how can you divide it into two parts, one for the On time and one for the Off time, so their sum is the On-Off-On time?
    • One more simplification -- If the LED is in one (unknown) State, (either On or Off, you don't know), how can you make it go into the other State?
    • OK, so now we have a Time for "On-Off-On", a mechanism to change the LED to the "other" state, and the idea that we want to do it twice so we make a "flash" (for which we want N).  Quiz:  How many "Transitions" are we talking about?  How much time per transition?  What kind of structure does something for a specified number of times?
    • Paraphrasing what they used to say on "Laugh-In" (you could look it up), "Put that in your For Loop and Smoke It!".

A final note.  The LED is an Indicator.  Place it where the changes are being made (it should be inside a loop inside a loop).  No Sequences, no Frames, no Property Nodes, no Case Statements, one Wait function, one Shift Register (which doesn't even need to be initialized), and a little arithmetic (which should be done before entering the For loop, as the calculation only needs to be done once).

 

See if you can figure this out.  It's quite simple, and fairly elegant.

 

"Socrates" Schor

0 Kudos
Message 11 of 12
(553 Views)

Oh, that is a lot of advices here:)

 

I think my program gonna work for me the way I have it, BUT I'm going to re-write it using all of your tips (or ones that I can figure out). 

So far I fixed the "counter" the way you suggested, thank you, that is very smart way of doing that. 

 

Unfortunately I got a cold I will take a pause for a day or two. 

Thank you again for all the help, I'll be back soon with new version of the program. 

 

0 Kudos
Message 12 of 12
(512 Views)