MicroToys Guide: Motors A. Danowitz, A. Adibi December A rotary shaft encoder is an electromechanical device that can be used to

Similar documents
Three-Stage Coil Gun

νµθωερτψυιοπασδφγηϕκλζξχϖβνµθωερτ ψυιοπασδφγηϕκλζξχϖβνµθωερτψυιοπα σδφγηϕκλζξχϖβνµθωερτψυιοπασδφγηϕκ χϖβνµθωερτψυιοπασδφγηϕκλζξχϖβνµθ

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

MSK4310 Demonstration

Lab 5: Inverted Pendulum PID Control

Application Note Using MagAlpha Devices to Replace Optical Encoders

L E C T U R E R, E L E C T R I C A L A N D M I C R O E L E C T R O N I C E N G I N E E R I N G

2.017 DESIGN OF ELECTROMECHANICAL ROBOTIC SYSTEMS Fall 2009 Lab 4: Motor Control. October 5, 2009 Dr. Harrison H. Chin

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

Shaft encoders are digital transducers that are used for measuring angular displacements and angular velocities.

MA3. Miniature Absolute Magnetic Shaft Encoder Page 1 of 8. Description. Order Using #MA3 starting at $36.00 per unit. Features

Sensors and Sensing Motors, Encoders and Motor Control

DC motor control using arduino

MICROPROCESSORS A (17.383) Fall Lecture Outline

EE 308 Spring S12 SUBSYSTEMS: PULSE WIDTH MODULATION, A/D CONVERTER, AND SYNCHRONOUS SERIAN INTERFACE

SHAFTED ROTARY POSITION SENSORS

Sensors and Sensing Motors, Encoders and Motor Control

MICROCONTROLLERS Stepper motor control with Sequential Logic Circuits

EE 314 Spring 2003 Microprocessor Systems

MA3. Miniature Absolute Magnetic Shaft Encoder Page 1 of 8. Description. Mechanical Drawing. Features

Massachusetts Institute of Technology. Lab 2: Characterization of Lab System Components

Design of double loop-locked system for brush-less DC motor based on DSP

dspic30f Quadrature Encoder Interface Module

MAE3. Absolute Magnetic Kit Encoder Page 1 of 8. Description. Mechanical Drawing. Features

PIC Analog Voltage to PWM Duty Cycle

Embedded Hardware Design Lab4

Interfacing to Analog World Sensor Interfacing

Microcontroller Based Closed Loop Speed and Position Control of DC Motor

University of California, Berkeley EE128, Fall Lab 7 A Microcontroller Based Position/Speed Controller

Data Sheet. AEAT-601B Incremental Magnetic Encoder. Description. Features. Exploded View. Applications

ECE 511: FINAL PROJECT REPORT GROUP 7 MSP430 TANK

Optical Kit Encoder Page 1 of 5. Description. Features

CprE 288 Introduction to Embedded Systems (Output Compare and PWM) Instructors: Dr. Phillip Jones

Lock Cracker S. Lust, E. Skjel, R. LeBlanc, C. Kim

Designing with a Microcontroller (v6)

Position Sensors. The Potentiometer.

AEDA-3200-Txx Series Ultra Miniature, High Resolution Incremental Encoders

ELCT 912: Advanced Embedded Systems

Data Sheet. AEDT-9340 Series High Temperature 115 C 1250/2500 CPR 6-Channel Commutation Encoder. Description. Features.

SERVO MOTOR CONTROL TRAINER

TECHNICAL DATASHEET Absolute Encoder AC 36 - BiSS / SSI

Mercury technical manual

Data Sheet. HEDL-65xx, HEDM-65xx, HEDS-65xx Series Large Diameter (56 mm), Housed Two and Three Channel Optical Encoders. Description.

Laboratory Seven Stepper Motor and Feedback Control

Computer Numeric Control

Modeling, Simulation and Implementation of Speed Control of DC Motor Using PIC 16F877A

Using Magnetic Sensors for Absolute Position Detection and Feedback. Kevin Claycomb University of Evansville

Operating Instructions

Engineering 6806 Project Design Labs in Electrical/Computer Engineering

PIC ADC to PWM and Mosfet Low-Side Driver

ANGULAR POSITION CONTROL OF DC MOTOR USING SHORTEST PATH ALGORITHM

