Вы находитесь на странице: 1из 64

Improvement of a Control System for a Brushless Linear Motor Based Gantry

Undergraduate Student Pro ject

by

Jesse Paulo V. Macabasco

2007-78003
B.S. Electronics and Communications Engineering

Adviser:

Professor Manuel C. Ramos, Jr.

University of the Philippines, Diliman

April 2013
1

Abstract

Improvement of a Control System for a Brushless Linear Motor Based Gantry

The Anorad Super Precision Gantry (SPG-500) is a dual-axis gantry operating on three

tracks, each one having a linear motor. In a previous project by Brocoy and Santos, a control

system for the gantry has been developed which is composed of motor drivers, power supplies, a

PID controller, feedback signal conditioning circuits, and a graphical user interface. Their system

was able to drive the gantry; their electronic commutation of the brushless linear motors depended

on a commutation frequency derived from the input velocity. Today, however, the gantry lacks a

driver unit that is readily available to any interested user. In this project, an improvement of the

motor drive of the previous control system was made and a driver unit was developed. The method

of six-step commutation used is based on the position of the brushless linear motor; this position is

measured from built-in encoders. Using an external microcontroller, position control can be done

by reading encoder feedback while velocity control can be implemented by varying the duty cycle

of the input pulse width modulated signal. The motor drivers and encoder signal conditioning

circuits were also improved.


i

From the Researcher:


I would like to recognize and thank the following people who have been signicant to the completion

of my project:

• Sir Odulio and Karl of the Power Electronics Laboratory

• Dr. Salvador and Dr. Somintac of the National Institute of Physics

• UP Engineering Guild and TFF, my families in EEE

• GCF Antipolo Youth, my spiritual family

• Prof. Escoto of the Power Electronics Laboratory, my examiner

• Prof. Manuel Ramos Jr., my undergraduate project adviser

• My RALmates: Joe, Jib, Sze and Angel

I dedicate this project to:

• My family: Jun, Helen, Jonathan and Jelene

• My Lord and Saviour: Jesus Christ

Not to us, Lord, not to us

but to Your Name be the glory

because of Your love and faithfulness.

Psalm 115:1
ii

Contents
List of Figures iv
List of Tables vi
1 Introduction 1
2 Problem Statement and Objectives 2
2.1 Statement of the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Objectives of the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.3 Signicance of the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

3 Review of Related Work 3


3.1 Control of Rotary Brushless DC Motors . . . . . . . . . . . . . . . . . . . . . . . . 3
3.2 Control of Linear Brushless Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

4 Preliminary Findings 6
4.1 Microcontroller Capability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.2 Encoder-Based Commutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.3 Position and Velocity Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.4 Encoder Signal Conditioning Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . 8

5 Methodology 9
5.1 Design of Driver Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1.1 Motor Drivers with AND Gates . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1.1.1 MOSFET Switches . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1.1.2 Gate Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1.1.3 Freewheeling Diodes and Bus Capacitors . . . . . . . . . . . . . . 11
5.1.1.4 AND Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.1.2 Encoder Signal Conditioning Circuits . . . . . . . . . . . . . . . . . . . . . . 13
5.1.2.1 Dierential Amplier . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.1.2.2 Zero-Crossing Detector . . . . . . . . . . . . . . . . . . . . . . . . 13
5.1.2.3 Logic Inverter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.1.2.4 Limit Switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.1.3 Internal Microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.2 Internal Microcontroller Programming . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2.1 Encoder-Based Commutation . . . . . . . . . . . . . . . . . . . . . . . . . . 15
iii

5.2.2 Locking and Direction Control . . . . . . . . . . . . . . . . . . . . . . . . . 17


5.3 External Microcontroller Programming . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3.1 External Microcontroller Design . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3.2 Velocity and Position Control . . . . . . . . . . . . . . . . . . . . . . . . . . 18

6 Results and Analysis 20


6.1 Driver Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
6.1.1 Motor Driver with AND Gates . . . . . . . . . . . . . . . . . . . . . . . . . 20
6.1.2 Encoder Signal Conditioning Circuit . . . . . . . . . . . . . . . . . . . . . . 22
6.1.3 Internal Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.1.4 Integrated Driver Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.2 Velocity Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.3 Position Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

7 Conclusions and Recommendations 27


7.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
7.2 Recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Bibliography 28
A Gantry and Linear Motors 29
A.1 Gantry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
A.2 Linear Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

B Electrical Characteristics of Motor 31


B.1 Electrical Cycle Length and Commutation Points . . . . . . . . . . . . . . . . . . . 31
B.2 Electrical Time Constant and Torque . . . . . . . . . . . . . . . . . . . . . . . . . . 32

C Encoders 33
D Schematics and Board Layouts 34
D.1 Motor Driver with AND Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
D.2 Encoder Signal Conditioning Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . 36
D.3 Internal Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
D.4 External Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

E Source Codes 39
E.1 Internal Microcontroller Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
E.2 External Microcontroller Code (for x-axis) . . . . . . . . . . . . . . . . . . . . . . . 43
E.3 External Microcontroller Code (for y-axis) . . . . . . . . . . . . . . . . . . . . . . . 47

F Driver Unit User Manual 51


F.1 Input/Output Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
F.1.1 Motor Control Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
F.1.2 Encoder and Limit Switch Ports . . . . . . . . . . . . . . . . . . . . . . . . 52
F.1.3 Motor Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
F.2 Power Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
iv

List of Figures
3.1 Liaw et. al's Control System [LSCC01] . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.2 Closed Loop Velocity Control [BS10] . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.3 Gantry Control GUI [BS10] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4.1 Previous Encoder Signal Conditioning Circuit [BS10] . . . . . . . . . . . . . . . . . 8

5.1 Project Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9


5.2 High Side Gate Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.3 Low Side Gate Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.4 MOSFET with Freewheeling Diode . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.5 Interfaced AND Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.6 Redesigned Encoder Signal Conditioning Circuit . . . . . . . . . . . . . . . . . . . 13
5.7 Limit Switch Conditioning Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.8 dsPIC30F4012 Internal Microcontroller [Mic05] . . . . . . . . . . . . . . . . . . . . 14
5.9 Closed Loop Encoder-Based Commutation . . . . . . . . . . . . . . . . . . . . . . . 16
5.10 Example External Microcontroller Signals . . . . . . . . . . . . . . . . . . . . . . . 18

6.1 µ
Built-In Deadtime of 7.40 s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
6.2 Combined Control Signals with PWM through AND . . . . . . . . . . . . . . . . . 21
6.3 Fabricated Motor Driver Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6.4 Quadrature Encoder Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6.5 Fabricated Encoder Signal Conditioning Circuit . . . . . . . . . . . . . . . . . . . . 22
6.6 Fabricated Internal Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.7 Integrated Driver Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.8 Commutation Signals with PWM for Velocity Control (2 phases and no load) . . . 24
6.9 Commutation Signal with PWM for Velocity Control (1 phase with motor load) . . 24
6.10 Encoder Signals for a) 1.32m/s Velocity and b) 0.07m/s Velocity . . . . . . . . . . 25
6.11 Control Signals for Initial Locking and Actuation . . . . . . . . . . . . . . . . . . . 26
6.12 Control Signals for Actuation with Velocity and Position Control . . . . . . . . . . 26

A.1 Anorad SPG-500 Model [Ano] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29


A.2 Actual SPG-500 Gantry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
A.3 Brushless Linear Motor [Aut04] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

B.1 Electrical Cycle Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31


B.2 Input PWM with 1kHz Frequency and 10% Duty Cycle . . . . . . . . . . . . . . . 32
v

C.1 MERS50 Output Signals [Ano99] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

