Single Chip Velocity Measurement System for Incremental Optical Encoders

Similar documents
CHAPTER III THE FPGA IMPLEMENTATION OF PULSE WIDTH MODULATION

dspic30f Quadrature Encoder Interface Module

Digital Systems Design

Audio Sample Rate Conversion in FPGAs

CS302 - Digital Logic Design Glossary By

UNIT-II LOW POWER VLSI DESIGN APPROACHES

Imaging serial interface ROM

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

Electronics Design Laboratory Lecture #4. ECEN 2270 Electronics Design Laboratory

EE 314 Spring 2003 Microprocessor Systems

Implementation of High Precision Time to Digital Converters in FPGA Devices

Analogue Interfacing. What is a signal? Continuous vs. Discrete Time. Continuous time signals

CHAPTER 5 NOVEL CARRIER FUNCTION FOR FUNDAMENTAL FORTIFICATION IN VSI

CS302 Digital Logic Design Solved Objective Midterm Papers For Preparation of Midterm Exam

Section 1. Fundamentals of DDS Technology

Control Systems Overview REV II

Field Programmable Gate Array-Based Pulse-Width Modulation for Single Phase Active Power Filter

PE713 FPGA Based System Design

UNIVERSITY OF VICTORIA FACULTY OF ENGINEERING. SENG 466 Software for Embedded and Mechatronic Systems. Project 1 Report. May 25, 2006.

BEE 2233 Digital Electronics. Chapter 1: Introduction

IMPLEMENTATION OF G.726 ITU-T VOCODER ON A SINGLE CHIP USING VHDL

CIS009-2, Mechatronics Signals & Motors

APPLICATION OF PROGRAMMABLE LOGIC DEVICES FOR ACQUISITION OF ECG SIGNAL WITH PACEMAKER PULSES 1. HISTORY OF PROGRAMMABLE CIRCUITS

Hello and welcome to this Renesas Interactive Course that provides an overview of the timers found on RL78 MCUs.

INF3430 Clock and Synchronization

INTRODUCTION. In the industrial applications, many three-phase loads require a. supply of Variable Voltage Variable Frequency (VVVF) using fast and

EMBEDDED DOPPLER ULTRASOUND SIGNAL PROCESSING USING FIELD PROGRAMMABLE GATE ARRAYS

Hardware/Software Co-Simulation of BPSK Modulator and Demodulator using Xilinx System Generator

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

Undefined Obstacle Avoidance and Path Planning

FPGA Implementation of a Digital Tachometer with Input Filtering

Advances in Antenna Measurement Instrumentation and Systems

A PC-BASED TIME INTERVAL COUNTER WITH 200 PS RESOLUTION

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

CHAPTER 4 FIELD PROGRAMMABLE GATE ARRAY IMPLEMENTATION OF FIVE LEVEL CASCADED MULTILEVEL INVERTER

Digital Logic ircuits Circuits Fundamentals I Fundamentals I

Generation of Gaussian Pulses using FPGA for Simulating Nuclear Counting System

PVA Sensor Specifications

Application Note: Pulse and Direction for the Position and Velocity Commands

Module 5. DC to AC Converters. Version 2 EE IIT, Kharagpur 1

Design and implementation of LDPC decoder using time domain-ams processing

64-Macrocell MAX EPLD

DFT for Testing High-Performance Pipelined Circuits with Slow-Speed Testers

Design and FPGA Implementation of an Adaptive Demodulator. Design and FPGA Implementation of an Adaptive Demodulator

FPGA Implementation of Digital Modulation Techniques BPSK and QPSK using HDL Verilog

Data Sheet. HCTL-2000 Quadrature Decoder/Counter Interface ICs HCTL-2000, HCTL-2016, HCTL-2020

PID Implementation on FPGA for Motion Control in DC Motor Using VHDL

PWM System. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

DS1075 EconOscillator/Divider

Implementing Logic with the Embedded Array

Chapter 5: Signal conversion

IMPLEMENTATION OF QALU BASED SPWM CONTROLLER THROUGH FPGA. This Chapter presents an implementation of area efficient SPWM

Controlling an AC Motor

DESIGN OF INTELLIGENT PID CONTROLLER BASED ON PARTICLE SWARM OPTIMIZATION IN FPGA

MS Project :Trading Accuracy for Power with an Under-designed Multiplier Architecture Parag Kulkarni Adviser : Prof. Puneet Gupta Electrical Eng.

