01-19-2023 10:15 AM
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.
01-19-2023 10:32 AM - edited 01-19-2023 10:34 AM
@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?
01-19-2023 10:54 AM
Or you want to create a XControl with the form of an array of LED?
Creating New Front Panel Objects with LabVIEW XControls
01-19-2023 11:28 AM - edited 01-19-2023 11:32 AM
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.
01-19-2023 12:18 PM
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…
01-19-2023 12:33 PM - edited 01-19-2023 12:34 PM
One thing I forgot to mention. I'm only using 4 leds instead of 30. so the code should be changed as shown below,
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.
01-19-2023 12:47 PM - edited 01-19-2023 12:49 PM
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)
01-19-2023 12:49 PM - edited 01-19-2023 12:50 PM
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…)
01-19-2023 12:56 PM - edited 01-19-2023 12:57 PM
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?
01-19-2023 01:06 PM - edited 01-19-2023 01:08 PM
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…