01-10-2011 09:15 AM
HI!
My problem is kind of basic, but one I have never encountered before. I want two VI’s to run simultaneously.
I am developing a program where the main VI is receiving a lot of measurements from a microcontroller, do some calculations before displaying them, and sending commands back to the microcontroller. All this works just fine but at one point I want to send a SMS via AT commands. The problems is the communications loop with the microcontroller can’t stop, so there is not time for the same loop (main VI) to be sending AT commands and waiting for a response. The solution can be another VI that starts in the background and just receives a string to send via SMS from the main VI, and does this simultaneously as the main VI continuously updates the measurements.
Is this possible?
Any help would be appreciated.
Kristoffer
01-10-2011 09:21 AM - edited 01-10-2011 09:25 AM
If you want two or more instances to run simultaniously go to the execution properties of the vi and make it reentrant.
Edit: After rereading your post I don't think I understood the question correctly. It's still early here !
It sounds more like you want a producer consumer design.
01-10-2011 09:24 AM - edited 01-10-2011 09:26 AM
It is more than possible, this has been one of LabVIEW's strong points for a very long time, parallel operations. I would recommend looking at the help for producer/consumer loops, parallel loops, etc. You probably want to have a main that launches the other two vi's, and then having the microcontroller comm loop sends the desired message to the other SMS comm loop as you propose.
There shouldn't be an issue of reentrancy here, these are two unrelated functions that just need to run in parallel. In fact both loops can be in the same vi, but it is probably "cleaner" to have them in their own.
As you work on this, post where you are, show us your attempts and we will give suggestions.
01-10-2011 09:32 AM
Thank you!
I kind of suspected it was possible, just never needed it before. I’ll do some reading on the producer/consumer loops, parallel loops and try it out tonight.
Kristoffer