DYNAMICALLY RECONFIGURABLE PWM CONTROLLER FOR THREE PHASE VOLTAGE SOURCE INVERTERS. In this Chapter the SPWM and SVPWM controllers are designed and

GE423 Laboratory Assignment 6 Robot Sensors and Wall-Following

87000 Series Size 34 Hybrid Linear Actuators

Analog I/O. ECE 153B Sensor & Peripheral Interface Design Winter 2016

Analog Inputs and Outputs

Digital Pulse-Frequency/Pulse-Amplitude Modulator for Improving Efficiency of SMPS Operating Under Light Loads

DESIGN OF MULTIPLYING DELAY LOCKED LOOP FOR DIFFERENT MULTIPLYING FACTORS

8253 functions ( General overview )

DS1075. EconOscillator/Divider PRELIMINARY FEATURES PIN ASSIGNMENT FREQUENCY OPTIONS

Field Programmable Gate Arrays based Design, Implementation and Delay Study of Braun s Multipliers

Computer Architecture Laboratory

Speed Control of BLDC Motor Using FPGA

Low-Power Digital CMOS Design: A Survey

Chapter 2 Analog-to-Digital Conversion...

AN APPLICATION SPECIFIC INTEGRATED CIRCUIT FOR DUAL-AXIS MOTION CONTROL

Combinational logic: Breadboard adders

AUTOMATIC IMPLEMENTATION OF FIR FILTERS ON FIELD PROGRAMMABLE GATE ARRAYS

In this lecture. System Model Power Penalty Analog transmission Digital transmission

Lecture 3, Handouts Page 1. Introduction. EECE 353: Digital Systems Design Lecture 3: Digital Design Flows, Simulation Techniques.

DIGITAL FILTERING OF MULTIPLE ANALOG CHANNELS

Simple Path Planning Algorithm for Two-Wheeled Differentially Driven (2WDD) Soccer Robots

Course Introduction. Content 20 pages 3 questions. Learning Time 30 minutes

28000 Series Size 11 Double Stack Hybrid Linear Actuators

DS1867 Dual Digital Potentiometer with EEPROM

MICROPROCESSORS AND MICROCONTROLLER 1

Run-time Power Control Scheme Using Software Feedback Loop for Low-Power Real-time Applications

DAV Institute of Engineering & Technology Department of ECE. Course Outcomes

Module -18 Flip flops

Clock and Data Recovery With Coded Data Streams Author: Leonard Dieguez

A HARDWARE DC MOTOR EMULATOR VAGNER S. ROSA 1, VITOR I. GERVINI 2, SEBASTIÃO C. P. GOMES 3, SERGIO BAMPI 4

Lecture 11: Clocking

Model 305 Synchronous Countdown System

AN FPGA IMPLEMENTATION OF ALAMOUTI S TRANSMIT DIVERSITY TECHNIQUE

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

When to use an FPGA to prototype a controller and how to start

EVDP610 IXDP610 Digital PWM Controller IC Evaluation Board

DS1267B Dual Digital Potentiometer

IES Digital Mock Test

A Variable-Frequency Parallel I/O Interface with Adaptive Power Supply Regulation

Size 23 Double Stack External Linear Size 23 Double Stack. 57M4 n n n n n n. 57L4 n n n n n n. E57M4 n n n n n n. Bipolar 5 VDC 12 VDC 2.

High Speed Binary Counters Based on Wallace Tree Multiplier in VHDL

FPGA IMPLEMENTATION OF POWER EFFICIENT ALL DIGITAL PHASE LOCKED LOOP

Speed Measurement Method for Digital Control System

Towards PVT-Tolerant Glitch-Free Operation in FPGAs

A COMPARISON ANALYSIS OF PWM CIRCUIT WITH ARDUINO AND FPGA

Transcription:

Single Chip Velocity Measurement System for Incremental Optical Encoders Pamela Bhatti, Blake Hannaford* Department of Electrical Engineering University of Washington, Seattle, WA 98195-2500 * corresponding author blake@ee.washington.edu (email) 083 In Press, IEEE Transactions on Control Systems Technology, June 1997. ABSTRACT A single chip system is designed, implemented, tested and analyzed for the measurement of velocity from incremental optical encoders with quadrature outputs. The system uses a field programmable gate array (FPGA) chip to take advantage of high flexibility and a low cost design cycle. The device uses two counting methods: period counting for low velocities and frequency counting for high velocities to obtain high resolution measurements for a wide range of velocities with a fixed 16bit word length. Verification testing of the device was consistent with predicted error and showed that quantization errors can be made arbitrarily small by adjusting the trade-off between velocity range and minimum resolution. This trade-off can be adjusted by the designer by simple modifications to the basic design. ACNOWLEDGEMENTS This research was supported in part by the National Science Foundation Presidential Young Investigator Award to the second author. We would also like to thank Jeff Hirschberg of the University of Washington Department of Computer Science and Engineering for valuable assistance with FPGA programming techniques and equipment. 1

