Read actual positions from Newport stage controller instrument ESP302

5 次查看(过去 30 天)
I have a Newport stage controller ESP302. I am able to successfully connect to the controller using the following line:
obj1 = tcpclient("192.168.254.254",5002,"ConnectTimeout",10);
I am also able to write commands to move the 3x stages connected to the controller to the desired positions. For example, to move stage 1 to the absolute position 75, I use the following:
writeline(obj1,'1PA75');
However, when I try to read the actual positions of the stages, I have to run the same query several times:
query(obj1,'1TP');
query(obj1,'1TP');
query(obj1,'1TP');
The first time it gives me 0, the second time it gives me the position of one of the other stages, and only the third time it gives me the actual position of Stage 1.
Looks like the problem is specific to Matlab, as the same commands work perfectly the first time when using the Newport application GUI. This is a problem as I need to read the stage positions quickly when the stages are in motion.

采纳的回答

Paul Lambrechts
Paul Lambrechts 2024-12-23
Hi, I am not sure if this will help but I notice that you are using the old "query" command in combination with the new "tcpclient" object.
  1 个评论
Aram Zeytunyan
Aram Zeytunyan 2025-1-3
Thank you for this hint! Although I wasn't able to directly use the "readline" command to read the actual positions of the individual stages (as it doesn't support the format used with the "query" command), but it helped me to identify the root cause of the issue. It turned out that Matlab "gets confused" when the stages are either in the motion state or parked once the motion is complete. If I simply initialize the stages and read their positions without moving them, Matlab would do the job. But if I try to read the positions after or during the motion, the 1TP (or 2TP or 3TP) query commands would result in NaN values or wrong values corresponding to the postions of one of the other stages. This is not the case with the Newport application GUI, which uses a command line similar to Matlab.
Anyways, I was able to avoid the issue by inserting the following line every time I command the stages to move:
readline(obj1);
For some reason, once I have this line after each move command, the actual stage positions are properly read using the "query" command. I am sure there are ways to use the "readline" command to read the position of the desired stage, but I wasn't able to do that. Instead, I first use the "readline" command immediately after the move command and only after that use the "query" command to read the position.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Packages 的更多信息

产品


版本

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by