D.1 Three Half-Bridge Conguration with Freewheeling Diodes and Bus Capacitors . . 34
D.2 Interfaced AND Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
D.3 Motor Driver Board Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
D.4 Encoder Signal Conditioning Circuit Schematic . . . . . . . . . . . . . . . . . . . . 36
D.5 Encoder Signal Conditioning Circuit Board Layout . . . . . . . . . . . . . . . . . . 36
D.6 Internal Microcontroller Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
D.7 Internal Microcontroller Board Layout . . . . . . . . . . . . . . . . . . . . . . . . . 37
D.8 External Microcontroller Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
D.9 External Microcontroller Board Layout . . . . . . . . . . . . . . . . . . . . . . . . . 38

F.1 Driver Unit Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51


F.2 Motor Control Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
vi

List of Tables
3.1 Commutation Table [BM11] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

5.1 Gate Drive Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12


5.2 Utilized Pins of the Internal Microcontroller . . . . . . . . . . . . . . . . . . . . . . 15
5.3 Six-Step Commutation Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

F.1 Ports of Driver Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51


F.2 Pin Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
1

Chapter 1

Introduction
Gantry systems are prevalent mechanisms in the eld of automation; their applications

range from simple pick-and-place operations in the production of small integrated chips to colossal

gantry cranes moving tons of metal in shipbuilding docks. A gantry is considered an industrial robot

as it is an automatically controlled, reprogrammable, multipurpose manipulator programmable in

three or more axes. Gantry robots, also called Cartesian or linear robots, are made up of prismatic

joints coinciding with the three axes of the Cartesian coordinate system (X, Y, and Z axes); this

conguration makes them advantageous over other robots in applications that cover large work

areas and those that require position accuracy. Gantry systems can be made very large and work

over an entire oor area; also, since they are easier to program with regard to motion, they can place

parts exactly where they should be. The gantries of today, especially small ones, now lean to the

use of linear motors instead of the traditional belt-and-pulleys, rack-and-pinions, and other linear

actuators; this is due to the higher precision and speed these motors can achieve. Additionally,

they have a faster response, better stiness, a zero backlash and no physical wear all due to

reduced mechanical parts. These high-speed and high-precision gantries are now employed in many

industrial factories: maximizing eciency of production lines and improving their throughput.

However, much research is still in progress with making these systems more ecient, faster and

more precise; the gantry itself or its control system is being looked into in attainment of these

desired advancements.
2

Chapter 2

Problem Statement and Objectives


2.1 Statement of the Problem
The gantry lacks a driver unit and control system readily available to any interested user.

2.2 Objectives of the Project


The project aims to improve the previous control system by implementing an encoder-

based electronic commutation of the brushless linear motors and developing a driver unit for the

gantry. This driver unit will include all the circuits and components in a neat package with clearly

marked connectors. The project also includes position and velocity control using an external

microcontroller.

2.3 Signicance of the Project


Completion of the project will mean an improved control system and a readily available

driver unit for the gantry. The driver unit will enable clean connections to the gantry as well as

allow students to easily interface with the driver of the gantry; the students may control its position

and velocity using their own microcontrollers.


3

Chapter 3

Review of Related Work


3.1 Control of Rotary Brushless DC Motors
In 2011, Buenaor and Munlawin used hall-eect sensors to determine the commutation

points of their rotary brushless motor [BM11]. Hall-eect sensors output either logic high or logic

low based on the polarity of the magnetic pole close to it. Their sensors are placed inside the motor

with 120 degrees spacing. Commutation then is done based on the output of these sensors and on

a corresponding six-step commutation table, as shown in Table 3.1.

Table 3.1: Commutation Table [BM11]

State Hall - 1 Hall - 2 Hall - 3 Phase C Phase B Phase A

0 0 1 1 0 + -
1 0 0 1 + 0 -
2 1 0 1 + - 0
3 1 0 0 0 - +
4 1 1 0 - 0 +
5 0 1 0 - + 0

However, the motors of the gantry do not have any hall-eect sensors; instead, it has

position encoders. This kind of sensors may also be used for commutation but will require more

lines of instructions and processing power. In an application note [SN05], a rotary BLDC motor

is divided into six sectors forming the six-step commutation table. Encoder pulses are counted to

determine rotor position which can be checked for commutation moments. This same method was

used for the gantry even though it has linear motors.


4

3.2 Control of Linear Brushless Motors


Linear brushless motors are just like rotary BLDC motors rolled out; hence, the same

proper commutation is essential. Liaw and others used both hall-eect sensors and linear encoders

to determine the moving member's position and the motor's commutation [LSCC01]. The same

concept with the rotary motors is applied with the only dierence of having linear motion and nite

space to move. However, their project used a complex sinusoidal algorithm for both position and

velocity control as seen in Figure 3.1 taken from their paper.

Figure 3.1: Liaw et. al's Control System [LSCC01]

In a previous project on the laboratory gantry, Brocoy and Santos developed a low-cost

control system that implemented PID control on the velocity. Their basis for velocity was the input

commutation frequency; varying it would dictate the speed of the motor [BS10].

Figure 3.2: Closed Loop Velocity Control [BS10]


5

Their commutation of the linear motors was dependent on the values computed from the

input velocity using the electrical characteristics of the motors. This is then maintained by a PID

controller; it computes the error between the actual and input velocities, applies the proportional,

integral and dierential terms, and updates variables. Finally, they prepared a graphical user

interface (Figure 3.3) that accepts inputs namely: position in mm (x and y) and velocities in m/s

(x and y). With a power supply xed at 55V, their speed was limited to a range of 0.05m/s to

0.35m/s [BS10].

Figure 3.3: Gantry Control GUI [BS10]

For this project, position control is implemented using an external microcontroller through

counting the pulses of incremental encoders and locking at the desired position. Velocity control

uses the PWM technique: chopping the applied voltage through pulse width modulation, varying

its duty cycle to lower the average voltage and dictating the velocity. Control of the gantry is done

through generation and reading of signals by an external microcontroller, instead of a graphical

user interface.
6

Chapter 4

Preliminary Findings
4.1 Microcontroller Capability
Since an encoder based-commutation is proposed, the microcontroller to be used should

be able to handle feedback at very high speeds. The motors of the gantry are rated at 4m/s,

2.5m/s, and 3.5m/s [Ano]; with position encoders that output one period of sinusoid every 20 m µ
[Ano99], the maximum frequency from the encoders would be 200 kHz. This means a feedback

µ
signal interrupts the microcontroller every 5 secs and that the counting of encoder pulses (for

determining position and commutation points), the changing of commutation, position control and

other tasks should all be done in that small time frame; this is to ensure no encoder pulses are

missed. The dsPIC30f4011/4012 microcontroller is chosen to perform the task; by using an external

7.3728 MHz crystal and selecting the PLL x16 oscillator mode [Mic05], it can reach its maximum

possible operating frequency of 117.96 MHz (limited to 120MHz) [Mic05]. With this setting, the

dsPIC can execute 29.49 MIPS (assuming PIC architecture of 4 clock cycles per instruction cycle);

this would set the upper limit of the interrupt service routine to be 147.46 instructions. The ISR

should be able to do all determined tasks with the number of instructions lesser than that limit.

4.2 Encoder-Based Commutation


For proof of concept and initial testing, a previously fabricated dsPIC30f4011 microcon-

troller board and motor driver are used to produce the proper encoder-based commutation of a

single motor of the gantry. For the rst test, the commutation signals of Brocoy and Santos were

reproduced (however, without their PID control) and fed into the motor; this test resulted to a

jittery motion. A second test used a square wave signal generator to simulate the encoder feedback
7

signals; this was fed to a GPIO pin polled by a microcontroller. The polling function contained all

the basic tasks required: determining the direction of the motor (left or right), counting the encoder

pulses (by incrementing or decrementing) which determines the position of the moving member,

and changing commutation by checking for xed commutation points. The limit to the number of

instructions of this function is strictly followed; with the necessary tasks, it is currently under that

limit. However, some encoder pulses are still missed brought about by the polling algorithm; this

made the counting inaccurate and produced unstable commutation signals. A third test was made

using external interrupts; this made the commutation signals more stable as every encoder pulse