1. Introduction In even the most basic controllers, PD or PID for example, velocity and position information are required. Angular position and velocity can be determined from an incremental optical encoder mounted on a rotating shaft. Optical shaft encoders are widely used transducers which have applications in robotics, manufacturing, semiconductor equipment, motors, and the medical industry. An optical encoder translates an angular position change into an electrical signal (figure 1). A digital encoder outputs a pair of digital square waves that are 90 degrees apart (quadrature) which convey the shaft s position change, as well as the direction of rotation. The rotational speed of the shaft can also be determined from the encoder output. The longer the period of the digital wave, the slower the encoder wheel is turning. To measure speed, a commonly used algorithm is to count a specific state transition (e.g. low to high) of a single wave during a fixed time interval. The angular speed is directly proportional to the number of transitions per second, or frequency of the quadrature wave: ω = counts ----------------- second 1 ------------------------------------------------ 2 π --------------------------- radians counts revolution revolution (1) A variety of implementations exist to determine position or velocity from an optical encoder signal. Readily available hardware, such as the HCTL-2000 integrated circuit, produces an angular optical encoder LED phototransistors cha chb (a) (b) (c) Figure 1. Optical encoder (a) Optical encoder mounted on robot manipulator: the resolution of the encoder is determined by the slit density of the encoder wheel - counts per revolution. (b) Transduction circuitry: an LED acts as a light source and phototransistors respond to light transmitted through the slits to produce a quadrature wave using supporting electronic circuitry. (c) Quadrature wave. 2

position measurement from encoder output. For the task of angular velocity measurement, there is currently very little available hardware. In some cases, customized hardware has been designed for velocity measurement [1,2]. As an alternative to hardware, the velocity measurement can be computed in software. The computation may use the position measurement or the encoder signal directly. It is desirable to enlist an optical encoder to determine both position and velocity. Using a single transducer to determine position and velocity reduces the total weight and complexity of the measurement system. For the highest performance systems, it is advantageous to determine the velocity in hardware. This approach is the most direct, quickest and least computationally intensive. It offers the programmer a result from which further computations may be carried out as required. In this paper we present a compact, single chip velocity measurement system (SCVMS) for optical encoders. The SCVMS employs two simple measurement techniques to significantly increase the available velocity measurement range, and can automatically select the highest resolution output for each velocity measurement. The two methods are: (1) to count the frequency of the quadrature signal for high velocities, and (2) to count the period of the quadrature signal for low velocities. The results of each method must be further processed by a microprocessor or other computer system. The frequency count must be converted to appropriate user units by multiplication by a constant. The period count must be inverted and then multiplied by a constant. Field-programmable gate array (FPGA) technology is an attractive choice to implement the velocity measurement system. FPGAs are high density chips and provide the user with 10 to 100 times greater logic capacity than Programmed Array Logic (PAL) devices. Also, since FPGAs are user-programmable, they significantly reduce the design to validation time by allowing in-house configuration. We chose the Xilinx LCA3000 FPGA series due to its logic capacity and I/O pin availability. It is also possible to measure velocity in software. There are three main approaches. First, both of the methods used by the SCVMS to measure angular velocity (period count and frequency count) could be implemented in software. For each technique, assisting hardware must send an interrupt to the software when an encoder output transition is observed. The software must then compute the frequency and period from the interrupts to measure the encoder velocity. Both of these approaches calculate the first difference of the angular position to produce a velocity measure- 3

ment. A band pass filter is required to filter out high frequency sampling noise, and differentiate the encoder position signal. A better filter is more computationally complex, and has a longer latency [3]. A third approach is to use model based techniques such as the alman Filter [4,5]. However, this technique usually requires floating point computation and models of the system dynamics, and noise statistics. If noisy signals are not a problem, which is a reasonable assumption for optical encoder signals, hardware is a good choice. Measuring the velocity directly in hardware is the quickest, and places the least computational demands upon the software system. Hardware velocity measurement requires additional hardware and thus increases costs. However, the new FPGA technology raises the possibility that the velocity measurement can be performed with a single chip. The purpose of this project was to evaluate the potential of FPGA technology in embedded highperformance control system design and to explore low-latency measurements of velocity from optical encoder signals. We do not attempt to derive an optimal velocity estimation algorithm in this project. Such a claim can only be made in the context of specific applications and signals. 4

