LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

In the attached code, each led is ON for 1 second and OFF 9 seconds. Right now the code is doing what it's supposed to do which is good (ON 1 second, OFF 9 seconds).  All I want to do is to create controls that correspond to this sequence I have on the attached code. If you try to run the code, it's working as I want it to work. 

Someone may ask, how do you know each LED is OFF for 9 seconds. I know because I'm using my phone timer. As soon the led that was ON turns OFF, I would start my timer.

Notice if you run the code, two or more leds are ON at the same time. Also, you will notice as soon as a particular led is off, the cycling keeps going. That's what I want. 

Also, someone may misunderstand me and say, but on your block diagram you have 1.65 seconds off time. I have 1.65 seconds to keep things running, the way it's running right now.

In a nutshell, the sequence is perfect. I just want controls on the front panel that corresponds to 1 second ON and 9 seconds OFF).

I've tried but can't figure out. 

Thanks in advance for your help.

P.S: Credit to Mr. Altenbach for this code. Can't post someone's code without giving them any credit. I just want to modify it. 

 

0 Kudos
Message 1 of 40
(1,563 Views)

@GRCK5000 wrote:

In the attached code, each led is ON for 1 second and OFF 9 seconds. Right now the code is doing what it's supposed to do which is good (ON 1 second, OFF 9 seconds).  All I want to do is to create controls that correspond to this sequence I have on the attached code. If you try to run the code, it's working as I want it to work. 

Someone may ask, how do you know each LED is OFF for 9 seconds. I know because I'm using my phone timer. As soon the led that was ON turns OFF, I would start my timer.

Notice if you run the code, two or more leds are ON at the same time. Also, you will notice as soon as a particular led is off, the cycling keeps going. That's what I want. 

Also, someone may misunderstand me and say, but on your block diagram you have 1.65 seconds off time. I have 1.65 seconds to keep things running, the way it's running right now.

In a nutshell, the sequence is perfect. I just want controls on the front panel that corresponds to 1 second ON and 9 seconds OFF).

I've tried but can't figure out. 

Thanks in advance for your help.

P.S: Credit to Mr. Altenbach for this code. Can't post someone's code without giving them any credit. I just want to modify it. 

 


I'm having trouble figuring out what you're asking.  If your code is already working, are you asking how you can optimize it?  Sorry, your intentions are unclear to me.

 

Edit:

I finally figured it out (it wasn't you, it was me).  So you want some status indicators that tell you what is going on?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 2 of 40
(1,552 Views)

Or you want to create a XControl with the form of an array of LED?

Creating New Front Panel Objects with LabVIEW XControls

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 3 of 40
(1,538 Views)

I will try my best to make myself clear.

Right now, each LED would turn ON for 1 second ON and 9 seconds OFF and that's perfect. I want controls (ON time and OFF time controls)  on the front panel that I can use to change the cycle. For example, instead of 1 second ON and 9 seconds OFF, it can 2 second ON and 11 Seconds OFF, but the way it is now 1 second ON and 9 Seconds OFF should be the default.

Also status indicators would be nice too.

Hopefully, it's clear now. Feel free to ask more questions.

0 Kudos
Message 4 of 40
(1,522 Views)

Hi GRCK,

 


@GRCK5000 wrote:

I want controls (ON time and OFF time controls)  on the front panel that I can use to change the cycle.


Convert your "on time"/"off time" constants into controls - that's just a right-click…

Then move those controls into the loop so they got read with each iteration: you should have learned to "OBEY DATAFLOW!" by now…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 40
(1,507 Views)

One thing I forgot to mention. I'm only using 4 leds instead of 30. so the code should be changed as shown below,

GRCK5000_0-1674152901760.png

Now run the code and you'll notice each 1 of the 4 leds would turn ON for 1 second and off for 9 seconds. So I want to create controls that would correspond to the current flow. However, these controls can be changeable. For example, instead 1 and 9 seconds ON-OFF, I can 2 seconds ON and 8 seconds OFF.

Sorry, I think I forgot to mention that I am only using 4 leds.

 

P.S: I know they are 9 seconds off because I am using my phone timer.

0 Kudos
Message 6 of 40
(1,493 Views)

If you want to change the timing during run, the two timing "constants" need to be changed to "controls" and be located inside the while loop.

 

(You made my code again much more complicated than needed)

0 Kudos
Message 7 of 40
(1,483 Views)

Hi GRCK,

 


@GRCK5000 wrote:

Now run the code and you'll notice each 1 of the 4 leds would turn ON for 1 second and off for 9 seconds.

P.S: I know they are 9 seconds off because I am using my phone timer.


For me they are 1s on and after 1.65s off - as is dictated by those corresponding constants!

 

I really don't know what you are talking about with those "9s off"… (2.65s*3=7.95s…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 40
(1,482 Views)

You're getting where I am. So based on your calculation, we have 1 second ON  and 7.95 seconds OFF for each relay. Now how do I modify the code so that on the control panel, I will have 1 second ON and 7.95 seconds OFF?

0 Kudos
Message 9 of 40
(1,471 Views)

Hi GRCK,

 


@GRCK5000 wrote:

we have 1 second ON  and 7.95 seconds OFF for each relay

Now how do I modify the code so that on the control panel, I will have 1 second ON and 7.95 seconds OFF?


There you are!

 

When you want to change your timings then you need to apply some simple math, based on number of LEDs and overal cycle time.

For me this sounds not like a LabVIEW problem, but like a basic algebra problem…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 40
(1,461 Views)