![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
robot
Diff: Calibration/Calibration.cpp
- Revision:
- 232:47f6cf4f9126
- Parent:
- 196:7172e6e28867
- Child:
- 239:09cd19ce7048
--- a/Calibration/Calibration.cpp Sat Nov 10 06:50:53 2018 +0000 +++ b/Calibration/Calibration.cpp Sat Nov 10 08:37:08 2018 +0000 @@ -9,6 +9,8 @@ #include "derived.h" #include "prefs.h" +#include "errors.h" + //output is in modulation depth void abc(float theta, float vd, float vq, float *a, float *b, float *c) { float valpha, vbeta; @@ -29,7 +31,12 @@ } void calibrate_position(IOStruct *io) { - io->pc->printf("%s\n", "Starting calibration procedure"); + if (!checks_passed()) { + io->pc->printf("%s\n", "Errors present, exiting"); + return; + } + io->pc->putc(127); + io->pc->printf("%s\n", "Calibrating..."); const int n = (int) (128); const int n2 = 10; @@ -74,7 +81,6 @@ //compensate for position rollover if (theta_actual - theta_last < -PI) rollover += 2 * PI; if (theta_actual - theta_last > PI) rollover -= 2 * PI; - io->pc->printf("%f,%f\n", theta_actual + rollover, theta_ref); theta_last = theta_actual; @@ -96,7 +102,6 @@ if (theta_actual - theta_last < -PI) rollover += 2 * PI; if (theta_actual - theta_last > PI) rollover -= 2 * PI; - io->pc->printf("%f,%f\n", theta_actual + rollover, theta_ref); theta_last = theta_actual; @@ -108,5 +113,8 @@ offset += (error_f[i] + error_b[n - 1 - i]) / (2.0f * n); } offset = fmodf(offset, 2 * PI); - io->pc->printf("Offset: %f\n", offset); + io->pc->printf("Done!\n"); + io->pc->printf("Offset = %f\n", -offset); + io->pc->printf("Use 'flush' to save this value to flash\n"); + _POS_OFFSET = -offset; } \ No newline at end of file