Strange position 1280 -> 1407

Hello,

I have some problems with the absolute servo position (command 4) in pololu mode.

I made a loop that would set the position (valid values from 500 to 5500) starting from a minimum and then slowly incrementing the value position.
When I hit the value 1280 (data1 = 10 and data2 = 0) the servo positioned itself in a position much higher than anticipated. Then incrementing the value through 1280 until 1407 doesn’t move the servo position.

However, from the value 1408 (data1 = 11 and data2 = 0) the servo positions itself perfectly until I reach it’s upper maximum level.

Has anyone experienced anything similar or have any clues as to what might cause this behaviour?

I have 2 identical servos that behaves exactly the same way. Using Mini SSC mode there is no strange positioning behaviour so I doubt it’s a mechanical error.

I have attached the code I use to generate the data stream.

stringstream ss;
ss << (unsigned char)0x80 << (unsigned char)0x01 << (unsigned char)0x04 << (unsigned char)servo << (unsigned char)(pos/128) << (unsigned char)(pos%128);

string st = ss.str();
write(s->fd, st.c_str(), 6);

Best,
Morten

Hello, Morten,

Is the servo happy below position 1280? Perhaps it just can’t go past 1408, and sending it lower positions causes it to try but fail at moving any farther. However, that would be quite a coincidence for the servo limit to match the 7-bit zone you’re describing. We’ve seen a few similar claims before, but it always turned out to be the user code or system. Do you have access to an oscilloscope or another way to look at the actual serial data being sent?

- Jan

Hi Jan,

Thanks for your reply. Yes, the servos are quite happy from absolute position 800 to 4500 other than the 1208 - 1407 values. Unfortunately, I don’t have an oscilliscope, but I will just list the code I use for connecting to the port. I am right now double-checking that I setup the port correctly. When I write the command values to the screen they are perfect and shouldn’t cause the mis-position.
Is there any other way I can help you with information?

Here’s how I connect to the port.

struct termios options;

this->fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY);

if (this->fd == -1)
	return 0;
else
	fcntl(this->fd, F_SETFL, 0);

tcgetattr(this->fd, &options);

cfsetispeed(&options, B19200);
cfsetospeed(&options, B19200);

options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~PARENB; // No parity
options.c_cflag &= ~CSTOPB; //clears the bits which cause a 2 bit stop width
options.c_cflag &= ~CSIZE; //clear bits which determine data length
options.c_cflag |= CS8; //8bit data

// set all of the options
tcsetattr(this->fd, TCSANOW, &options);

By the way, here is one of those previous similar discussions; unfortunately, we don’t know if it got resolved:

Can you try using our serial transmitter utility to manually send out the byte sequences that are giving you trouble?

- Jan