stepper motor control using labview in a …aseegsw.com/past...

25
Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education 1 Session G-19 STEPPER MOTOR CONTROL USING LABVIEW TM IN A COMPUTER NUMERICALLY CONTROLLED DESKTOP MILL Usha L Manepalli, Dr. M. Elsayed Department of Mechanical Engineering University of Louisiana at Lafayette Lafayette, LA, USA [email protected] [email protected] Dr. Cherif Aissi Department of Industrial Technology University of Louisiana at Lafayette Lafayette, LA, USA [email protected] Abstract The advantage of stepper motor motion control system in a computer numerically controlled (CNC) desktop mill is the high holding torque at low speeds. The aim of this paper is to utilize stepper motors, build their control circuit and write a LabVIEW TM program that reads and implements a CNC code, in the form of a text file, for engraving operations on a desktop mill. The program also controls the basic functions of the desktop CNC mill, such as turning the spindle on and off and controlling travel limits of the worktable. The basic CNC code included linear and circular interpolations, which provide the foundation necessary for the implementation of any future design expansion of the program. LabVIEW TM is a graphical programming language produced by National Instruments of Austin, TX, USA. 1. Background In 1995, Eric Stutes et al. 1 successfully designed and manufactured a fully operational desktop CNC milling machine under the guidance of Dr. M. Elsayed. In this CNC project, DC brush servo motors were used as a conventional motor technology to produce rotary motion in response to an applied voltage. So basically, a close-loop feedback system was used to drive the ballscrew slides for X and Y axis movements using several subroutines and the software library provided by Technology 80 for a Model 5650 controller card 1 .

Upload: leque

Post on 08-Feb-2018

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

1

Session G-19

STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED DESKTOP MILL

Usha L Manepalli, Dr. M. Elsayed Department of Mechanical Engineering

University of Louisiana at Lafayette Lafayette, LA, USA

[email protected] [email protected]

Dr. Cherif Aissi

Department of Industrial Technology University of Louisiana at Lafayette

Lafayette, LA, USA [email protected]

Abstract The advantage of stepper motor motion control system in a computer numerically controlled (CNC) desktop mill is the high holding torque at low speeds. The aim of this paper is to utilize stepper motors, build their control circuit and write a LabVIEWTM program that reads and implements a CNC code, in the form of a text file, for engraving operations on a desktop mill. The program also controls the basic functions of the desktop CNC mill, such as turning the spindle on and off and controlling travel limits of the worktable. The basic CNC code included linear and circular interpolations, which provide the foundation necessary for the implementation of any future design expansion of the program. LabVIEWTM is a graphical programming language produced by National Instruments of Austin, TX, USA. 1. Background In 1995, Eric Stutes et al.1 successfully designed and manufactured a fully operational desktop CNC milling machine under the guidance of Dr. M. Elsayed. In this CNC project, DC brush servo motors were used as a conventional motor technology to produce rotary motion in response to an applied voltage. So basically, a close-loop feedback system was used to drive the ballscrew slides for X and Y axis movements using several subroutines and the software library provided by Technology 80 for a Model 5650 controller card1.

Page 2: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

2

In this work, the servo motors used in the CNC miniature mill are replaced by stepper motors mainly due to their high holding torque at low speeds, their excellent precise positioning mechanism, their simple open-loop feedback system applications and their lower cost. The work is covered mainly in two steps:

1. Test setup I: Build a stepper motor driver interface and control a small 2-phase, bipolar stepper motor using LabVIEW through digital output of a DAQ (Data Acquisition) card for full, half and micro-stepping in both clockwise and counter-clockwise directions.

Figure 1-A Small Stepper Motor Purchased from Danaher Motion2

2. Test setup II: To apply the knowledge of LabVIEW and stepping sequence in operating

the X and Y axes motion of CNC miniature mill for the engraving operation using ballscrew slides and appropriate stepper motors.

Figure 2-Motor and Lead screw Arrangement3

2. Objectives The main objectives of this research are:

1. To replace the existing servo motors with stepper motors control system for the desktop CNC milling machine.

2. To develop a driver and an interface circuit between the CNC machine and a PC. 3. To develop a LabVIEW program that can generate machine command from basic CNC-

code.

3. Scope of the Research • The controller will be built using LabVIEWTM, a graphical programming language produced

by National Instruments of Austin, TX, USA. • The LabVIEW Program is built based on the basic G-codes, which are G0, G1, G2 and G3. • The new controller will be applied to an existing milling machine, which is the CNC milling

machine by replacing the existing servo-motor controller with the new controller.

Page 3: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

3

32 16 8 4 2 1

• An interfacing circuit board will be built based on the stepper motor in order to interface between the controllers (PC) and the CNC milling machine.

• Actual machining will be done by executing a subroutine for, a) Linear interpolations (G0, G1) b) Circular interpolations (G2, G3) c) Engraving operations (A-Z and 0-9) which utilize (a) and (b)

4. Test Setup-I Stepping Sequence for Full/ Half/ Micro-Steps mode: For a four-coil motor, a four-bit code sequence is needed to energize the appropriate poles at any one time. The sequence needed to make the rotor turn can be done in either “full step” or “half step” increments. The difference between these two modes is that the application of some of the codes is omitted. This can be seen in the Tables 1 and 2. Both the speed and direction may be changed at any instant by applying the appropriate codes at the stepper motor’s signal line. Full-step mode: The phase switching for the small bipolar stepper motor (Test Setup-I) with full-step, i.e., 7.50

step angle is shown in Table 1. This gives a full step rotation in both clockwise and counter clockwise directions. Step angle, θs (degrees/ step) = 3600/ Rs (steps/ rev) [4] Where ‘Rs’ is Stepping rate For Full Step, θs = 7.50 So, Rs = 3600÷ 7.50 = 48 steps/ rev

Table 1-Full-Step Sequence for a Stepper Motor with 7.50 Step Angle where: 7B, 9B & 7A, 9A are I1B, I0B & I1A, I0A respectively (control current levels) 8B & 8A are Phase B & Phase A respectively (control direction) A and B are two IC chips (NJM3770AD3) used in stepper driver circuit in Test Setup-I. Half-step mode: Similarly, the stepping sequence for half and micro-step is given in Table 2 and Table 3 respectively. For Half Step, θs = 3.750 (half of full step angle) So, Rs = 3600÷ 3.750 = 96 steps/ rev

CW

dir

ectio

n

Step 7B 9B 8B 8A 7A 9A Nos θs (deg)

C

CW

dir

ectio

n

1 0 0 1 1 1 1 15 0 2 1 1 0 1 0 0 52 7.5 3 0 0 0 0 1 1 3 15 4 1 1 1 0 0 0 56 22.5 1 0 0 1 1 1 1 15 30

Page 4: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

4

Table 2-Half-Step Sequence for a Stepper Motor with 3.750 Step Angle where: 7B, 9B & 7A, 9A are I1B, I0B & I1A, I0A respectively (control current levels) 8B & 8A are Phase B & Phase A respectively (control direction) LabVIEW and Data Acquisition LabVIEW is a program development application developed by National Instruments. It uses a graphical programming language to create programs in block diagram form. It is called a virtual instrument (VI) because its appearance and operation can replicate an actual instrument. A VI consists of a front panel and a block diagram. The front panel is an interactive user interface that simulates a panel of physical instruments like knobs, push buttons, other controls and indicators. Whereas, the block diagram acts as back end, where the actual programming is written using different functions and codes5.

Figure 3-Front Panel of Stepper Motor (Half/Full-Step).vi

CW

dir

ectio

n

Step 7B 9B 8B 8A 7A 9A Nos θs(deg)

CC

W d

irec

tion

