[Servo controller range 0° to 180° with micromaestro]

Hi guys,

I’ve some problem with Micro Maestro and Arduino.

I use this routine to comunicate Micro to move my Servo in some position:

  byte serialBytes[4]; //Create the byte array object that will hold the communication packet.
 
   target = (map(target, 0, 180, 1000, 2000) * 4); //Map the target angle to the corresponding PWM pulse.
 
   serialBytes[0] = 0x84; // Command byte: Set Target.
   serialBytes[1] = ServoChannel; // First byte holds channel number.
   serialBytes[2] = target & 0x7F; // Second byte holds the lower 7 bits of target.
   serialBytes[3] = (target >> 7) & 0x7F; // Third byte holds the bits 7-13 of target.
 
   ServoController.write(serialBytes, sizeof(serialBytes)); //Write the byte array to the serial port.

The problem is that my servos does not reach 0° and 180° position, ie the extremes of servo.

I tryed to change values 1000 and 2000 but nothing happens.

What is the problem?

For greater precision add that the maestro status led is RED (I read code error with micro standalone application and the error is “Serial protocol error”). I think that is red because the baudrate 9600 that i choice to comunicate with my micro is to high.

I tryed to handle my servo directly with pin out of arduino and command “myservo.write(0)” and “myservo.write(180)” works perfectly.

thanks,

Daniele

Hello.

A baud rate of 9600 bps is a common serial communication speed for these types of electronics, and the Maestro can support baud rates up to 200,000 bps in fixed-baud mode or 115200 bps in autodetect-baud mode. The error you are getting might be caused by the initialization of the serial port; some serial ports can send junk data when starting up. If you click the “Clear Errors” button in the “Errors” tab of the Maestro Control Center after your program initializes, does the error happen again, or does it stay cleared? Are you doing a reset of the Maestro after initializing the serial communication? This might help to make sure the Maestro is receiving a clean signal.

Which serial mode do you have the Maestro set to? If you have it set to “UART, detect baud rate”, are you sending the required 0xAA byte to initialize the baud rate? If you are using the “UART, fixed baud rate” setting, make sure it is set to 9600.

The servo might not have a 180° range over the 1 to 2ms pulse range. You can test this by using the Maestro Control Center and extending the range if you need to, but be careful not to send it pulses beyond its operating range as this could damage the servo.

Also, I do not see a problem with how your serial bytes are formatted, but I am not sure what the mapping is for. Since it is not a complete code, it might have a good purpose, but I cannot tell what that might be from the code you posted. If none of the other steps has solved your issue, could you post a simple complete code that demonstrates the problem and describe your setup?

-Brandon

Hi Brandon,
thanks a lot for your response.

I solved both problems with your indication. :laughing:

I’ve only one doubt:

It seems that I can’t set micro maestro’s pinout, from arduino code, ie. in servo mode rather than input mode or output mode.
Must be set from maestro standalone application “Maestro control Center”. Do you confirm?

I am glad my suggestions helped.

All the commands for the Maestro’s serial interface are listed in the Maestro User’s Guide. You cannot change the mode of a channel (or any other persistent parameters on the Maestro) through serial commands. However, you could configure the channels in the Maestro Control Center beforehand, and they should remain configured this way when using serial communication.

-Brandon

Ok Brandon,

Thanks a lot :stuck_out_tongue: