LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error question

Hi,

 

I want to put an optimization block (quadratic programming) in a while loop with a dt of 100 ms. The optimization block is iterative, and it's possible it can't produce an outcome in 100 ms. What happens then? Does the while loop just go to the next cycle and you get an error or does it keep running until the block is solved going over 100 ms. There are some stopping criteria on the optimization block like maximum time or amount of function calls, but there is also other code in the loop, so I don't really know how long it should run before it should stop.

 

Regards

 

KF_

0 Kudos
Message 1 of 11
(3,664 Views)

What do you mean a dT of 100 mS? How are you "setting" that? Are you using a timed loop structure, or just a while loop with your calculations and a seperate 100mS function. If it is the later the delay will come after your calculations, then the loop will go to the next iteration. If it is the timed loop, it will go to the iteration at a 100 mS, if your calculation is done. In other words if your calc take 87 mS, the loop will delay 13 mS more before going to the next iteration. If your calc goes 100mS+ the loop will iterate immediately after your calculation, and show a "finished" on the terminal on the inside of the left side of the loop.

 

This assume that your calculations are being done in LabVIEW. If you are going to a dll or other code it will depend on the code. Some do not return until completed, others return immediately. The later don't return values, otherwise LabVIEW would wait for data to be present.

Message Edited by LV_Pro on 04-16-2010 11:57 AM
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 11
(3,647 Views)

Hi,

 

I am using a loop with a millisecond multiple block and not a timed loop. But I am not getting the difference between the two. "In other words if your calc take 87 mS, the loop will delay 13 mS more before going to the next iteration." I always thought both the timed loop and the plain loop with a millisecond multiple block did this. So the loop will go over the 100 ms untill the problem inside the loop has been solved. Can i prevent this from happening? Also it is possible that the optimization block in the loop just can't find a solution, beause there isn't one and it will give an error with the option continue or stop. Can I prevent this from popping up? The block has an error output and input, can I wire the output to a case structure, so when an error occurs it gives something I want it to give without the dialog box of continue or stop popping up? The output of the optimization block are signals to systems which drive a small distillation column, so when the optimization block fails to give a solution I just give values I set.

 

Regards

 

KF_

Message Edited by KF_ on 04-16-2010 11:45 AM
0 Kudos
Message 3 of 11
(3,636 Views)

There are several differences between a timed loop and a while loop (with wait until next ms multiple)

- The while loop can only use software timing. The timed loop can use software and harware timing (depending on the device you use it with/for/on)

- The timed loop allows you manually to assign a specific processor to a specific timed loop. The while loop doesn't

- The timed loop also allows you to assign priorities to the different loops, so that a more critical loop will behave more deterministic.

- ...

 

With the timed loop you can force a loop to execute "correctly" by setting a timeout.

You can also perform error handling and pass errors through to a next iteration in a timed loop, but this will take time away from your calculation.

You can also put a case structure in a timed loop.

Is the popup because of an error or is the popup created by the optimization block?

 

I would advise you to use a timed loop if you're planning to implement the system you described.

 

 

 

 

 

 

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 4 of 11
(3,585 Views)

If the pop up error block is not something you coded, but instead it is a Labview created pop uo, then you probably have Automatic Error Handling turned on.  You can turn it off by going to the Tools menu - Options - Block Diagram - Error Handling (at least this is where it is in LV2009).  Uncheck the boxe(s) for enabling automatic error handling.

Warning:  During development, it is wise to have this option turned on to catch errors you didn't anticipate.  After debuggin your app, turn it off to prevent a user from seeing an unexpected pop up.  You can trap all errors and gracefully exit the program or perform some function.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 11
(3,575 Views)

Hi,

 

Thanks for the replies, I have one more question, There are two timed loops structures which control the destillation column, but if they use different frequencies it doesn't seem to run smoothly. Can i solve this with assigning a different processorto each loop for instance?

0 Kudos
Message 6 of 11
(3,550 Views)

If you could attach your code, maybe we can see what you are talking about.  What do you mean by "it doesn't run smoothly"?

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 11
(3,530 Views)

I attached the control program for the column, it has 3 timed loops, one loop gets the data from the sensors, the second has the PID's and such in it and the third does data logging. if those 3 use different frequencies, it has trouble running, it goes beserk a bit. There alot of global or local variables in it though.

 

Regards

 

KF

0 Kudos
Message 8 of 11
(3,521 Views)

OMG!  You need a monitor the size of a wall to see the entire vi.  Bad practice.  Why do you use shared variables?  Are you communicating with some other process?  One of your loops is labled non-deterministic, yet it is a timed loop.  If it is non-time critical, no need for a timed loop.  You should break this up into subvi's for each data gathering.  You could call the subvi's in parallel so they all run at the same time.  Send your data between subvi's and the datalogger by using a queue.  The gathering would go along in a timed fashion, and the datalogger would just log whatever comes in.  The queue would hold all the data until it is processed.  You need to rethink your architecture.

 

- tbob

Inventor of the WORM Global
Message 9 of 11
(3,514 Views)

If you think this is bad, i will not show you the MPC program Smiley Very Happy

 

I think the main problem is probably the data collecting yes, the queue is a good idea, I will try it. I'm not sure anymore why they are shared variables, probably had something to do with the CompactRio, plain local variables should be ok now.

 

Regards

 

KF

0 Kudos
Message 10 of 11
(3,508 Views)