05-01-2019 07:45 AM
I am using LabVIEW to control a Schneider MDrive Stepper motor with integrated controller over a TCP connection.
I can write and read to and from the motors using the following VIs:
This is what I am using to send commands to the motor. It runs without issue.
This is what I am using to read information from the motor. It too seems to work without issue.
I want to use the above VIs to make another which writes to the motor and then reads from it until the given parameter reads back the setpoint. Basically, I'm assigning a value to a parameter and keeping the VI running until the motor has reached steady state for that parameter. Below is what I am using for that.
With this one, I'm trying to send a command and keep the VI running until I can confirm the setpoint has been met. This VI works the first time it runs.
If I try to run the VI a 2nd time with a different value, the VI gets hung up in a loop, where it continues to see the previous setpoint.
As you can see above, the IV hangs in the the reading loop indefinitely after the first run. I want to say this is connected to the port used. I think the read VI is seeing information at the port from the previous process, but I am not sure how exactly to free it up. Any advice would be much appreciated.
Solved! Go to Solution.
05-01-2019 08:35 AM
05-01-2019 08:52 AM
Yes, it's still giving me the same behavior as before.
I have noticed that if stop I run the Write VI on its own, it seems to reset so the Write & Confirm VI runs like I expect.
05-01-2019 09:17 AM
So my next question is likely something that you're already confident is not true, but just to check the simple things: are you sure the expected value is (in the example) the current acceleration, and not the current setpoint for the acceleration?
As a side note, should I be looking at the LMD Modbus/TCP Protocol Implementation manual?
05-01-2019 10:43 AM
Good look. Turns out what I am reading out (10000 in Write and Confirm.vi) is the actual acceleration on the motor. And that the command to write the setpoint (20000) never went through. I checked this using the software from Schneider that came with the motors.
And that's the correct manual you're looking at.
05-01-2019 11:29 AM
I figured it out. It's not my best work, but I got something going. See below.
I added the for loop around the TCP Write.vi because running it twice seems the only reliable way of getting the command out. I'm still not entirely clear why this works.
Timing seems to have been another factor. I noticed that the VI ran better when I ran it with Highlight Execution enabled, so I added the 10ms wait to each loop. What I think was happening was that the VI was reading outputs before the motor had time to process the write command.