LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Turn LED ON (1 second) and OFF (9 seconds). Code modification trouble!!!


@GRCK5000 wrote:

I think the problem is with my wording. 😔


Then draw a 40second timeline and four traces, one line for each led that should be on at any given time.

0 Kudos
Message 21 of 40
(1,154 Views)

I am sorry. 1 complete cycle should 10 seconds, not 40 seconds. Then the same thing repeats again. So 1 cycle > 10 seconds, 2 cycles > 20 seconds, 3 cycles > 30 seconds and so on. 

0 Kudos
Message 22 of 40
(1,152 Views)

So shorten the times accordingly.

0 Kudos
Message 23 of 40
(1,149 Views)

I changed the off time to 2s as shown below. I get exactly what I want. Each led is being OFF for 9 seconds in 1 complete cycle which is 10 seconds, but here the problem I've been having instead of having a control with 2 seconds there, I would like to have 9 seconds meaning each led will have to be off for 9 seconds for 1 complete cycle of 10 seconds.

GRCK5000_0-1674175481960.png

 

Something similar to this drawing:

GRCK5000_1-1674175963168.png

 

 

 

0 Kudos
Message 24 of 40
(1,142 Views)

So do the math on the off time based on 9s in the control and the number of LEDs, "on" time, etc. before building the array. The rest can remain.

0 Kudos
Message 25 of 40
(1,128 Views)

@GRCK5000 wrote:

I changed the off time to 2s as shown below. I get exactly what I want. Each led is being OFF for 9 seconds in 1 complete cycle which is 10 seconds, but here the problem I've been having instead of having a control with 2 seconds there, I would like to have 9 seconds meaning each led will have to be off for 9 seconds for 1 complete cycle of 10 seconds.

GRCK5000_0-1674175481960.png

 

Something similar to this drawing:

GRCK5000_1-1674175963168.png

 

 

 


So, the Duty cycle and Cycle time remain constant, just the phase of your pulse varies. Then, you need to have a control to specify the initial delay (0-9sec) for a 1sec pulse in a 10sec cycle time.

The question becomes, how do you know the start of a cycle? because in all the cases, the time between the pulses is a constant 9sec.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 26 of 40
(1,115 Views)

I just found the solution by doing 2nd grade math. 

GRCK5000_0-1674180507739.png

Front panel

GRCK5000_1-1674180556004.png

 

Now I can breathe. Yes!!!!

 

0 Kudos
Message 27 of 40
(1,114 Views)

So you said that later you want to expand it to more LEDs. Does that mean that later more than one LED is lit?

 

I don't think you need to do any math, you simply need to adjust the logic and redefine "one cycle".

It is a really bad idea to add random constants to the diagram. You need to do the math based on known existing values (off time, on time, # of LEDs, etc.) so you can easily change the timing (e.g. set the on time to 2s or off time to 11s) without doing second grade math all over again.

 

Again, please attach your latest VI. Please set embedded images to "large"!

0 Kudos
Message 28 of 40
(1,090 Views)

Wow!  So much effort just to blink a light on and off.  Such inappropriate use of the High Resolution Timer.  But you are very skillful in tricking well-intentioned LabVIEW developers to waste their time with your behavior ...

 

This blinks one LED according to the On and Off times set on the Front Panel, which can be changed as it runs.  It is so simple, uses no math (which is even simpler than "Simple math"), and can be explained to someone with no computing experience once you explain the graphical elements.  [In case you haven't guessed, the Stop button is in the False case, wired to the While Loop's Stop control to get it to stop at the end of the Off time].

DEMO Better Blinker.png

 

Are you actually trying to make a "Marquee" light, where you have a 1D Array of Booleans and you want to turn one of them on for, say, 1 second, then turn it off and turn the next one on, and so on until you turn off the last one and turn the first one back on?  [Note that this simple formulation has only an "On Time", as the "Off Time" for each LED becomes simply the Array Size - On Time].  That's even easier than the above, especially if you start out with an "Initialized Array of Boolean" which has the pattern (which need not be "only one LED on" -- in fact, you could create a 7 x 7N Array of Booleans, pre-initialize it by setting the N 7x7 sub-arrays with LEDs on to represent 5x7 Capital Letters that scrolls across the screen like the Times Square Marquee.

 

@Altenbach shouldn't need to help you with this one!

0 Kudos
Message 29 of 40
(1,085 Views)

For significantly better testing algorithms, I would display the LED state on a chart vs time.

 

Here's one possibility using "simpler math":

 

altenbach_0-1674234643286.png

 

As I said, once you have much more LEDs or the off time is shorter than the (# of LEDs x on time), multiple LEDs might be lit at any given time and you probably need to maintain an array of elapsed times.

 

0 Kudos
Message 30 of 40
(1,074 Views)