servo alignment / calibration

sparki.servo(SERVO_CENTER) doesn’t align the eyes plane with sparki’s front plane, but rather at a 5-10 degree angle. I tried to unscrew it and rotate manually, but the assembly uses tiny gears, so I can get either 5-10 degrees off to the left or 5-10 degrees off to the right, but no alignment.

Since the alignment is off, 180 degree sweeps will make the eyes hit the display and using the angles to drive the wheels needs manual calibration in code. I now have to manually patch every piece of code that relies on servo angle, which is super annoying. Is there a way to calibrate the servo in the firmware such that I get the alignment right on boot?

PS. Where is the full sparki spec? I want to print the servo angles on the screen, but I’m at a loss where to start.

The Sparki.h file starts with this code:

#ifndef Sparki_h
#define Sparki_h

#include “Arduino.h”
#include “Print.h”

#define SHIFTREG_LATCH TXLED0 // PD5
#define STATUS_LED 13
#define BUZZER 11 // PB7
#define ULTRASONIC_ECHO 5 // PC6
#define ULTRASONIC_TRIG 10 // PB6
#define IR_RECEIVE 7 // PE6
#define IR_SEND 6 // PD7

#define SERVO 9 //
#define SERVO_LEFT -90
#define SERVO_CENTER 0
#define SERVO_RIGHT 90

I’d imaging that that you can set the centre calibration on the 2nd last line. (ex-> 3 or -4 instead of 0…should equate to +3 or -4 degrees correction). Haven’t checked it though.

That’s a good pointer, but insufficient. One needs to make sparki.servo() aware of the calibration factor, such that programatic requests for angles other than SERVO_CENTER do the right thing instead of being misaligned by a few degrees.

Fair point.

Has anyone come up with a proper fix for this issue. My Sparki arrived with the same problem. The “eyes” are not lined up when centered with the front reference plane of the robot.