Building a 6DOF Joystick: Master/Slave test
Following from my earlier post I got all six servos converted. Now I have two Rotary Stewart Platforms next to each other on my desk. From the outside they look pretty similar. Inside I’ve converted one set of servos by removing the PCB inside and leaving the potentiometer.
I also removed one gear so that the potentiometers could turn freely. I call this one the Master and it’s going to be my joystick.
I read the sensors with this code.
[code language=”c”]void setup() {
Serial.begin(9600);
Serial.println("START");
}
void loop() {
int i;
for(i=0;i<6;++i) {
Serial.print(analogRead(A0+i));
Serial.print(‘\t’);
}
Serial.print(‘\n’);
delay(100);
}[/code]
When I read from the six sensors I get values like this.
[code language=”c”]379 416 488 600 396 632
269 320 355 708 347 654
273 294 309 756 348 631
338 326 311 770 348 595
396 370 381 740 348 581
445 418 580 580 380 598
428 417 644 525 471 562
429 408 532 608 540 486
410 394 394 694 543 446
447 415 349 725 497 456
424 408 276 821 372 570
357 379 352 776 320 675
224 294 438 705 321 721
93 183 337 787 321 710
131 165 244 859 320 685
297 248 163 930 320 618
351 302 177 926 320 617
364 335 332 814 321 648
359 351 553 623 360 672
306 324 609 584 434 641
306 316 589 592 532 538
319 317 501 654 531 530
429 381 484 662 531 486
500 444 581 595 535 473
580 513 711 478 655 362
609 554 738 450 707 305
619 581 747 447 707 292
618 594 744 452 707 287
604 596 729 474 708 302
592 590 722 477 706 313
588 584 728 478 708 316
589 580 727 478 706 328
589 567 725 479 708 329
590 554 727 478 706 328
588 554 728 479 708 329
589 563 727 478 706 328[/code]
Then I convert those values to PWM signals and send them back out to the second set of servos, the Slave. The physical relationship is 1:1. The wiring is slightly backwards – the pin numbers run the other way on the far side of the Arduino so I put servo 1 in digital pin 7, servo 2 in pin 8, and so on.
I’m finding as I test this that the inputs and the outputs don’t match 100%. They’re very close but in some cases input moves 90 degrees and the matching output only moves 75. A configurable scale (*k) and constant (+c) adjustment for each input should take care of that.
Tonight I read How to make an UNO appear as a joystick to your computer and Wednesday I will give it a shot. With a little luck I can get this working and play Kerbal Space Program better. I have never successfully achieved an Orbital Rendezvous and it fills me with horrible, horrible nerd shame. I’m also going to 3D print a grip so it feels more like a traditional joystick. Minecraft and Descent are also good candidate games. Animatronics, too.
Mondays are supposed to be improve the site day but for the next two days I’m shipping orders, 3D printing, and getting ready to show off the Makelangelo at Grandview Elementary right here in Vancouver.