is counted without time delays and debouncing. The third test conrmed, through the smooth

motion of the gantry, the possibility of encoder-based commutation (note that this test was still

done with the signal generator simulating the encoders at some frequency). A fourth test was done

by using the actual position encoders of the gantry. The output of these encoders are fed into

the previously designed signal conditioning circuit (Figure 4.1) and used as external interrupts to

the microcontroller. After nding and calibrating for the commutation points (see Appendix B.1)

and adding initial movement (both done through software testing), the motor ran smoothly. These

tests were done at supply voltages of below 32V (with a minimum of 15V being able to drive the

motor).

4.3 Position and Velocity Control


After conrming encoder-based commutation, tests were made for both position and ve-

locity control. First, for the position control, two pre-determined positions were set in the mi-

crocontroller code through the number of encoder pulses. Once the rst count was reached, the

gantry motor stopped, locked to position, and released to stop current draw; after a time delay, it

ran again and did the same for the second position. This test conrms the position control to be

implemented: counting the number of encoder pulses and stopping the motor at its corresponding

position. This test also showed consistency, reaching the same points every time (tested for at least

ve times); however, the actual positions reached are o by a few millimeters from the desired. A

possible explanation to this oset can be that the single microcontroller that initiates movement

is actually missing some pulses while doing it (i.e. at initial movement). With an external micro-

controller dedicated to counting the encoder feedback, this oset is expected to be eliminated. A

second test involves changing the direction of the motor; after reaching the rst position (direction

is from right to left), the direction is changed (from left to right) to reach the second position. This

involves decrementing the count of encoder pulses, instead of incrementing it. This also means the
8

motor has to start at an origin position (ideally at the end of the linear motor), and increment the

count of encoder pulses (position) rst before decrementing it.

For the velocity control, the encoder-based commutation of one motor is tested at dierent

applied voltage levels; this is done by changing the voltage supply directly. These tests were done

at 15V, 24V, 32V, 40V, 50V, and 65V; they resulted to dierent motor speeds that are proportional

to the voltage: the higher voltage supply, the higher velocity. Actual speeds were not measured

quantitatively; that task will require software timers to measure the period of the encoder signal, to

compute its frequency and translate it to actual motor velocity. However, qualitatively, the results

conrmed that velocity can be varied through changing the applied voltage.

4.4 Encoder Signal Conditioning Circuit


The encoder signal conditioning circuit of Brocoy and Santos is also inspected. A signal

generator is used to simulate the encoder sinusoidal output and fed to the conditioning circuit.

Upon testing, it was seen that their design cannot handle the maximum encoder output frequency

of 200 kHz for the x-axis motor (the encoder signal frequency is dictated by the speed of the

motor: the faster it runs, the higher the frequency). Signals with higher frequencies than 120kHz

were attenuated to around 3V and appeared to be just periodic spikes instead of the ideal square

waves. The dsPIC30f4011 would not be able to count these as interrupts because of its electrical

characteristics at 30MIPS (operates at voltage 4.5 to 5.5V) [Mic05]. A temporary solution is to

lessen the value of the pull-up resistor; this resulted to a better conditioned 5V square wave signal

at 200 kHz. However, upon actual testing with the motor, it is found out that the encoder signal

conditioning circuit still needs to be further redesigned to produce better signals.

Figure 4.1: Previous Encoder Signal Conditioning Circuit [BS10]


9

Chapter 5

Methodology
The objective of this project was to improve the control system of the gantry by imple-

menting an encoder-based commutation of the brushless motors, develop a driver unit that includes

the motor drivers, the encoder signal conditioning circuits and the internal microcontrollers, and

eventually demonstrate velocity and position control using external microcontrollers.

Figure 5.1: Project Block Diagram


10

5.1 Design of Driver Unit


5.1.1 Motor Drivers with AND Gates

The motor drivers built are three half-bridge congurations with P-Channel MOSFETs

as high side switches and N-Channel MOSFETs as low side switches. Their gate drivers are de-

signed using discrete components; the motor driver board also includes the freewheeling diodes,

bus capacitors and the logic AND gates.

5.1.1.1 MOSFET Switches


The MOSFETs used are IRF9530 and IRL530A, both having 100V maximum drain-source

voltage and can handle up to 12A and 14A maximum continuous drain currents, respectively. These

are within the proposed ratings of the motor driver at 65V and 10.5A, based on the motor ratings.

IRL530s are logic FETs which have lower VGS(T H) than IRFs (a maximum 2V compared to 4V);

this means they turn on faster than their counterpart IRFs.

5.1.1.2 Gate Drivers


The gate drivers of the MOSFETs are implemented using discrete components, mainly

around TIP31Cs operated as switches. The high side gate driver was designed to switch the VGS
of the P-MOSFET between -12V and 0V; this is done by operating the TIP31C in the forward

active and cut o regions. A 5V in HI will put T1 in forward active and output 53V in its collector

side; this voltage (with a few drops) will be seen at the gate of the P-MOSFET. The totem pole

conguration (T2 and T3) is for current gain and the paralleled diode and resistor to speed up

switching. A 0V in HI will cut o T1 and 65V will be seen at the P-MOSFET's gate.

Figure 5.2: High Side Gate Driver


11

The low side gate driver was designed to switch the VGS of the N-MOSFET between 12V

and 1.6V; this is done by operating the TIP31C this time in the saturation and cut o regions. A

5V in LO will put T4 in saturation and output VCE(SAT ) of 1.8V; this voltage (with a few drops)

will be seen at the gate of the N-MOSFET. A 0V in LO will cut o T4; the voltage divider formed

by R5 and R6 will output 16V and x the N-MOSFET's gate at around 12V. The low side gate

driver also has the totem pole conguration and the paralleled diode and resistor.

Figure 5.3: Low Side Gate Driver

5.1.1.3 Freewheeling Diodes and Bus Capacitors


Freewheeling diodes, connected anti-parallel to the MOSFETs, are essential in the pro-

tection of the switching devices from sudden voltage spikes [BM11]. They also redirect current (to

and from the motor) allowing continuous ow of power in the system. The freewheeling diodes

used are PBYR3060PTs: dual schottky rectier diodes that have a peak reverse voltage of 60V, a

low forward voltage of 0.7V and an output current of 30A. Both diodes of the PBYR are connected

anti-parallel to each MOSFET of the motor driver.

Figure 5.4: MOSFET with Freewheeling Diode

Bus capacitors are essential in sourcing and sinking high instantaneous currents caused by

the switching; they charge and discharge energy helping the power supply provide the instantaneous

demands [HP10]. They also protect the MOSFETs from the damaging voltage spikes [Col10]. The

µ
bus capacitance was set to 8.8mF (four 2200 F 100V electrolytics in parallel) and were placed

physically near the motor driver's input voltage supply (see Appendix D.1).
12

5.1.1.4 AND Gates


To achieve the desired commutation signals for velocity control (see Section 6.2), the

control signals to the motor driver are modied through logic gates. They are used to combine

the low frequency commutation signal with the high frequency input PWM signal; this allows

variation of average voltage (chopping of applied voltage). Based on the gate drive logic (Table

5.1), AND gates are needed for both the HI and LO side control signals in order to produce the

desired commutation signals.

Table 5.1: Gate Drive Logic

HI LO High Side Switch Low Side Switch OUT

1 1 on o V+
1 0 on on forbidden
0 1 o o FLOAT
0 0 o on GND

The logic gates used are MC74ACT08N which are quad 2-input AND gates. These gates

are interfaced with 10k pull down resistors in both its input and output terminals; this would set

the default logic (default input or output) to 0 (0V). This ensures that the motor driver will not

actuate the motor while there is still no input PWM signal from the external microcontroller.

Figure 5.5: Interfaced AND Gate

The motor driver board includes the three half-bridges (MOSFET switches and gate

drivers), the freewheeling diodes, the bus capacitors and the interfaced AND gates. The logic

