Sei sulla pagina 1di 16

7

PIC18MICROCONTROLLER {MotorControl} {M C l}
MohamadFauziZakaria http://fkee.uthm.edu.my/mfauzi

PART PART1
Interfacetohighpower Interface to high power Relay

mfauzi

3 January, 2011

RELAY a. Electromechanical Relay


Has three components:
Coil 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 Maximum DC/AC voltage and current handled by contacts

mfauzi

3 January, 2011

Driving a relay
4

mfauzi

3 January, 2011

RELAY b. Solid-state Relay


Made from semiconductor materials Advantages solid-state over electromechanicall relays Ad t lid t t l t h i l
Faster switching response time Longer life cycle Need low input current (can be interfaced directly to microcontroller) Small size

mfauzi

3 January, 2011

Connection to a Solid-state Relay


6

mfauzi

3 January, 2011

OPTOISOLATOR
7

Also called optocoupler Used to reduce the effect of voltage spike especially in coil winding system (e.g.: motors). The gap between transmitter and receiver is to prevent the electrical current surge from reaching the g system
mfauzi 3 January, 2011

PART PART2
PWMandRelatedMotorControl PWM and Related Motor Control

mfauzi

3 January, 2011

PWM in CCP AND ECCP


9

PIC18 CCP and ECCP Modules

CCP Registers
1. CCPxCON : to select the compare, capture, and PWM modes 2. CCPRxL a. 16-bit compare register p g b. 16-bit capture register c. 8-bit duty cycle register

PIC18 Usage of Timers

3. CCPRxH

PIC18F4550: ECCP1 and CCP2 Pins


10

PWMBlockDiagram PWM Block Diagram


11

There are three registers involved: 1. 1 CCPxCON: CPP Control 2. PR2 : Period 3. 3 CCPRxL: Duty Cycle 4. T2CON: Timer2 Control 5. TMR2: Timer2 buffer 6. TRIS: I/O Direction

Factors in PWM
12

2 factors in creating pulses in PWM:


Period Duty Cycle (DC)

DC is often stated in the percentages form i ft t t d i th t f

13

14

15

PWM Period
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

PWM D t C l Duty Cycle


17

Uses 10-bit register of Duty Cycle

DC9 DC8 DC7 DC6 DC5 DC4 DC3 DC2 DC1 DC0
CCPRxL Main Duty Cycle 0 0 1 1 CCPxCON Decimal Point DC1 DC0 0 1 0 1 Value 0 0.25 0.5 0.75

Steps in Programming PWM


18

1. 2. 3. 4. 5. 6. 6

Set the PWM period by writing to the PR2 register. Set th S t the PWM d t cycle b writing t CCPRxL for the higher 8 bits. duty l by iti to CCPR L f th hi h bit Set the CCPx pin as an output. p p Using the T2CON register, set the prescale value. Clear the TMR2 register content. Configure the CCPxCON register for PWM and set DCxB1:DCxB0 bits for the decimal portion of the duty cycle. Start Ti 2 St t Timer2.

7.

PWM: Example
19

Create a 2.5 kHz PWM with a 75% DC on the CCP1 pin by using 4 prescale and Fosc = 10 MHz.

PR2 = [Fosc/(Fpwm x 4 x TMR2 Prescale Value)] - 1 DC = 75% x 249 = 186 75 186.75

MOTORCONTROL MOTOR CONTROL


20

SpeedMotorControlthroughPWMgeneratingby CCPRegister CCP Register OnOffatanypinusinghardwareTimerorSoftwareDelay. FeedbackSensor: Encoder CounterforT0CKIandT1CKI Polling/Interrupt. INT0,1,2 INT0,1,2 polling/interrupt. OtherPins polling. Potentiometer/VariableResistor Potentiometer / Variable Resistor
ADC

DCMotor DC Motor
21

HBridgeMotorDriver

VEXTABRUSHLESSSERVOMOTOR VEXTA BRUSHLESS SERVOMOTOR


22

23

Oriental Vexta DC Brushless Servomotor

RCServomotor RC Servomotor
24

Allservoshavethreewires:
Black orBrown isforground. Red isforpower(~4.86V). Yellow,Orange,orWhite isthesignal wire(35V).

mfauzi

3 January, 2011

25

PART 3 PART3
StepperMotor Stepper Motor

mfauzi

3 January, 2011

STEPPER MOTOR
26

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

Motor speed : measured in steps/s, is a function of the switching rate. rate Holding torque: the amount of torque at zero rpm condition
mfauzi 3 January, 2011

STEPPER MOTOR
27

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

Step St per second and rpm relation d d l ti

mfauzi

3 January, 2011

28

STEPPER MOTOR step sequence


Fullstep p (4step) Normaldrive 1 2 3 4 Wavedrive 1 2 3 4 HalfStep(8 p( step) Normal 1 2 3 4 5 6 7 8 A 1 1 1 0 0 0 0 0 Winding g B 0 0 1 1 1 0 0 0 C 0 0 0 0 1 1 1 0 D 1 0 0 0 0

0 1 1

mfauzi

3 January, 2011

CCW CW

29

STEPPER MOTOR INTERFACE using ULN2003

mfauzi

3 January, 2011

STEPPER MOTOR INTERFACE


30

mfauzi

3 January, 2011

STEPPER MOTOR INTERFACE


31

mfauzi

3 January, 2011

Programming
32

mfauzi

3 January, 2011

Potrebbero piacerti anche