MicroToys Guide: Motors N. Pinckney April 2005

Speed Feedback and Current Control in PWM DC Motor Drives

J1 Line APPLICATION FEATURES DESCRIPTION RUGGED-DUTY SHAFTED ENCODERS

Chapter 6: Sensors and Control

Data Sheet. AEDB-9340 Series 1250/2500 CPR Commutation Encoder Modules with Codewheel. Features. Description. Applications

AN ARDUINO CONTROLLED CHAOTIC PENDULUM FOR A REMOTE PHYSICS LABORATORY

Hello, and welcome to this presentation of the FlexTimer or FTM module for Kinetis K series MCUs. In this session, you ll learn about the FTM, its

Microprocessors A Lab 4 Fall Analog to Digital Conversion Using the PIC16F684 Microcontroller

Compatible Products: LAC L12-SS-GG-VV-P L16-SS-GG-VV-P PQ12-GG-VV-P P16-SS-GG-VV-P T16-SS-GG-VV-P

EE 308 Lab Spring 2009

The line driver option offers enhanced performance when the encoder is used in noisy environments, or when it is required to drive long distances.

Project Proposal. Low-Cost Motor Speed Controller for Bradley ECE Department Robots L.C.M.S.C. By Ben Lorentzen

PSoC Academy: How to Create a PSoC BLE Android App Lesson 9: BLE Robot Schematic 1

Controlling DC Brush Motor using MD10B or MD30B. Version 1.2. Aug Cytron Technologies Sdn. Bhd.


Real-time Math Function of DL850 ScopeCorder

ams AG austriamicrosystems AG is now The technical content of this austriamicrosystems application note is still valid. Contact information:

Position and Velocity Sensors

Mini Encoder High Resolution

Small DC Motor Control

EXPERIMENT 6: Advanced I/O Programming

Optical Kit Encoder Page 1 of 11. Description. Mechanical Drawing. Features

Allen-Bradley. Using the 1756-MO2AE with the TR Encoder (Cat. No ) Application Note

Lab 1: Steady State Error and Step Response MAE 433, Spring 2012

AS General Description. 2 The AS5245 Adapter board. AS5245-AB-v1.0 Adapterboard OPERATION MANUAL. Programmable Magnetic Rotary Encoder

Servo control: Ball on beam

DC Brushed Motor Controller Module EDP-AM-MC1

The quadrature signals and the index pulse are accessed through five inch square pins located on 0.1 inch centers.

The rangefinder can be configured using an I2C machine interface. Settings control the

A PID Controller for Real-Time DC Motor Speed Control using the C505C Microcontroller

DC Motor and Servo motor Control with ARM and Arduino. Created by:

Agilent AEDA-3200-Txx Series Ultra Miniature, High Resolution Incremental Encoders

Agilent AEDA-3300 Series Ultra Miniature, High Resolution Incremental Kit Encoders Data Sheet

A Comparison of Performance Characteristics of On and Off Axis High Resolution Hall Effect Encoder ICs

Stepping motor controlling apparatus

n Measuring range ,02 N m to N m n Clockwise and counter-clockwise torque n Low linearity deviation of ± 0.05 % F.S.

Exercise 2-2. Antenna Driving System EXERCISE OBJECTIVE DISCUSSION OUTLINE DISCUSSION

ECE 511: MICROPROCESSORS

Feedback Devices. By John Mazurkiewicz. Baldor Electric

Smart off axis absolute position sensor solution and UTAF piezo motor enable closed loop control of a miniaturized Risley prism pair

4 / 24,5 2,6 / steel, black coated. clockwise, viewed from the front face. ø15,9 ø17-0,052 ø6-0,05 8,1 ±0,3 2, T

Data Sheet. AEDS-9240 Series 360/720 CPR Commutation Encoder Module. Features. Description. Applications

Magnetic Encoder Kit User s Guide

Magnetic Sensor - Incremental / Absolute WMSA50

University of Texas at El Paso Electrical and Computer Engineering Department

Walle. Members: Sebastian Hening. Amir Pourshafiee. Behnam Zohoor CMPE 118/L. Introduction to Mechatronics. Professor: Gabriel H.

TECHNICAL DATASHEET Absolute Encoder AC 36 - BiSS / SSI

