pic18 motor control

Upload: adamwaiz

Post on 04-Apr-2018

233 views

Category:

Documents


2 download

TRANSCRIPT

  • 7/30/2019 pic18 motor control

    1/16

    77

    PIC18MICROCONTROLLER

    MotorControMohamadFauziZakaria

    http://fkee.uthm.edu.my/mfauzi

    PART12

    3 January, 2011mfauzi

  • 7/30/2019 pic18 motor control

    2/16

    RELAY

    3a. Electromechanical Relay

    Has three components:

    o Spring

    contacts

    Relay characteristics to be considered Types of contacts SPST, SPDT, DPDT

    Voltage and current for energizing the coil

    pull-in (minimum) current = pull in voltage/coil resistance

    3 January, 2011mfauzi

    4

    3 January, 2011mfauzi

  • 7/30/2019 pic18 motor control

    3/16

  • 7/30/2019 pic18 motor control

    4/16

    7

    Also called optocoupler

    Used to reduce the effect of voltage spike especially in coil windingsystem (e.g.: motors).

    transmitter and receiver

    is to revent the

    electrical current surgefrom reachin the

    system

    3 January, 2011mfauzi

    PART28

    3 January, 2011mfauzi

  • 7/30/2019 pic18 motor control

    5/16

    9

    PIC18 CCP and ECCP Modules CCP Registers

    1. CCPxCON : to select the compare,capture, and PWM modes

    2. CCPRxLa. 16-bit compare register

    b. 16-bit capture register

    PIC18 Usage of Timers3. CCPRxH

    c. 8-bit duty cycle register

    10

  • 7/30/2019 pic18 motor control

    6/16

    11

    There are three registers involved:

    .2. PR2 : Period

    .

    4. T2CON: Timer2 Control

    .

    6. TRIS: I/O Direction

    12

    2 factors in creating pulses in PWM: Period

    Duty Cycle (DC)

    s o en s a e n e percen ages orm

  • 7/30/2019 pic18 motor control

    7/16

    13

    14

  • 7/30/2019 pic18 motor control

    8/16

    15

    16

    Uses the PR2 register to set the PWM period

    When TMR2 is equal to PR2, the following three events occur on the

    next increment cycle:

    TMR2 is cleared

    The CCPx pin is set

    exception: if PWM duty cycle = 0%, the CCPx pin will not be set

    The PWM duty cycle is latched from CCPRxL into CCPRxH

  • 7/30/2019 pic18 motor control

    9/16

    17

    uty yc e

    Uses 10-bit register of Duty Cycle

    DC9 DC8 DC7 DC6 DC5 DC4 DC3 DC2 DC1 DC0

    CCPRxL CCPxCON

    Decimal PointMain Duty Cycle

    DC1 DC0 Value

    0 0 0

    0 1 0.25

    1 0 0.5

    1 1 0.75

    18

    1. Set the PWM period by writing to the PR2 register.

    2. e e u y cyc e y wr ng o x or e g er s.

    3. Set the CCPx pin as an output.

    4. Using the T2CON register, set the prescale value.

    5. Clear the TMR2 register content.

    .

    the decimal portion of the duty cycle.

    7. ar mer .

  • 7/30/2019 pic18 motor control

    10/16

    19

    Create a 2.5 kHzPWM with a 75%

    DC on the CCP1 pinby using 4 prescaleand Fosc = 10 MHz.

    PR2 = [Fosc/(Fpwm x 4 x TMR2 Prescale Value)] - 1

    .

    20

    SpeedMotorControlthroughPWMgeneratingby

    OnOff

    at

    any

    pin

    using

    hardware

    Timer

    or

    Software

    Delay.

    FeedbackSensor:

    Encoder

    CounterforT0CKIandT1CKI Polling/Interrupt.

    INT0 1 2 ollin interru t.

    OtherPins polling.

    ADC

  • 7/30/2019 pic18 motor control

    11/16

    21

    HBridgeMotorDriver

    22

  • 7/30/2019 pic18 motor control

    12/16

    23

    D BServomotor

    24

    Allservoshavethreewires:Black orBrown isforground.

    Red isforpower(~4.86V).

    Yellow,

    Orange,

    or

    White is

    the

    signal wire

    (3

    5V).

    3 January, 2011mfauzi

  • 7/30/2019 pic18 motor control

    13/16

    PART325

    3 January, 2011mfauzi

    26

    3 common types that identified by the number of connections to the

    .

    Motor speed : measured in steps/s, is a function of the switching

    . Holding torque: the amount of torque at zero rpm condition

    3 January, 2011mfauzi

  • 7/30/2019 pic18 motor control

    14/16

    27

    Step angle: minimum degree of rotation associated with a single step.

    ep per secon an rpm re a on

    3 January, 2011mfauzi

    STEPPER MOTORstep sequence

    28

    Fullste HalfSte 8 Windin

    (4step) step)

    Normal

    drive Wave

    drive Normal A B C D

    1 1 1 0 0 1

    1 2 1 0 0 0 CCW

    2 3 1 1 0 0

    2 4 0 1 0 0

    3 5 0 1 1 0

    3 6 0 0 1 0

    CW

    4 7 0 0 1 1

    4 8 0 0 0 1

    3 January, 2011mfauzi

  • 7/30/2019 pic18 motor control

    15/16

    STEPPER MOTOR INTERFACE

    29using ULN2003

    3 January, 2011mfauzi

    STEPPER MOTOR INTERFACE

    30

    3 January, 2011mfauzi

  • 7/30/2019 pic18 motor control

    16/16

    STEPPER MOTOR INTERFACE

    31

    3 January, 2011mfauzi

    32