cesarvandevelde / HerkulexServo

An Arduino library for communicating with Herkulex smart servos.
https://cesarvandevelde.gitbooks.io/herkulexservo/
MIT License
7 stars 1 forks source link

Compatibility with DRS-0602 #3

Open ckiw opened 2 years ago

ckiw commented 2 years ago

Hello,

Do you know if your lib is compatible with DRS-0602 type of servos even for simple commands ?

(I have one off them but I didn't get it to work for the moment)

Thanks, Alexis

cesarvandevelde commented 2 years ago

I took a quick look; the command set and the registers look very similar. I'd start by verifying the packet structure and the opcode values against the information from the datasheet. Also, it's best to start with a hardware serial port. Software serial is less stable at higher baud rates, iirc. A decent logic analyzer is worth its weight in gold for stuff like this...

ckiw commented 2 years ago

Thanks a lot

I'm using a arduino mega so I tried with both Hard and Soft Serial. It has previously been used and don't know the ID or the baudrate saved inside. It's a brain teaser.

Good idea for the logic analyzer ! (an espotek labrador, I don't know if it will be sufficent) I give you infos if I get something so you can update the doc

Alexis

cesarvandevelde commented 2 years ago

Just about any logic analyzer should be fine, the UART bus is relatively low speed. It will tell you (1) if packets are being sent correctly and (2) if there's a response from the servo.

It's best to start by getting the STAT command to work. Other commands may not respond with an ACK if the ACK policy register has been modified:

Request Herkulex Servo status r(Status Error, Status Datail) Always send reply to STAT Packet regardless of r(ACK Policy)

There are 8 possible values for baud rate and 253 possible servo IDs, so you could try to brute-force it...

ckiw commented 2 years ago

Hello,

After many hours (and your precious help, stat cmd + logic analyser). I finaly succeeded

I made a connection error by linking tx to tx and rx to rx. I was solved quickly.

The real burden was for position. The 0602 can go from 10627 to 22129 (by default) image (opposed to 21 to 1002 for the 0101) So any exemple fail (from the arduino libs), even to ones from the manual are wrong because they are copy-pasted from the 0101 doc. So I had only errors even by sending byte per byte the JOG commands from the manual. 🤷‍♂️ I tried to modify the bytes 8 and 9 and I got some mouvement. Finally I understood I needed bigger numbers and I realised why !

By using correct position values it worked like a charm, all the fonctions are the same. I'd like to add an exemple for 0602 in the lib examples

As far as I know, the only difference in the protocol is for the VOR fonction (velocity overide) page 41

Alexis

cesarvandevelde commented 2 years ago

That's great to hear! I'd be happy to merge your example for the 0602. I'm also open to improving the library to cover the entire Herkulex family, but that will require some thought. The following (potential) issues come to mind:

ckiw commented 2 years ago

Hello,

HerkulexServo servo_a(herkulex_bus, 10, DRS-0602); HerkulexServo servo_b(herkulex_bus, 11, DRS-0101);

and then behind the scene make the conversion. The resolution for the 0602 is image