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.

Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

My motor receives data via a serial connection, but it won't move. What am I doing wrong?

Solved!
Go to solution

Hello everyone,

 

as the title says, I am trying to use a motor called "MP285" by Sutter Instruments via LabView. The control unit of this motor only has a RS232-output, but I use a Serial-to-Usb-Adapter to connect the device to the PC.

 

My problem is the following:

I tried to perform a basic Input/Output test by using the Ni MAX an sending ASCII strings to the control unit (after configuring it according to the reference manual), which worked fine. I also used the "jabber"-function of the control unit to send an output string to the PC and was also able to read that string from the buffer. Besides, when I used a LabView-VI to send a command via VISA Write, it also appears on the display of the control (at least the ASCII letters).

 Accordingly, I assume that the Serial-to-USB-adapter does work. Is that for sure, or can the adapter evoke any other problems?

 

However, when I try to use the shipped controlling software, the motor won't work. Furthermore, I contacted the customer support and they sent me some VIs and a LabView-Project, which was tested by the company. Unfortunately, it did not work for me. The motor wouldn't move, when I sent the command, although the LabView-interface indicates that there the connection between PC and controller has been established. As the program has many features and I only need a command to move the motor, read the position and set the origin, I tried to build my own VI. I had a look at some basic VIs for motor control and referred to the manual.

 

As it seems, the controller uses data streams of full bytes (8 bits, not ASCII) in Big Endian for its strings (I copied the information at the bottom of this text). Thus, I tried to concatenate particular strings to send it via VISA in the correct form (see attached). Do I have to convert the "m" into hexadecimal explcitly? I looked up "Convert ASCII to Hexadecimal", but when I try this, the output string does not change.

However, when I send this string to the controller in normal mode, nothing happens . When I activate the Input/Ouput test (see above), there is a m displayed on the controller unit. So I guess, I am messing up the command structure. Can anybody help me please?

 

Kind regards

 

 

PS: Sorry for cleaning up the diagramm..

 

PPS: For some reason, I could not attach the VI because " The contents of the attachment doesn't match its file type". So, I changed the name in "-vi" instead of ".vi" as suggested by a forum user. Hope this works for you!

 

 

Excerpt form the reference manual:

General Information:

"Command requests are single bytes followed by optional parameters and terminated by a
carriage return (CR, 0Dh). The data stream consists of full bytes (all 8 bits — not ASCII.
The lowest order byte (for example, of the four bytes encoding the X coordinate) is the first
into the controller and is the first out. The default Baud rate is 9600. Commands are
processed bytewise by interrupt and executed only after the terminating CR is received.
There are no delimiters within command strings. The controller will reply with carriage
return (CR, 0Dh) at the completion of normal command processing."

 

Command structure:

 

Get Current Position      command ‘c’CR 063h + 0Dh
                                           returns xxxxyyyyzzzzCR three signed long (32-bit) integers + 0Dh

 

Go To Position                 command ‘m’xxxxyyyyzzzzCR 06Dh + three signed long (32-bit) integers + 0Dh    
                                            returns CR 0Dh

 

 

Setting up for Serial Communication:

 

First, use the 9-pin serial port cable provided with the MP-285 to connect the “serial port” of
your computer to that of the MP-285 controller. Next configure your terminal emulator (e.g.,
HyperTerminal in Microsoft Windows (9X and above) to the following settings (or their
equivalent):
• TTY mode
• Echo typed characters locally only (do not echo input to the computer serial port back to
the controller)
• Baud rate to 9600
• 8 data bits, no parity, 1 stop bit
• COM port - set to the port to which you have connected the MP-285 controller

 

"

0 Kudos
Message 1 of 15
(6,137 Views)

Are you sure you are heading down the right path?  There are several things that will keep a motor from moving, most of them electrical.  You appear to have communications, so are you making the correct connections?  Is there some kind of enable input?

0 Kudos
Message 2 of 15
(6,121 Views)

You can control the motor via a hardware control,too. This works fine, so I assume that the motor is correctly connected to the control unit.

 

Your suggestion is good, I will have a look at the manual again. However, at the beginning of the chapter (Computer interface) it says:

"The controller is ready to accept remote serial input about one second after power-on."

 

There is no hint that you have to select an option to differntiate between direct hardware control and remote control. But maybe it is hidden and I did not find it yet.

 

Btw: Is my code for generating a Big endian command correct?

 

 

0 Kudos
Message 3 of 15
(6,108 Views)

After having a close look at the manipulator, controller and the manuals, I did not find anything to switch on an "computer-controlled mode". Except for going into the "move" mode, there seems to be nothing necessary for the movement of the manipulator..:/

Message 4 of 15
(6,060 Views)

Hi, 

if you say, it is working out of NI DAQmx via the panels after you made the correct settings, then you have to find out, where the difference between these settings and the settings you made in LabVIEW are. The easiest way to do this by the help of IO-Trace.

http://www.ni.com/download/ni-io-trace-14.0.1/4914/en/

Via IO Trace you can have allook how the driver communicates via RS232. Compare the result between LV and MAX. 

 

Furthermore I had a look at your source code. There seems to be a mistake. you can set the termination character via the driver or manually adding it to the string. you did both, so you will sent the termination character twice. Use the following node for checking your settings. You can also change the settings by writing to these  properties.

 prop node

Furthermore use IO Trace to find all the differences. I hope this helps!

 

 

Best Regards, Fabian

0 Kudos
Message 5 of 15
(6,054 Views)

The Enable Termination Character on the Configure Serial Port VI only enables the detection of an incoming termination character.  If you need to send one, either use the property node, or do just what you have been doing. You are not currenlty sending 2 termination characters.

 

I would separate your commands and queries.  Just send the command to move and see if that works.  Also, just query the position by itself.  Don't try to do all at once.

0 Kudos
Message 6 of 15
(6,045 Views)

Thank you for your feedback!

 

To make this clear: I dont know if the motor MOVES when sending the appropriate command via MAX. That is because I dont know how to enter the binary? command. I only tried to send some string like "dear moto please move" to see if this ASCII string can be displayed on the control unit while running the input-mode (which I described above).

 

This works for both, MAX and my Labview-Vi.

 

However, these are the I/O traces:

 

1. MAX: I sent the string: "Test"

 

NI I/O trace:

 

viWrite (ASRL25::INSTR (0x026B41E8), "Test", 4, 4) Process ID: 0x0000123C         Thread ID: 0x00001434 Start Time: 16:18:31.599       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

2. LabView-Vi (I removed everything that followed the first "Visa Write" and added the recommended property node to check if my termination char is correct). I sent string "TEST".

 

14.  viOpenDefaultRM (0x065171F0) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.918       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

15.  viParseRsrc (0x065171F0, "COM25", 4, 25) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.918       Call Duration 00:00:00.002 Status: 0 (VI_SUCCESS)

16.  VISA Set Attribute ("COM25", 0x3FFF001A, 3000) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.920       Call Duration 00:00:00.020 Status: 0 (VI_SUCCESS)

17.  VISA Set Attribute ("COM25", 0x3FFF0021, 1200) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.940       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

18.  VISA Set Attribute ("COM25", 0x3FFF0022, 😎 Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.940       Call Duration 00:00:00.001 Status: 0 (VI_SUCCESS)

19.  VISA Set Attribute ("COM25", 0x3FFF0024, 10) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.941       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

20.  VISA Set Attribute ("COM25", 0x3FFF0023, 0) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.941       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

21.  VISA Set Attribute ("COM25", 0x3FFF0038, 1) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.941       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

22.  VISA Set Attribute ("COM25", 0x3FFF0018, 13) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.941       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

23.  VISA Set Attribute ("COM25", 0x3FFF0025, 0) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.941       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

24.  VISA Set Attribute ("COM25", 0x3FFF00B3, 2) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.941       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

25.  VISA Get Attribute ("COM25", 0x3FFF0018, 13) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.941       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

26.  VISA Get Attribute ("COM25", 0x3FFF0038, True) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.941       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

27.  VISA Write ("COM25", "TEST", 4) Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.941       Call Duration 00:00:00.001 Status: 0 (VI_SUCCESS)

28.  VISA Close ("COM25") Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:24:34.942       Call Duration 00:00:00.110 Status: 0 (VI_SUCCESS)

 

Both strings are correctly displayed.

 

 

0 Kudos
Message 7 of 15
(6,009 Views)

The next thing I tried out was to send a simple move command, first using the simple input/output test-mode of the controller so that I can actually read on the display, which string is received by the controller.

 

There are to different display modes in the simple input/output test-mode: ASCII and decimal.

 

Here is, what happens when I send a move command with x=y=z=0. My VI creates the following string: 6D00 0000 0000 0000 0000 0000 000D 

 

Trace says:

13.  VISA Write ("COM25", "m.............", 14)Process ID: 0x0000154C         Thread ID: 0x00000678 Start Time: 16:32:38.915       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

In the properties of this string I found Buffer contents:

00000000: 6D 00 00 00 00 00 00 00      m . . . . . . .  (7 points)

00000008: 00 00 00 00 00 0D                  . . . . . . (6 points)

 

Accordingly, I assume that my VI sends the correct string.

 

However, the ASCII display of my controller only displays "m". If I use the decimal mode (which displays the 3-number ASCII codes for each character I type, the dispay shows:

109 000 000 000 000 000 000 000 000 000 000 000 000  013

 

109 seems to bem and 013 is the decimal for carriage return, so the controller received the correct string, didn't it?

 

I dont know how to type this string in the MAX environment, so I cannot post the outcome of that trial. If I simply copy the string (6D00 0000 0000 0000 0000 0000 000D) the trace shows:

 

1.  viWrite (ASRL25::INSTR (0x0E7CC1D8), "6D00 0000 0000 0000 0...", 35, 35) Process ID: 0x00001954         Thread ID: 0x00000E40 Start Time: 16:45:49.326       Call Duration 00:00:00.000 Status: 0 (VI_SUCCESS)

 

But I dont think that this is the right way.

 

When I use "10" for the "x" input (which then is multplied by 25, so actually I am sending "250"), the sent string is:

6D FA 00 00 00 00 00 00 00 00 00 00 00 0D

Thus, the Endianess seems to work, too. The decimal display now shows : 109 250 000 000 000 000 000 000 000 000 000 000 000  013.

 

 

After that, I exited the simple input/output test-mode (in which commands are only displayed, not executed) of the controller unit and sent the exact same string. The result: the motor does not move at all, but changes the position information one the display after a while..

 

Best wishes

 

 

 

 

 

EDIT: When I send the "Get position" command, I actually get the right position!

0 Kudos
Message 8 of 15
(6,007 Views)

Are you sure your motor isn't moving?  I think it is moving very slowly, or very little distance.

0 Kudos
Message 9 of 15
(6,001 Views)

Good idea! Indeed, if I listen closely to the motor, there seems to be a little noise after having sent a move command.

 

So I will try to set the movement speed to a distinct value. Maybe it is set to 0 for any reason. I had a similiar problem with another motor, which also movement very slow when controlled via Labview without adjusting the speed.

 

But I onc need your help. To set the velocity of the motor, a special string design is necessary. The manual says:

 

Change Velocity command ‘V’xxCR 056h + one unsigned short (16-bit) integer + 0Dh (Note: Uppercase ‘V’)

Note: The lower 15 bits (Bit 14 through 0) contain the velocity value. The high-order bit (Bit 15) is used to indicate the microstep-to-step resolution: 0 = 10, 1 = 50 uSteps/step.

 

How can I create such a string? I mean the V and CR are easy to add, but how do I build up the 16 bit integer? Can I create a numeric U16 like: 00 00 00 00 00 01 10 01 00 for setting the velocity to the value 100 and the resolution to 10 µSteps? What is meant with the "high-order" bit? Is it the most left or the most right bit? I am not so familiar with Endianess..

And if I want to set the velocity via a control: How can I build this string if the user only wants to enter "100" to set the speed?

 

Best wishes and thank you for your suggestion!

0 Kudos
Message 10 of 15
(5,982 Views)