Lab 4: Pulse Width Modulation and Introduction to Simple Virtual Worlds (PWM) (PWM)



Similar documents
Timer A (0 and 1) and PWM EE3376

ETEC Digital Controls PIC Lab 10 Pulse Width Modulation

AVR Timer/Counter. Prof Prabhat Ranjan DA-IICT, Gandhinagar

Section 14. Compare/Capture/PWM (CCP)

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

1/22/16. You Tube Video. Definitions. Duty Cycle: on-time per period (specified in per cent)

Real-Time Clock. * Real-Time Computing, edited by Duncan A. Mellichamp, Van Nostrand Reinhold

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

AN3332 Application note

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

Pulse Width Modulation Applications

HT1632C 32 8 &24 16 LED Driver

PWM IN AVR. Developed by: Krishna Nand Gupta Prashant Agrawal Mayur Agarwal

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

ServoOne. Specification. Option 2 - Technology. x 11. x 8 X 8. x 10. x 9. x 7. x 6 TTL Encoder / TTL Encoder simulation

USB-QUAD08. Eight-channel Quadrature Encoder Input Device. Specifications

RENESAS TECHNICAL UPDATE

HT46R14A Single Phase AC Induction Motor Frequency Converter Application

Motor Control using NXP s LPC2900

How many high-speed counters (HSCs) are provided by the SIMATIC S PLC? SIMATIC S FAQ March Service & Support. Answers for industry.

Flexible Active Shutter Control Interface using the MC1323x

Hello and welcome to this training module for the STM32L4 Liquid Crystal Display (LCD) controller. This controller can be used in a wide range of

Talon and Talon SR User Manual

DS1104 R&D Controller Board

EFC Frequency converters

Flexible Counter Series in DIN size 24 x 48 mm

Frequency Converter Fv

X8 Option 2 - Technology

Stepper motor I/O. Application Note DK Motion Control. A General information on stepper motors

CPU systron S S S 250c. systron S S S 250c. CPUs to the process modules. Stand-alone PLC

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

DP8570A DP8570A Timer Clock Peripheral (TCP)

Simulink Models for Autocode Generation

Servo Info and Centering

Pulse Width Modulation (PWM) LED Dimmer Circuit. Using a 555 Timer Chip

FRC WPI Robotics Library Overview

Lab Experiment 1: The LPC 2148 Education Board

Instructions for Setting the T560 Digital Delay Generator for the Target Delay

AN3252 Application note

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

DEVELOPMENT OF DEVICES AND METHODS FOR PHASE AND AC LINEARITY MEASUREMENTS IN DIGITIZERS

Description. Dimensions. Features. precision works better

Microcontroller for Variable Speed BLDC Fan Control System. T.C. Lun System Engineer, Freescale Semiconductor, Inc.

PowerBox PBX 180. Installation and Users Guide

Configuring the FlexTimer for Position and Speed Measurement with an Encoder

DS1621 Digital Thermometer and Thermostat

CHAPTER 11: Flip Flops

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

DAC Digital To Analog Converter

Counters and Decoders

ADS9850 Signal Generator Module

The Design of DSP controller based DC Servo Motor Control System

Semiconductor MSM82C43

A Lesson on Digital Clocks, One Shots and Counters

AN3371 Application note

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

Serial Communications

Display Board Pulse Width Modulation (PWM) Power/Speed Controller Module

Preset Counter signo 721

A Lesson on Digital Clocks, One Shots and Counters

PCM Encoding and Decoding:

CPW Current Programmed Winder. Application Handbook. Copyright 2002 by Eurotherm Drives, Inc.

MicroMag3 3-Axis Magnetic Sensor Module

AP TriCore. Sinusodial 3-Phase Output Generation Using The TriCore General Purpose Timer Array. Microcontrollers

80 Series - Modular timers 16 A. Features

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

Section 15. Quadrature Encoder Interface (QEI)

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

Experiment 8 : Pulse Width Modulation

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

Timer Value IRQ IACK

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

Using the Siemens S65 Display

Chapter 6 PLL and Clock Generator

