Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Calibration/calibration.cpp
- Revision:
- 55:5afc2865ef7f
- Parent:
- 47:e1196a851f76
- Child:
- 57:57a108e15b52
diff -r 8e76a8727f92 -r 5afc2865ef7f Calibration/calibration.cpp --- a/Calibration/calibration.cpp Fri Feb 19 22:40:19 2021 -0800 +++ b/Calibration/calibration.cpp Thu Feb 25 21:53:26 2021 -0800 @@ -89,6 +89,7 @@ error_f = new float[n](); // error vector rotating forwards error_b = new float[n](); // error vector rotating backwards const int n_lut = 128; + constexpr size_t lut_size = sizeof(int) * n_lut; lut = new int[n_lut](); // clear any old lookup table before starting. error = new float[n](); @@ -227,12 +228,12 @@ } lut[ind] = (int) ((error_filt[i*NPP] - mean)*(float)(ps->GetCPR())/(2.0f*PI)); printf("%d %d %d \n\r", i, ind, lut[ind]); - wait(.001); + ThisThread::sleep_for(1ms); } ps->WriteLUT(lut); // write lookup table to position sensor object //memcpy(controller->cogging, cogging_current, sizeof(controller->cogging)); //compensation doesn't actually work yet.... - memcpy(&ENCODER_LUT, lut, sizeof(lut)); // copy the lookup table to the flash array + memcpy(&ENCODER_LUT, lut, lut_size); // copy the lookup table to the flash array printf("\n\rEncoder Electrical Offset (rad) %f\n\r", offset); if (!prefs->ready()) prefs->open();