AND gates were included in the board to reduce electromagnetic interference and noise brought

about by wirings between modules and components. The layout of the board was also planned such

that the power section (high voltage 65V) is physically far from the control section (low voltage

5V). The parallel bus capacitors and freewheeling diodes are physically placed near their respective

half-bridges and the power supply (see Appendix D.1).


13

5.1.2 Encoder Signal Conditioning Circuits

The encoder signal conditioning circuits were also improved. The encoders of the gantry's

linear motors are optical, analog and incremental; they output a single period of sinusoid for every

µ
20 m displacement. These sinusoidal signals are converted to 5V square wave signals that are

readable by microcontrollers. Since the commutation of the brushless linear motors are encoder-

based (see Section 5.2.1), proper conditioning of these signals is crucial.

5.1.2.1 Dierential Amplier


The previous dierential amplier OPA2132 was used to amplify the millivolt level si-

nusoids to around 1.8Vpp. The previous circuit exhibited crossover distortion in its output; this

distortion produced extra unwanted pulses. The RC lter was removed from the circuit and lessened

this distortion.

5.1.2.2 Zero-Crossing Detector


The previous LM311 comparator congured as a zero-crossing detector was used to convert

the sinusoid to a 5V square wave signal. However, the output of the previous zero-crossing detector

conguration is unstable especially when there is no input (no sinusoid because there is no actuation

of the motor). This instability of output sometimes produces oscillations and create additional

unwanted pulses. Introducing a hysteresis voltage at the input by adding a very large feedback

resistor (2.2Meg) and a small capacitor (22pF) to the conguration stabilized its output.

5.1.2.3 Logic Inverter


The output of the LM311 comparator with the 10k pull up resistor has a slower rise time;

so it was fed into two inverters of a HCF4069 (so it is not inverted in the end) which improved its

rise time signicantly and also reduced some noise.

Figure 5.6: Redesigned Encoder Signal Conditioning Circuit


14

5.1.2.4 Limit Switches


The gantry also has optical limit switches, indicating the end of the linear motors. The

previous conditioning circuit (Figure 5.7) is used for the limit switches.

Figure 5.7: Limit Switch Conditioning Circuit

5.1.3 Internal Microcontrollers

The 28-pin dsPIC30F4012s (Figure 5.8) are used as the internal microcontrollers; they

are fast and capable enough to produce the six input signals to the motor driver, read an input

pin for direction, and accept external interrupts for encoder feedback and locking of motors (Table

5.2) [Mic05].

Figure 5.8: dsPIC30F4012 Internal Microcontroller [Mic05]


15

Table 5.2: Utilized Pins of the Internal Microcontroller

Pin Function Application Use

2 RB0 (output) A-LO (gate drive)


3 RB1 (output) A-HI (gate drive)
4 RB2 (output) B-LO (gate drive)
5 RB3 (output) B-HI (gate drive)
6 RB4 (output) C-LO (gate drive)
7 RB5 (output) C-HI (gate drive)
15 INT1 (external interrupt) encoder feedback
16 INT0 (external interrupt) lock motor
25 RE1 (input) direction
26 RE0 (input) lock motor

The internal microcontrollers were programmed to implement the encoder-based com-

mutation (Section 5.2.1); moreover, they were interfaced such that running of the motors would

become dependent on an external microcontroller.

The output of PORT B (pins 2,3,4,5,6,7) were connected correspondingly to the inputs

of the AND gates (whose other input is the external microcontroller's PWM signal) on the motor

driver board. An output of the encoder signal conditioning circuit was connected to INT1 (pin 15).

INT0 (pin 16) and RE0 (pin 26) were shorted in the layout of the internal microcontroller; this

is due to the algorithm used for locking the motor through this equivalent pin (see Section 5.2.2).

RE1 (pin 25) was left as an input pin for direction.

The oscillator crystal used for the internal microcontroller was 7.3728MHz to operate it

at the highest frequency (see Section 4.1).

5.2 Internal Microcontroller Programming


5.2.1 Encoder-Based Commutation

This is the approach used for running the brushless linear motors of the gantry. The

properly conditioned 5V square wave output of the encoders is read by the internal microcontroller

as external interrupts. Each time this external interrupt pin goes from low to high logic, an interrupt

service routine is performed. The ISR includes the following tasks:

• Count the number of encoder pulses for position (incrementing or decrementing depending

µ
on direction, encoders has 20 m resolution)

• Check for commutation points (the linear motors have commutation points every 250 encoder

pulses or every 5mm)


16

• Change commutation if commutation point is reached (this is done by changing the state of

the switches through a commutation table)

The six-step commutation table used is shown in Table 5.3. The phase states are achieved by

setting the inputs (assigned PORT B) to the motor driver as seen on the same table.

Table 5.3: Six-Step Commutation Table

State Phase A Phase B Phase C A-HI A-LO B-HI B-LO C-HI C-LO

0 F + 0 0 1 1 1 0 0
1 + F 0 1 1 0 1 0 0
2 + 0 F 1 1 0 0 0 1
3 F 0 + 0 1 0 0 1 1
4 0 F + 0 0 0 1 1 1
5 0 + F 0 0 1 1 0 1
Symbols: + - supply, 0 - ground, F - oat (state output of half-bridge)

The encoder-based commutation is a closed loop method (i.e. changing the state of the

three phases is dependent on encoder feedback). Figure 5.9 shows the closed loop encoder-based

commutation. However, this loop is not always closed with the inclusion of the AND gates; it made

the encoder-based commutation dependent on the external input PWM signal. With no input from

the external microcontroller, the loop will not close and the motor will not actuate.

Figure 5.9: Closed Loop Encoder-Based Commutation

Upon start up of the driver unit, the internal microcontroller will initialize its output and

input pins, the external interrupts, and the starting sequence of commutation. Afterwards, it will

enter an innite loop polling (for direction) and waiting for external interrupts (for commutation

and for locking) at the same time.


17

5.2.2 Locking and Direction Control

Locking is essential in the control of the brushless motors:

• to initially align the motors at a commutation point for correct implementation of encoder-

based commutation and

• to properly stop the motors at desired positions.

An input lock pin (the shorted pins of INT0 and RE0) will read from an external microcontroller

a logic high for locking or a logic low for unlocking the motor (i.e. while that pin is logic high, the

motor will be locked). An ISR is entered once a change from low to high logic at INT0 is detected

and will do the following:

1. hold the current commutation state while RE0 is logic high,

2. once RE0 changes to logic low, release motor,

3. set next commutation state then exit ISR.

While the lock pin is held at logic high, the current commutation state of the motor is held too;

however, this procedure also needs the presence of the input PWM (since they are inputs to AND

gates) to lock the motor. While the motor is locked, it draws a continuous stall current from the

supply; so it must not be locked for too long. The motor then is released (i.e. all three phases'

outputs are unpowered/oat) to stop this current draw and the next commutation state is set so

that it may still actuate and not just lock after exiting the ISR.

Dealing with two interrupts (and their ISRs), the priority for INT0 (locking) was set

higher than INT1 (commutation) since it should stop the motor's actuation at any desired time.

Nesting of interrupt service routines was also disabled.

The direction of the motor's actuation can be controlled through a direction pin (assigned

as RE1); its input logic determines the direction of the motor (either forward/left or reverse/right).

This is done by polling that direction pin and setting a program variable to either 0 or 1; checking

this variable every time and determining encoder count (increment or decrement) and commutation

sequence (forward or reverse).

The direction should be set before actuating the motor and should not be changed in the

middle of running the motor. Direction change should be done while motor is at a stop position;

this is to ensure that the proper encoder-based commutation is maintained (see Section 5.3 for

proper timing of input signals).


18

5.3 External Microcontroller Programming


An external microcontroller was included in the project to demonstrate position and

velocity control of the brushless linear motors. It was programmed to read and generate control

signals in connection to the developed driver unit.