2. Design Considerations In this section we will present a review of the two methods of operation of the SCVMS along with their inherent limitations. In addition, we will discuss how we selected the operating range for the current design of the SCVMS to offer a wide range of detectable velocities. In review, the SCVMS employs two counting-based methods to determine velocity: (1) to count the frequency of the quadrature signal for high velocities, and (2) to count the period of the quadrature signal for low velocities. To determine the frequency count, the number of transitions are counted over given time interval. To determine the period count, the time between two given transitions is counted. These two counting methods have limitations. For the frequency count, overflow occurs at high encoder frequencies. At low encoder frequencies the time between encoder transition is long and the frequency count loses resolution. The period count also presents a loss in resolution, but at high encoder frequencies where the time between transitions is short. As the encoder frequency becomes very low, the period count then overflows. The period count (output p ) is a function of the encoder frequency and the counter clock frequency: output p = f clkp ----------------- f encoder (2) For a given counter clock frequency and an n-bit counter, saturation will occur for f encoder f clkp -------------. For example, a 16bit period counter with a f clkp of 1kHz saturates at encoder 2 n 1 frequencies below 15x10-3 Hz. The saturation frequency can be decreased by using a larger counter, and/or decreasing the clock frequency. The frequency count (output f ) is a function of the encoder frequency and timing interval. A counter establishes a timing interval of duration ---------, where represents the timer counter maximum value, and represent the timer clock frequency. Hence, output f is: 5

32bit counter could be used with the minimum output level set to 10. For the frequency measure- output f = f encoder interval = f encoder --------- (3) For a given timing interval, saturation will occur for encoder --------- 2 n. For example, a 1 16bit counter with a timing interval of 10msec saturates at encoder frequencies above 6.6 MHz. The saturation frequency can be increased by using a larger counter, and/or decreasing the timing interval. The frequency count resolution is constrained to be, and the period count resolution is fixed --------- to f clkp. Since the SCVMS counts the period and frequency in parallel, it is able to select the output with the highest resolution in real time. A detailed error analysis will be presented in Section 5. As an initial heuristic, the SCVMS is designed to select the larger of the two output values, or allow both values to be accessed by the user. To illustrate this point, refer to Figure 2 in which a log-log plot of frequency vs. output is shown. The left curves illustrate the period count method for three f clkp values. The right curves illustrate the frequency count method for three timing intervals, ---------. The upper horizontal line indicates a 16bit counter saturation limit. Consider the case when =100 Hz and --------- = 100 msec. Each is illustrated by the solid curve in figure 2.When f encoder = f clkp, output p is 1. At the same encoder frequency, output f is 10. By using counter values from both counting methods, the SCVMS has two results to compare and can output the measurement with the highest result. As f another example, when f encoder = ------- clk, output f is 1 and output p is 10. Again, the SCVMS has the option to present the result with the highest counter value. The SCVMS design is limited to a 16bit counter. A larger counter could employ a single measurement technique to achieve the same dynamic range as presented by the SCVMS. For example, a 6

10 5 10 4 10 3 output 10 2 10 1 10 0 10-2 10 0 10 2 10 4 10 6 10 8 frequency (Hz) Figure 2. Log Output vs. Log Frequency The left curves illustrate the period count method for three f clkp values: f clkp =100Hz (-), 1Hz (x), and 10kHz (o). The right curves illustrate the frequency count method for intervals: --------- =100msec (-), --------- =10msec (x), and --------- =1msec (o). Note that the upper horizontal line indicates a 16 bit counter saturation limit. ment technique, an interval of 66sec allows detection of frequencies from 0.15Hz to 65MHz. This corresponds to a velocity update rate of 1.55x10-2 Hz, which is too slow for most practical control applications. For the period measurement technique, an f clk of 640MHz allows detection of frequencies from 0.15Hz to 64MHz. This requires a clock frequency well above the operating limit of Xilinx FPGAs (150MHz maximum) and most other logic devices. The SCVMS can be configured to operate on any combination of period count and frequency count curves. The user can select the minimum output value and the period count vs. frequency count transfer point. Also, the curve selection determines the maximum and minimum detectable 7