PowerPC Microprocessor Clock Modes

DT9836 Series. BNC Connection Box. OEM Embedded Version

AN Application Note: FCC Regulations for ISM Band Devices: MHz. FCC Regulations for ISM Band Devices: MHz

AN4646 Application note

I 2 S bus specification

Designing an efficient Programmable Logic Controller using Programmable System On Chip

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note: AN00103 Enabling DSD256 in the USB Audio 2.0 Device Reference Design Software

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

AN LPC1700 RTC hardware auto calibration. Document information. RTC, Hardware Auto Calibration, LPC1700, Graphic LCD

Pulse Width Modulation

Hollow Cylinder Apparatus (GDS SS-HCA)

Speed Controller 4-Quadrant PWM configurable via PC

TwinCAT NC Configuration

Lab 5 Getting started with analog-digital conversion

SIGNAL GENERATORS and OSCILLOSCOPE CALIBRATION

The Design of a Low-Cost and Robust Linkage Position Sensor

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Microcontroller Programming Beginning with Arduino. Charlie Mooney

FEATURES DESCRIPTION APPLICATIONS BLOCK DIAGRAM. PT2272 Remote Control Decoder

LSI/CSI LS7362 BRUSHLESS DC MOTOR COMMUTATOR/CONTROLLER DESCRIPTION:

AFG-100/200 series USB Modular Arbitrary Function Generator. Date: Oct, 2014

PART B QUESTIONS AND ANSWERS UNIT I

Transcription:

1 Lab 4: Pulse Width Modulation and Lab 4: Pulse Width Modulation and Introduction to Simple Virtual Worlds Introduction to Simple Virtual Worlds (PWM) (PWM)

Virtual Spring and Virtual Wall 2 Virtual Spring Puck attached to a reference point by a virtual spring with constant k If the puck is moved to either side, spring exerts a restoring force F s = kx We will use a motor and encoder to create a virtual torsional spring Virtual Wall On one side of a virtual wall ( x < x 0 ), wheel spins freely (motor applies no force) Once the wheel rotates into ( x > x 0 ), motor applies a force Virtual Spring (top) and Virtual Wall

3 Equations T w = KΘ w T w = Wheel Torque, Nmm K = Spring Constant, Nmm/degree Θ w = Displacement, degrees Embedded system units are encoder counts and PWM duty cycle! (Counts/Encoder Rev)(Wheel Rev/Degree) = Counts/Degree

Duty Cycle-to-Motor Torque (ETH) 4 0.24-0.76 dc +/- 835 Nmm Motor Torque (Nmm) 1606 0-1606 Motor Limits 0.5 1.0 duty cycle (0,1) T m (dc 0.5) Nmm

Enhanced Modular Input/Output Subsystem (emios) 5 Use emios to generate Pulse Width Modulation (PWM) signal to the motor 24 channels with many different operating modes See Chapter 17 MPC5553-RM emios Operation Modes Timer Mode Input Channel Modes Single Action Input Capture Input Pulse Width Measurement Input Period Measurement Pulse/Edge Accumulation Pulse Edge Counting Quadrature Decode Output Channel Modes Single Action Output Compare Double Action Output Compare Output Pulse Width Modulation Center Aligned Output Pulse Width Modulation Output Pulse Width and Frequency Modulation Buffered UM & ETH: OPWFMB

6 Programming the emios Like other peripherals, the emios must be configured by writing commands to special purpose registers emios Module Configuration Register (MCR) emios Channel Control Register (CCR) emios Channel A/B Data Registers (CADR, CBDR) Structure to access these registers is contained in MPC5553.h

emios OPWFMB 7 We will be using the OPWFMB mode emios data registers CADR and CBDR configure PWM duty cycle and switching period Counter [] Output 10 C max 8 C Th 6 T C 4 2 0 0 0.5 1 1.5 2 Time[s]; T C =0.1s T On = T C C Th 1 0 T = T C C max T On = D T 0 0.5 1 1.5 2 Time[s]; T C =0.1s OPWFMB counter and PWM output