5.3.1 External Microcontroller Design

A 40-pin dsPIC30F4011 was used for the external microcontroller board. It has a PWM

Motor Control Module that is useful in creating the required PWM input signal to the driver unit.

It can also operate at the same frequency as the internal microcontroller using the same oscillator

crystal (7.3728MHz x16PLL). The external microcontroller was fabricated to simulate the external

user's own microcontroller and produce the signals for motor control (Figure 5.10).

Figure 5.10: Example External Microcontroller Signals

5.3.2 Velocity and Position Control

The velocity of the brushless linear motors is directly proportional to the applied voltage;

this was veried in preliminary ndings (see Section 4.3). With the motor driver and interfaced

AND gates, the PWM input from the external microcontroller will chop the applied voltage. By

changing the duty cycle of the PWM signal, the average voltage is varied directly aecting the

motor's velocity. The larger duty cycle, the faster the motor actuates (and vice versa).

The dsPIC30F4011's PWM Motor Control Module and mikroC's functions were used to

produce the input PWM signal and implement velocity control:

• PWMx_Mc_Init - initialize the PWM, set its period/frequency

• PWMx_Mc_Set_Duty - set the duty cycle of the PWM


19

• PWMx_Mc_Start - enable the PWM signal output

• PWMx_Mc_Stop - disable the PWM signal output

The external microcontroller was programmed to output the PWM signal and other control signals

(locking and direction) as shown in Figure 5.10. Initially, the signal for locking is created, the

PWM signal enabled for some time and then stopped (this it to lock the motor in place and release

after). Then the PWM signal is enabled (with a chosen duty cycle) and direction is also set (1 or

0); with this, the motor actuates.

Position control using the external microcontroller is through reading the encoder pulses

and locking the motor once the desired number of pulses (corresponding to a distance) is reached.

INT1 (pin 23) is used as the external interrupt pin for the encoder feedback; its ISR contains only

an increment to a count variable. In the main loop, a check for the position (encoder count) is

always done and generates a signal for locking once it is reached.

For multiple positions, a position ag was used; its value determined the order of the

desired position. After reaching one position, it is updated and informs the microcontroller of the

new position. The position sensed then becomes relative; it is not an absolute position but rather

the distance travelled by the moving member of the linear motor. Also, the stop time between two

positions can be an opportunity to change the direction or the velocity of the motor.
20

Chapter 6

Results and Analysis


6.1 Driver Unit
The motor drivers, the encoder signal conditioning circuits, and the internal microcon-

trollers were fabricated and tested individually. Afterwards, they were integrated to form the driver

unit and tested with the actual motor.

6.1.1 Motor Driver with AND Gates

The three half-bridge conguration was tested with 65V and no load; it can switch at

higher frequencies up to 20kHz with no heating problems and no signicant distortion. It also

µ
showed a built-in deadtime of about 7.4 s that ensures the high-side and low-side switches are not

turned on simultaneously at any given time (Figure 6.1).

µ
Figure 6.1: Built-In Deadtime of 7.40 s
21

With the interfaced AND gates, the low frequency control signals from the internal mi-

crocontroller are combined with the high frequency PWM input signal from the external micro-

controller. Figure 6.2 shows the combined control signals (HI and LO) to the motor driver. These

control signals chop the applied voltage, varying the average voltage directly aecting the motor's

velocity (see Section 6.2).

Figure 6.2: Combined Control Signals with PWM through AND

Figure 6.3: Fabricated Motor Driver Board

Since the bus capacitance of the motor driver is relatively large (8.8mF), it requires a

waiting time to charge up before operation. It is advised to ramp up the voltage from 0V to 65V

instead of powering instantaneously at 65V; this is to avoid spikes of inrush current.


22

6.1.2 Encoder Signal Conditioning Circuit

The encoder signal conditioning circuit was fabricated and tested with the actual encoder

of the gantry. Figure 6.4 shows the converted quadrature encoder signals with voltage levels ac-

ceptable to microcontrollers (~4V). One of these signals is read by the internal microcontroller for

the encoder-based commutation; however, both signals are still made available to the external user.

Figure 6.4: Quadrature Encoder Signals

The output signals of the redesigned encoder signal conditioning circuit are more stable

and accurate than the previous designs'. The better encoder signals allow more precise readings

and position sensing.

The limit switch conditioning circuit also outputs a stable high at the end of the linear

motor, and a stable low anywhere else. However, the gantry lacks complete limit switches for all

axes: the x-axis motor has only its right limit switch working while the y-axis motors have none.

Figure 6.5: Fabricated Encoder Signal Conditioning Circuit


23

6.1.3 Internal Microcontroller

The internal microcontroller was able to implement the encoder-based commutation. It

produced six input control signals to the motor driver while handling two external interrupts (for

commutation and for locking) and polling an input pin (for direction).

Figure 6.6: Fabricated Internal Microcontroller

6.1.4 Integrated Driver Unit

After individual tests, the motor driver, the encoder signal conditioning circuit, and the

internal microcontroller were integrated to form the driver unit. It was connected to the x-axis

motor and encoder and tested with the external microcontroller using the appropriate control

signals. When the driver unit was powered but still has no input from the external microcontroller,

the motor remained at rest and no current was drawn. When the correct control signals were fed,

the driver unit was able to actuate the motor, control its velocity, direction and position.

Figure 6.7: Integrated Driver Unit


24

6.2 Velocity Control


The motor's velocity was controlled by varying the duty cycle of the input PWM signal

from the external microcontroller. The desired commutation signals, shown in Figure 6.8 and

Figure 6.9 are hard chopped through the combined control signals shown in Figure 6.2.

Figure 6.8: Commutation Signals with PWM for Velocity Control (2 phases and no load)

Figure 6.9: Commutation Signal with PWM for Velocity Control (1 phase with motor load)

The range of velocities with the xed 65V supply were determined by separately feeding

a 90% duty cycle (for the maximum) and a 10% duty cycle (for the minimum) PWM signal. While

the PWM was fed, the encoder signal was probed through the oscilloscope; its period indicated

µ
the velocity of actuation. Since a period of encoder signal corresponds to 20 m displacement, the

velocity can be computed by:

20µm
velocity = (6.1)
Tperiod
where Tperiod is the period of the encoder signal in seconds.
25

Figure 6.10: Encoder Signals for a) 1.32m/s Velocity and b) 0.07m/s Velocity

For Figure 6.10a, the input PWM's duty cycle was 90% and frequency was 1kHz; the

µ
encoder signal's period was measured to be 15.2 s. Computing for the corresponding velocity:

20µm
velocity90% = = 1.32m/s (6.2)
15.2µs

With the input PWM's duty cycle changed to 10% and its frequency to 111Hz, the same

procedure was done with Figure 6.10b:

20µm
velocity10% = = 0.07m/s (6.3)
290µs

The frequency was also changed since at 1kHz and 10% duty cycle, the motor cannot

reach the required current to produce torque due to the very short ON-times of switching (smaller

period and even smaller ON-times due to small duty cycle). This may be due to the motor's

electrical characteristics (see Appendix B.2). To accommodate lower velocities, the ON-times was

kept constant (~1msec) and correspond to the low duty cycle (e.g. 10%); in turn, the period is

lengthened (~10msec) and lowered the frequency (~100Hz). This resulted to smoother actuation

of the motor at a slow speed.

With these results, the brushless linear motors of the gantry can be actuated from a

minimum velocity of 0.07m/s to a maximum velocity of 1.32m/s.


26

6.3 Position Control


The external microcontroller was tested to implement position control. Initially, the motor

was locked in place and was done by the actual signals shown in Figure 6.11. The yellow signal is

for the lock pin while the blue signal is for the PWM input pin; the motor was locked only when

both signals are logic high. With the yellow signal at logic low (motor is unlocked) and PWM input

(blue signal) enabled, the motor was actuated.

