Serial Commands timing and Scripts

I am planing on using the Mini Maestro 18 to control an ROV. An arduino UNO reading info from a ps2 controller then sending down the commands through a tether.

When i tell the ROV to go forward one motor starts before the other, so the ROV go’s to the left a little bit each time. is there an easy fix to get a pair of motors to turn on and off at once?

Scripts i have not worked at scripts yet. Is it passable to run a script to close our gripper, then stop when a force sensor is tripped. And as we are running this script send serial commands to move round?

thanks for all the help

Because there exists many robots that go straight, then yes, it is possible to write software that starts motors at the same time.

Is it possible for your robot, with your controller? I don’t know. You’re only talking about the sending part (PS/2 + Arduino + Tether) not the receiving/controlling part, and it’s the receiving/controlling part that needs to be told to do things at the same time. What particular controller is on the other end of the tether? Exactly how are you sending the commands to that controller?

If you really can’t change the controller, and really can’t send the commands fast enough, then a “cheat” would be to send this sequence:

  1. Start left side at half speed.
  2. Start right side at full speed.
  3. Start left side at full speed.
    The time delays will end up canceling each other out, and the amount of drive on each side will end up being the same.

That being said: Are you sure that the reason it’s turning is the timing in the starting? Unless you have encoders on your motors or wheels, and your controller pays attention to those encoders, you will not get perfect match between the two driving sides.

Thats a good idea

i forgot to add in the servo controller so the path looks like
ps2>arduino uno> tether >Maestro Servo 18

the tether is just gnd, rx,tx

the code i am using is

      v = (100-abs(LX)) * (LY/100) + LY;
      w = (100-abs(LY)) * (LX/100) + LX;
      spd = (v + w) / 2 ;
      tur = (v - w) / 2 ;

      settarget(left_M, spd, speed_min, speed_max);
      settarget(right_M, tur, speed_min, speed_max);

void settarget(unsigned char servo, unsigned int target, int min_target = 2000, int max_target = 10800)
{
  target = map(target, -100, 100, min_target, max_target);
  mySerial.write(0xAA); //start byte
  mySerial.write(0x0C) ; //device id
  mySerial.write(0x04); //command number
  mySerial.write(servo); //servo number
  mySerial.write(target & 0x7F);
  mySerial.write((target >> 7) & 0x7F);
}

LX and LY are the left analog stick from the ps2 in a range from -100 to 100

I may need to move to the compact protocol. that might speed things up a little bit

any idea’s if i can run a script and send servo positions, with out waiting for the script to end?

Thanks for adding the information!

I haven’t used the Maestro, though, so you’d have to read the documentation for that to figure out how to set multiple servos at once. The higher your serial communications rate is, and the smaller each command is, the less delay there will be between the commands, and thus the faster the controller should be able to set the values – but I don’t know what it actually does.

Hello.

Switching to the compact protocol should have less of a significant effect on speed than selecting a higher baud rate. What baud rate are you using?

You do not have to wait for the script to end; you can send Set Target commands while it is running. You can also use the Set Multiple Targets command to simultaneously set the targets of a contiguous block of channels. More information about this command can be found under the Serial Servo Commands section of the Maestro’s user’s guide.

-Jon