8 emios PWM Data Registers The value in register CBDR determines the switching period (in clock ticks) duty cycle resolution and switching period are related

9 emios PWM Data Registers The value in register CADR determines the duty cycle OPWFMB: CADR=DC*CBDR Example: 10% DC CADR = 10; CBDR = 100; Resolution = 1%

10 emios PWM Data Registers Note about Double Buffering: Reading CADR returns the Register A1 value Writing CADR writes the value to Register A2 The same applies for CBDR Values in Registers A2&B2 are latched into A1&B1 when there is a match on Comparator B

11 emios PWM Comparators Comparators A and B trigger on exact matches Comparator A Match: Output set to EDPOL Comparator B Match: Output set to negative EDPOL Counter is Reset Registers A2&B2 latch into Registers A1&B1

12 PWM Frequency Configuration 2 prescalers located in the module control register (MCR) and the channel control register (CCR) determine the PWM frequency Global Prescaler (all 24 channels) GPRE: emios_mcr[16:23] global prescaler divides system clock by 1 to 256 (see Table 17-7) System clock is 120MHz We want PWM frequency = 20000 HZ Channel Prescaler UCPRE: emios_ccr[4:5] Additional timebase scaling (divide by 1 to 4)

13 EMIOS_MCR GPRE: Global prescaler - selects the clock divider as shown in Table 17-7 GPREN: Prescaler enable (enabled = 1) GTBE: Timebase enable (enabled = 1)

14 EMIOS_CCR See Table 17-10 UCPRE: Selects clock divider 0b00 = divide by 1 0b11 = divide by 4 UCPREN: Prescaler enable (enabled = 1) BSL: Bus select (use internal counter, BSL = 0b11) EDPOL: Edge polarity (trigger on falling edge = 0) MODE: Selects the mode of operation. See Table 17-11 or 17-29 (we want output pulse width and frequency modulation, buffered, with FLAG set on both matches)

15 Lab 4 Software As usual, you are given mios.h with function prototypes; you will write the functions in mios.c, plus application code in lab4.c Four functions are required: Init_MIOS_clock Init_PWM Set_PWMPeriod Set_PWMDutyCycle

16 Lab 4 Software Init_MIOS_clock, Init_PWM: Configure the MCR, CCR and set initial values for the data registers Use the structure defined in MPC5553.h to access the registers Initialize the data registers to 50% duty cycle (zero torque output) Don t forget to turn on the output pads for the PWM channel /* Init data registers CADR and CBDR for 50% duty cycle */ EMIOS.CH[miosChannel].CADR.R = newperiod>>1; /* divide by 2 */ duty_cycle[mioschannel] = 0.50f; /* initialize static global */ EMIOS.CH[miosChannel].CBDR.R = newperiod; /* Turn on the output pads for our PWM channel */ SIU.PCR[179 + mioschannel].b.pa = 0b1; SIU.PCR[179 + mioschannel].b.obe = 0b1;

17 Lab 4 Software Set_PWMPeriod, Set_PWMDutyCycle 24 bit values written to data registers CADRn, CBDRn determine period and duty cycle Values are NOT units of time Clock Ticks per period For 120MHz system clock: counts_per_period = 120000000/PWM_FREQ

18 Lab 4 Assignment Use everything you ve learned so far: Read a duty cycle value from a QADC pin and output a PWM signal to the oscilloscope Drive the motor and haptic wheel with the PWM signal Experiment with different frequencies and observe motor response What do you expect to happen at 2Hz? 20KHz? Output and feel a constant 200 Nmm torque Implement the virtual spring and virtual wall using QD function of the etpu and the emios PWM Measure oscillation frequency for virtual spring, and timing of software loop that implements the spring Experiment with different values of the spring constant for the virtual wall and observe the effect

19 Lab 4 Assignment You will need to write the following code (template files are provided) worlds.h and worlds.c Code for the virtual spring and virtual wall As usual, prototypes are contained in worlds.h; you write the code for these functions in worlds.c motor.h and motor.c Code to generate motor output torque lab4.c Read the encoder, calculate the restoring torque and output the appropriate PWM to the motor