Figure 6.11: Control Signals for Initial Locking and Actuation

The same signals (as seen in Figure 6.11) were used in locking the motor even in the middle of

actuation. While actuating, the encoder signals were read by the external microcontroller as exter-

nal interrupts and increment the position counter. Figure 6.12 shows the PWM input (blue signal)

with 60% duty cycle and the encoder signal (yellow signal) read by the external microcontroller.

Figure 6.12: Control Signals for Actuation with Velocity and Position Control

Multiple and repetitive tests on position control showed much consistency; it almost always

locked in the same desired positions (after 15000 encoder pulses or 300mm in either direction) even

with varying velocities. It was not perfect since there are times the motor would lock in place;

commutation was not changed caused by the internal microcontroller's short count.
27

Chapter 7

Conclusions and Recommendations


7.1 Conclusions
An improvement of the previous control system by implementing an encoder-based com-

mutation of the brushless linear motors and the development of a driver unit for the gantry has

been realized through this project. The electronic commutation of the brushless motors is now de-

pendent on the position of the moving member determined by reading the encoder feedback. The

driver unit, that includes the improved motor drivers, encoder signal conditioning circuits, and an

internal microcontroller, is able to accept signals from an external microcontroller and allow control

over the motors' velocity, direction, and position.

7.2 Recommendations
The researcher recommends the improvement of position sensing of the brushless motor;

either by making the encoder feedback more accurate and precise or by changing the hardware

altogether. Installation of Hall Eect sensors to provide absolute positions of commutation points

will ensure better actuation of the brushless motors. PID controllers may also be implemented to

lessen errors in both position and velocity control.

The driver unit also needs a current limiting feature to oer protection to itself and to

the motors. With current limiting, locking of motors in place for a long time could be achieved;

this is essential in many gantry applications.

The power demands of the driver unit may also be addressed by building or buying a

power supply with enough specications (larger to provide more current/torque to the motors). A

switching regulator may be built to produce the +5V supply.


28

Bibliography
[Ano] Anorad Product Line, Multi-axis Overhead Positioning Systems for High Precision Man-
ufacturing High Performance Precision Gantry Systems, pp. 1013.

[Ano99] Anorad Linear Motor Division, MERS50 Linear Encoder System, 1999.

[Aut04] Anorad/Rockwell Automation, LEA and LEB Linear Motors User Manual.

[BM11] K.A. Buenaor and A.A. Munlawin, Three-Phase Brushless DC Hub Motor Drive for
Electric Motorcycle, University of the Philippines Diliman (2011).

[BS10] J. Brocoy and J.R. Santos, Development of a Linear Motor Based Gantry, University of

the Philippines Diliman (2010).

[Col10] S. Colton, Design and Prototyping Methods for Brushless Motors and Motor Control,
Massachusetts Institute of Technology (2010).

[HP10] S. Hossain and R. Pedro, Eect of BLDC Motor Commutation Schemes on Inverter Ca-
pacitor Size Selection, XIX International Conference on Electrical Machines (2010).

[LSCC01] C.M. Liaw, R.Y. Shue, H.C. Chen, and S.C. Chen, Development of a linear brushless DC
motor drive with robust position control, IEE Proceedings - Electric Power Applications

148 (2001), no. 2, 111.


[Mic05] Microchip Technology Inc., dsPIC30F4011/4012 Data Sheet, 2005.

[SN05] Freescale Semiconductor and Application Note, 3-Phase BLDC Motor Control with
Quadrature Encoder using 56F800 / E Design of Motor Control Application Based on,
136.
29

Appendix A

Gantry and Linear Motors


A.1 Gantry
The dual axis gantry is an Anorad Super Precision Gantry (SPG-500); it operates on a

horizontal plane through two parallel tracks (Y-axis) and one track mounted on top of the two

forcers of the parallel ones (X-axis) [Ano]. Each track is a linear motor. Figure A.1 shows the

SPG-500 model. Figure A.2 shows the actual gantry in the laboratory.

Figure A.1: Anorad SPG-500 Model [Ano]


30

Figure A.2: Actual SPG-500 Gantry

A.2 Linear Motors


The gantry is composed of three tracks, each one a linear motor. Two Anorad LEB6

linear motors make up the Y-axis while a single Anorad LEA4 linear motor is used for the X-axis.

These ironless brushless linear motors each consists of a stationary U shaped channel containing the

permanent magnets, and a moving coil that traverses in between. Similar to rotary servo motors,

coil windings are connected in 3-phase arrangement; it also requires a commutation sequence to

run properly. Figure A.3 shows the basic conguration of Anorad LEB6 and LEA4 [Aut04].

Figure A.3: Brushless Linear Motor [Aut04]


31

Appendix B

Electrical Characteristics of Motor


B.1 Electrical Cycle Length and Commutation Points
The term electrical cycle length is the distance for one run through of six-step commuta-

tion. The linear motors have an electrical cycle length of 30mm [Aut04] (dividing by 6 will give

5mm). This conrms the experimental value of 250 encoder pulses between commutation points

which corresponds to that 5mm (250 × 20µm = 5mm).

Figure B.1: Electrical Cycle Length


32

B.2 Electrical Time Constant and Torque


The term electrical time constant is the time it takes the motor coil to charge up to 63%

of the rated values of current and torque (overcoming the coil's resistance and inductance) . The

linear motors have an electrical time constant of 0.55msec [Aut04]. This has an eect on torque

production while implementing the chopping of applied voltage through PWM. The combination

of the input PWM's frequency and its duty cycle corresponds to the ON-time (the time the HI side

switch is ON and the power supply provides current to winding). With ON-times lesser than the

electrical time constant, the torque produced in the windings may be too little to actuate the motor;

this may be why at lower duty cycles, the motor cannot be actuated properly (locks or jitters). A

work around this would be to maintain an ON-time of at least the electrical time constant, and

adjust the period (frequency) to have the desired duty cycle.

Figure B.2: Input PWM with 1kHz Frequency and 10% Duty Cycle
33

Appendix C

Encoders
The encoders of the gantry's motors are MERS50 linear encoders which are high precision,

position feedback transducers. They are non-contact, optical encoders; it comprises a scale strip

attached to the axis and a scanning readhead. Its outputs are analog sinusoidal signals; each period

µ
of sinusoid corresponds to a 20 m displacement [Ano99].

Figure C.1: MERS50 Output Signals [Ano99]


34

Appendix D

Schematics and Board Layouts


D.1 Motor Driver with AND Gates

Figure D.1: Three Half-Bridge Conguration with Freewheeling Diodes and Bus Capacitors
35

Figure D.2: Interfaced AND Gates

Figure D.3: Motor Driver Board Layout


36

D.2 Encoder Signal Conditioning Circuit

Figure D.4: Encoder Signal Conditioning Circuit Schematic

Figure D.5: Encoder Signal Conditioning Circuit Board Layout


37

D.3 Internal Microcontroller

Figure D.6: Internal Microcontroller Schematic

Figure D.7: Internal Microcontroller Board Layout


38

D.4 External Microcontroller

Figure D.8: External Microcontroller Schematic

Figure D.9: External Microcontroller Board Layout


39

Appendix E

Source Codes
E.1 Internal Microcontroller Code
/*IMPROVEMENT OF A CONTROL SYSTEM FOR A BRUSHLESS LINEAR MOTOR BASED

GANTRY*/

/*

dsPIC30F4012 code for gantry (internal microcontroller)

7.372MHz osc x16 PLL

encoder-based commutation

external interrupt at INT1 (pin15) for commutation

external interrupt at INT0 (pin16) and input at RE0 for locking

input at RE1 for direction (0 for left/forward and 1 for right/backward)

*/

/**************************GLOBAL VARIABLES*******************************/

void main();

void init_INTx();

void interrupt0();

void interrupt1();

int sequence = 0;

int commutation_table[] = {0x0D, 0x1C, 0x34, 0x31, 0x13, 0x07};

