10-28-2008 11:02 AM - edited 10-28-2008 11:05 AM
Hello all,
I am new to Labview (started today) and I have to control 3 switches and watch 3 inputs (LEDs). I am a microcontroller/C guy, so all this is confusing to me.
I was able to get Labview talking to the NI box so I can control the switches (outputs) and read the LEDs (inputs). After that I am totally lost.
All I want to do is loop (indefinitely) and:
1. Turn on Valid (switch 1), start a timer and wait for OK (LED 1) to turn on. Write the timer value to a file with a date/time stamp.
2. Turn on Request (switch 2), start a timer and wait for GRT (LED 2) to turn on. Write the timer value to a file with a date/time stamp.
3. Turn on POD Placed (switch 3), start a timer and wait for Placed (LED 3) to turn on. Write the timer value to a file with a date/time stamp.
4. Turn all switches off and restart loop.
If someone can show me how I can put the switch inside a loop, turn it on, and wait for the LED with a timer, that would help so much.
Thanks!
10-28-2008 12:00 PM
Hi pzoom,
Welcome to LabVIEW! I'm going to give you a few pointers towards information that maybe useful to you. Have you looked at the example finder? You can find this by going "Help->Find Examples..." from a blank VI and searching for topics from there. There are a number of different ways that you could calculate the time. You could compare the system clock (Tick count) before and after your code; this could be done using a flat sequence (attached image). Or you could use the "elapsed Time" Express VI (Located at "Expres-> Exec Control"). There are a number of different timing solutions available from the Timing palette "Programming->Timing". Specifically there is the Ge Date/Time in seconds Vi which would probably be of use.
If you need further help please let me know,
10-28-2008 01:22 PM
Thanks Andrew for the reply. Could you tell me how I can set the switch within the loop? In C, I would set SW1=1 - how do I do that in LV? I can seem to find examples using the DAQmx for simple I/O.
10-29-2008 04:39 AM
Hi pzoom,
If you wish to reset something, I would suggest you use local variables. I've attached an example VI which will turn an LED on for one second and then reset the switch. Please have a look at this code to see the operation. In order to create local variables, right click on any control or indicator you have, and go to "Create->Local Variable". You can change local variables to either Read or write by right right-clicking on the local variable and pressing either "change to read" or "change to write".
10-29-2008 11:02 AM
Hi pzoom,
Can you please tell us the model number of the NI hardware that you are using?
Best wishes,
Wallace F.