08-01-2011 05:19 AM
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.
Solved! Go to Solution.
08-01-2011 06:04 AM
Could you post a simple VI where we can see what you have already done?
08-01-2011 06:18 AM
This what I have so far. I've tried customising a few controls and left the others as standard for now.
08-01-2011 06:36 AM
08-01-2011 08:47 AM
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:
08-01-2011 08:51 AM
Try this I hope it is a good solution to solve your problem.
08-02-2011 02:22 AM
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?
08-02-2011 03:30 AM
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.
08-02-2011 05:55 AM
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.
08-02-2011 08:01 AM - edited 08-02-2011 08:01 AM
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.
