07-01-2024 09:39 AM
Hi all,
Struggling to understand why this is failing.
I am trying to communicate with the Prior X-Y stage ES111\G through an Optiscan III.
I can communicate with the stage through NI MAX, however I cannot get the stage to move or get anything in the read buffer in my vi.
I have tried PS\r to get the position and also *IDN?\r\n.
Solved! Go to Solution.
07-01-2024 12:47 PM
Welcome to the LabVIEW Forums, AW.
When you "communicate with the stage through NI MAX", what does that mean? Can you send VISA commands (such as *IDN?) and get a reasonable response? If so, can you give a "Move" command, and also get a response?
If these are both True, then most of the "hard work" has been done. From MAX, you know the VISA settings that you need, such as Baud Rate, Parity, # Data Bits, Parity, etc., and can compare these to the default values you left unwired (so they take the default values!) in your Configure Serial Port function (you forgot to wire Error Out to the next function's Error In).
You are new to VISA, so don't know that the next three functions after the VISA Write should be removed! Wire the VISA Reference directly to VISA Read, and specify 1000 as the number of Bytes to read. When you did the first VISA Configure Serial Port, you (wisely) kept the top two inputs unwired, which says "Start reading until you get a 0x0A (Line Feed) or (nothing 10 seconds)" -- this is what you want to do if you are expecting the peripheral to send you a response. No guessing how many bytes to read, VISA will tell you.
So first try out MAX, and if MAX works, fix your code and try the "improved" LabVIEW code. Let us know how both "experiments" worked.
Bob Schor
07-02-2024 04:42 AM
Hi Bob,
Thanks very much for your response. My apologies for being a newbie to the forums.
I should've explained better, by communicating I mean that I can send VISA commands on NI MAX like *IDN? (ID command query) or PS (position query) or F,100 (Move forward 100 command).
When getting the position, I send the query PS/r and in the buffer I see:
So, it does get the correct position but there is an error in return data.
Running F,100\r moves the X-Y stage with no errors as it is just a write command.
\r is the termination character.
At least I can move it without error.
Compared the default values and all in line there, fortunately!
Wired the Error out to Error In, good spot!
I also made the changes to the 3 functions following VISA write, thanks!
I tried running with and without a termination character wired to the VISA Serial Configuration and I am getting a response in the read buffer, which is brilliant!
Now the only issue I have is that I am still getting an error message
When I have 'highlight execution' turned on, I notice that the error message is 'OK' until what seems like the last iteration of the loop where that error comes in.
Thanks so much for your help, you've definitely solved my question as now I can actually move the stage and query its position. The only issue I am left with is that error which also appeared in NI MAX
07-02-2024 09:11 AM
Try adding a wait function inside the loop, to avoid reading from Visa faster that your equipment can respond.
07-02-2024 12:02 PM
There's a "mistake" (what I would call "harmless", but it invites "modification" which will cause a mysterious mistake" and a real mistake. Both are in the picture you posted.
I recommend deleting the Termination Char input to the initial VISA command, as it is the default, and drawing attention to it might tempt someone to change it (which you don't want). When NI leave inputs with non-zero default values unwired (as here), it's usually because they are already set to what NI considers the "best" value. If you agree, leave it unwired.
The "bug" is using a Shift Register in the While Loop that does the VISA Read. What was the command that you gave to start this process, and more important, what do you expect the response to be? Recall that as you have set up VISA, every time you give a VISA Command that has a response (that you have to read), the response will be terminated with a <LF>, so unless you are expecting 1000 bytes all at once, the safe way to read "all the data, and only the data coming back is to read 1000 bytes, expecting (and getting!) fewer.
However, if your "Instruction" (the VISA Write) is "Send me 10 readings", then you put the VISA Read (with number of bytes wired in as 1000) inside a FOR loop with an index of 10, and pass the 10 values out as an Array, ignoring the Bytes Read output.
See if that fixes things.
Bob Schor
07-04-2024 05:48 AM
Hi Bob,
I removed the termination character input and I fully removed the Shift Register.
Now I just read directly from the VISA Read function.
Using 1000 didn't actually work for me so I reverted back to Bytes at Port in the Property Node which works.
I have it working without error now.
Thanks for all the help!