1 0 0 1 1 1 1 15 0 2 0 0 1 1 0 0 12 3.75 3 1 1 0 1 0 0 52 7.5 4 0 0 0 1 0 0 4 11.25 5 0 0 0 0 1 1 3 15 6 0 0 0 0 0 0 0 18.75 7 1 1 1 0 0 0 56 22.5 8 0 0 1 0 0 0 8 26.25 1 0 0 1 1 1 1 15 30

32 16 8 4 2 1

Page 5: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

5

Figure 4-Block Diagram of Stepper Motor (Half/Full-Step).vi

Fig. 3 and Fig. 4 show the front panel and block diagram of full-step mode with step angle 7.5 deg. Micro-step mode: For Micro-Step, θs = 0.750 (1/10th of full step angle) So, Rs = 3600÷ 0.750 = 480 steps/ rev Compared to full and half-steps, where the stepper motor tends to be slightly jerky in its operation as the motor moves step by step, in micro-step it runs at a smoother rate.

Page 6: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

6

Table 3-Micro-Step Sequence for a Stepper Motor with 0.750 Step Angle

where: 7B, 9B & 7A, 9A are I1B, I0B & I1A, I0A respectively (control current levels) 8B & 8A are Phase B & Phase A respectively (control direction) Working Principle of Test Setup-I The Test setup-I as shown in Fig. 5 includes a stepper motor, driver interface, DAQ board (device 3), 5V DC Power supply and a PC with LabVIEW software installed. Depending upon the size of the stepper motor, its windings require a substantial drive current. In this case, it ranges between 100mA- 700mA. This drive current is essential for our specified motor to run. Stepper motor driver with two of NJM3770AD36 IC chips, shown in Fig. 6, provides the current switching to each of the four lead wires (1-Black, 2-Yellow, 3-Grey, 4-Red) or the two windings.

CW

dir

ectio

n Step 7B 9B 8B 8A 7A 9A Nos θs (deg)

CC

W d

irec

tion

1 0 0 1 1 1 1 15 0 2 0 0 1 1 1 0 14 0.75 3 0 0 1 1 0 1 13 2.25 4 0 0 1 1 0 0 12 3.75 5 0 1 1 1 0 0 28 5.25 6 1 0 1 1 0 0 44 6.75 7 1 1 0 1 0 0 52 7.5 8 1 0 0 1 0 0 36 8.25 9 0 1 0 1 0 0 20 9.75 10 0 0 0 1 0 0 4 11.25 11 0 0 0 1 0 1 5 12.75 12 0 0 0 1 1 0 6 14.25 13 0 0 0 0 1 1 3 15 14 0 0 0 0 1 0 2 15.75 15 0 0 0 0 0 1 1 17.25 16 0 0 0 0 0 0 0 18.75 17 0 1 0 0 0 0 16 20.25 18 1 0 0 0 0 0 32 21.75 19 1 1 1 0 0 0 56 22.5 20 1 0 1 0 0 0 40 23.25 21 0 1 1 0 0 0 24 24.75 22 0 0 1 0 0 0 8 26.25 23 0 0 1 0 0 1 9 27.75 24 0 0 1 0 1 0 10 29.25 1 0 0 1 1 1 1 15 30

32 16 8 4 2 1

Page 7: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

7

Figure 5-Schematic representation of Test Setup-I7

The input step signals generated from digital I/O (P0.0 to P0.5) transfer to stepper driver pins 7B, 9B, 8B, 8A, 7A, 9A respectively. These input signals or the pulses from the switches or the ports energize the phase windings consecutively, causing the stepper motor to run.

Figure 6-Pin Configurations of NJM3770AD3 Chip6

Fig. 6 shows the pin configurations of NJM3770AD3 and the inputs (7, 8 and 9) and outputs (1 and 15) of IC chip are used in for the signals to flow through the driver circuit from DAQ board to the stepper motor leads.

Motor leads to pins 1 & 15

Pins 7, 9 are I1, I0 respectively and Pin 8 is Phase.

34

12

LabVIEW Software

PC

P0.0 P0.1 P0.2 P0.3 P0.4 P0.5

Stepper Motor Driver