encoder frequencies. With the flexibility offered by the SCVMS design, the user can tailor the system for a velocity range of interest and a minimum level of resolution. To reconfigure the measurement system, f clk and f interval must be changed. The actual steps involved will be explained in Section 4: FPGA implementation procedure. For our hardware implementation, we chose parameters based upon a typical encoder with 1024 counts per revolution (cpr) and a maximum encoder speed of 10,000 revolutions per minute. This presented a maximum encoder frequency of 170,666 counts per second. We selected and --------- that would enable the SCVMS to detect the largest frequency range possible. The following criteria were considered in selecting f clkp and --------- : the maximum counter size was limited to 16bits for compatibility with microprocessor word length. This gives a maximum counter output of 2 16 1. The frequency count timing interval was chosen as 1msec for a 1kHz velocity update rate commonly used by advanced motion controllers (right o curve, Figure 2). Subsequently, we chose =1000 and =1MHz. This selection corresponds to a counter value of 170 at a maximum frequency of 170,667 Hz. For the period count, curves of three different f clkp frequencies are shown (Figure 2). The intersection of these curves with the 1msec interval curve set the transfer point, and the minimum output value. A minimum counter value of 3 was chosen which set f clkp as 10kHz (left o curve, Figure 2). 8

3. Design Description SCVMS CSEL position period freq count count count module module module output module 8 up down WRITE mode select 2 input module transition detector data cha chb 2 READ 2 address Figure 3. SCVMS Design Overview The main modules of the SCVMS are shown. In this section we present the velocity measurement system design using a hierarchical approach. Beginning with an functional overview, we then discuss the details of the current SCVMS design structure. Information concerning additional features for prototype testing, and personal computer (pc) or microprocessor interface will also be presented. The inputs to the system are a quadrature wave from the optical encoder, and a user selected measurement mode (mode select). The mode select signals are latched into the input module during a write cycle. This data determines whether the period count, frequency count or highest resolution 9

result is output. In addition to the 16bit position or speed result, the system also provides status information such as direction, counter overflow, data ready and output result type (eg. period, frequency, auto-period, etc.). Asserting the address lines during a read determines whether the status word or the measurement result is output. The SCVMS is structured as a set of functional modules (Figure 3). The quadrature wave is directed to the transition detector which outputs an up pulse or a down pulse based on the quadrature sequence. These pulses are input to the measurement modules : (1) 16bit position counter, (2) 16bit period counter and (3) 16bit frequency counter. Each of these modules operates in parallel. The results are directed to the output module which presents data as specified by mode select and address select. In the current design, the position counter is omitted. Although the Xilinx chip has the logic capacity to implement the complete design, Xilinx FPGA technology provides limited routing resources. Xilinx software enabled placement of the complete design but laborious hand routing would have had to be done. All of the other modules are implemented in the current design and we will describe the structure of each. Every module contains a state machine operating on a baseline clock of 4MHz. The transition detector module is mainly a state machine which takes the quadrature waves as the input and outputs up/down pulses to both measurement modules. The period count module is divided into a slow velocity state machine, a 16bit synchronous up counter (period counter), and an 18bit data register. The state machine controls the period counter and outputs signals such as direction, data ready, and counter overflow. A f clkp of 10kHz clocks the period counter. Its 16 bit value is latched into the 18bit data register by the data ready signal (DRl). The additional two bits of the data register contain the direction signal (Rdirl) and a counter overflow flag (RROL). The frequency counter is divided into a high velocity state machine, 8bit synchronous up counter (frequency counter), interval timer, and a 10bit data register. The state machine controls the frequency counter, interval timer and also outputs direction, data ready, and counter overflow signals. The timer provides a 1msec interval by counting to 1000 while clocked with a 1MHz signal. The frequency counter is clocked with up or down pulses and recognizes them only during the 10

1msec interval. The frequency counter was scaled down since only 8 bits are required to contain the maximum encoder frequency count for the encoder example we selected. The frequency counter value is latched into the 10bit data register by the data ready signal (DRh). The additional two bits of the data register contain the direction signal (Rdirh) and a counter overflow flag (RROh). To produce the required f clkp and, a set of frequency dividers are provided. A base two counter divides the baseline clock of 4MHz into 1MHz to generate. This 1MHz signal is divided further by two cascaded base 10 counters to produce a 10kHz signal for the period counter. The output module design is interface specific. For data acquisition and velocity calculations, we chose to interface the SCVMS with a pc. As a result, only 8 bits of the 18 bit output from the measurement modules can be read at a time. A multiplexer uses the address and mode select to chose the 8 bit word expressed during a read. Either the status word, the lower 8 bits of the measurement result, or the upper eight bits of the measurement result is displayed. Also included in the output module are output data ready state machines which produce a data ready signal (ODRI and ODRh) to indicate a new measurement result for the period count and the frequency count. This indicates if a new result is being presented since the last READ. For testing purposes, the input module contains an internal quadrature wave generator. A square wave input to a state machine generates a quadrature wave of 1/4 the input frequency. The quadrature wave direction can also be selected with the Indir signal. This module also contains the input register for the mode select (MDS), quadrature select (quadsel), and Indir signals. 11

