ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Cnc- Arduino


Enviado por   •  27 de Febrero de 2014  •  963 Palabras (4 Páginas)  •  404 Visitas

Página 1 de 4

Proyecto Control P+I+D

Objetivo.- Basado en este proyecto construir prototipo de regulación de velocidad de motor empleando encoder óptico como sensor de velocidad, y realizar su calibración de parámetros de los modos de control (Sintonización).

« Arduino Uno Keeps Header Offset

Improving the Beginner’s PID – Sample Time »

Improving the Beginner’s PID – Introduction

In conjunction with the release of the new Arduino PID Library I’ve decided to release this series of posts. The last library, while solid, didn’t really come with any code explanation. This time around the plan is to explain in great detail why the code is the way it is. I’m hoping this will be of use to two groups of people:

• People directly interested in what’s going on inside the Arduino PID library will get a detailed explanation.

• Anyone writing their own PID algorithm can take a look at how I did things and borrow whatever they like.

It’s going to be a tough slog, but I think I found a not-too-painful way to explain my code. I’m going to start with what I call “The Beginner’s PID.” I’ll then improve it step-by-step until we’re left with an efficient, robust pid algorithm.

The Beginner’s PID

Here’s the PID equation as everyone first learns it:

This leads pretty much everyone to write the following PID controller:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30 /*working variables*/

unsigned long lastTime;

double Input, Output, Setpoint;

double errSum, lastErr;

double kp, ki, kd;

void Compute()

{

/*How long since we last calculated*/

unsigned long now = millis();

double timeChange = (double)(now - lastTime);

/*Compute all the working error variables*/

double error = Setpoint - Input;

errSum += (error * timeChange);

double dErr = (error - lastErr) / timeChange;

/*Compute PID Output*/

Output = kp * error + ki * errSum + kd * dErr;

/*Remember some variables for next time*/

lastErr = error;

lastTime = now;

}

void SetTunings(double Kp, double Ki, double Kd)

{

kp = Kp;

ki = Ki;

kd = Kd;

}

Compute() is called either regularly or irregularly, and it works pretty well. This series isn’t about “works pretty well” though. If we’re going to turn this code into something on par with industrial PID controllers, we’ll have to address a few things:

1. Sample Time - The PID algorithm functions best if it is evaluated at a regular interval. If the algorithm is aware of this interval, we can also simplify some of the internal math.

2. Derivative Kick - Not the biggest deal, but easy to get rid of, so we’re going to do just that.

3. On-The-Fly Tuning Changes - A good PID algorithm is one where tuning parameters can be changed without jolting the internal workings.

4. Reset Windup Mitigation -We’ll go into what Reset Windup is, and implement a solution with side benefits

5. On/Off (Auto/Manual) - In most applications, there is a desire to sometimes turn off the PID controller and adjust the output by hand, without the controller interfering

6. Initialization - When the controller first turns on, we want a “bumpless transfer.” That is, we don’t want

...

Descargar como (para miembros actualizados)  txt (6.4 Kb)  
Leer 3 páginas más »
Disponible sólo en Clubensayos.com