Hi Jim,
Sorry - my fault - wrong header - i should have said $OUTP,...
I'll add(put back) some human readable debugging stuff soon - the strings output are the data that the processing sketch read.
That would be the refresh rate, yes (it's in hz). There are 2 software timers which trigger the two lines individually. By the looks of it, you have no accel code running.
Find the commented out section at the bottom of the Accel() routine:
/*
ax_m = 0; // debug - these are the expected values from the accels.
ay_m = 0;
az_m = 1024;
*/
remove the comments, and comment out this:
ax_m = x_val; // assign the values to externally accessible variables
ay_m = y_val;
az_m = z_val;
This will fake the values from the accel and it should all begin to make a little more sense!
This will make the mixing work as the servo timings will start adding up to the correct values. The numbers in the $OUTP,... string should be within the range of 1000 and 2000.
Have a look for the SerialIO() routine, at the end of the routine there is something that will resemble this:
if (millis() - timer2 >= 300) {
timer2 = millis();
// Serial output
Serial.print("$SENS,"); Serial.print(int(rotationZ)); Serial.print(","); Serial.print(int(angleX57.2957795130823)); Serial.print(","); Serial.print(int(angleY57.2957795130823));Serial.print(",");Serial.print(az_m);Serial.print(","); Serial.print(int(refreshrate));Serial.println();
// Serial.print("Sensor data, ZGyro: "); Serial.print(int(rotationZ)); Serial.print(", Angle X: "); Serial.print(int(angleX57.2957795130823)); Serial.print(", AngleY: "); Serial.print(int(angleY57.2957795130823));Serial.print(", Z axis accel: ");Serial.print(az_m);Serial.print(", Refresh rate: "); Serial.print(int(refreshrate));Serial.println();
}
if (millis() - timer3 >= 300) {
timer3 = millis();
Serial.print("$OUTP,"); Serial.print(valueX+minPulse);Serial.print(","); Serial.print(valueY+minPulse); Serial.print(",");Serial.print(pitch); Serial.print(",");Serial.print(pulseThrottle); Serial.print(","); Serial.print(pulseTailRotor); Serial.println(",");
// Serial.print("Computed control output data, X control: "); Serial.print(valueX+minPulse);Serial.print(", Y control: "); Serial.print(valueY+minPulse); Serial.print(", Pitch: ");Serial.print(pitch); Serial.print(", Throttle: ");Serial.print(pulseThrottle); Serial.print(", Yaw: "); Serial.print(pulseTailRotor); Serial.println();
}
I've added some human readable lines to it, you can copy and past this to replace what's there and then comment out whichever statements you don't want printing.
I hope this sheds some light on the situation.
I might point out here that the values for X Y and Pitch being printed out are not sent to servos directly, they are computed in this form first, then the CCPM mixing takes place, making the servo outputs pretty meaningless in display terms (again i should mention the processing sketch - these are basically all the values I'd discovered I'd like to monitor)
Once you've got all the values in the $OUTP line to be in the correct 1000-2000 (microseconds) range you should see nice smooth servo motion, and correct mapping of the controls onto your CCPM heli.
If you have a mechanical mixing system on your heli (and your servos actually do provide pitch, X and Y as individual functions) then you could make a few changes to allow for the needed values to be sent to the right servos. You could effectively do away with the mixing altogether, and send the intermediate X Y and Pitch values to the servos. Please bear in mind that all the values from the intermediate X Y and pitch stage will need minPulse adding to them if you should want to (or need to) drive servos with those values.
I hope this hasn't added to the confusion. Please feel free to email me (using the address on my website) with code you are working on attached with your own comments/questions/suggestions and I'm happy to have a look.
Cheers,
Ed