09-13-2012 03:50 PM
Greetings,
I am very confused trying to control a serial pan tilt unit. Currently I have the below VI that does not perform the same when I step through as when I run it. When I stop through it, the "number" that I am trying to read out of the string is perfect. But when I run it I get nothing. What is the difference between stepping through and running a VI?
Attached VI for reference.
Thanks much for any assistance.
09-13-2012 03:55 PM
I currenlty don't have LV 2012 installed so I couldn't look at your VI. However issue is timing related. When you step through the code everything has much more time. When you run your code is going much faster. You probably need to extend timeoutsor include some delay between operations.
09-13-2012 04:00 PM
You are sending a command and immediately check for bytes at port, then read that many. Most likely you need to wait a short time before the bytes arrive.
09-13-2012 04:00 PM
That thought had occured to me and I thought I had proved to myself that that was not the case. However now I just believe I don't know how to delay between actions. I need to delay between a "Visa Flush I/O" and a "Visa Write", I believe. I've only found ways to slow down loops. How to you slow down between two specific operations?
By the way thanks for the feedback!
09-13-2012 04:02 PM
altenbach,
I had put a "Time Delay" function into my loop, that didn't do it. I was assuming to delay in the spot I mention above.
09-13-2012
04:07 PM
- last edited on
10-09-2024
09:46 AM
by
Content Cleaner
You are talking about loops but there are no loops. Can yo explain?
If you simply place a wait inside the case structure, it will execute in parallel with the rest of the code, and will not delay anything inside the case.
You need to insert it into the dataflow at the correct place. There is an express VI that already contains error terminals, simply insert it in the right place (into the error wire between the fnctions that need to be delayed.
Alternatively, you could add a small while loop that checks for "bytes at port" until data has arrived.
09-13-2012 04:13 PM
Ah, thank you. I meant case structure, sorry. I do not believe I have the package for the VI you suggested, or at least it doesn't show up in the search palette. I will try your suggestion of a while loop.
When you say it executes in parallel I believe you, as it did not work, however when I stepped through with the delay it delayed right after the "VISA Write" function. That suggests to me that it delays then. That confused me.
Thanks for the quick responses and help, fellas.
09-13-2012 04:45 PM
When you step through or use execution highlighting, there will be long delays between every single operation, giving your instrument enough time to respond.
09-14-2012
02:32 PM
- last edited on
10-09-2024
09:47 AM
by
Content Cleaner
@altenbach wrote:
You are talking about loops but there are no loops. Can yo explain?
If you simply place a wait inside the case structure, it will execute in parallel with the rest of the code, and will not delay anything inside the case.
You need to insert it into the dataflow at the correct place. There is an express VI that already contains error terminals, simply insert it in the right place (into the error wire between the fnctions that need to be delayed.
Alternatively, you could add a small while loop that checks for "bytes at port" until data has arrived.
If you are expecting text that has a termination character, you can init the serial VISA with the termination character. Then you no longer need anything to do with "bytes at port" or a wait loop. The VISA READ will simply wait until either of two things happen - either it detects the termination character or it times out. If you have more than one termination character, set the termination character to the last termination character and strip the white space off the end.