Hi all!
This is almost ridiculous, but I have to ask for help.
Our robot is getting close to a point, where the Madam of the house is ready to consider it as member of a family. Well, new born child is smarter and cuter, but hey, beauty is in the eye of the beholder, right?
Anyway, here's the problem.
SD21 takes the value for the servo position in to bytes. I have tested that it works both ways, so the mathematic is probably right.
What happens, is that when I increase the value by one on each round, servo jumps MUCH TOO MUCH when the value goes from 1529 to 1530, an daround 1540-1544 it jumps back to where it actually should be. We have to controllers, same thing. Maybe firmware problem, maybe something that I can't see in this code.
Here is my old faithful test code, this time even shorter, but functioning.
EDIT. Corrected 255 to 256
#include <Wire.h>
#define SD21 0x61 //SD21 I2C Address, shifted by one bit from original 0xC2:sta
byte ServoHigh, ServoLow;
int Pos_ms=1400;
int ServoNro=0;
int Luku;
void setup()
{
Wire.begin();
Serial.begin(9600);
}
void loop()
{
Pos_ms=Pos_ms+1;
if (Pos_ms > 1600)
{
Pos_ms=1400;
}
ServoHigh = byte(Pos_ms / 256);
ServoLow = byte(Pos_ms - ServoHigh);
Wire.beginTransmission(SD21);
Wire.send(0); //Speed Servo 0
Wire.send(30);
Wire.endTransmission();
Wire.beginTransmission(SD21);
Wire.send(1); // Servo 0, Low Byte to Register 1
Wire.send(ServoLow);
Wire.endTransmission();
Wire.beginTransmission(SD21);
Wire.send(2); // Servo 0, High Byte to Register 2
Wire.send(ServoHigh);
Wire.endTransmission();
delay(100);
}
Electric is ok, Arduino only controls this module through I2C, controller's power is guarantee. But all servo channels do this.
Problem appears today when we started to fine tune arm positions, step by step incremental with the servo positioning.
As usual, any advice is welcome!
Thanks!
Cheers,
Kari