Electronic – Brushless motor control poisition (design own PID?)

brushless-dc-motorpid controllerrobotrobotics

I got a few motor similar to the image below from a old scanner and I want to apply them in a robotic arm to move the arm because BLDC motors have a large torque I then control with arduino. Well, in order to do that I came across that maybe I would need to control their position moving at 60 rpm would be a reasonable speed (PID controller right?). Also the specification of a similar motor is at the link below to more informations.
https://www.nidec.com/en/product/search/category/B101/M102/S100/NCJ-42M-FeH/

Questions
Where I can find a step-by-step instructions to build my own PID like hardware needed, electrical circuit used, etcc?

enter image description here

I really appreciate your support guys!!

Best Answer

http://robotsforroboticists.com/pid-control/ seems to have a fairly simple PID pseudo code implementation. Also, it has some info into how to tune the gains.

In any type of control you gonna need to vary the input, in the case of DC motors is changing the supply voltage (or PWM). And you need feedback of the output, for motor is a tachometer or encoder, check the motor datasheet if one of the pins from the assembly would provide feedback on the rotation speed.

Transform that feedback into RPM and use that value as, in the PID example above, actual_value. Transform output so it can be used as your PWM bias.

I also suggest using unwinding for the integral error and output. Simply use if/else conditions to avoid those variables to exceed a threshold you defined.

To control the motor you can feed the PWM output into the gate of a N channel MOSFET, and connect negative terminal of the motor and ground throught the mosfet terminals.