LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help, I'm trying to control a blinking LED, by sending it a true or false inside a case structure.

Solved!
Go to solution

Help, I'm trying to control a blinking LED, by sending it a true or false inside a case structure. The LED has been modified to look like a specific indicator, so I can not simply create a property node for the LED and set that to blinking (unless someone can tell me how). I can see from various posts a number of ways to to set my modified indicator blinking, but they all use while loops. What I'm struggling with is controlling the while loop using a Boolean true or false.

What I'm trying to achieve is to create a virtual car dash board and control it using serial data. I've built a VI to read 3 bytes from the serial port and the data I'm sending to the VI will be in the format of a letter followed by 2 numbers. I'm using the letter to set the case structure then pass the numbers to various cases as selected by the letter.

I'm then comparing the 2 numbers and depending on the ASCII values I'm getting a true or false from the comparison.

So once I've set the indicator blinking I will need it to remain blinking until it gets another command to stop.

0 Kudos
Message 1 of 17
(5,407 Views)

Could you post a simple VI where we can see what you have already done?

Ricky
Italian Developer engineer
www.www.selt-sistemi.com
0 Kudos
Message 2 of 17
(5,399 Views)

This what I have so far. I've tried customising a few controls and left the others as standard for now.

0 Kudos
Message 3 of 17
(5,397 Views)

Hi!

 

Maybe you can get inspiration from this

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 4 of 17
(5,392 Views)

Side-comment: Do not place the VISA Configure Serial Port inside the loop. Initialize once outside the loop, do your reading inside, then close the session outside the loop when done:

0 Kudos
Message 5 of 17
(5,376 Views)

Try this I hope it is a good solution to solve your problem.

Ricky
Italian Developer engineer
www.www.selt-sistemi.com
0 Kudos
Message 6 of 17
(5,371 Views)

Thanks for that. Being new to LabVIEW and this is my first VI, I'm not sure what you did there, any chance of an explanation?

0 Kudos
Message 7 of 17
(5,345 Views)

Of course, what I did was:

 

what I did was:

1. I added a cluster with boolean values which are controlling the second loop which is working in parallel to the main loop.

2. In the main loop, you read the COM (I have simulated this action with a string control where I typed the code to check if the VI works properly, but I suggest to follow the advise of the other to initialise the port before launching the main loop and close it when the loop has been stopped) then you parse the byte read and you check them to switch on or off the properly led, I added a cluster that store the status of the led (on or off status) then I also added the software to change the state of the properly boolean value into the cluster which value is maintened because of the shift register on the loop.

3. In the second loop I'm checking which boolean in the cluster is true, I took its index form the array I had got from the convertion which the function cluster to array had done, in the second for-loop I'm changing the value of the array which archives the status of the led. At least before setting the value of the properly led I negate the value saved in the status array. This array is stored in a shift register of the loop.

 

I hope it is clear....

Sorry for my bad English.

 

Regards.

Ricky
Italian Developer engineer
www.www.selt-sistemi.com
0 Kudos
Message 8 of 17
(5,335 Views)

Thank you for that, just one more thing. I've tried modifying the block diagram to get left and right indicators to flash instead of the highbeam and temperature indicators.

But for some reason they will not flash, they turn on and turn off as I tell them via the serial connection.

I've obviously missed something in the block diagram, but can't find it.

I created local variables for the left and right indicators and replaced the Temp and Highbeam ones with those in the inner case structure in the top loop.

I created 'constant's from the 'blinking' cluster in the top loop to use outside the lower loop.

0 Kudos
Message 9 of 17
(5,322 Views)

There is an easier way to get an LED blinking. Use the Blinking property. The blink rate is set via the LabVIEW options, and this value is saved in the LabVIEW.ini. If you eventually create an application you can ship a pre-configured settings file for your application with the blink rate set.

 

0 Kudos
Message 10 of 17
(5,309 Views)