Name Signed. Introduction In this lab you will control the angular position of a Servo motor using the PWM module with the HCS12 board.

Similar documents
Pulse Width Modulation Applications

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

ETEC Digital Controls PIC Lab 10 Pulse Width Modulation

CHAPTER 11: Flip Flops

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

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

Servo Info and Centering

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

Timer A (0 and 1) and PWM EE3376

Interrupts and the Timer Overflow Interrupts Huang Sections What Happens When You Reset the HCS12?

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

MANUAL FOR RX700 LR and NR

Small Hardware Development and Prototyping Board for the SX28

Lab Experiment 1: The LPC 2148 Education Board

M68EVB908QL4 Development Board for Motorola MC68HC908QL4

EMBEDDED C USING CODEWARRIOR Getting Started Manual

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

Global Motion Technology Inc Web THCSA200. Capacitive sensor plasma & Oxy-fuel Torch Height Control

SKP16C62P Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

Software Manual RS232 Laser Merge Module. Document # SU Rev A

Chapter 02: Computer Organization. Lesson 04: Functional units and components in a computer organization Part 3 Bus Structures

Arduino Motor Shield (L298) Manual

RC Camera Control. User Guide v /20/2012

How to read this guide

Decimal Number (base 10) Binary Number (base 2)

CAUTION! THE 7I29 USES VOLTAGE AND POWER LEVELS THAT REPRESENT A HAZARD TO LIFE AND LIMB.

Computer Organization and Components

DC Motor control Reversing

Freescale Semiconductor, I

Talon and Talon SR User Manual

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

PROJECT PRESENTATION ON CELLPHONE OPERATED ROBOTIC ASSISTANT

Ocean Controls RC Servo Motor Controller

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

Using the HCS12 Serial Monitor on Wytec Dragon-12 boards. Using Motorola s HCS12 Serial Monitor on Wytec s Dragon-12 boards

AVR Butterfly Training. Atmel Norway, AVR Applications Group

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

AN3332 Application note

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

CoE3DJ4 Digital Systems Design. Chapter 4: Timer operation

Table 1 Comparison of DC, Uni-Polar and Bi-polar Stepper Motors

Interfacing Analog to Digital Data Converters

Push button 2, 3, 5gang with room thermostat (RTR) and display flush-mounted xx, xx, xx

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

ECE 495 Project 3: Shocker Actuator Subsystem and Website Design. Group 1: One Awesome Engineering

Allen-Bradley/Rockwell

Lab 3: Introduction to Data Acquisition Cards

Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362

Basic Pulse Width Modulation

UNIVERSITY OF COLIMA Smart Car Race

How To Use A Watt Saver On A Microcontroller (Watt Saver) On A Cell Phone Or Mp3 Player

DKWF121 WF121-A B/G/N MODULE EVALUATION BOARD

ASYNCHRONOUS COUNTERS

Optimize your simple machines... Modicon M218 Selection Guide

Introduction to Arduino

How To Use A Power Supply On A Powerline 2.2 (Ai)

isppac-powr1220at8 I 2 C Hardware Verification Utility User s Guide

Quick Start Guide. MRB-KW01 Development Platform Radio Utility Application Demo MODULAR REFERENCE BOARD

Work with Arduino Hardware

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

Accurate Measurement of the Mains Electricity Frequency

PICNet 1. PICNet 1 PIC18 Network & SD/MMC Development Board. Features. Applications. Description

The enable pin needs to be high for data to be fed to the outputs Q and Q bar.

MODEL 5010 DUAL CHANNEL SMOKE/FIRE DETECTION MODULE

ADS9850 Signal Generator Module

MIDECO 64-outputs MIDI note decoder USER MANUAL. Roman Sowa 2012

Quick Start Guide. TWR-MECH Mechatronics Board TOWER SYSTEM

Lab 1: Introduction to Xilinx ISE Tutorial

EXPERIMENT 8. Flip-Flops and Sequential Circuits

ET-BASE AVR ATmega64/128

Scripting Language Reference. SimpleBGC 32bit

Serial Communications

8-ch RAID0 Design by using SATA Host IP Manual Rev1.0 9-Jun-15

HT1632C 32 8 &24 16 LED Driver

Using the Siemens S65 Display

Robot Board Sub-System Testing. Abstract. Introduction and Theory. Equipment. Procedures. EE 101 Spring 2006 Date: Lab Section # Lab #6

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

UniPi technical documentation REV 1.1

User and installation manual

RPLIDAR. Low Cost 360 degree 2D Laser Scanner (LIDAR) System Development Kit User Manual Rev.1

DCDC-USB. 6-34V 10A, Intelligent DC-DC converter with USB interface. Quick Installation Guide Version 1.0c P/N DCDC-USB

Digital I/O: OUTPUT: Basic, Count, Count+, Smart+

WEA-Base. User manual for load cell transmitters. UK WEA-Base User manual for load cell transmitters Version 3.2 UK

Table 1 below is a complete list of MPTH commands with descriptions. Table 1 : MPTH Commands. Command Name Code Setting Value Description

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

Tutorial. replace them with cell-phone operated module. The advantages of a cell-phone operated bot are:-

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

A 5 Degree Feedback Control Robotic Arm (Haptic Arm)

DMX-K-DRV. Integrated Step Motor Driver + (Basic Controller) Manual

User Guide Reflow Toaster Oven Controller

HC(S)08-System for Development and Training

Manual Serial PCI Cards

3. Programming the STM32F4-Discovery

Easy Step 1000 Stepper Driver Module

HC12 Assembly Language Programming

Flexible Active Shutter Control Interface using the MC1323x

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

Freescale Semiconductor, I

Analog Servo Drive 25A8

Programming A PLC. Standard Instructions

Transcription:

CENG 412 Embedded Systems Lab 11 Servo Motor Angular Position Control Name Signed Introduction In this lab you will control the angular position of a Servo motor using the PWM module with the HCS12 board. Equipment HCS12 workstation, standard bench equipment, Servo Motor Procedure Part A On the course web site locate and read the Servo Motor Control handout and answer the following questions. Use the Lab 11 Work Sheet to configure the program code. 1. What is the period and frequency of the pulse train needed to be sent to the Servo motor to control its position? Period Frequency 2. What are the pulse width (time high) values needed to position the motor at the 0 degree position 90 (or neutral) position 180 position 3. What are the pulse train duty cycle values needed to position the motor at the 0 degree position 90 (or neutral) position 180 position 4. What is the pin number for PWM channel 0 on the Demo Board header connector? Pin number Procedure Part B Create a CodeWarrior C and Relocatable Assembler project. 1

Assembler Code For the Assembly code write a program that outputs a square wave at the frequency determined above on PWM channel 0 on the Demo Board at the pin determined above. The C code will pass a parameter to the Assembler code to set the Duty Cycle of the square wave. In the Assembler code save this value in memory. Later in the code you will need to load this value into the PWMDTY0 register. Because of the low frequency requirements for the square wave, the Assembler code will need to use a pre-scale value for both ClockA (divide by 16) and ClockSA (divide by 150). C Code For the Assembly code write a program that reads the values from the Pushbutton switches on the Demo Board, processes this data and does the following: When SW2 is pressed the motor will move to the 0 degree position When SW3 is pressed the motor will move to the 90 (or neutral) position When SW4 is pressed the motor will move to the 180 position Processing the Data When writing the C code to process your data you will need to take into account the following information: The Pushbuttons are connected to PORTAD0. Information on how the switches are connected is shown below. The switches are active low. The logic level of any of the switches goes from a High to a Low when the switch is pressed. Switches SW2, SW3 and SW4 are connected to bits 4, 5, and 6 of PORTADO. These will need to be shifted to the lower 3 bits for the masking operation. Use a Switch/Case statement in the C code framework and call a userprogrammed function called SetPosition that passes an integer value that represents Duty Cycle to the Assembler code to control the motor position. PORTAD0 The upper 4 bits of PORTAD0 are connected to the push button switches on the HC9S12 Demo Board. You must configure the bits in PORTAD0 by writing 1 s to the appropriate bits. 2

PORTAD0: equ $8f ;port AD0 data register (input only) ATD0DIEN: equ $8d ;port AD0 Digital Input Enable register ;(0-disable digital input, 1-enable digital input) Figure 1: Basic Port AD0 Registers CPU Board Demo Board H1 Pin No. PAD7 26 SW5 SW2 SW3 SW4 SW5 PAD6 27 SW4 PAD5 28 SW3 PAD4 29 SW2 PAD3 PAD2 PAD1 25 24 23 LIGHT POT TEMP PAD0 22 n/c Figure 2: Pushbutton switches on HCS12 Workstation Circuit Set-Up The Servo motor has 3 wires, Red, Black and White. Connect the Red wire to + 5V on a DC power supply, the Back wire to ground of the power supply and the White wire to required pin on the Demo board Header. Be sure that the ground of the power supply is connected to the ground of the Servo motor and the ground of the HC9S12 board. Measurements Connect a scope to the Demo Board pin to view the PWM waveform created. Measure the Period T of the PWM waveform 3

PWM waveform Period Press SW2. Measure the Time High of the PWM waveform Press SW3. Measure the Time High of the PWM waveform Press SW4. Measure the Time High of the PWM waveform Do these measured values agree with those in Part A step 2? C Code ************************************* Servo Motor Position Control Lab1 - CENG 412 DGL March 26/12 This programs controls the angular position of a Servo motor. Input signal from Push Button switches. Program passes parameter for duty cycle value to the Assembler program that uses PWM function Be sure that the ground of the power supply is connected to the ground of the Servo motor and the ground of the HC9S12 board. ************************************** #include "derivative.h" #include <hidef.h> #include <stdio.h> void SetPosition(int); derivative-specific definitions common defines and macros function prototype void main(void) { ATD0DIEN = 0x70; enable PortAD0 for digital input while(1) { switch ((~PORTAD0>>4)&0x07) process bits 0-2 of modified PortAD0 contents { case 1: SetPosition(x); break; 0 deg position case 2: SetPosition(y); break; 90 deg position case 4: SetPosition(z); 180 deg position asm("swi"); 4

Assembly Code ;***************************************** ;* ;* Assembler function using PWM to control ;* Servo motor position. Position ;* control value is passed as a parameter. ;* Servo requires a 20 msec pulse train ;* Duty cycle parameter is passed from C code ;* Uses PWM channel 0 ;* ;***************************************** XDEF SetPosition include mc9s12dp256.inc ;register addresses defined in the file mc9s12dp256.inc PWME0: equ $?? ;mask to enable channel 0 dutyc: ds.b 01 ;reserve 1 byte in memory for duty cycle value SetPosition: stab dutyc movb #01, PWMCLK ;select ClockSA movb #$??, PWMPRCLK ;select Clock A prescale to 16 movb #$??, PWMSCLA ;select ClockSA prescale to 150 movb #1, PWMPOL ;channel 0 O/P high at start movb #0, PWMCAE ;select left aligned mode movb #$0C, PWMCTL ;8 bit mode, stop PWM in wait and freeze mode movb #???, PWMPER0 ;set PWM period as 20 msec movb dutyc,pwmdty0 ;load duty cycle value from memory movb #0, PWMCNT0 ;reset PWM0 counter movb #PWME0,PWME ;enable PWM channel 0 rts Lab Exercise Written by David Lloyd Computer Engineering Program Humber College 5