Go Down

Topic: DC Servomotor Controller for mach3 (Read 127 times) previous topic - next topic


Jan 05, 2018, 05:08 pm Last Edit: Jan 05, 2018, 09:17 pm by joker691

I want to share my dc servo controller. It will be used on cnc milling machine im building (still in progress).
Im using Due board because uno/mega cannot handle encoder with big CRP and it have lot of build stuff like encoder function with filters and dead time compensation ( not used for now :) ). I tried to use comments as much i can but my english is not perfect :).

I made "shield" for due board but i found some mistakes so i dont want to put here schematic because i have to repair it and make version 2. I use schmitt triggers for inputs outputs and encoder with level convertors. 

The servo controller consist position and velocity regulator with update rate set to 1 kHz.
There are two operation modes. First (default by power up) is step/dir positioning and second is service mode with build in motion controller with triangular and trapezoidal move profiles.

When motor is powered on, controller is chcecking positioning error and pwm time at max value. if an error occurs, power for motor goes off. Well, im not decided how to turn back power on my cnc machine, so now its possible only with serial command "drive1" or "reset" (reset will zero encoder position).
On display on  bottom row there are states of inputs and outpus. They are not used in code for any function only to show on LCD.

During tunnig gains its good to plot vales to see how regulators are acting.

Reference velocity from mach3 is not perfect but is good enough. Maybe some filter will help it.

Here is video on my testing linear unit with mach3 manual movements (motor speed 3000 rpm) :

Serial commands:

service1     enable serial functions. When service mode is enabled step/dir inputs are not working
service2    disable serial functions and enable step/dir function
speed        set speed value with parameter for motion controller in impulses for one time sample. example: speed20
acc             set acceleration with parameter for motion controller in ramp steps count. Less is faster. Example: acc100
ptp             set desired motor position. After this command will motor start moving!  Example: ptp100000
kpp            with value of position proportional gain
kdp            with value of deriv position gain
kps             with value of proportional speed gain
kis              with value of integral speed gain
dbc            with value of deadband compensation
drive1        turn on motor motor power
drive2       turn off motor motor power
reset         reset cpu
?                 help

Go Up