sets up closed loop motor control More...
Classes | |
class | controlloop.ClosedLoop |
Closed Loop Control System. More... | |
Variables | |
controlloop.ENB = pyb.Pin (pyb.Pin.board.PC1, pyb.Pin.OUT_PP) | |
controlloop.IN3 = pyb.Pin (pyb.Pin.board.PA0, pyb.Pin.OUT_PP) | |
controlloop.IN4 = pyb.Pin (pyb.Pin.board.PA1, pyb.Pin.OUT_PP) | |
controlloop.tim5 = pyb.Timer (5, freq=20000) | |
controlloop.mot2 = motor_drv.MotorDriver(ENB, IN3, IN4, tim5) | |
controlloop.enc2 = EncoderReader.EncoderReader(2) | |
controlloop.controller2 = ClosedLoop(.1, 0.00005, 0.75, 0) | |
int | controlloop.setpoint = 100 |
controlloop.PWM = controller2.run(enc2.read(), setpoint) | |
sets up closed loop motor control
After setpoint and K_p gain values are set by user, the controller continuously checks the encoder values to minimize the setpoint error. However, there is always a steady state error due to there being no integrator in the control loop.