Interfacing dspace to the Quanser Rotary Series of Experiments (SRV02ET)

Rotary Encoder System Compact Model Range

Transcription:

Introduction A rotary shaft encoder is an electromechanical device that can be used to determine angular position of a shaft. Encoders have numerous applications, since angular position can be used to determine position or velocity of a mechanical device connected to a shaft making them ideal for speed control or for precise motor movement. A common application is in motor feedback and motors are commonly sold with encoders attached to the end. There are two general types of shaft encoders, absolute and relative. Absolute encoders offer the exact angular position of a shaft at any given time, whereas relative encoders can only measure change in angular position relative to an arbitrary datum (such as the moment a switch is activated). In the case of relative encoders, more sensors are required if exact position is desired. This paper documents an absolute shaft encoder, primarily due to ease of integration and cost. Construction of both sensors is different; however, the general principle is the same. Optical sensors detect patterns on a rotating disk, which are directly attached to a rotating shaft (which can then be connected to the device of interest, such as a motor s shaft). Absolute encoders commonly use optical sensors which read graycodes on the disk (Figure 1). Depending on accuracy, this could be a simple black dot which the sensor detects on each rotation. For slightly more precision, a basic code can be printed on a paper disk using a postscript utility, then glued on to a solid disk (see References).

Figure 1: Sample Encoded Disks This code must then be decoded in hardware or software to determine the corresponding angular position. Relative encoders also use optical detectors and disks; the disks have radial slots which the optical detectors recognizes each time it passes through its field of view. More sensors can be attached to increase precision, and if direction (forward/reverse) is desired, then the design requires two sensors at a phase offset (such encoders are called quadrature encoders). Although the absolute shaft encoder documented in this paper does not utilize the above techniques, the background is useful if the reader is designing their own encoder (there is an excellent link in the References section to a site describing exactly how to do design your own encoder). The encoder described here, the MA2 miniature absolute magnetic shaft encoder, uses magnetic techniques to provide 0.35 resolution at 1024 positions per revolution. There are two output options, analog and PWM. The analog option outputs an analog voltage between 0V and the input voltage (maximum of 5V) that is proportional to the absolute shaft position. The PWM option outputs a pulse width modulated digital signal nearly 1000 times per second with a duty cycle that is proportional to the absolute shaft position. Both encoders offer the same functionality, so

choosing which to purchase is primarily a function of preference and the capabilities of the microcontroller. When ordering the encoder, there are a number of other options including ball bearings and shaft diameter. It is highly recommended the user purchases the ball bearing option and also buys the connector offered by US Digital, as the non-ball bearing option has significant resistance in rotation and the encoder requires the manufacturer s custom connector. For details, see the US Digital purchase site (References). Analog Absolute Shaft Encoder A diagram of the absolute encoder is shown in Figure 2. There are inputs for ground and Vdd (maximum of 5V). The encoder has one output which consists of a voltage, between 0 and Vdd, which indicates the current shaft angular position relative to an arbitrary reference position. There is a jump discontinuity in the voltage output as the shaft completes a revolution and the output drops from Vdd to 0V. Because of this, when the encoder shaft is spun at a constant speed, the output should take the form of a sawtooth wave.

Coupling Figure 2: A schematic of the shaft encoder. In order to use the US Digital magnetic shaft encoder, the encoder shaft must first be coupled to the DC motor shaft. Several of the motors in the Microprocessors s lab have a small portion of the motor shaft jutting out of the back of the motor; coupling the encoder to the motor shaft here is ideal since it will not get in the way of normal shaft operation. In order to physically couple the two shafts together, US Digital markets a number of couplers to attach the encoder to various shaft sizes. According to their applications engineer, however, rubber tubing should work just as well. The rubber washer-like inserts used in standard screwdriver packaging can also be successfully used for coupling. For ease of coupling, be sure to purchase the ball bearing option! Velocity Calculations Before the shaft encoder can be used in a digital system, the change in A/D conversion values between sampling periods must be correlated to an actual angular

