PID Motor Control: Presented by Bo Chiasson

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 85

PID Motor Control

Presented by Bo Chiasson
Overview

● Wiring/ Components needed


● LabView Introduction
● Basic DC motor control
● Encoders
● PID Control
● Nav x
Components needed
Wiring
Wiring ctd...
LabView
LabView ctd...
LabView
LabView
LabView
LabView
LabView
LabView
LabView
LabView
LabView
Basic Motor Control
Give it a try
Flat Sequence
Flat Sequence
Give it a try
Case Structure
Case Structure ctd...
Case Structure ctd...

- On front panel “ctrl & space” to search


Case Structure ctd...
Case Structure ctd...
Case Structure ctd...
Case Structure ctd...
Case Structure ctd...
Case Structure ctd...
Case Structure ctd...
Case Structure ctd...
Case Structure ctd...
Case Structure ctd...
Case Structure ctd...
Give it a try
Stuck on the case “Wait”
You must add a local “variable” and a “constant”
Right click on “enum”
Constant will be where you want to go next
- From “wait” to “forward”
- “Forward” to “Stop”
- Stay on “Stop”
Case structure can behave similar to a flat
sequence but allows more room for being
autonomous.
Case Structure ctd...

Goal: Make robot drive in a square

- Open type def. on “enum”


- Add “Stop 2” and “Turn”
Case Structure ctd...

The reason we selected “make type def.” for the enum earlier is so that our local variables will
auto populate. Otherwise we would have to delete the local variable and add a new one every
time we add a new case.
Case Structure ctd...

- Add a case for every value on the case structure


- Add the motor movements for turning and stopping
- Make sure to have the case go to the correct next case
Case Structure ctd...

In the event that your cases are created out of order logically...
Case Structure ctd...
Just right click on the case structure, rearrange cases..

Click and drag to the correct order and select “OK”


Case Structure ctd...
Case Structure ctd...

We have just created an open loop, meaning it will continue to perform the task created without
feedback from an outside source.
Create a virtual folder
Place all VI’s and Controls created so far into
new Virtual Folder
Take a break…
Encoders
Four possible ways to wire

A & B MXP Connections DAQ EN0 Connections DAQ EN1 Connections


Encoder from “myrio”
Encoder ctd...

- The encoder VI will count the pulses


- Divide the counter value by the known ticks per revolution (1440)
- Refer to data sheet for the ticks per rev
- We now know how many times the wheel has rotated
Encoder ctd...

- Take the known wheel circumference and multiply by pi


Encoder ctd...

- Multiply both together to determine the distance travelled


Encoder ctd...

- Multiply by 2.54 to convert inches to cm if desired.

Note: This is used for a motor with direct drive meaning a 1:1 ratio. If you are using anything
else you must multiply it by the gear ratio you have it at. Ex. 1440 encoder but a gear ratio of
30:1. Meaning motor shaft will spin 30 times before the wheel rotates once. To get an accurate
count you would multiply 30 by 1440 and get 43200 ticks per rev rather than 1440.
Give it a try

Use “round to nearest” to change the resulting output to a whole number


Studica Tool Kit
Studica Encoder

Compare results
PID Control

- PID control is a control loop feedback mechanism used in automation and process control
- Uses a closed loop rather than an open loop
PID Control ctd...

Open Loop Example:

- Clothes dryer
- Timer to dry clothes
- Stops whether clothes are damp or dry

Closed Loop Example:

- Thermostat
- Set a temperature
- Furnace or AC will kick in and out to maintain temp

Difference between open and closed loop:

- Closed loop includes feedback


PID Control ctd...

Three key features in PID control:

- Setpoint (SP)
- What you want the process variable to be
- Process Variable (PV)
- What you are measuring
- Error (E)
- Difference between SP and PV
PID Control ctd...

Proportional

- Will produce an output proportional to error. The larger the error, the larger the control
output based on the “Gain Factor” (K).

Integral

- Accounts for past error values. If there is still error overtime it will change the output by
an “Integral Factor” (I) until error is gone.

Derivative

- Known as rate of change. Seeks to reduce the effect of the error by exerting a control
influence generated by a rate of change.
PID Control ctd...

Tuning

-Refers to adjusting the P,I, and D values until a desired control response is created.
PID Control ctd...
PID Control ctd...

Responses Created:

Quarter Amplitude Decay


PID Control ctd...

Derivative tends to be used in slower applications such as level control.

For faster processes and applications such as flow loops or motor control we only use
Proportional and Integral control known as “PI Controllers”

Using this newly gained knowledge we will now get into creating a PI Controller for motor
control.
PID Control ctd...

Goal:

Determine what will be the SP, PV, and Error for motor control
PID Control ctd...

Desired Distance Distance travelled

Encoder
PID Control ctd...
PID Control ctd...

Create new VI called PI Control


PID Control ctd...
PID Control ctd...

Try tuning your controller to get desired response.


PID Control ctd...

Try with two motors


Take a break...
PID Control ctd...

Goal:

Create 3 new sub VI’s

- Straight
- Right Turn
- Left Turn
PID Control ctd...
PID Control ctd...
PID Control ctd...
PID Control ctd….

Goal: Create a VI to navigate through a maze using the 3 new subVI’s created

You might also like