10
Fall 2014 California State University, Chico. Department of Mechanical and Mechatronic Engineering and Sustainable Manufacturing. MECA 482: Control System Design Instructor: Daisuke Aoyagi, [email protected] Names and IDs: Abdon Francisco Aureliano Netto, 006955885, [email protected] Gabriel Fontes Iasbeck, 006556538, [email protected] Title: Final Project Report 1. Conceptual Design The project consist in a DC motor controlled by an Arduino having an encoder as feedback. Taking the derivative of the encoder signal it is possible to get the velocity and then compare to the input (desired velocity) getting an error and correcting this error through a PID controller in the Arduino. The velocity control was then applied to an electronic pulley to lift different masses with constant velocity. The Block Diagram is showed below: Figure 1 - Block Diagram

Conveyor Report

Embed Size (px)

DESCRIPTION

Final Control System Design Project

Citation preview

Page 1: Conveyor Report

Fall 2014

California State University, Chico. Department of Mechanical and Mechatronic Engineering and Sustainable Manufacturing.

MECA 482: Control System Design Instructor: Daisuke Aoyagi, [email protected] Names and IDs: Abdon Francisco Aureliano Netto, 006955885, [email protected] Gabriel Fontes Iasbeck, 006556538, [email protected]

Title: Final Project Report

1. Conceptual Design

The project consist in a DC motor controlled by an Arduino having an encoder as feedback. Taking the

derivative of the encoder signal it is possible to get the velocity and then compare to the input (desired velocity)

getting an error and correcting this error through a PID controller in the Arduino. The velocity control was then

applied to an electronic pulley to lift different masses with constant velocity.

The Block Diagram is showed below:

Figure 1 - Block Diagram

Page 2: Conveyor Report

Fall 2014

2. Detailed Design The picture bellow represent the project which data came from:

Figure 2 - The Project built

The desired project consist on a simulation of a motorized pulley, which in this case carry a load of 85 grams. The

programming code is attached on Appendix. The sensor utilized is an encoder attached on the motor that send pulses

Page 3: Conveyor Report

Fall 2014

to Arduino that controls the motor velocity and direction.

Figure 3 - Wire Diagram

The description of each wire in the wire diagram showed on Figure 2 is:

Table 1 - Wire Diagram description.

Wire Function

1 Motor Power Supply

2 Motor Ground

3 Encoder Power Supply

4 Encoder Ground

5 Set of Pulse Output Line

6 Set of Pulse Output Line

7 Power Supply 5V(not used)

8 Ground

9 Pulse 1

10 Pulse 2

3. Step Response Test

Each student chose 2 cases: Abdon – PI and PID, Gabriel – P and PD.

To get the data from the experiment, it was collected the motor velocity in every 0.212 seconds by reading the

encoder. A constant mass was lifted up by the pulley and the control type and gains were varied.

To apply the step response, a desired speed of 80 RPM (8.37 rad/s) was set and the mass started to lift from the rest.

All gains were set based on experiments to get the most stable final values, in other words it was tuned it. It was also

found the constant of time λ.

Page 4: Conveyor Report

Fall 2014

a) Only P.

For a Kp=0.09 the graphic Velocity x Time found it was:

Figure 4 - Step Response only P

𝜆 = 0.775

b) Only PD

For a Kp=0.15 and Kd=0.003 the graphic Velocity x Time found was:

Figure 5 - Step Response only P and D

𝜆 = 0.375

0.00

2.00

4.00

6.00

8.00

10.00

0 1 2 3 4 5 6 7 8 9

Vel

oci

ty (

rad

/s)

Time (s)

Only P=0.09

Output Desired Velocity

0.00

2.00

4.00

6.00

8.00

10.00

0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00

Vel

oci

ty (

rad

/s)

Time (s)

P=0.15 D=0.003

Output Desired Velocity

Page 5: Conveyor Report

Fall 2014

c) Only PI

For a Kp=0.15 and Ki=0.003 the graphic Velocity x Time found was:

Figure 6 - Step Response only P and I

𝜆 = 0.275

d) PID all turned on

Figure 7 - PID all turned on

𝜆 = 0.365

0.00

2.00

4.00

6.00

8.00

10.00

12.00

0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00

Vel

oci

ty (

rad

/s)

Time (s)

P=0.1 I=0.003

Output Desired Velocity

0.00

2.00

4.00

6.00

8.00

10.00

0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00

Vel

oci

ty (

rad

/s)

Time (s)

P=0.1 D=0.01 I=0.001

Output Desired Velocity

Page 6: Conveyor Report

Fall 2014

4. MATLAB simulation Gabriel: PD simulation:

Theory: Analyzing the plots of the topic number 3 the system is very likely to be a 1st order system. Based on the theory we

have a Transfer Function of a first order system being:

𝐺(𝑠) =𝐴

𝜆𝑠 + 1

A step input of 8.37 rad/s was applied and the S.S. output is 8.37(average)

𝜆 = 0.375 𝑠

𝐺(𝑠) =𝐴

0.375𝑠 + 1

lim𝑠→0

𝑠 ∗ 𝐹(𝑠) = 𝐹(∞)

= lim𝑛→∞

𝑠 ∗𝐴

0.375𝑠 + 1∗

8.37

𝑠→ 𝐴 = 1

