09-20-2011 06:39 AM
Thanks, I will definitely experiment with the daqmx functions. And by various testing, I have realized the way while loops work and have already enclosed the entire code in a while loop. I've mostly been building small pieces of code in blank projects and using indicators to see if its working as I envision; observing and testing different data bits. A little time consuming, but a great way to learn.
As for the stop program; I need the program to run forever unless it it closed as we need to have certain functions (to be added to the VI) active continuously. This is again fixed by placing the entire code in a loop.
With the entire code in a while loop, is there a way to make a case structure execute only once during a true input? For example if you have a push button T/F and someone holds down the button, I need the case structure to only execute once no matter how long the button is held; to have it activate again only if the button is released and pressed again.
Also, I've looked into training, but money concerns mean google and Labview for Everyone are my resources. It's fun learning on my own, and when I get really stumped I post on here
Ryan
09-20-2011 02:47 PM - edited 09-20-2011 02:50 PM
Hey Ryan,
To make the case structure execute only once when the switch is pressed, right click your button that is returning true/being pressed and select the mechanical action "Latch when pressed". This will send a true value only once even if the button is held down and wont send another true until it is released and pressed again.
Here is more information on the other options of mechanical options. Feel free to do a little experimenting by wiring a switch to an led indicator in a while loop. Use the highlight execution tool to see exactly whats happening.
http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/changemechactofboolswitch/
Hope this helps,
Luke West
09-26-2011 08:24 AM
That is the function I need-but unfortunately the input to the case structure is not a front panel button, it is a T/F value derived from a signal that comes from external hardware.
I need a way to latch a boolean value without having a front panel input so that when a true value is inputted, it sends one signel true pulse to the case structure and then immediately resets to false.
-Ryan
09-26-2011 10:50 AM
Hey Ryan,
For this case, you may want to create a state machine. Use a case structure, a shift register, an enum, and some local variables. I've attached a simplified version that detects when a value goes above a threshold constant. It will perform the threshold action only once (even if the value stays true) and then enter an above threshold state, titled threshold detected wait. Whatever actions you would like to be performed only when the threshold is initially passed can be put into the case structure 'threshold detected action'
Heres an online example on state machines
https://decibel.ni.com/content/docs/DOC-4594
Regards,
Luke W
09-26-2011 01:24 PM
Using a state machine alsmost works-but the trouble comes from the outside signal being the trigger. I used your structure and replaced the 'greater than' functions with the waveform scalar limit comparison, and connected that to the daqmx signal. I used a local variable in the 'threshold detected, wait' case to take the place of your control. However, you cannot use local variables to call an active signal; it takes the most recent reading and re-uses it indefinitily, creating an infinite loop.
I then tried inserting a separate daqmx function in the 'threshold detected, wait' case, but there seems to be an issue whenever you use more than one daqmx function, even if they are not used simultaneously.
Is there any way to inport live data into various cases?
Ryan
09-27-2011 05:06 PM - edited 09-27-2011 05:07 PM
Hey Ryan,
You can feed live data into the case structure and eliminate the use of local variables at all
Luke W
09-28-2011 06:28 AM
I was having an issue with doing that with the daq assist. I figured it out; I had all of the daq assists set to continous samples and they were interfering with each other, now I have them set to 1 sample and it works.
Thanks!