Interface

DAQ Extender Board

(Digital I/O)

Stepper Motor

5V DC

7B 9B 8B 7A 9A 8A

Page 8: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

8

Table 4-Pin

Description of NJM3770AD3 Chip6

Figure 7-Stepper Motor Driver Interface6

Fig. 7 is the schematic of the NJM3770A IC chip and its pin configuration is shown in Table 4.

DIP Symbol Description 1 MB Motor output B, Motor current flows from MA to MB when

phase is high. 2 T Clocking oscillator. Timing pin connect a 56KΩ resistor and a

820pF in parallel between T and Ground. 3,14 VMM Motor supply voltage, 10 to 40 V. Pins 3 and 14 should be wired

together. 4,5 GND Ground and negative supply. Note these pins are used for heat

sinking. 12,13

6 VCC Logic voltage supply normally +5V. 7 I1 Logic input. It controls, together with the I0 input, the current

level in the output stage The controllable levels are fixed to 100, 60, 20, and 0 %.

8 Phase Controls the direction of the motor current of MA and MB outputs.

9 I0 Logic input. It controls, together with the I1 input, the current level in the output stage

The controllable levels are fixed to 100, 60, 20, and 0 %. 10 C Comparator input. This input senses the instantaneous voltage

across the sensing resistor, filtered through a RC Network. 11 VR Reference voltage. Controls the threshold voltage of the

comparator and hence the output current. Input resistance: typically 6.8KΩ± 20%

15 MA Motor output A, Motor current flows from MA to MB when phase is high.

16 E Common emitter. Connect the sense resistor between this pin and ground.

Page 9: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

9

Figure 8-Typical stepper motor driver application with NJM3770A6

where: 7B, 9B & 7A, 9A are I1B, I0B & I1A, I0A respectively (control current levels) 8B & 8A are Phase B & Phase A respectively (control direction) A and B are two IC chips (NJM3770AD3) used in stepper driver circuit in Test Setup-I.

Figure 9-Digital Control of Stepper Motor Experiment I

Stepper Motor

5V DC

NI DAQ USB Board Digital I/O

Stepper Driver Control Circuit

PC LabVIEW Software

Grey

Black

Yellow

Red

7B 8B

9B

9A

7A

8A

B

A

Page 10: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

10

741

1

2

5

4

3

V215 V

V410 V

0

0

4

R21kKey=A

50%

U4DC 10M

Ω 5.000 V+

-

DC10M

00

7

8 Ω

Vi

U6

Ω

5.000 V+

-

XMM1

2

0

Vo

Fig. 9 shows a photo of the Test Setup-I, where a PC with LabVIEW program gives the stepping input signals to stepper driver through a digital NI-DAQ USB board. The output signals from the stepper driver control circuit, which is described in Fig. 8, are used for rotary motion of the stepper motor through the motor leads. 5. Test Setup-II Stepper Control Circuit in Test Setup-II

Figure 10-Typical Wiring Diagram [8]

In Fig. 10, the microstepping drive receives digital input signals from DAQ-board and the output signals are sent to stepper motor through an extension cable. A 35V DC power supply is given to the drive.

Figure 11-Schematic Diagram of Voltage Follower in *NI Multisim A special case of the non-inverting amplifier is that of the Voltage Follower. The voltage follower has the output signal connected to the inverting input terminal of the op amp as shown in Fig. 11. The analysis of this device shows that Vout= Vin. Also the output is in phase with the input. The common use for a voltage follower is to create a buffer in a digital circuit9. It acts as isolation between the input (DAQ board) and the output (Microstepping Drive).

Page 11: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

11

*National Instruments Multisim is an easy-to-use schematic capture and simulation software.