𝐺(𝑠) =1

0.375𝑠 + 1

Matlab code: G=tf(1,[0.375 1]);

opt=stepDataOptions('StepAmplitude',8.37);

[v,t]=step(G,opt);

plot(t,v,'-','LineWidth',2);grid on; title('PD controller');

ylabel('velocity[rad/s]');xlabel('time[s]');hold all

%importing experimental data to matlab using the “import data” button

%variables time and vel are the experimental data vectors

plot(time,vel,'r--o');legend('input','output'); xlim([0 3.5])

Plot Result:

Page 7: Conveyor Report

Fall 2014

Abdon: PID simulation Theory: From the textbook I know that a velocity control system is a first order system, therefore:

𝐺(𝑠) =𝐴

𝜆𝑠 + 1

A step input of 8.37 rad/s was applied and the S.S. output is 8.37(average)

𝜆 = 0.365 𝑠

𝐺(𝑠) =𝐴

0.365𝑠 + 1

To find D.C gain (A), apply the final value theory:

lim𝑠→0

𝑠 ∗ 𝐹(𝑠) = 𝐹(∞)

= lim𝑛→∞

𝑠 ∗𝐴

0.365𝑠 + 1∗

8.37

𝑠→ 𝐴 = 1

Therefore:

𝐺(𝑠) =1

0.365𝑠+1

Matlab code: G1=tf(1,[0.365 1])

opt=stepDataOptions('StepAmplitude',8.37)

[v,t]=step(G1,opt);

plot(t,v,'-','LineWidth',2);grid on; title('PID controller');

ylabel('velocity[rad/s]');xlabel('time[s]');hold all

%importing experimental data to matlab using the “import data” button

%variables time and vel are the experimental data vectors

plot(time,vel,'r--o');legend('input','output'); xlim([0 3.5])

Plot Result:

Page 8: Conveyor Report

Fall 2014

5. Conclusion

Abdon: PID control have so many applications. PI controllers are preferred to control first order plants. On the other

hand, PID control is vastly used to control two or higher order plants. In almost all cases fast transient response and

zero steady state error is desired for a closed loop system. PID is preferred is that it provides both of these features at

the same time. This project also showed that project is harder than you can think, project and design cost time and

money and cannot be made with no planning.

Gabriel: This project showed to me how powerful a PID control can be. Despites its simplicity compared to another

control types, it proved itself very effective. I learned that is very important to tune the gains of the system as best as

possible because it makes a huge difference. While P takes account on how fast the system respond, D is sensitive to

how big the error is changing (making the system stabilize faster) and I make sure that the error that is stacking (not

being corrected) will be fixed. I also have learned that when building a 100% handmade structure or mechanism to a

is very important to be careful when taking measurements and building the parts of the mechanism because when we

mount it, all the little mistakes made during the process will stack and the final equipment will not be as good as

desired.

Page 9: Conveyor Report

Fall 2014

Appendix. #include <Wire.h> //I2C protocol library

#define driver 0x0f // driver adress

#define DirectionSet 0xaa //direction header

#define Nothing 0x01// bit filler

#define MotorSpeedSet 0x82 //speed header

#define encoder0PinA 2

#define encoder0PinB 4

volatile long encoder0Pos=0;

long newposition;

long oldposition = 0;

unsigned long newtime;

unsigned long oldtime = 0;

long vel;

int error=0;

int sumerror=0;

int last_error=0;

float Kp=0.1;

float Kd=0.01;

float ki=0.001;

float PID;

int velo;

int spd=25;

void MotorSpeedSetA (unsigned char speedA){

Wire.beginTransmission(driver);

Wire.write(MotorSpeedSet);

Wire.write(0);

Wire.write(speedA);

Wire.endTransmission();

}

void MotorDirectionSet(byte dir)

{

Wire.beginTransmission(driver);

Wire.write(DirectionSet);

Page 10: Conveyor Report

Fall 2014

Wire.write(dir);

Wire.endTransmission();

}

void setup() {

Wire.begin(); // join i2c bus (address optional for master)

delayMicroseconds(10000); //wait for motor driver to initialization

pinMode(encoder0PinA, INPUT);

digitalWrite(encoder0PinA, HIGH); // turn on pullup resistor

pinMode(encoder0PinB, INPUT);

digitalWrite(encoder0PinB, HIGH); // turn on pullup resistor

attachInterrupt(0, doEncoder, RISING); // encoDER ON PIN 2

Serial.begin (9600);

Serial.println("start"); // a personal quirk

}

void loop() {

MotorSpeedSetA(spd);

delay(10); //this delay needed

MotorDirectionSet(0b1000); //0b1010 Rotating in the positive direction

// delay(10000);

newposition = encoder0Pos;

newtime = millis();

vel = (newposition-oldposition) * 1000 /(newtime-oldtime);

velo=(vel*60/6280); //RPM

//Serial.print ("speed = ");

Serial.println (velo);

Serial.println (newtime);

oldposition = newposition;

oldtime = newtime;

error=80-velo;

sumerror=sumerror+error;

PID=+(Kp*error)+ (Kd * (error - last_error)) + ki*sumerror;

last_error=error;

spd=spd+int(PID);

delay(200);

}

void doEncoder()

{

if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB)) {

encoder0Pos++;

} else {

encoder0Pos--;

}

}