4Brushed DC Motor Field Magnets Stator DC Power Supply Armature or RotorAxleCommutatorBrushes
5How to Code PWM Example here will cover MSP430 Concepts can be easily extended
6Reading the Datasheet One pin has multiple functions Set PxSEL accordinglyP2DIR |= BIT2; // set P2.2 as outputP2SEL |= BIT2; // use pin as TA1.1Why |= operator?
7Setting Timer Values Counter counts up each clock cycle What do the different modes mean?CCR0 = ;Why minus 1?
8Looking into ‘MSP430G2231.h‘ We are using Timer A We must set TACTL TACTL = TASSEL_2 + MC_1; // SMCLK, up to CCR0Which clock do you want to use?
9PWM Output Modes We are using Timer A1.1 OUTMOD_1 sets at CCRx CCTL1 = OUTMOD_7; // reset at CCR1; // set at CCR0OUTMOD_1 sets at CCRxOUTMOD_2 toggles at CCRx, resets at CCR0
10Setting the Duty Cycle We are using Timer A1.1 Recall: Now: TACTL = TASSEL_2 + MC_1; // SMCLK, up to CCR0CCR0 = ;CCTL1 = OUTMOD_7; // reset at CCR1; // set at CCR0Now:CCR1 = 200-1; // 20% duty cycleWhat will this do?
11DACs and PWM Amplification DACs are used to convert a digital signal to analogWhy does a PWM signal become a steady DC value?Microprocessors can’t provide enough current to drive a motor
12Back Electromotive Force (EMF) A motor converts electrical energy to mechanical energyThis conversion can go both waysIf a motor is spinning it will generate electrical energyCalled back emf
15Functional Block Diagram of PWM DC Motor Control
16Ramp Control Is an integrator Adjusts the set point up to the desired value.
17PID Control e(t)= Setpoint - measured Kp, Ki and Kd must be tuned according to desired output characteristics
18DC Motor ModelBasic DC motor systems can be represented by this electromechanical schematic. (bottom-left)The motor speed (𝜃) as a function of input voltage (𝑉) is governed by an open loop transfer function. (bottom-right)It is helpful to characterize the motor to obtain simulations/projected results along with PID estimates for the system.𝜃 𝑉 = 𝐾 𝐽∙𝑠+𝑏 𝐿∙𝑠+𝑅 + 𝐾 2
19Motor Characterization In order to obtain the motor parameters, basic DC machine tests must be used.To get an estimate for Rwdg :The rotor must be locked.5 different voltages are supplied to the windings.The current is measured.Ohm’s Law: 𝑉 𝐼 =𝑅 to find average resistanceVoltage (Volts)Current (Amps)Resistance (Ohms)0.30 V0.23 A1.304 Ω0.50 V0.39 A1.282 Ω0.70 V0.56 A1.250 Ω1.00 V0.79 A1.266 Ω1.20 V0.88 A1.364 ΩRwdg = Ω
20Motor Characterization Cont. Rotor speed and input voltage are directly related by the motor constant (K) in the equation:𝐾= 𝑉 𝑆𝑈𝑃𝑃𝐿𝑌 − 𝑉 𝐵𝐸𝑀𝐹 𝜔 𝑅𝑂𝑇𝑂𝑅 = 𝑉 𝑆𝑈𝑃𝑃𝐿𝑌 − 𝐼 𝐴𝑅𝑀 ∙ 𝑅 𝑊𝐷𝐺 𝜔 𝑅𝑂𝑇𝑂𝑅A no-load test supplying 12.0 Volts to the motor results in 830 mA drawn at a speed of ~14,200 rpm (1, rad/s).Using the winding resistance from before, the Back EMF is subtracted from the supply which results in:K = V/rad