Figure 12-Stepper Motor Controller Circuit with Voltage Follower in Test Setup-II Fig. 12 shows that the voltage follower circuit acting as an isolator between the circuits, i.e., stepper driver circuit (X and Y drive) along with relay circuit (spindle drive), and the NI- DAQ digital I/O USB boards. The DC power supply for the Voltage follower, i.e., Vcc ≈10V. In the test setup-II for CNC desktop mill, a total of 10 voltage followers are used. So, instead three LM 324 ICs (Integrated Chips) are utilized for this. Working Principle of Stepper Motor in Axis Drive: The movement along the different axis is required either to move the cutting tool to the work table to the desired positions. In order to accomplish accurate control of position and velocity, stepper motors are used for axis drive. In the test setup-II, X and Y axes of the work table are controlled by stepper motors and Z-axis or the cutting tool (spindle) is controlled by pneumatic actuator, which is activated by a relay circuit10. Controlling Resonance in the Mechanism: If a rigidly mounted stepping motor is rigidly coupled to a frictionless load and then stepped at a frequency near the resonant frequency, energy will be pumped into the resonant system, and the result of this is that the motor will literally lose control. There are two basic ways to deal with this problem:

Voltage Follower Circuit

120V AC Power Supply

Stepper Drivers

NI- DAQ Digital I/O

Stepper Motors

Page 12: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

12

1. Use of elastomeric motor mounts or elastomeric couplings (Appendix A shows the drawings of the motor mounts and couplings) between motor and load can drain energy out of the resonant system, preventing energy from accumulating to the extent that it allows the motor rotor to escape from control.

2. Viscous damping can be used. Here, the damping will not only draw energy out of the resonant modes of the system, but it will also subtract from the total torque available at higher speeds. The end bearing for the lead screw offers an opportunity for viscous damping, as do the ways on which the load slides. Even the friction found in sealed ballbearings or Teflon on steel ways can provide enough damping to prevent resonance problems11.

Spindle Drive The spindle drive is controlled by a pneumatic/ air cylinder activated by solenoid air valve (Fig. 14) using two solid state I/O relays and DAQ board (device 2). The device shown in the Fig. 13 is the solenoid air valve used for spindle UP/ DOWN actions. A close circuit supplies 5V DC to the relay and thereby spindle is either extended or retracted from the work piece. Another device is the spindle motor, which is again controlled by a third relay and same DAQ board for spindle ON/ OFF positions. Fig. 15 shows the photo of all the connections for spindle drive.

Figure 13-Wiring Diagram of Solid State Digital I/O Relay These Solid state I/O switching modules deliver an electrically clean, photo-isolated, noise-free "output" interface from logic level control systems (NI-DAQ board) to external loads such as motors, valves, solenoids, etc.

Figure 14-Working of Solenoid Air Valve12

Air Cylinder

Solenoid

AC Power Supply 120VAC

RELAY

3+ 4- DC I/P

1 2 AC O/P

DCVoltage5 V

Switch

Device

Page 13: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

13

An air compressor (Fig. 15) is used to supply a pressurized air of about 75-85 PSI or 6 bar to the pressure center of the solenoid air valve. When the solenoid is activated and displaces downward, then the pressurized air is sent to the air cylinder. Here when pressure P1> P2, the piston in the air cylinder is forced down, moving the spindle downward. Similarly, when P2>P1, the piston is forced up, moving the load (spindle) upward.

Figure 15-Experimental Test Setup-II

Figure 16-CNC Desktop Mill

Fig. 16 shows a closer view of the CNC desktop mill, where a spindle is operated by a solenoid air valve. A ball end mill is used as a cutting tool. Clamping is used to fix the work piece to the work table. Two stepper motors are used to control the X and Y slides movement. Limit switches are used at each end of the X and Y axes.

Clamping

Solenoid Air Valve Spindle

Work Table

Work Piece

Slides Stepper Motor

Ball End Mill

Limit Switches for Y-axis

PC with LabVIEW Program

Air Compressor

NI-DAQ USB

Relay Circuit

Stepper Driver

Desktop Mill

Page 14: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

14

