I am using mini-maestro12 in C language.
We are calling speed, acceleration and position continuously without delay, so I want to know if there is a problem with this.
Sometimes the command does not run under certain circumstances, so we are checking to see if it is a maestro issue.
The interval is about 50ms - 1000ms.
pololu protocol
example>
...
SetSpeed(fd, channel, atoi(argv[3]));
SetAcceleration(fd, channel, atoi(argv[4]));
SetTarget(fd, channel, (atoi(argv[5]) + 1500) * 4);
...
int SetTarget(int fd, unsigned char channel, unsigned short target)
{
#ifdef DBG
printf ("Entering the SetTarget channel:%d target: %d\n", channel, target);
#endif
if(target < 2560 target > 9216) // 640 * 4 = 2560, 2304 * 4 = 9216
{
printf("Error > Target value should be 640-2304 microseconds, was: %d\n", target);
return 0;
}
if(channel < 0 channel > 9){
printf("Error > Channel value should be 0-9, was: %d\n", channel);
return 0;
}
unsigned char command[] = {0x84, channel, target & 0x7F, target >> 7 & 0x7F};
if (write(fd, command, sizeof(command)) == -1)
{
perror("error writing");
return -1;
}
return 0;
}
int SetSpeed(int fd, unsigned char channel, unsigned short speed)
{
#ifdef DBG
printf ("Entering the SetSpeed channel:%d speed: %d\n", channel, speed);
#endif
if (speed < 0 speed > 255)
{
printf("Error > speed value should be 0-255, was:%d\n", speed);
return 0;
}
if(channel < 0 channel > 9){
printf("Error > Channel value should be 0-9, was: %d\n", channel);
return 0;
}
unsigned char command[] = {0x87, channel, speed & 0x7F, speed >> 7 & 0x7F};
if (write(fd, command, sizeof(command)) == -1)
{
perror("error writing");
return -1;
}
return 0;
}
int SetAcceleration(int fd, unsigned char channel, unsigned short value)
{
#ifdef DBG
printf ("Entering the SetAcceleration channel:%d value: %d\n", channel, value);
#endif
if (value < 0 value > 255)
{
printf("Error > Acceleration value should be 0-255, was:%d\n", value);
return 0;
}
if(channel < 0 channel > 9){
printf("Error > Channel value should be 0-9, was: %d\n", channel);
return 0;
}
unsigned char command[] = {0x89, channel, value & 0x7F, value >> 7 & 0x7F};
if (write(fd, command, sizeof(command)) == -1)
{
perror("error writing");
return -1;
}
return 0;
}