I have an Arduino based motor controller and it is working on a library based on Adafruit_MotorShield V2 version. Using that library, I am able to send below line to control the speed of the motor:
void setMotorSpeed(int spd);
In the above line, speed is set in PWM between -255 to 255. I wanted to get this working under simpleFOC as I saw it working on brushless motors and it was really smooth.
Any help on how to implement this?
Yes. Checked that link. However i am not able to understand how to use another library along with this to run the motors. Any slight hint would take it further
I don‘t think you can reasonably use both libs in parallel. Go for SFOC and program that function by yourself on top of it.
I understand how to do it, but not able to achieve that. The logic is I use simpleFOC DCDriver1PWM driver. When I am calling void DCDriver1PWM::setPwm(float U), I need to somehow call setMotorSpeed(spd) inside that which will route to Adafruit library. I will take care of Adafruit Library part and how to control speed from there, but SFOC is taking voltage, I am confused
You could write your own DCDriver class, and call the Adafruit one from he setPwm() method. You can convert the voltage to an integer in the range -255 to 255 if you know the driver.voltage_power_supply.
But this motor driver is using I2C control. I have never tried running the control loop via I2C output, it may be too slow. You can try it out and let us know