Limit Switches in Motion Control A limit switch is a device that produces a signal used to stop the motor. Limit switches are usually used to indicate an end of travel, or to prevent a motor from travelling too far in one direction or crossing the work space limits. In this experiment, the stepper motors cannot move any more than a specified distance (5.5in. each direction) without doing damage to the motor or the surroundings. When a limit switch (Fig. 17) is activated in the direction of travel, a controller needs to stop motion in that direction as soon as possible. To accomplish this, ReadDigPort_2.vi as shown in Appendix C is used in a while loop in the main program to stop immediately at the press of the roller. This acts like an emergency stop and the whole program and machine comes to a stand still. To get any movement, the limit must be disabled.

Figure 17-Limit Switch and its connections for longitudinal slide of the desktop mill When the XY table has moved to the farthest position it can move to, the motor must stop trying to push it any further. If there were no limit switches on the XY table, the motor would reach the end of travel, but still continue to turn, causing damage to either the motor or the XY table13.

6. Results and Discussions

This section includes the description of LabVIEW programming (Fig. 19-36) to read CNC-code text file and to be able to complete the engraving operation14 on desktop CNC miniature mill. The program is written to execute sub-routine of any 3 letters (A-Z) or 3 numbers (0-9).The CNC code for letters A to Z and numbers 0 to 9 are explained in Appendix B. A flow chart is illustrated in Fig. 18 for the LabVIEW program used to read a CNC-code text file. The Main VI (Subroutine_Main.vi) is having a SubVI called Sub Code VI which contains all the different CNC codes (G0, G1, G2, G3, Home, M5 and L9201) used in the program. A SubVI for each of the CNC code is written.

Page 15: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

15

Figure 18-Flow Chart for the LabVIEW Program to read a CNC-Code text file Main VI Program:

Figure 19-Front Panel of Subroutine_Main.vi

Figure 20-Block Diagram of Subroutine_Main.vi

Engrave SubVI

Spindle SubVI

Limit Switch SubVI

Linear Interpolation

SubVI

G0 G1 G2 G3 Home M5 L9201

Main VI

Sub Code VI

Circular Interpolation

SubVI

Page 16: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

16

Sub Code VI Program:

Figure 21-Front panel of Sub_Code.vi Fig. 21 shows front panel of the Sub Code VI. Here a menu ring that has different CNC-codes and another ring that contains the characters, i.e., letters (A-Z) and numbers (0-9) are used. Linear Interpolation Sub VI: G0, G1

Figure 22-Front Panel of Feed Rate All_with Limit Switch.vi

Figure 23-Block Diagram of Feed Rate All_with Limit Switch.vi

Page 17: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

17

Ring Properties

Table 5-Test Menu Ring Properties The Table 5 shows the different cases used in Linear Interpolation SubVI.

Figure 24-Front Panel of SubVI Feed Rate _with Limit Switch.vi

Page 18: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

18

Figure 25-Block Diagram of SubVI Feed Rate_with Limit Switch.vi

Circular Interpolation SubVI: G2, CW

Figure 26-Front Panel of CW Circular Interpolation (G2) SubVI.vi

Figure 27-Block Diagram of CW Circular Interpolation (G2) SubVI.vi

Page 19: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

19

Circular Interpolation SubVI: G3, CCW

Figure 28-Front Panel of CCW Circular Interpolation (G3) SubVI.vi

Figure 29-Block Diagram of CCW Circular Interpolation (G3) SubVI.vi

Page 20: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

20

Figure 30-Front Panel of CW/CCW Circular Interpolation SubVI.vi

Figure 31-Block Diagram of CW/CCW Circular Interpolation SubVI.vi

Page 21: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

21

Figure 32-Description of algorithm in CW/CCW Circular Interpolation SubVI.vi

Spindle SubVI: M5

Figure 33-Front Panel of Spindle Motion (UP/ DOWN/ ON/ OFF).vi

Figure 34-Block Diagram of Spindle Motion (UP/ DOWN/ ON/ OFF).vi

