LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Vary LED OFF time with unchanging ON time.

Solved!
Go to solution

I have an emulation of ship navigation lights to check logical pattern construction. I would like to blink lights in particular patterns, but not in the standard fixed identical time for the lit and dark periods one would get in a loop with a wait. What I envision is ON for 250ms and OFF for 1, 2, 5, 10 seconds selectable.

 

Anyone done anything like that?

0 Kudos
Message 1 of 12
(1,425 Views)

I haven't specifically done that, but it is easy enough.

 

Are you asking a specific question?  This sounds like homework.  What have you tried so far?

0 Kudos
Message 2 of 12
(1,360 Views)

I agree, this looks like a great beginner exercise doable in a few minutes (I just did!). How much LabVIEW experience do you have?

 

Some things to decide. Should there be a pulse a t=0? What should happen if the duration is changed from 10s to 1s, two seconds after the last pulse? (e.g. wait for the full 10 seconds or switch immediately?) etc.

 

 

0 Kudos
Message 3 of 12
(1,346 Views)
Solution
Accepted by topic author andy.mcleod@unh.edu

Let's go with a description of one way for you to try coding it

 

You want a Generate Pulse.vi inputs Duration as I32 default 250, Surpress as BOOL required. Output Error Out as error cluster.  Inside is a simple case Structure driven by Surpress TRUE does nothing and outputs no error,  FALSE drives your hardware pulse for Duration in msec and outputs appropriate error if unsuccessful. 

 

Main Vi Front panel controls numeric  OFF Time as I32 in msec (I recommend a knob), BOOL,  STOP button since that's a proper latching button. 

 

Block diagram; 

Create a while loop with 1 I32 Shift register initialized to -1 around both terminals 

Create an Event Structure around both terminals ( that would be inside the while loop) 

Wire the left side Shift register to the Event Timeout and OFF Time terminal back to the Right side Shift Register 

Edit the events handled by the Timeout case adding OFF Time Mouse Up and STOP Value Change we only need one Event case.

After the event case drop Generate Pulse.vi and an OR . 

Wire STOP to Surpress and an OR Input 

Wire Error Out to the other OR Input 

Wire OR output to the While loop conditional terminal

Drop a Simple Error Handler.vi after the While loop and wire Error out into its input

 

Document 

Press run

This is not the only way to do this but, it's a great starter exercise for a beginner,  easy to describe following good practices, scales nice, and I don't know what your hardware is. I've abstracted hardware in the subvi while seeing to the timing and UI needs you seemed concerned with. 

 

BONUS there are all kinds of nice and easy things we can DO to it if requirements are clarified (changed) by the user


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 12
(1,337 Views)

This marked solution disappoints me.   I would hope that the OP would post back with the coded solution for the benefit of other users.  

 

I know that additional questions,  tweaks, and comments from other posters COULD have made this thread a resource worth the effort I expended to set up that sample exercise.   

 

I also think that the solution won't earn an "A"  (ironically,  its probably worth a "C+")

 

So, to the OP, come back for the learning opportunity.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 12
(1,306 Views)

I can see that I should be a bit more critical of my own decision making process before blasting out a help request. It's been 5 years since I did any LabVIEW work. Your words are taken to heart. The project is well in hand and I thank you for the help.

0 Kudos
Message 6 of 12
(1,297 Views)

andy.mcleod@unh.edu wrote:

I can see that I should be a bit more critical of my own decision making process before blasting out a help request. It's been 5 years since I did any LabVIEW work. Your words are taken to heart. The project is well in hand and I thank you for the help.


Not so much! It's just that time of year when homework request threads show up frequently.   We try to get the students to do the work without discouraging them from critical thinking. 

 

With a ".edu" in your alias you can understand why we suspected homework 

 

Happy to have helped 


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 12
(1,290 Views)

Here's what I came up with yesterday. Simple loop, no event structures or other complications.

(It would be easy to subtract 250ms from the off-times so the light flashes in exactly 1, 2, 5, or 10s intervals. It is also easy to start it with a flash instead of a wait. I probably would use a radiobutton control for the time selector. Note that the loop time should not be larger than the greatest common divisor of all wait times. The chart is just for illustration and can be deleted, of course)

 

See if this can give you some additional ideas.

 

altenbach_1-1611595130167.png

 

 

0 Kudos
Message 8 of 12
(1,287 Views)

@altenbach wrote:

I probably would use a radiobutton control for the time selector.

 

it could like that (same code!)

 

altenbach_0-1611596437121.png

 

0 Kudos
Message 9 of 12
(1,278 Views)

@altenbach wrote:

@altenbach wrote:

I probably would use a radiobutton control for the time selector.

 

it could like that (same code!)

 

altenbach_0-1611596437121.png

 


Hey, I did give myself a  C+ for the exercise assuming a homework assignment.  Do note that all those same questions/ improvements have nice places to hook up.

 

I am going to ask you though, ..  how do you get the hardware back to default on FP Close without an event Structure? Yeah, that was an obvious easy add to the exercise:D. I do like the radio button as long as its set to allow exactly 1 selection ( a property hard to see in your code)

 

I imagine the A+ solution would have eventually been a QMH properly initializing and closing any resources. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 12
(1,260 Views)