4. FPGA Implementation Procedure We selected a user-programmable Xilinx FPGA chip to implement the velocity measurement system. The process of taking a conceptual design to a final FPGA chip implementation consists of four main steps. The first is to generate a reduced logic description of the design. The second step is to take the description and fit it to FPGA architecture. The third is to determine placement and routing of the fitted design description. The final step involves programming the chip with the configuration information. To perform the first and second steps, we used the ABEL Hardware Description Language software. ABEL provides the resources for design description, simulation, reduction and fitting the design to an ABEL supported device. For step three (placement and routing) Xilinx software was required. This software (XACT) also generates a bitstream file used for programming a Xilinx. During programming a Xilinx can interface with either an external memory device, or a processor peripheral to obtain the bitstream. We chose to house the bitstream sequence in an external memory device (EPROM). To implement the SCVMS we chose an LCA3090. We considered CLB capacity, I/O pin availability, and speed grade for determining the device type. We selected the largest of the 3000 series (320 CLBs) because our design requires the largest logic capacity. An additional CLB overhead was necessary to compensate for placement and routing limitations of Xilinx technology. We also selected an 84 pin grid array (PGA) package type, which easily met our design requirement of 20 I/O pins and additional I/O availability for test points. The number of I/O pins enables sufficient controllability and observability during hardware testing. In considering the speed grade, we made sure that the maximum flip-flop toggle rate was well above the maximum baseline clock frequency. Consequently, a speed grade of 100MHz (-100) was selected. The Xilinx LCA3000 series offers features for enhanced performance that we took advantage of. To reduce delay and skew for critical signals, there are two dedicated clock buffers, GCL and ACL. We used GCL to route the 4MHz baseline clock signal and, ACL for the 1MHz clock signal. Utilizing GCL and ACL released limited routing lines between the logic blocks. Another useful feature is an enable clock (.ec) control for internal flip-flops. Holding this pin low prevents the flip-flop from responding to any changes at its input. This protected the system 12

against clock glitching errors as a result of gated clock signals. Although Xilinx FPGA technology is sufficient for implementing the SCVMS, the design realization procedure has its challenges. The software used in each of the four design steps has limitations. The optimization done by the ABEL software on the counters resulted in an inefficient mapping to Xilinx s Logic Cell Array (LCA) architecture. The counters required many CLBs. As a result, we designed the counters as specified in the Xilinx data book. Other limitations to consider are the efficiency of the fitter in mapping the design to LCA architecture, and how optimal is the placement and routing determined by a simulated annealing algorithm. A thorough analysis must be conducted in order to weigh each of these factors, but our experience has proved that they limit full utilization of Xilinx architecture to about 40% of the listed CLB capacity. We have deferred addressing the issue of user reconfiguration of the SCVMS until this section. Design reconfiguration involves all the four implementation steps that have been described. For the SCVMS to operate along a different set of curves (but still limited to a 16bit output size), three modifications must be made to the ABEL source file. F clkp must be changed to change the period count curve. This may involve tapping off a frequency from the existing frequency divider module or adding more blocks to it. To change the frequency count curve, a similar process is required. A change in the timing interval can be accomplished by modifying the timing interval counter. Again, this involves copying and/or altering pre-existing code. Finally, the transfer point should be altered and this entails editing a single equation. Following the ABEL file modifications, the design must be fitted, mapped and placed and routed. Also, the EPROM must be reprogrammed. The total time for this procedure is 6-8 hours for an experienced designer. This will vary of course, depending upon the available computing resources which perform the most time consuming procedures of fitting, and placement and routing. 13

