Hey everyone, thanks for this great library, and I look forward to contributing.
I am working with some brushless and brushed DC motors and would like to leverage the SimpleFOC ecosystem to control both and integrate with ROS. Right now, my issue relates to the closed loop brushed DC motor control using the Simple FOC DC motor library (GitHub - simplefoc/Arduino-FOC-dcmotor: Control DC motors using SimpleFOC's infrastructure). I want to use it to control a brushed motor through an RC ESC’s PWM from my microcontroller. I have a rotary quadrature encoder and an AS5047P magnetic encoder to use, but I would first like to test in open-loop mode. The library references this kind of setup here (Arduino-FOC-dcmotor/src/drivers at main · simplefoc/Arduino-FOC-dcmotor · GitHub), with the DCDriver1PWM driver to control both speed and direction, which is common for Servos and RC ESCs. However, I am having difficulties setting this up. My ESC operates at 50Hz PWM frequency with 1000 microseconds being full reverse and 2000 microseconds signaling full forward throttle with 1500 microseconds being the neutral point (called threshold) in the library. The input voltage to the ESC/motor is about 6 volts. I should also note that I am able to control the motors using the standard Arduino IDE Servo library (e.g. using Servo.write(0-180 degrees) or Servo.writeMicroseconds(1000-2000)). I have a Raspberry Pi Pico, Teensy 4.1, and Arduino Mega 2560 for testing. My questions are as follows:
- Is it possible to use the library/Simple FOC with my setup?
- If so, how can I set this up as the documentation does not specify units, e.g. for threshold, setPwm function, etc?
- How does the library write to the DCDriver1PWM driver? Using <Servo.h> or analogWrite?
- What are the expected values for the setPwm function?
If all else works, then I will try the other control methods. Thanks for your help.