02-10-2012 05:09 PM
I have a vi I created to calibrate a voltage reading. I have 3 buttons the user pushes to set the volts for 3 different ranges. The 3 buttons trigger an event structure to capture the data. When I click on the second button everything locks up. I can't stop the vi with the stop button or anything for that matter. I have to right-click on the labview tab at the bottom of the screen and close it there. I have checked the code for the second button but I can't find anything different than the first one that works fine. Any suggestions as to what might be happening. I just started using Labview so my debugging skills are not very good. Thanks.
Solved! Go to Solution.
02-10-2012 05:58 PM
I think I may have found the problem. I had 2 event structures in one loop. Took the second one out and it seems to be working better.
02-12-2012 11:42 AM
You should never have more than one event structure per loop. You can always addn more event cases to the same event structure.
This is actually pretty good for a beginner program (and I know the program is not finished), but there are still a few things you might want to consider.
Here's a quick draft showing some ideas. The code is not complete and I probably would do many thing differently.
02-13-2012 06:53 AM
Thank you very much for your input. Like I said I just ordered Labview and started working on it in January. I have been programming in Visual Basic for about 10 years. I changed to Labview when the computers we ordered started changing and the data acquisition cards we use will no longer fit in the computers. The program I am trying to duplicate is pretty large and has a lot of screens and data that need to be saved from each test. When I created this program I was wondering how you do stuff in a specific order. I noticed that there was a lot of things happening in my program but I couldn't make sense of the order it did them in. In Visual Basic it executes line by line but I really don't know how to do stuff in order in Labview. I don't understand shift registers. I have read about them but I guess it hasn't sunk in yet. I really appreciate the input. I am going to try and make sense of the changes you made to my program. Thanks again for your help.
02-13-2012 09:56 AM
@Surgeboard2012 wrote:
I don't understand shift registers. I have read about them but I guess it hasn't sunk in yet.
A shift register is basically persistent data local to a loop where, with each iteration, you can read the current value on the left, modify (or not) on the loop diagram, then write the updated value on the right.
In many cases (unless e.g. an array changes size) it can be handled in place as a single memory location, making it very efficient and fast.
02-13-2012 10:53 AM
I am trying to use the program you modified. Instead of the values that is put a constant into the array I will be reading an input from a task created in NI Max. I changed the constants to a VI reference like you did with the boolean values for the buttons. It gives me an error when I do that. Is what I am trying to do right? When I start the program I am going to call a task that I created and read the channel and it will be displayed in the Raw Volts indicators. When I hit Capture I will get the Volts and Raw Volts and that is one point of my line. I will be reading the same channel but my data that I read will need to be displayed in the Raw Volts 2 indicator and so on until I get the last value. Do I call the task outside the While loop? Also when on of the buttons is pushed there is a limit check on the value that was entered. If it doesn't fall within the limits it flash up a message and it should clear the value entered and reset the button to false. Like I said I am very very new to this. Thanks for your help.
02-13-2012 10:56 AM
Showing a picture of the code or attaching a VI would be much more helpful. Words typically cannot accurately describe what you are actually doing. 😉
02-13-2012 11:03 AM
@Surgeboard2012 wrote:
I changed the constants to a VI reference like you did with the boolean values for the buttons. It gives me an error when I do that. Is what I am trying to do right?
No, you are still using the buttons to trigger the event, so leave all that code untouched. All you need to do is add reading of the DAQ value whenever the event fires.
02-13-2012 12:58 PM - edited 02-13-2012 01:04 PM
OK. I couldn't modify the program you modified for me. But here is what I am trying to do. I have a problem though. When I start the program it only reads the volts once at the beginning of the program. I have looked at some examples and I am not doing anything different except I am calling a task that I created. I tried doing it the same way the other example programs do but I get the same result. I am doing something wrong but I don't know what it is.
02-13-2012 01:43 PM
Your code is still crawling with race conditions. Why do you think you need all these local variables?
Basically you are reading the the DAQ, calculating the linear regression based on incomplete data and do some math based on the value of "current step" while waiting for the event to fire. these things happen immediately at the start of the new iteration, so most likely they will be stale by the time you are pressing a button.
You did not correct a single things that I said was wrong.