From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Motion Controller Through Serial

Solved!
Go to solution

Hello, 

 

I want to use labview to design user interface for controlling 3 axis motor. I have newmark NSC M3 E series motion controller and linear stage. 

When I use the company's software terminal, after giving the commands, the motor can successfully move, but when I give the commands in labview, it seems the commands written to the buffer cannot be read successfully. I attached my code screenshot, hope someone can give me some advice. 

3axis_motor.JPG

Thanks

0 Kudos
Message 1 of 16
(3,173 Views)

Hi.

I am a beginner as well however I would look at some of the VISA examples in labVIEW,If I had to do what you need to do !

You do  not need so many Visa writes I am quite sure about that.

I would think that you 

(1) Open Visa

(2) collect you're commands in a logical order the Controller needs then Write the string of commands to the Controller 

(3) loop through the sequence until you want to quit the program then Close the VISA resource and with a error dialog at the end of this Open ,Write,Close order of the VISA Vi's 

 

 

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 2 of 16
(3,143 Views)

When you have a new device, always "play with it" using MAX first, as you can get immediate feedback on how your device works.

 

There is not much information on the Web about your device, but it appears that it may be expecting a "terminated" command line (I would use <CR><LF> at the end of your command strings).  Do not use Bytes at Port -- that is the (incorrect) command to use when reading from the Serial Port (but, again, it is almost always wrong to use it).

 

Try sending commands terminated with your selected Termination Character (again, I recommend <LF>, 0x0A), then read and see if there is anything that it returns.  Once you see that you can communicate with your device, write appropriate LabVIEW code to duplicate what you did with MAX.

 

Bob Schor

0 Kudos
Message 3 of 16
(3,139 Views)

Disclaimer: I never used one of these controllers before. I downloaded a users manual from the website and quickly looked thru it. I don't know if it is the correct manual for your device, but all the commands you've used are in there. I'm pretty much guessing, but here are my suggestions:

 

1. For commands with only two ASCII characters (case-insensitive), you do not need a termination. If the command requires an operand (i.e. command followed by a number) then a termination character IS REQUIRED. The termination character can be a space, carriage return, or semi-colon. The manual recommends using the semi-colon to terminate ALL commands. So the correct syntax of your commands would be

 

az;uu629.921;
MR-10;GO;

 

EDIT: Your original command has a space between MR-10 and GO. So technically it will work since "space" is a valid terminator. One of the reasons the users manual recommends using the semi-colon is to "improve readability"

 

2. The command ?uu is a query. You need to put a VISA Read after that command

 

3. As others have said, GET RID OF BYTES AT PORT!!! All responses back from the controller use a <LF> as the termination character. You already wired a "TRUE" to the VISA Configuration Serial Port to enable the termination character (default char is <LF>). Use it. Remove the Bytes at port and instead wire a constant to the VISA Read terminal with a large number of bytes to read. Something like 1000.

 

4. Why do you have a read inside the loop to begin with? According to the manual, none of the commands (VL, AC, MR, GO) send back a response. If your intent is to see if the positioner is finished moving, then you need to look at the "Done Flag" using the QA, or QI command (just guessing) and read the response for the status register.

 

5. Minor point: Since your velocity and Acceleration never changes, the VL and AC commands would be better outside the loop.

0 Kudos
Message 4 of 16
(3,120 Views)

Hello guys, 

 

I made some modification on the code, again the read buffer still cannot read anything. I give the command uu629.921, and if I give ?uu, the read buffer should show 629.921 right? but it's not. And according to the motor movement, it can be seen that the uu629.921 doesn't right to the controller. why would that happen? I attached my VI, if you have any ideas please do the modify on my VI. 

 

Thanks

0 Kudos
Message 5 of 16
(3,102 Views)

For the vi I attached, I don't know if I put the <LF> that you guys mentioned to the right place or not...Anyway, if I delete the <MF>, the code still does not work well.

 

Also, one more thing, some part of the code can work, like I can choose the x axis to move. however, the UU defines the step size, it does not work.  

0 Kudos
Message 6 of 16
(3,100 Views)

Update

 

Now the UU has been written to the system, this is good, however, I still could not read the ?UU successfully. 

0 Kudos
Message 7 of 16
(3,098 Views)

@zyb1003 wrote:

Update

 

Now the UU has been written to the system, this is good, however, I still could not read the ?UU successfully. 


1. <LF> is the abbreviation for Line Feed. Don't use that. Depending how you are displaying the command string, use the hex value 0A or the escape sequence \n    EDIT: don't use <LF> at all in the command.

 

2. According to the manual, the Line Feed is for terminating VISA Reads. The semi-colon is used to terminate the Write commands

 

I cleaned up your VI, and corrected the ?uu command termination. Try it and let me know how it works.

0 Kudos
Message 8 of 16
(3,093 Views)

also I find the return count ouput is alway 1. 

0 Kudos
Message 9 of 16
(3,092 Views)

Hello Jamiva, 

 

I tried your vi and the read buffer still does not show anything

0 Kudos
Message 10 of 16
(3,088 Views)