Problem with fuzzy logic motor controller

4 views (last 30 days)
I want to make a fuzzy logic motor controller to control a DC motor such that when a speed(in rpm) is given, motor should change the speed according to this fuzzy logic system.
I used fuzzy logic toolbox and defined two input variables; 'error'(given speed - current speed) and 'dError'(error - previous error) each ranging [-300 300] and each with 5 MFs. Output MF is also with 5 MFs ranging [-255 255] (Motor speed). I made rules preferring this.
When I run this code, the speed goes to a value but it is not the value I want. Did I use ' evalfis() ' incorrectly? Can someone please help me find what I've done wrong here?
motorControl = readfis('MotorControl.fis')
currentSpeed = 0; %motor starts from 0rpm
speed = 55; %motor should come to 55rpm
k = 1;
prevError = 0; %Im not sure if this is correct
while currentSpeed <= speed
error = speed-currentSpeed;
dError = error-prevError;
time(k) = k;
spd(k) = currentSpeed;
currentSpeed = evalfis([error dError], motorControl);
%did I use 'evelfis()' incorrectly?
k= k+1;
if k == 100 %I put this here because currentSpeed <= speed...
break; %...never satisfy. currentSpeed gets to a speed...
end %...but its not the speed I've given
prevError = error;
end
plot(time, spd)

Answers (1)

Arkadiy Turevskiy
Arkadiy Turevskiy on 13 Feb 2014
What you are doing does not make sense if you are trying to control a motor.
In a control system the controller produces actuator command (something like voltage command or PWM duty cycle). The actuator drives the motor, you measure motor speed and close the feedback loop.
So in your case the controller should use error and derror to produce PWM signal. Then you need motor model to take PWM signal and produce resulting motor speed.
In your code you do not have motor model, and you controller outputs the motor speed, which does not make any sense.
HTH. Arkadiy

Communities

More Answers in the  Power Electronics Control

Categories

Find more on Fuzzy Inference System Modeling in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!