Being told I'm wrong is such a lovely thing to hear.
The fact of the matter is: despite some of my mis-wording, I'm not.
I don't post my entire code anymore because everyone always gets hung up on the stupid little details.
Sending 1 properly constructed servo move example results in a proper servo movement.
Sending a block of properly (manually) constructed moves, results in proper movement
Sending a
(for int i=0; int i<12;I++){ // this is purely made-up example code
ServoMove(i,PWM);
}
ServoExecute;
results in wildly unpredictable movements, if I send it twice or three times, the servos sometimes move properly.
My clones don't use the same IDE, so therefore they are IDE dependent.
Okay (and I, for your enjoyment, will include my entire length of unmodified code)
To Recap:
#1 The amount data sent over my TX lines seems to directly influence the amount of "Glitching" that my servo controller applies. No it's not my code, that I can assure you is sound. The only variable in the equation is the MULTI line vs PREFAB line of code I send.
#2 My clones have different IDE's, are different boards altogether, and are in no way, shape, or form library compatible.
Honestly coming to the forums is always my last resort. You guys always seem to find a way to point a finger or tell me how I'm an idiot. I don't come claiming to be a genius in English or Coding.
Is it possible to keep this thread going instead of getting hung up on the details and killing it?
CONCATENATION is my issue.
This is my main file, I don't know if It still works, but it contained the gist of my code
// ONYX
// __
//Rear Right:4 | |SC| |Rear Left:2
// |___|32|___|
// ||
// __|wMPU|__
// | |
//Front Right:3| |Front Left:1
//
//Servo Groups:
// Group Name (HIP,KNEE,ANKLE):GROUP #
// Front Left (0,1,2):1
// Rear Left (12,13,14):2
// Front Right (16,17,18):3
// Rear Right (28,29,30):4
//---Servos: 12 x HS-5645MG (~750us - ~2200us)------
int ServoList[12] = {0, 1, 2, 12, 13, 14, 16, 17, 18, 28, 29, 30};
int ServoCenters[12] = {1800, 1900, 1250, 1200, 1100, 1750, 1200, 1100, 1750, 1800, 1900, 1250};
int ServoCenterPM[12] = {667, 80, 633, 400, 0, 310, 640, 0, 310, 429, 0, 344};
int Servo_IN_DOWN_Limit[12] = {1000, 2000, 2200, 1500, 1100, 2200, 2000, 1100, 2200, 1500, 1900, 750};
int Servo_OUT_UP_Limit[12] = {2200, 750, 700, 750, 200, 750, 750, 2200, 750, 2200, 750, 2200};
int ServoGroup[12] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4,};
int InversionBit[12] = {0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,}; //If 1: Counts from 2200 down to 750 (Inverted) ||| If 0: Counts from 750 up to 2200 (Non-Inverted)
//Limits:
// # (OUT/UP, IN/DOWN) (CENTER)
// 0 (O2200, I1000) (1800)
// 1 (U750, D2000) (1900)-
// 2 (U700, D2200) (1250)
// 12 (O750, I1500) (1200)
// 13 (U2200, D1100) (1100)-
// 14 (U750, D2200) (1750)
// 16 (O750, I2000) (1200)
// 17 (U2200, D1100) (1100)-
// 18 (U750, D2200) (1750)
// 28 (O2200, I1500) (1800)
// 29 (U750, D1900) (1900)-
// 30 (U2200, D750) (1250)
//Modes (Set in initialize function):
//1 --- Autonomous
//2 --- Single Servo Control (Cycle Servos)
//3 --- Inverse Kinematic Leg Test (Cycle Legs)
#include "math.h"
const float pi = 3.14159;
int pm = 500;
void setup() {
initialize(1, 9600);
}
void loop() {
raiseLeg(1,1,1);
}
void initialize(int mode, int baud){ //takes mode # and communication baud rate to begin and control following movements
Serial.begin(baud);
if(mode == 1){
for(int i = 0; i < 12; i++){
groupSet(ServoList[i], ServoCenters[i]);
groupMove(100);
}
delay(1000);
}
}
void raiseLeg(int group,int factor, int cor){ //Raises and lowers legs, takes group number, rasies it by a factor(255-full down---->0-full rasied, can be used to control single group(cor=0) or the corresponding walking group(cor=1)
}
pulsetoPermille(int pulse,int pin){
int maxLimit = Servo_OUT_UP_Limit[pin];
int minLimit = Servo_IN_DOWN_Limit[pin];
return((-1000*pulse-minLimit)/(minLimit-maxLimit));
}
void servoMove(int pin, int permille, int final){
int center = ServoCenters[pin];
int maxLimit = Servo_OUT_UP_Limit[pin];
int minLimit = Servo_IN_DOWN_Limit[pin];
int group = ServoGroup[pin];
int invert = InversionBit[pin];
float Pulse;
if(permille>1000)pm=1000;
if(permille<0)pm=0;
Pulse = ((minLimit-maxLimit)/(0-1000)*permille) + minLimit;
Serial.print("#");
Serial.print(pin);
Serial.print(" P");
Serial.print(Pulse);
if(final==1){
Serial.print(" T");
Serial.println(100);
delay(100);
}
}
void groupSet(int servo, int position) { //Sets servo group move values, but does not execute the move; use groupMove to execute synced move
Serial.print("#");
Serial.print(servo);
Serial.print(" P");
Serial.print(position);
}
void groupMove(int time){ //Execute group move set by groupSet
Serial.print(" T");
Serial.println(time);
delay(time);
}
void IK(float x, float y, float l1, float l2){ //Inverse Kinematic equation
float c2, s2, k1, k2;
c2=(x*x+y*y-l1*l1-l2*l2)/(2*l1*l2);
s2=sqrt(1-c2*c2);
k1=l1+l2*c2;
k2=l2*s2;
float theta1=atan2(y,x)-atan2(k2,k1);
float theta2=atan2(s2,c2);
float deg1=theta1*180/pi; //conversion to degrees using new variable
float deg2=theta2*180/pi;
Serial.println(" ");
Serial.println(" ");
Serial.println(" ");
Serial.print("T1=");
Serial.println(theta1);
Serial.print("Deg1=");
Serial.println(deg1);
Serial.print("T2=");
Serial.println(theta2);
Serial.print("Deg2=");
Serial.println(deg2);
}
ONYX_Control_ManualSerial_Dudenofuckingclue.pde (4.23 KB)