We use: two gimbal SparkFun 12V 3-Phase BLDC motors with encoders AS5048A Gimbal Motor with Encoder - 12V, 467RPM - SparkFun Electronics ; two SparkFun 3-Phase Brushless TMC6300 motor-drivers; one SparkFun Artemis RedBoard ATP microcontroller board; one Lipo 7.4V 5200 mAh battery.
We need to write a code to control the motors. I found out that this example position PID-control code Position Control example | Arduino-FOC can be edited to match our project. However, there are some issues. One of them is that target_angle is the zero speed point as far as I can see. That is, the rotor stops and is held at a target angle. We need to accelerate the rotors until they reach a target angle. Right after the rotors pass a target angle, they have to coast or to continue to move at a low speed. Could someone please tell how to make target_angle as the non-zero speed point? Thank you.
You can accomplish this in a lot of different ways, I think the easiest is to combine the angle control and velocity control examples into one code that combines their use (angle until it is reached, velocity can have it spin at a speed for x seconds and then switch back to angle control and loop
Thank you, TS-Russell. We use motor.controller = MotionControlType::angle . I think how the PID-control code executes is the following. Say, target_angle is set as 180 degrees or pi (in radians because the code defines speed in radians per second). The function motor.velocity_limit= sets a maximal velocity during the 180-degree distance. Therefore, the PID-control code corrects the rotor’s motion so that the rotor moves for the 180-degree distance and stops exactly at the 180th degree without overshooting or undershooting.
The function motor.move() uses target_angle as its argument, not a velocity value. Hence, motor.move(0.5) means that the rotor moves for the 0.5-radian distance at the max speed set by the function motor.velocity_limit = . Therefore, the rotor should be stopped and held at the 0.5th angle. As a result, it is unclear how to make the rotor coast or decrease its speed (without being held) right after the rotor passes target_angle = 0.5 ? If I mistake something, please let me know.