Engrave SubVI: L9201 The L word, L920114 is used for Engraving operations. Before running the Main VI, make sure that all the G-code text files for the characters (A-Z and 0-9) are in the same folder as that of Engrave SubVI. All the text files are tab delimited.

Page 22: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

22

Figure 35-Front Panel of LUS.vi (Reads Text file of English Alphabet (A-Z) and Numbers (0-9))

Figure 36-Block Diagram of LUS.vi Character Box G-code for each English Alphabet, i.e., from A to Z and Numbers, i.e., from 0 to 9 is written. Here the character box (Fig. 37) height is taken as 1.4 in. and its width ranges from 0.8 to 1.2 in. depending upon the character or the letter width. In other words, the Start and End points for each letter box is (0, 0) and (0.8, 1.4) or (1.2, 1.4) respectively.

Page 23: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

23

Letter U

0.8, 1.4

0.2, 0.2 0.6, 0.2

0.2, 0.40, 0.4 0.8, 0.4

0, 1.4

0.6, 0.4

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

0 0.2 0.4 0.6 0.8 1X-axis

Y-a

xis

G1G0G3

X,Y I, J

Letter L

0, 1.4

0.8, 0.2

0.8, 1.4

0, 0.3 0.1, 0.3

0.1, 0.20

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

0 0.2 0.4 0.6 0.8 1 1.2

X-axis

Y-a

xis

G1G0G3X,YI, J

Figure 37-Character/Letter Box

Engraving (ULL) An example of engraving, i.e., letters ‘ULL’ on the CNC desktop mill is achieved by using G-code from tables 6 and 7 and the corresponding tool path is shown in the Fig. 38 and Fig. 39.

Table 6-G-code for Letter ‘U’ Figure 38-Character Box for Letter ‘U’

Table 7-G-code for Letter ‘L’ Figure 39-Character Box for Letter ‘L’

Code X Y I J G0 0 1.4 0 0 G1 0 0.4 0 0 G3 0.2 0.2 0.2 0.4 G1 0.6 0.2 0 0 G3 0.8 0.4 0.6 0.4 G1 0.8 1.4 0 0

Code X Y I J G0 0 1.4 0 0 G1 0 0.3 0 0 G3 0.1 0.2 0.1 0.3 G1 0.8 0.2 0 0 G0 0.8 1.4 0 0

EP

S

Width

Hei

ght

Page 24: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

24

Figure 40-Engraving on CNC Desktop Mill Fig. 40 shows a photo taken after the engraving operation on the CNC desktop mill used in Test setup-II. 7. Conclusions In this paper stepper motors, which have high holding torque at low speeds, are utilized to build their control circuit and write a LabVIEW program that reads and implements a CNC code, in the form of a text file, for engraving operations on a desktop mill. The program also controls the basic functions of the desktop CNC mill, such as turning the spindle on and off and controlling travel limits of the worktable. The basic CNC code included linear and circular interpolations, which provide the foundation necessary for the implementation of any future design expansion of the program. The paper also took one step beyond the set goals, namely engraving operation subroutines for English Alphabet (A to Z) and numbers (0 to 9) were written and executed on the desktop mill. Limitations The limitations of the open-loop approach include:

1. It is not good for applications with varying loads, it is possible for a stepper motor to lose steps, and its energy efficiency level is low.

2. It has resonance areas which must be avoided15. 8. Scope of Future Work

1. Apart from milling, this experiment can be used for drilling, turning, boring, & grinding operations. It can be further applied on machines like pipe bending coil winding, flame cutting, welding, etc.

2. The CNC codes used in this paper are G0, G1, G2, G3, M5 and L9201. In addition to this, there are several CNC codes which can be programmed and implemented.

3. Instead of reading the code from a text file (.txt) which is written manually, it can be generated readily by using a CAM package like GibbsCAM, MasterCAM, etc.

4. To improve the function of CNC mill, a 4-axis or 5-axis can be added. This can be used to machine complex parts like turbine blades.

5. There is a scope to increase the machine operational envelope, i.e., the worktable size, which is too small for machining.

