Problem with fuzzy logic motor controller

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)

답변 (1개)

Arkadiy Turevskiy
Arkadiy Turevskiy 2014년 2월 13일

0 개 추천

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

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

도움말 센터File Exchange에서 Fuzzy Logic in Simulink에 대해 자세히 알아보기

질문:

2013년 12월 25일

답변:

2014년 2월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by