velocity of the encoder shaft. Since the Harrisboard 2.0 provides a regulated 3.3V power supply for peripherals, 3.3V is used as Vdd for the purposes of these calculations. The encoder works by varying an analog output from GND at the zero degrees shaft position to V dd at roughly one full rotation. Thus, the voltage output of the encoder over any single turn can be represented by the equation: ba = V (1) where V is the encoder output voltage, A is the shaft angle (in degrees) and b is a scaling factor. Given V = 3.3V at A = 360, b = 0.009167. Given a desired shaft speed of X rpm, to find the change in A/D values between sampling, first convert to revolutions per second by dividing by 60: X Z = rps (2) 60 where Z is the speed in revolutions per second and X is the shaft speed as defined above. Next, use the sampling encoder sampling rate S to determine the desired change in angle A between measurements: Z A = *360 (3) S This can be converted into a desired encoder V by plugging A into equation (1). Once V has been found, the desired change in A/D readout between samples can be determined. Since the PIC is based on an 8-bit architecture, it is common for only the upper 8 bits of the 10 bit A/D value to be used. Assuming an 8 bit A/D value, the input voltage range of 0 to 3.3V is essentially divided into 256 discrete voltage steps of 3.3V 256 = 0.012890624. Thus, the desired difference between any two successive V ADval values is:

AD =. 012890625 V 0 (4) Since the encoder essentially produces a sawtooth waveform, whenever the shaft completes a revolution, equation (4) no longer holds true and AD becomes a relatively large negative number. If the shaft is guaranteed to always be traveling in the forward direction, then if AD is negative, the shaft must have completed a revolution. In order to get the change in position out of this, merely subtract the AD value from 0x100 which should account for the shaft overflow. If the shaft is expected to travel both forwards and backwards, overflow can essentially be estimated by comparing the last two AD values. If the latest AD is negative and the previous value is positive, assuming that the motor changes direction relatively infrequently compared to the number of revolutions made by the shaft, it is safe to assume that the shaft has overflowed and 0x100 should be added to the AD value. Cost Part Number Details Price MA-2-A Analog Absolute Shaft Encoder $29.00 B8 (1/8" ball bearing option) $6.00 CA-7941-1FT Connector with cables attached $5.00 References Application of Absolute Shaft Encoder in PID Motor Controller: <Prof Harris, please include hyperlink to our PID motor contoller Microp s Project> MA2 Absolute Shaft Encoder Purchase Site: http://www.usdigital.com/products/ma2/ Useful sight on designing your own encoder: http://www.geology.smu.edu/~dpa-www/robo/encoder/pitt_html/encoders.html

Appendix A: Final C code /* Encoder_Reader.c: Sample code for reading and * calculating velocity from an analog * output absolute shaft encoder. * Authors: Andrew Danowitz, Amir Adibi * Date: December 2006 */ #include <p18f452.h> #include <timers.h> short ADLast[2] = 0,0; //previous AD values short ADPres; //latest AD value /* Function Prototypes */ void main(void); void isr(void); #pragma code low_vector = 0x18 void low_interrupt(void) _asm GOTO isr _endasm #pragma code void main(void) TRISA = 0xFF; //Set A/D converter port for input //Set up timer 1 to interrupt roughly once every 10ms INTCON = 0xF0; //enable interrups TMR0H = 0x00; //set timer initial values TMR0L = 0x3D; T0CON = 0xC7; //start the timer //wait for timer interrupt while(1)

#pragma interruptlow isr void isr(void) //reset the timer INTCON = 0xF0; //enable interrups TMR0H = 0x00; //set timer initial values TMR0L = 0x3D; T0CON = 0xC7; //start the timer //Configure the A/D converter to read from encoder ADCON1 = 0x00; ADCON0 = 0x8D; //Wait for valid A/D data while(adcon0bits.go==1) //Read A/D value ADPres = ADRESH; //if the voltage has only decreased this last round, //then we assume that the shaft has just completed a //rotation and is still moving forward. if (ADPres>=0x00F0 && ADLast[1]<=0x0010) //If the shaft did overflow, then the difference //between the new and old angle values is 0x100 //plus the new eight bit angle value minus the //old angle value dad = 0x0100+ADLast[1] - ADPres; //If the shaft hasn't completed a revolution, the //change in angle is just new minus old else dad = ADLast[1]-ADPres; //Push the latest AD value into the stack ADLast[0] = ADLast[1]; ADLast[1] = ADPres;