LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

vi locking up will not respond or stop running.

Solved!
Go to solution

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.

0 Kudos
Message 1 of 14
(3,728 Views)
Solution
Accepted by topic author Surgeboard2012

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. 

0 Kudos
Message 2 of 14
(3,722 Views)

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.

 

  • You don't need to wire from the button terminals to the event structure. I recommend to place the terminals inside the associated events (This is typically absolutely needed for latch action booleans, but it does not hurt in you case either).
  • You don't have an event for the stop button, meaning the VI cannot be stopeed directly, just aborted. I don't see the need for a stop button. Use the cancel button and add an evet case for it.
  • You write two registry values in parallel. I would recommend to use an autoindexing for loop to reduce the code complexity by 50%.
  • Why are you reading all the values for the fitting from value property nodes? Use wires directly.
  • The fitting has a race codition, because there is no data depedency. It is likely that the fitting executes before the event structures and thus shows stale data most of the time.
  • You need to disable the button at program start, else the enabling does not really do anything. Your code also assumes that the three buttons are clicked in a certain order. This seems uneceessary.
  • You don't need the timeout case if it is not used.

Here's a quick draft showing some ideas. The code is not complete and I probably would do many thing differently.

Message 3 of 14
(3,695 Views)

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.   

0 Kudos
Message 4 of 14
(3,671 Views)

@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.

0 Kudos
Message 5 of 14
(3,658 Views)

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.

0 Kudos
Message 6 of 14
(3,654 Views)

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. 😉

0 Kudos
Message 7 of 14
(3,651 Views)

@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.

0 Kudos
Message 8 of 14
(3,644 Views)

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. 

0 Kudos
Message 9 of 14
(3,632 Views)

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.

0 Kudos
Message 10 of 14
(3,625 Views)