Below code is a part of my Arduino code
if (c == 't') {
Serial.println("Executing test move");
for (float ph = 0.0f; ph < 6.28318530718f * 50; ph += 0.63f) {
time = millis();
float pos_m0 = 1.0f * sin(ph);
odrive.SetCurrent(0, pos_m0);
// diplay serial monitor
odrive_serial << "r axis" << 0 << ".controller.input_torque"
Serial << odrive.readFloat() << '\t';
odrive_serial << "r axis" << 0 << ".motor.current_control.Iq_measured"
Serial << odrive.readFloat() * k << '\n'; // k is torque constant
}
}
Because for loop takes 2 ms in one cycle I adjust ph value and achive 10Hz.
However, motor does not rotate smoothly. (If “odrive_serial << ~” statement is commented out, motor rotate smoothly.)
What’s wrong with my program?
Thanks.