6. In this paper, X and Y axes are controlled by stepper motors and Z-axis is controlled by a pneumatic cylinder operated by a solenoid valve using LabVIEW. A study can be made

Page 25: STEPPER MOTOR CONTROL USING LABVIEW IN A …aseegsw.com/past Proceedings/G-19_Manepallil_Elsayed.pdf · STEPPER MOTOR CONTROL USING LABVIEWTM IN A COMPUTER NUMERICALLY CONTROLLED

Proceedings of the 2010 ASEE Gulf-Southwest Annual Conference, McNeese State University Copyright © 2010, American Society for Engineering Education

25

by using a stepper motor for Z-axis as well. The rotational bipolar stepper motors can be replaced by linear stepper motors and studied further.

7. A simulation that allows user to see a preview of the cutter’s tool path either in 2D (XY Graph) or in 3D view can be developed using a LabVIEW VI program16.

References

1. Stutes, E., Potier, B., Jr. and Thibodeaux, C., 1995, “Computer Numerically Controlled Desktop Milling Machine,” Report, Mechanical Engineering Department, The University of Southwestern Louisiana, Lafayette, LA, pp. 1-49.

2. Portescap, 42M048C Series Stepper Motor Manual, 2005, Danaher Motion, West Chester, Pennsylvania, 42M048C StepperCS 134 v6.09.pdf 3. Groover, M.P., 2007, Automation, production systems, and computer-integrated manufacturing, Prentice Hall,

Upper Saddle River, New Jersey, pp. 139-178. 4. Sokoloff, L., 2004, Applications in LabVIEW, Prentice Hall, Upper Saddle River, New Jersey, pp. 386-401. 5. National Instruments Corporation, 2006, Getting Started with LabVIEW, Manual, Austin, Texas, pp. 1-1. 6. New Japan Radio Co, Ltd., 2005, NJM3770A Datasheet,

http://semicon.njr.co.jp/njr/hp/productDetail.do?_isTopPage=false&_productId=401&_moveKbn=PRODUCT_DETAIL_MOVE_SPEC

7. Sokoloff, L., 2004, Applications in LabVIEW, Prentice Hall, Upper Saddle River, New Jersey, pp. 386-401. 8. Sure Step Manual, First Edition, Revision A, 2004, Manual Number: STP-SYS-M,

http://www.automationdirect.com/static/manuals/surestepmanual/history.pdf 9. Michigan Tech., 2005, Operational Amplifiers, Lab Report, pp. 1-2,

http://www.ece.mtu.edu/labs/EElabs/EE3305/OpAmp_Lab_I.pdf 10. Pabla, B.S., Adithan, M., 1994, CNC Machines, New Age International, Daryaganj, New Delhi, India, pp. 24-

72. 11. Jones, D. W., 1995, “Control of stepping motors, a tutorial,” The University of Iowa Department of Computer

Science, Iowa City, Iowa, http://www.cs.uiowa.edu/~jones/step/ 12. Dorf, R. C. and Bishop, R. H., 2008, Modern Control Systems, Prentice Hall, Upper Saddle River, New Jersey,

pp. 69. 13. National Instruments, 2006, “Limit Switches in Motion control Tutorial,”

http://zone.ni.com/devzone/cda/tut/p/id/4465 14. Fadal User Manual, 2003, Fixed Subroutines, Section 6, Compumachine Inc., Danvers MA, pp.111-116,

http://www.compumachine.com/Support/Downloads/Fadal/User%20Manual/0060__Sect_6_ _Fixed_Subroutines.pdf

15. Baldor Electric Company, 2000, Servo Control Facts, A Handbook Explaining the Basics of Motion, Fort Smith, Arkansas, pp.10-16, http://www.baldor.com/support/literature_load.asp?ManNumber=MN1205

16. Feng, Y. N., 2007, “LabVIEW Controlled Desktop Computer Numerical Control (CNC) Mill,” National Instruments ASEAN Virtual Instrumentation Applications Contest, Singapore.