DIY LabVIEW Crew Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Asyncrhonous call

Greetings,

I am having problems debugging a solution where I used an asynchronous call via LabVIEW.  The Asynchronous call is to a VISA com port read.  The first one starts a state machine that reads the data, filters it, saves the filtered data to a text (CSV) file (has a counter so that the file does not grow too large), then ports the filtered data to a functional global variable.  Then in the main program when I need the com port data all I have to do is a functional global variable read.  Then when done with the program I do another asyncrhonous call to stop the state machine.

The problem I am running into is that once in a while the state machine does not save the data.  I suspect that the problem is coming from stopping the state machine.  To start and stop the state machine I use the invoke node to set the control values and then start or stop the vi.  I am using LabVIEW 2010.  The last 2 invoke nodes are where an error is thrown when changing the state machine from run to stop.  If it is stopped and I stop it again it does not throw an error.

Any thoughts/comments/suggestions?

Mike

Mike
0 Kudos
Message 1 of 4
(8,722 Views)

Hi Mike

I think I can see your problem. In the case statement where you attempt to start / stop the vi, what you're actually doing is starting the vi in both cases (by calling the Run Vi invoke node). So if you run it and then attempt to stop it you'll probably get an error along the lines of ".. is in an incompatible state for this operation" (I can't remember the exact wording off the top of my head) because you're trying to run a vi thats already running.

Change the invoke node in the stop case to Abort vi.

regards

Mike

0 Kudos
Message 2 of 4
(4,623 Views)

Hi Mike,

Thanks, wasn't aware of that one.  That got it so it runs without error, since I noticed that when stopping it returned an error.  The state machine is doing a com port read, which unfortunately occasionally throws an error.  .  I ran it overnight starting it and stopping it and I had a few where I had no bus data.  this morning , so I put in a clear error after the com port read.  We'll see what happens.

Mike

Mike
0 Kudos
Message 3 of 4
(4,623 Views)

Hi Mike,

You may get more help posting your question in the LabVIEW forum.

However seeing as it appears (from the path in your VI) that you may work for Bosch, I'll try to help you here.

Your going to get all sorts of problems stopping and starting it via the VI server all the time.

Best practice for asynchronous code is to start your separate process (using the VI server as you have), communicate with it via queues until you don't need it anymore, then terminate it.

The asynchronous process should run continuously as the 'consumer' in a 'producer/consumer' pair. It should probably be a type of queued action engine.

If you attach the "BusMonitor_StateMachine.vi" I can show you how to do it.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 4 of 4
(4,623 Views)