Trouble porting from MiniSSC to Compact

Hi

I have a programm written in processing that controlls servos via a 6 channel micro maestro.
Now I want the servos to move as exact as possible so I figured using the compact protocoll would be better than MiniSSC (higher resolution right ?).

While my servos move with the minissc method you see in my code the compact method doesn’t work at all. It also raises a Serial Error on my maestro and lights up the red light.

void minissc()
{
   size(512, 512);
   myPort = new Serial(this, "COM3", 115200); //max 115.2 kbps for Serial mode: Dual-port
   myPort.write(0xFF);
   myPort.write(0xFF);
   myPort.write(0x00);
   myPort.write(125); //x-servo
   myPort.write(0xFF);
   myPort.write(0x01);
   myPort.write(125); //y-servo
}

void compact()
{
   size(512, 512);
   myPort = new Serial(this, "COM3", 115200); //max 115.2 kbps for Serial mode: Dual-port
   myPort.write(binary(10000100));
   myPort.write(binary(00000001));
   myPort.write(binary(01110000));
   myPort.write(binary(00101110));
}

Any ideas what I’m doing wrong ?

Hello.

What serial error are you getting? There is more than one. In a lot of languages, “01110000” is interpreted as octal because it starts with the number 0, and this could cause problems. The documentation of the binary function is available, and it looks like you are using it wrong. I recommend using hex instead of trying to use binary, just like the Mini SSC code you have that is working.

–David

Thank you for your fast response!

You are right of course. In the code I’ve posted binary() is used wrong. Binary usually converts something into binary which is what I’m doing in my “production code”. I’ve tried to simplify the example for the forum and forgot to remove the binary() - sry about that.

I’ll give hex a shot and if that doesn’t work I’ll come back with the exact error message.