5. Period Count and Frequency Count Error Analysis A user of the SCVMS will be concerned with any errors affecting output p and output f. One source of error is an inaccuracy in the baseline clock which will produce errors in f clkp and. Generally, clocks for digital systems are very accurate. Hence, clock inaccuracy is not a significant source of error. Theoretically, the velocity measurement system itself should not introduce any error into output p and output f. Since the SCVMS is a digital system, it does introduce quantization error. Factoring quantization error into the system outputs, the user will be able to obtain a measured encoder frequency. For SCVMS verification, we compared predicted vs. observed outputs for an input encoder frequency. Additional errors were introduced into output p and output f due to the test set-up. We present a procedure to predict a range of expected output values considering both test set-up error propagation and quantization error. Testing involved applying a baseline clock (F clk ) and a quadrature wave to the system. F clk was divided down by the frequency divider module to yield f clkp and. The baseline clock was measured with a frequency counter, and f encoder (quadrature frequency) was measured with an oscillocsope (Figure 4). There is an uncertainty in both F clk and f encoder used to compute an expected output. For F clk, there is an uncertainty ( f clk ) due to a difference in the frequency counter measurement of F clk and the actual F clk applied to the system. This difference produces uncertainties f clkp and. Since f encoder is measured with an oscilloscope, the uncertainty in f encoder is due to a measurement error f encoder. Both uncertainties will produce a variation of the output from an expected output. This output variation can be considered an output error. 14

frequency counter F clk Fclk SCVMS output oscilloscope f encoder Figure 4. SCVMS Count Output Verification Set-Up A frequency counter measures F clk and an oscilloscope measures f encoder. An output error in period count ( the period count, output p is a function of f clkp and f encoder : ε p ) due to f clkp and f encoder can be estimated. Recall that for output p = f clkp --------------- f encoder (4) A Taylor series expansion of output p can be used to predict retaining only the first-order partial derivatives we find: ε p. Performing the expansion and ε p = output p output + p f clkp f encoder (5) 1 f ε p f clkp --------------- clkp = + f encoder --------------- f encoder 2 f encoder (6) Consequently for a given f clkp the propagation of errors from input to output p as a function of encoder frequency can be estimated. Following the same procedure, we can estimate a frequency count error as a result of and 15

ε f f encoder ( ). For the frequency count, output f is a function of f encoder, and : output f = f encoder -------- (7) where -------- represents the timing interval. A Taylor series approximation of output f yields ε f : 1 f ε f f encoder -------- encoder = + f f clk --------------- 2 clkf (8) For a given and, the propagation of errors from input to output f as a function of clock frequency can be estimated. In addition to frequency error, there is quantization error. Each output of the SCVMS, (output p and output f ) is determined by a counter. To understand how a counter introduces quantization error, consider a counter which increments on falling clock edge transitions. When the counter is enabled, the count enable signal is generally not synchronized with f clk. The counter will only increment after a falling edge f clk transition, and does not have the resolution to determine where in the clock cycle count enable occurs. As a result, fractions of a count will not be detected. When the counter is disabled, the count disable is generally not synchronized with f clk and again the counter cannot detect fractions of a count. Combining frequency error and quantization error, we can predict what range the experimental output should fall within. Considering frequency error only, the period count range may be predicted as: output ppredicted = ouput ptheoretical + ε p (9) For a given f encoder, quantization error causes rounding down of the minimum value of the predicted range, and rounding up the maximum value. This is accomplished by truncating the range for output p and adding a 1 to the higher output prediction. output ppredicted = T[ output ptheoretical + ε p ] + { 1} (10) 16

where T[] represents truncation, and {1} represent a quantization error factor. Using a similar approach, the frequency range count may be predicted as: output fpredicted = T [ output ftheoretical + ε f ] + { 1} (11) where T[] and {1} are as above. By comparing the experimental values with the predicted ranges, the system performance can be verified. 17

6. Testing Procedure and Results Functional testing was performed on the SCVMS. We took advantage of the field-programmability of Xilinx LCAs, to test the design iteratively. Beginning with the transition detector, each module was added, and then tested until complete design verification was achieved. The SCVMS was also tested to determine how well the experimental output results correspond with predicted output results using the analysis outlined in section 5. The set-up consisted of a logic analyzer, oscilloscope, two frequency generators and a 5 volt power supply. For testing, a quadrature signal was synthesized by the internal quadrature generator. An external frequency generator supplied a square wave to the quadrature generator. The generator produced a quadrature wave of 1/4 the square wave frequency with the direction determined by the Indir signal. The baseline clock was supplied by another frequency generator. To test the period count output, we varied the square wave input frequency and measured the quadrature wave frequency, f encoder, with an oscilloscope. Also, the period count was determined using a logic analyzer. The period count was recorded for each f encoder measurement. Due to signal generator limitations, a baseline clock frequency of 1MHz was applied rather than 4MHz as specified in the design. To maintain f clkp at 10kHz, we scaled the frequency divider accordingly. To test the frequency count output, the same procedure was followed as for the period count. Again due to signal generator limitations we reduced to 100Hz instead of 1MHz. To determine a predicted counter output for the period count, equation (6) is applied. 1 f clk ε p = f clk --------------- + f encoder --------------- f encoder 2 f encoder (12) Considering quantization errors, truncation is performed as specified in equation 10. The predicted period count range is plotted against logf encoder (Figure 5). The experimental period count results (+) are also plotted against logf encoder. System performance is illustrated by experimental results falling within the predicted range as shown. 18

