PIC Microchip Set-Up

advertisement
DASL
Motor Control Tutorial
PIC Microcontroller
In this PPT, all the materials covered up for the
PIC microcontroller set-up would be studied.
Preliminary skills: Knowing of basic C grammar and basic circuit
analysis, and manual reading.
Introduction
 PIC stands for “Peripheral Interface Controller”.
 PIC is a family of Harvard architecture microcontrollers
made by Microchip Technology.
 PIC is programmed and run by MPLAB software.
 In this tutorial, dsPIC33F - J128MC804 model will be used.
2
Peripheral Pins
 As shown in Fig 1 and 2
(on next slide), all the
peripheral PINs having
different functions are
commanded.
Figure 1
3
Peripheral Pins
Figure 2
4
Peripheral Pins
 Each of peripheral PINs are commanded for different
functions such as ADC, PWM, GIO(General Input &
Output), QUART, QEI, etc.
 In the next two slides, Table 1-1 shows the PIN names and
what all the PINs are functioning for.
 Depending on the purpose of a experiment, specific PINs
need to be used and wired on the proper device.
5
Peripheral Pins
6
Peripheral Pins
7
Tips for Manual Search
 All the manuals are provided on Microchip Technology’s
website - http://www.microchip.com/, therefore you can
easily search the functions and pins that you want to use.
 Since all the provided manuals are PDF files you can easily
search the key word by CTRL + F.
 All the necessary manuals for motor control are provided
on the last slide of this PPT.
8
Hardware
 dsPIC33F - J128MC804
 MPLAB ICD2 & 3 (ICD 3 is recommended since extra
works are necessary for the use of ICD 2) – A compiler
sending the data from a computer to a PIC chip and vice
versa.
 The Base Electric Circuit – The properly designed
electric circuit is needed to implement the PIC chip(In this
tutorial, the electric circuit designed by one of the Hubo lab
members will be used).
※ The procedure to make the base circuit will be discussed later.
9
Software Programs
 MPLAB
 C30 compiler
 OrCAD
 All the necessary software programs are provided on the blog.
<MPLAB>
10
<The interface of OrCAD>
Software Programs – MATLAB
11
Software Programs - MATLAB
• This initial set-up is necessary for the time interrupt function in the main code.
12
Software Programs - MATLAB
All the setups in ‘Init PWM’ allows motors
to be controlled by PWM signals.You can
manually change the settings based on the
qualification of the motor that you use.
13
Software Programs - MATLAB
14
Software Programs - MATLAB
‘Init QEI’ function is set up to enable the users to read the data in real time from an encoder.You can
get the data in a desired format by calculating a proper mathematical equation.
15
QEI & PWM
QEI stands for Quadrature Encoder Interface. In general, almost all of the encoders have two
pins which generate A & B signals and as shown in Fig 3, signal A and B intersects consistently
and this pattern is converted from the analog signal to digital signal by the QEI function in PIC
chip.
There are four registers in QEI function, which are shown below:
• Control/Status Register (QEIxCON)
• Digital Filter Control Register (DFLTxCON)
• Position Count Register (POSxCNT)
• Maximum Count Register (MAXxCNT)
※ ‘x’ is the number of a channel or a register.
16
QEI & PWM
17
Figure 3
QEI & PWM
Figure 4
18
QEI & PWM
 PWM stands for Pulse-Width-Modulator.
 PWM is generally used for motor control & LED lightness
control.
 PWM tutorial will be provided on the blog.
19
QEI & PWM
20
QEI & PWM (Channel)
<MCPWM1 Module>
•
•
•
•
21
MC
PTEN
Prescale
PTMOD
<MCPWM2 Module>
•
•
•
•
Pair mode
Pin enable
Iue
Dead time
QEI & PWM (Frequency)
22
QEI & PWM (Frequency)
23
QEI & PWM (Frequency)
24
QEI & PWM (Mode)
Single pulse mode
25
QEI & PWM (Mode)
Single Pulse Mode
Free Running Mode
26
QEI & PWM (Mode)
Count Mode
27
QEI & PWM (Mode)
28
QEI & PWM (Mode)
29
QEI & PWM (Pin Setting)
As shown in the preceding slides there are two channels and for first
module there are three sets of high and low signals and for second
module there is only one set of the signals.
30
QEI & PWM (Dead Time)
• It is enabled only in complementary mode.
• To prevent a electric short in a circuit.
31
QEI & PWM (Enabling)
• This register is used to enable PWM function.
32
Download