LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LEDs flashing on front panel in different modes

Hey there,

 

I'm relatively new to the world of LabVIEW and currently struggling to work out my homework task.

 

The task was the following:

  • 5 LEDs on the front panel
  • 3 modes of lighting the LEDs:
    • 1. let the LEDs flash simultaneously
    • 2. let the LEDs flash succesively (LED1 turns on; when LED1 turns off, LED2 turns on etc.)
    • 3. let LED1 flash 5 times, then let LED2 flash 5 times etc.
  • switch the mode only after pressing OK
  • manipulate the flashing delay

I figured out how to implement mode 1 and 2 (I will add a link to the project) but I don't know how to mode 3.

 

Here's what I currently got:

 

jonask99_1-1733240927467.png

 

I embedded the whole code in a producer/consumer structure.

 

Right now, LED1 is flashing 5 times before LED2 flashes one time, then it gets back to LED1 flashing. I know that this is because of the way I defined the inner case structure.

 

Is the approach with the inner case structure valid?

I will probably need another array but right now I'm pretty much stuck, so I'm thankful for any kind of help!

 

 

I am working on Labview 2021.

0 Kudos
Message 1 of 5
(108 Views)

This is a very simple task and you have way too much code for such a simple problem. All you need is a simple state machine running at a constant rate that changes state as a function of elapsed time and mode.

 

  • I would use an array or cluster of of LEDs.
  • Your delay should not be orange! (there are many other orange wires that should be blue)
  • Properly done, the code will probably fit on half a postcard.

I'll have a look....

0 Kudos
Message 2 of 5
(95 Views)

See if this can give you some ideas....

 

Note that the loop spins at a constant 50ms and changes state as a function of accumulated time. This is especially useful for longer time delays that would interfere with responsiveness. You want to read the controls often, even if the delay is 30 seconds.

 

altenbach_0-1733245436523.png

 

 

(of course your teacher reads this forum too, so make sure you fully understand the logic, then apply selected ideas to your code. Be creative!)

 

0 Kudos
Message 3 of 5
(61 Views)

Hi altenbach,

 

thank you very much for taking the time and designing the code!

 

There are definitely some ideas which i will use, e.g. the clustering and using more of "or"/"and" logic.

 

However, i think my original message might have been somewhat misleading. The mode "flash 5 times" does not refer to all LEDs flashing simultaneously for only 5 times. It was rather supposed to look like this: The first LED flashes 5 times while all other LEDs are off. Then the second LED flashes 5 times and so on. All this going on indefinitely.

I am pretty sure that I can make this work with "replace array subset" but it still really throws me off...

 

And concerning my prof: He will for sure be around the forum from time to time but the homework is voluntary and not graded. So this should not be a problem 🙂

0 Kudos
Message 4 of 5
(27 Views)

Yes, I did not read the description in detail, but your "5" mode would only requite some very minor changes to implement, It is just a longer cycle with otherwise very similar logic. (It is actually simpler than the current 5 flash cycle). Try it!

 

You could actually add many more flashing modes by just adding items to the enum and adding more cases. Scalability is always good!

0 Kudos
Message 5 of 5
(17 Views)