int direction = 0; //either 0 (left/forward) or 1 (right/backward)

int encoder_count = 0; //0 at start

int commutationpt = 250; //no. of pulses between commutation pts


40

/***************************INITIALIZE********************************/

void init_INTx(void)

INTCON1bits.NSTDIS = 1; //no nesting of interrupt service routines

IPC0bits.INT0IP = 7; //highest priority

IPC4bits.INT1IP = 1; //lowest priority

INTCON2 = 0x0000; //Setup INT0, INT1, INT2, INT3 & INT4 pins

//to interrupt on rising edge

IFS0bits.INT0IF = 0; //Reset INT0 interrupt ag

IFS1bits.INT1IF = 0; //Reset INT1 interrupt ag

IEC0bits.INT0IE = 1; //Enable INT0 Interrupt Service Routine

IEC1bits.INT1IE = 1; //Enable INT1 Interrupt Service Routine

/**********************INTERRUPT SERVICE ROUTINES**************************/

/*

ISR for LOCKING MOTOR

entered once lock pin goes from logic low to logic high

holds current commutation state while lock pin is logic high

release motor (oat) once lock pin goes from logic high to logic low

sets next commutation state

*/

void interrupt0() iv IVT_ADDR_INT0Interrupt{

IFS0bits.INT0IF = 0; //Clear the INT0 interrupt ag or else

//the CPU will keep vectoring back to the ISR

LATB = commutation_table[sequence]; //hold current commutation state

while(PORTEbits.RE0 == 1){ //lock motor while RE0 pin is high

LATB = 0b010101; //release motor

delay_ms(500);

if(PORTEbits.RE1 == 1){

sequence++;

direction = 1;

}else{
41

sequence;

direction = 0;

if(sequence == 6)

sequence = 0;

else if(sequence == -1)

sequence = 5;

LATB = commutation_table[sequence]; //set next sequence

encoder_count = 0;

/*

ISR for COMMUTATION OF MOTOR

entered every encoder pulse

senses position through counting of encoder pulses

checks for commutation points

change commutation state if commutation point

set direction only at commutation point

*/

void interrupt1() iv IVT_ADDR_INT1Interrupt{

IFS1bits.INT1IF = 0; //Clear the INT1 interrupt ag or else

//the CPU will keep vectoring back to the ISR

if(PORTEbits.RE0 != 1){ //if lock pin is not high

if(direction == 1){

encoder_count; //decrement position

}else if(direction == 0){

encoder_count++; //increment position

//commutation

if(encoder_count%commutationpt == 0){

if(PORTEbits.RE1 == 1){

sequence++;

direction = 1;
42

}else if(PORTEbits.RE1 == 0){

sequence;

direction = 0;

if(sequence == 6)

sequence = 0;

else if(sequence == -1)

sequence = 5;

LATB = commutation_table[sequence]; //change commutation

encoder_count = 0;

/***************************MAIN FUNCTION*********************************/

void main(){

//initializations

TRISB = 0b001000000; //Initialize PORTB as output

TRISEbits.TRISE0 = 1; //Initialize RE0 as input

TRISEbits.TRISE1 = 1; //Initialize RE1 as input

//initialize external interrupts

init_INTx();

//starting motor

LATB = commutation_table[0]; //initial state

while(1){ //innite loop for interrupts

/*****************************END OF CODE*********************************/
43

E.2 External Microcontroller Code (for x-axis)


/*IMPROVEMENT OF A CONTROL SYSTEM FOR A BRUSHLESS LINEAR MOTOR BASED

GANTRY*/

/*

dsPIC30F4011 code for external microcontroller

7.372MHz osc x16 PLL

for x-axis (with limit switch and lower duty cycles)

velocity control with duty cycle of PWM input

20% minimum duty without jitter/locking

position control through reading of encoders (external interrupt at INT1)

locking of motor through RB0 and RB1 (1 for locked and 0 for unlock)

direction control through RB2 (0 for left and 1 for right)

limit switch at RD2 (0 or 1)

*/

/**************************GLOBAL VARIABLES*******************************/

void main();

void init_INTx();

void interrupt1();

void pwwmc_init();

void init_lock_motor();

void lock_motor();

void run_motor();

unsigned int pwm_period;

unsigned int freq = 1000; //1kHz

unsigned int pll = 16; //x16 PLL

unsigned int freqpll = 0;

unsigned int encoder_count = 0;

int pos = 0; //position ag


44

/***************************INITIALIZE********************************/

void init_INTx(void)

INTCON2 = 0x0000; //Setup INT1 pin to interrupt on rising edge

IFS1bits.INT1IF = 0; //Reset INT1 interrupt ag

IEC1bits.INT1IE = 1; //Enable INT1 Interrupt Service Routine

void pwmmc_init(void) {

TRISE = 0x0100; //initialize PWM pins as outputs and FLTA as input

freqpll = freq/pll;

pwm_period = PWM1_MC_Init(freqpll, 0xFF, 0xFF, 0x00);

PWM1_Mc_Set_Duty(pwm_period, 1);

PWM1_Mc_Set_Duty(pwm_period, 2);

PWM1_Mc_Set_Duty(pwm_period, 3);

void init_lock_motor(){

LATB |= 0b000011; //lock motor

PWM1_Mc_Set_Duty(2*pwm_period, 1);

PWM1_Mc_Set_Duty(2*pwm_period, 2);

PWM1_Mc_Set_Duty(2*pwm_period, 3);

delay_ms(250);

PWM1_Mc_Start(); //enable PWM input

delay_ms(100); //100msec to lock motor at start

PWM1_Mc_Stop(); //disable PWM input

LATB &= 0b000100; //clear lock pin

encoder_count = 0;

void lock_motor(){

LATB |= 0b000011; //lock motor

PWM1_Mc_Set_Duty(pwm_period, 1);

PWM1_Mc_Set_Duty(pwm_period, 2);

PWM1_Mc_Set_Duty(pwm_period, 3);

delay_ms(100); //time to lock motor at position

PWM1_Mc_Stop(); //disable PWM input


45

LATB &= 0b000100; //clear lock pin

encoder_count = 0;

void run_motor(oat duty){

PWM1_Mc_Set_Duty(duty*2*pwm_period, 1); //change duty

PWM1_Mc_Set_Duty(duty*2*pwm_period, 2);

PWM1_Mc_Set_Duty(duty*2*pwm_period, 3);

delay_ms(250);

PWM1_Mc_Start(); //enable PWM input (move motor)

/**********************INTERRUPT SERVICE ROUTINES**************************/

void interrupt1() iv IVT_ADDR_INT1Interrupt{

IFS1bits.INT1IF = 0; //Clear the INT1 interrupt ag or else

//the CPU will keep vectoring back to the ISR

encoder_count++;

/***************************MAIN FUNCTION*********************************/

void main(){

//initialize external interrupts

init_INTx();

//initialize pwm

pwmmc_init();

TRISB = 0b001000000; //Initialize PORTB as output

LATB = 0b000000; //initial direction is left

TRISDbits.TRISD2 = 1; //Initialize RD2 as input

delay_ms(3000);

init_lock_motor();

LATB |= 0b000100; //change direction to right

delay_ms(3000);

run_motor(0.20);

while(1){

if(PORTDbits.RD2 == 1 && pos == 0){ //origin

delay_cyc_long(3);

if(PORTDbits.RD2 == 1){
46

lock_motor();

pos = 1; //for 1st desired position

LATB &= 0b000000; //change direction to left

delay_ms(5000);

run_motor(0.70);

if(encoder_count == 20000 && pos == 1){ //1st desired position is reached

lock_motor();

pos = 2; //for 2nd desired position

LATB |= 0b000100; //change direction to right

delay_ms(5000);

run_motor(0.40);

if(encoder_count == 20000 && pos == 2){ //2nd desired position is reached

lock_motor();

pos = 3; //for 3rd desired position

LATB &= 0b000000; //change direction to left

delay_ms(5000);

run_motor(0.80);

if(encoder_count == 5000 && pos == 3){ //3rd desired position is reached

lock_motor();

pos = 4; //for 4th desired position

LATB &= 0b000000; //change direction to left

delay_ms(5000);

run_motor(0.50);

if(encoder_count == 5000 && pos == 4){ //4th desired position is reached

lock_motor();

/*****************************END OF CODE*********************************/
47

E.3 External Microcontroller Code (for y-axis)


/*IMPROVEMENT OF A CONTROL SYSTEM FOR A BRUSHLESS LINEAR MOTOR BASED

GANTRY*/

/*

dsPIC30F4011 code for external microcontroller

7.372MHz osc x16 PLL

for y-axis (no limit switch and higher duty cycles)

velocity control with duty cycle of PWM input

50% minimum duty without locking

position control through reading of encoders (external interrupt at INT1)

locking of motor through RB0 and RB1 (1 for locked and 0 for unlock)

direction control through RB2 (0 for forward and 1 for backward)

limit switch at RD2 (0 or 1)

*/

/**************************GLOBAL VARIABLES*******************************/

void main();

void init_INTx();

void interrupt1();

void pwwmc_init();

void init_lock_motor();

void lock_motor();

void run_motor();

unsigned int pwm_period;

unsigned int freq = 1000; //1kHz

unsigned int pll = 16; //x16 PLL

unsigned int freqpll = 0;

unsigned int encoder_count = 0;

int pos = 0; //position ag


48

/***************************INITIALIZE********************************/

void init_INTx(void)

INTCON2 = 0x0000; //Setup INT1 pin to interrupt on rising edge

IFS1bits.INT1IF = 0; //Reset INT1 interrupt ag

IEC1bits.INT1IE = 1; //Enable INT1 Interrupt Service Routine

void pwmmc_init(void) {

TRISE = 0x0100; //initialize PWM pins as outputs and FLTA as input

freqpll = freq/pll;

pwm_period = PWM1_MC_Init(freqpll, 0xFF, 0xFF, 0x00);

PWM1_Mc_Set_Duty(pwm_period, 1);

PWM1_Mc_Set_Duty(pwm_period, 2);

PWM1_Mc_Set_Duty(pwm_period, 3);

void init_lock_motor(){

LATB |= 0b000011; //lock motor

PWM1_Mc_Set_Duty(2*pwm_period, 1);

PWM1_Mc_Set_Duty(2*pwm_period, 2);

PWM1_Mc_Set_Duty(2*pwm_period, 3);

delay_ms(250);

PWM1_Mc_Start(); //enable PWM input

delay_ms(100); //100msec to lock motor at start

PWM1_Mc_Stop(); //disable PWM input

LATB &= 0b000100; //clear lock pin

encoder_count = 0;

void lock_motor(){

LATB |= 0b000011; //lock motor

PWM1_Mc_Set_Duty(2*pwm_period, 1);

PWM1_Mc_Set_Duty(2*pwm_period, 2);

PWM1_Mc_Set_Duty(2*pwm_period, 3);

delay_ms(100); //time to lock motor at position

PWM1_Mc_Stop(); //disable PWM input


49

LATB &= 0b000100; //clear lock pin

encoder_count = 0;

void run_motor(oat duty){

PWM1_Mc_Set_Duty(duty*2*pwm_period, 1); //change duty

PWM1_Mc_Set_Duty(duty*2*pwm_period, 2);

PWM1_Mc_Set_Duty(duty*2*pwm_period, 3);

delay_ms(250);

PWM1_Mc_Start(); //enable PWM input (move motor)

/**********************INTERRUPT SERVICE ROUTINES**************************/

void interrupt1() iv IVT_ADDR_INT1Interrupt{

IFS1bits.INT1IF = 0; //Clear the INT1 interrupt ag or else

//the CPU will keep vectoring back to the ISR

encoder_count++;

/***************************MAIN FUNCTION*********************************/

void main(){

//initialize external interrupts

init_INTx();

//initialize pwm

pwmmc_init();

TRISB = 0b001000000; //Initialize PORTB as output

LATB = 0b000000; //initial direction is forward

TRISDbits.TRISD2 = 1; //Initialize RD2 as input

delay_ms(3000);

init_lock_motor();

//LATB |= 0b000100; //change direction to backward

pos = 1;

delay_ms(3000);

run_motor(0.90);

while(1){

if(encoder_count == 20000 && pos == 1){ //1st desired position is reached

lock_motor();
50

pos = 2; //for 2nd desired position

LATB |= 0b000100; //change direction to backward

//LATB &= 0b000000; //change direction to forward

delay_ms(5000);

run_motor(0.90);

if(encoder_count == 20000 && pos == 2){ //2nd desired position is reached

lock_motor();

pos = 3; //for 3rd desired position

LATB &= 0b000000; //change direction to forward

//LATB |= 0b000100; //change direction to backward

delay_ms(5000);

run_motor(0.90);

if(encoder_count == 5000 && pos == 3){ //3rd desired position is reached

lock_motor();

pos = 4; //for 4th desired position

LATB &= 0b000000; //change direction to forward

//LATB |= 0b000100; //change direction to backward

delay_ms(5000);

run_motor(0.60);

if(encoder_count == 5000 && pos == 4){ //4th desired position is reached

lock_motor();

/*****************************END OF CODE*********************************/
51

Appendix F

Driver Unit User Manual


The driver units allow a user to interface microcontrollers with the gantry. They contain the motor

drivers, the encoder signal conditioning circuits and the internal microcontrollers. They have three

ports and two power connections as illustrated in Figure F.1.

Figure F.1: Driver Unit Interface

Table F.1: Ports of Driver Unit

No. Assignment

1 Motor Control Port


2 +5V, -5V, GND (Driver Unit Power)*
3 Encoder and Limit Switch Port
4 +65V, GND (DC Bus Voltage)*
5 Motor Port
* as shown in Figure F.1 from left to right
52

F.1 Input/Output Ports


F.1.1 Motor Control Port

The Motor Control Port contains both input (PWM input, lock, direction) and output

(encoder and limit switches) pins for motor control. It is a DB-9 female connector with the following

pin assignments:

Figure F.2: Motor Control Port

Table F.2: Pin Assignments

Pin No. Assignment

1 PWM Input
2 Lock
3 Direction
4 GND
5 GND
6 Encoder A
7 Encoder B
8 Limit Switch A
9 Limit Switch B

F.1.2 Encoder and Limit Switch Ports

Connect the encoder and limit switch cables of the gantry to these ports.

F.1.3 Motor Port

Connect the motor cable/s of the gantry to this port.


53

F.2 Power Connections


The driver unit has the following power demands for operation:

• +5V, -5V, GND (Driver Unit Power)

• +65V, GND (DC Bus Voltage)

Binding posts are available to connect the driver unit to power supplies. Refer to Figure F.1 and

Table F.1 for connections.

Notes/Reminders:

• Make sure the voltages are strictly +5V and -5V (for Driver Unit Power). Exceeding voltage/s

will damage the internal microcontroller and other integrated chips.

• Be careful not to switch the +5V with the -5V supply.

• The driver unit draws 0.20A to 0.25A while powered on.

• The x-axis motor draws from 0.10A to 3A while actuated (varies with velocity).

• The y-axis motors draw from 0.5A to 5A while actuated (varies with velocity).

• The x-axis motor draws up to 3A while locked.

• The y-axis motors draw up to 5A while locked.

• To ensure protection of the driver unit and the motors, do not lock motors for too long since

the driver unit lacks a current limiting feature. Suggested time duration for locking motor/s

is anything between 100msec and 1sec.

• Reset the Driver Unit Power (turn o and turn on the power supply) if motor locks for more

than the set time duration. This will stop the motor current draw and reset the internal

microcontroller program.

Вам также может понравиться