New User Questions

I am a student at Auburn University and I’m working on a project that requires the use of servomotors. I have to admit that I have very little experience with robotics and electronics.

We purchased a USB 16-Servo Controller for the project. I was wondering if there are any tutorials on how to use the Pololu Serial Transmitter software that comes along with the hardware? I understand its a very simple request, but I am not sure where to even begin. Any help would be appreciated.

Hello.

You control the servo controller by sending it commands, which are sequences of bytes. The commands are covered in the manual. The simplest one is in the Mini SSC II mode (put on the blue shorting block), where you just send three bytes: 255, the servo number, and the servo position. To try that with the serial transmitter utility, put the three numbers in a 3-byte command row, push the button, and the three bytes will be set. For example, sending 255, 0, 0 will move servo 0 to one extreme, and sending 255, 0, 254 will move it to the other extreme (the 255 is a special byte that you can’t use for servo number or position).

- Jan

I used the 3-byte command, but now I am experiencing a different sort of problem. I can manually type in different positions (0-254) to send the motor, but sporadically receive a fatal error. Just by resetting the board and sending the same command, the motor responds properly. For instance, I had a servo attached to connection 15 and here are the results:

255 15 180 Success
255 15 100 Success
255 15 213 Success
255 15 72 Failure
UNPLUG
255 15 72 Success

That’s strange. What is your power setup?

- Jan

We are using a 6-Volt AC/DC converter running straight from the wall into the controller board. We also have a USB connection from the computer into the board.

Also, while I have your attention, I have seen some sample codes of C++ running the controller boards. The default programming language for our department is MatLab. Is it possible to use MatLab for the controller board or should find myself a C compiler?

If you’re using one of those “wall wart”-type converters, it’s probably not a good way to go. Do you have the same problem if you don’t connect servos and servo power?

It’s possible to use Matlab to control serial devices. There have been several posts on our forums about it; just do a search for Matlab, and I think you’ll see some relevant results.

- Jan

Here’s a simple example function to command a Pololu servo controller from Matlab:

function moveServo(s,x)
%moveServo(s,x) for Pololu serial servo controllers, using Pololu mode
%(remember to remove the blue mode-selection jumper!) absolute position
%command #4. You may need to edit the port variable in this file to match
%your com port.
%
%s=servo number
%x=absolute position, 500<=x<=5500

port = 'COM3';%Edit to your com port number

ser1 = serial(port);
set(ser1, 'InputBufferSize', 2048);
set(ser1, 'BaudRate', 9600);
set(ser1, 'DataBits', 8);
set(ser1, 'Parity', 'none');
set(ser1, 'StopBits', 1);

fopen(ser1);
fwrite(ser1, [128, 1, 4, s, binvec2dec(bitget(x,8:13)), binvec2dec(bitget(x,1:7))]);

fclose(ser1);
delete(ser1);

You can copy-paste the commands into the Matlab command line, or save it as a file called moveServo.m in a directory in your Matlab path and call it as a function.
You can also download the .m file here.

One thing to keep in mind when you’re sending lots of commands, you shouldn’t be opening and closing the serial port for each one. Open the serial port once, send all your commands, then close it when you’re all done!

-Adam

First off, I wanted to say thanks Jan and nexisnet for your responses. They have been very helpful and I appreciate the assistance you all are giving.

I went ahead an unplugged the AC/DC converter and the servo motor from the board. The only connection to the board is the USB cable. Unfortunately, I was getting the same results when running the board in SSC mode. I would type in a few commands that work, then a fatal error, then after resetting, the command that caused the fatal error would work. Eventually, another command would cause a failure.

Are you opening and closing the port for every command or otherwise changing settings on the port? Do you have the same problem with our serial transmitter utility?

- Jan

Up to this point I have only been playing around with the serial transmitter utility I downloaded from the pololu website. I haven’t been changing any settings in between tests. I’m only typing in and performing them one after the other with the utility.

I don’t think we’ve tried the utility with the USB servo controller, so we’ll give that a try and see if we can reproduce your problems.

- Jan