Pololu Micro Maestro and Arduino YUN -> PROBLEM

Hi guy,

I’m very falling in crazy…I don’t know the problem…

In little world, I have my Arduino Yun version communicate with micro maestro which handle my two servo motors in the pan&tilt webcam.

Ok…follow the core sketch code:

YunClient client = server.accept(); if (client) { x = 0; y=0; x = client.parseInt(); //Leggi il primo valore client.read(); //Leggi / y = client.parseInt(); //Leggi il secondo valore maestro_set_target(0, y); maestro_set_target(1, x); client.stop(); }

where maestro_set_target is

void maestro_set_target(byte servoChannel, int angle){ //set the target for a servo //servo is the servo number (typically 0-5) //angle is the target, from 256 to 13120, in quarter-microseconds angle = (map(angle, 0, 180, MIN_SERVO_MILLIS, MAX_SERVO_MILLIS)*4); //Mappa il valore di "target" tra 500 e 2500 maestro_send_command(0x84, servoChannel, angle, 0); }

and maestro_send_command is

[code]void maestro_send_command(byte cmd, byte servoChannel, int target, byte device){

// id del device non utilizzato al momento

// sends a command with 3 byte of data
MAESTRO_START_TRANSMISSION();

serialBytes[0] = cmd; // Il primo byte contiene il Set Target --> move servo
serialBytes[1] = servoChannel; // Primo byte: indica su quale canale è in ascolto il servo
serialBytes[2] = target & 0x7F; // Secondo byte: selezione i 7 bit meno significativi di target (0-6)(LSB)
serialBytes[3] = (target >> 7) & 0x7F; // Terzo byte: prelevo i 7 bit pi√π significativi di target (7-13)(MSB)

MaestroSerial.write(serialBytes, sizeof(serialBytes)); //Scrivo l’array di byte su Maestro
MAESTRO_END_TRANSMISSION();
}[/code]

When I send command to servo from web trough java script canvas,

One of two servo (always the same) after same minute of use, fall in permanent block and does not move anyway…

It seems that the servo falling in block when I send it around 180 degree… but not always… :question: :question: :question: :question: :question: :question:

HELPPPPPPP MEEEE pLEASEEEEE

Hello.

Could you clarify what you mean when you say that the servo locks up when sending it to around 180 degrees, but not always? Can you describe what it is doing when it locks up and how often it happens? If your system allows for it, could you try swapping the channels on the Maestro that your servos are plugged into and seeing if the problem follows the servo or the channel?

Also, you might want to double check your “maestro_set_target” code when mapping the angle. I am not sure what your MIN_SERVO_MILLIS and MAX_SERVO_MILLIS values are, but your comments seem to contradict each other. If you wanted to map angle to values between 500 microseconds and 2500 microseconds, you should make sure that MIN_SERVO_MILLIS and MAX_SERVO_MILLIS are set to 500 and 2500 respectively (since you are multiplying the whole thing by 4). This would correspond to 2000 and 10000 in quarter-microseconds.

-Brandon