AmadeusCosimo
Newbie level 1
Hej,
i am using a H Bridge (LMD18200) for controlling a DC Motor. Therefore i am using the Pin8 Current Sensing Output and a simple PI-controller. My problem is that i just can measure the abs value of the motor current, if i get the datasheet right. Does anyone know how to get the real signum of the current?
I tried to just take the signum of the desired current which i apply to the motor controller, but when i am using a sinusoidal input i get problems at the zero crossing.
My controller code at the moment looks like this (i am using matlab/simulink and a dspace box CP1103)
My strategie know was to control the abs value of the error (IMx_d-IMx) and take the signum of the desired current as the direction bit of the H-Bridge. Furthermore i just set the output voltage as zero when the desired current is zero. But this step results in problems.
i am using a H Bridge (LMD18200) for controlling a DC Motor. Therefore i am using the Pin8 Current Sensing Output and a simple PI-controller. My problem is that i just can measure the abs value of the motor current, if i get the datasheet right. Does anyone know how to get the real signum of the current?
I tried to just take the signum of the desired current which i apply to the motor controller, but when i am using a sinusoidal input i get problems at the zero crossing.
My controller code at the moment looks like this (i am using matlab/simulink and a dspace box CP1103)
Code:
Dir_x ... direction bit for H-Bridge
UMx....Voltage for DC motor which is later on converted into a PWM Signal (0..1) -> (0..12)V
e1I.... Error for integral value of PI Controller
reset...to reset the controller errors when starting the simulation/measurement
AntiWindUp....freeze the integral value when reaching the maximum voltage
IMx_d...desired current
IMx....measured current
par...parameter-file
function [UMx,Dir_X] = PICurrentControl(resetI,IMx_d,IMx,AntiWind,par)
persistent e1I
if isempty(e1I)
e1I=0;
end
persistent e1
if isempty(e1)
e1=0;
end
persistent Ux
if isempty(Ux)
Ux=0;
end
if (resetI)
e1I=0;
end
%Calculate Control Deviation
e1=abs(IMx_d)-abs(IMx);
%1..AntiWindup on, 0..of
if(AntiWind)
if (Ux < 12 && Ux > -12)
e1I=e1I+0.01*e1;
else
e1I=e1I;
end
else
e1I=e1I+0.01*e1;
end
if(IMx_d == 0)
Ux = 0;
e1I = 0;
else
Ux = par(1)*e1 + par(2)*e1I;
end
UMx = abs(Ux);
if (sign(IMx_d) >=0)
Dir_X = false;
else Dir_X = true;
end
My strategie know was to control the abs value of the error (IMx_d-IMx) and take the signum of the desired current as the direction bit of the H-Bridge. Furthermore i just set the output voltage as zero when the desired current is zero. But this step results in problems.
Last edited by a moderator: