Hi all,
For my next project I’d like to vary the torque of a motor based on its position, effectively turning the motor in to a spring with a variable / tunable spring rate.
I’m thinking a simple control loop that sets torque based on motor position would do the trick.
My question is can I read motor position from the simple foc library in the main loop of my Arduino code? If so how would it be achieved?
Any constructive thoughts would be much appreciated.
I would probably start by reading the SimpleFOC documentation here:
void loop() {
// IMPORTANT - call as frequently as possible
// update the sensor values
sensor.update();
// display the angle and the angular velocity to the terminal
Serial.print(sensor.getAngle());
Serial.print("\t");
Serial.println(sensor.getVelocity());
}
you may also find some interest in “haptic textures”, there are a few threads on this board discussing this. In those case they are using angle error with a separate control loop to create variable stiffness and software-defined detents. some of the code from those projects is usable for your purpose and may prove a nice set of examples to learn from.