10 5 10 4 period count output 10 3 10 2 10 1 10 0 10-1 10 0 10 1 10 2 10 3 10 4 encoder frequency (Hz) Figure 5. Log predicted period count and log experimental period count vs. log f encoder. Solid lines: Predicted period count range. + : Experimental period count results. The same approach is taken to verify the frequency count. The predicted frequency count range is plotted against a linear scale of f encoder (Figure 6). The experimental frequency count results (+) are also plotted against f encoder. Analogous to the period count, system performance is illustrated by experimental results falling within the predicted range. 19

10 3 Predicted and experimental frequency count vs. log encoder frequency frequency count output 10 2 10 1 10 0 10 1 10 2 10 3 10 4 10 5 encoder frequency (Hz) Figure 6. Predicted frequency count and experimental frequency count vs. log f encoder. Solid lines: Predicted period count range, (+) Experimental period count results. 20

7. Analysis and Discussion The method we outlined in Section 6 to predict the output considering propagation error and quantization error corresponds well with the experimental data. For both the period count and the frequency count, the experimental output results fell within their respective predicted ranges. Considering output p, the quantization error is dominant at the higher encoder frequencies where there are fewer counts. This is well illustrated by the divergence of the lines determining the predicted output range, and by the testing results (Figure 8). For output f, quantization error dominates at the lower encoder frequencies where there are fewer counts (Figure 9). Although the SCVMS employs both the period count and the frequency count methods, there is a frequency range where there is range of largest quantization error. This is the range near the transfer point. Since the transfer point is adjustable by the designer, the trade-off between quantization error and measurement range can be made explicit. To test the SCVMS, a constant frequency representing an encoder velocity was input to the system. As a result, acceleration was not considered. Encoder acceleration measurement is beyond the scope of this paper, but we propose an option. Acceleration may be measured in software using the SCVMS velocity measurement results. To implement an acceleration measurement in hardware would require inversion of the period count result which can be done more easily in software. 21

8. Conclusion We have designed, implemented and verified a single chip velocity measurement system for optical shaft encoders or other sensors having digital gradiative outputs. The system is able to measure simulated encoder frequencies over a wide range. Due to the reprogrammability of Xilinx FPGAs, the frequency measurement range, as well as the minimum output resolution can easily be modified by an experienced designer. Looking ahead, the next step is testing the SCVMS with an actual encoder. Currently the system is designed to interface with a pc for data acquisition, and its output could readily be processed and directed to a motion controller. Hence, the performance of the SCVMS within a complete system can be verified. Another area to examine is shaft acceleration as addressed in Section 7. We would like to propose that the SCVMS is an attractive choice for use with motion controllers. The SCVMS is a compact, cost-effective measurement system implemented in hardware. It offers a quick velocity measurement without placing a high demand upon computing resources which may be limited. FPGA technology has continued dramatic progress since this work was performed in 1993. Most of the implementation difficulties we encountered are no longer serious issues. 22

List of References [1] A.. Bejczy, Z. Szakaly, Universal Computer Control System for Space Telerobotics, Proceedings of the IEEE Conference on Robotics and Automation, vol.1, pp. 318-324, Raleigh, N.C., 1987. [2] C.R. Uhlik, Experiments in High-Performance Nonlinear and Adaptive Control of a Two- Link, Flexible-Drive-Train Manipulator, Doctoral Dissertation, Appendix B, pp. 167-170, 1990. [3] I. Amidror, S. Usui, Digital-Low Pass Differentiation for Biological Signal Processing, IEEE Transactions on Biomedical Engineering, vol. 29, pp. 686-692, 1982. [4] R. E. alman, A New Approach to Linear Filtering and Prediction Problems, Journal of Basic Engineering (ASME), 82D, pp. 35-45, March 1990. [5] P. R. Belanger, Estimation of angular velocity and acceleration from shafter encoder measurements, Proceedings of IEEE International Conference on Robotics and Automation, pp. 585-589, Nice, France, 1992. 23