DESIGN AND IMPLEMENTATION OF A REMOTE

2 downloads 0 Views 4MB Size Report
A flash and flash media server are used to turn on a web camera connected .... Many descriptions have been used during the years, to define what NC is.
DESIGN AND IMPLEMENTATION OF A REMOTE CONTROLLER FOR A THREE-AXIS MILLING MACHINE

A Thesis Submitted to the College of Engineering of Nahrain University in Partial Fulfillment of the Requirements for the Degree of Master of Science in Computer Engineering

by HAYDER SAADI RADEAF (B.Sc., 2008)

Thoul Hijjah

1431

November

2010

Abstract CNC (Computer Numerical Control) machines are widely used in production fields since they produce similar parts in a minimum time, at higher speed and with possibly minimum error. A CNC system is designed, implemented and tested to control the operation of a laboratory milling machine having three axes that are moved by using a stepper motor attached to each axis. The designed control system consists of two PCs (server PC and client PC), the server PC is connected to the machine through its parallel port by using designed interface circuit. The client PC is used to control and monitor the machine operations remotely, and a network/internet connection is used to establish a connection with the server PC to control the machine. The required shape on the wooden piece is drawn by using one of the drawing software like AUTOCAD® or 3D MAX and it is saved in a well-known file format (DXF), then that file is fed to the machine controller either by the operator or by the connected client PC, then that shape will be machined. The CNC system using developed algorithms that read the DXF file fed to the machine, extracts (line, circle, arc, ellipse or polyline) shapes from the file and generates commands to move the machine axes so that these shapes can be machined. A flash and flash media server are used to turn on a web camera connected to the server PC, capturing live video and broadcasting that video to the network

i

so that the connected client PC can receive the broadcasted live video and can display it in the client PC screen for the purpose of monitoring. The designed CNC system is tested by feeding different DXF files to the controller to be machined and the parts resulted are accepted since the error generated is small (less than 0.1 mm).

ii

List of Contents Contents

Pages

Abstract

i

List of Contents

iii

List of Abbreviations

vii

List of Figures

ix

List of Symbols

xii

Chapter One: Introduction 1.1 The History of Numerical Control

1

1.2 Definition of NC

2

1.3 PC-Based CNC System

2

1.4 Literature Survey

3

1.5 Aim of the Work

6

1.6 Thesis Organization

7

Chapter Two: Theoretical Concepts 2.1 Introduction

8

2.2 Elements of a CNC System

8

2.2.1 Input Devices

9

2.2.2 MCU (Machine Control Unit)

9

2.2.2.1 Data Processing Unit

10

2.2.2.2 Control Loop Unit

10

iii

2.2.3 Machine Tool

10

2.2.4 Driving System

10

2.2.5 Feedback Device

11

2.2.5.1 Positional Feed Back Devices

11

2.2.5.2 Velocity Feedback Device

11

2.2.6 Display Unit

12

2.3 CNC Principles

12

2.3.1 Cartesian Coordinate System

12

2.3.2 Programming Systems

16

2.3.3 Positioning Types

17

2.3.3.1 Point-to-Point Positioning

17

2.3.3.2 Continuous Path (Contouring)

18

2.4 Control Systems

19

2.4.1 Open Loop Systems

20

2.4.2 Closed Loop Systems

21

2.5 Parallel Port Interface

22

2.6 Network Sockets

23

2.7 Flash and Flash Media Server

24

2.7.1 Uses of Flash Media Server

24

2.7.2 Flash Media Server Operation

25

Chapter Three: The Proposed Control System Design 3.1 Introduction

26

iv

3.2 General System Architecture

27

3.3 Hardware System Design

29

3.3.1 The Standard Parallel Port

30

3.3.2 Interface Circuit

30

3.4 Software System Design

31

3.5 Server PC Program

34

3.5.1 Connecting to Client PC

36

3.5.2 Receiving Files from Client PC

36

3.5.3 Extracting Drawings from Received Files

36

3.5.4 Controlling the Movement of the CNC Axes

40

3.5.5 Speed Control of the Drill DC Motor

46

3.5.6 Drawing Shapes Algorithms

47

3.5.6.1 Drawing Line Algorithm

47

3.5.6.2 Drawing Circle Algorithm

49

3.5.6.3 Drawing Arc Algorithm

51

3.5.6.4 Drawing Ellipse or Arc of Ellipse Algorithm

54

3.5.6.5 Drawing Polyline Algorithm

59

3.6 A Client PC Program

63

3.7 The Flash Programs

65

3.7.1 The Flash Server Program (Broadcaster)

65

3.7.2 The Flash Client Program (Receiver)

66

v

Chapter Four: System Implementation and Results 4.1 Introduction

67

4.2 CNC Controller Preparations

67

4.2.1 The Server PC Preparation

68

4.2.1.1 The Platform

68

4.2.1.2 The Web Server

68

4.2.1.3 The Media Server

69

4.2.1.4 Accessing the Parallel Port

69

4.2.1.5 Hardware Requirements

70

4.2.2 General Preparations

70

4.2.3 Installing Project Files

72

4.3 The System GUI

73

4.3.1 Server PC GUI

73

4.3.1 Client PC GUI

77

4.4 Testing Results

80

Chapter Five: Conclusions and Suggestions for Future work 5.1 Conclusions

89

5.2 Suggestions for Future Work

90

References

92

vi

List of Abbreviations Abbreviation

Meaning

AC

Alternating Current

AMF

Action Message Format

BLU

Basic Length Unit

CLU

Control Loop Unit

CNC

Computer Numerical Control

DC

Direct Current

DLL

Dynamic Link Library

DPU

Data Processing Unit

DXF

Data Exchange Format

FLV

Flash Live Video

FMS

Flash Media Server

FPGA

Field Programmable Gate Array

GUI

Graphical User Interface

IC

Integrated Circuit

IP

Internet Protocol

MCU

Machine Control Unit

MIT

Massachusetts Institute of Technology

NC

Numerical Control

PC

Personal Computer

PLC

Programmable Logic Controller

PWM

Pulse Width Modulation

vii

RPC

Remote Procedure

RTMP

Real Time Messaging Protocol

SWF

Small Web Format

TCP

Transmission Control Protocol

TCP/IP

Transmission Control Protocol/ Internet Protocol

USB

Universal Serial Bus

viii

List of Figures Figure

Title

Page

(2-1)

Elements of CNC System

9

(2-2)

Intersecting lines form right angles and establish zero point

14

(2-3)

A three-dimensional coordinate planes (axes) used in CNC

14

(2-4)

The quadrants formed when the X and Y axes cross are used

15

to accurately locate points from the XY zero, or origin point (2-5)

A work-piece dimensioned in the incremental system mode

16

(2-6)

A work-piece dimensioned in the absolute system mode

17

(2-7)

The path followed by point-to-point positioning to reach

18

various programmed points on the XY axis (2-8)

Simple contour

19

(2-9)

Complex contour

19

(2-10)

Open Loop Control System

20

(2-11)

Close Loop Control System

21

(2-12)

The parallel port female connector and pin configuration

22

(3-1)

Architecture of the system

28

(3-2)

74LS245 Octal Bus Transceiver

31

(3-3)

System Pin Diagram

32

(3-4)

A General View of the Software Design

33

(3-5)

A flowchart of server’s visual basic program

35

(3-6)

A flowchart of receiving files from client

38

(3-7)

A flowchart of open the DXF file algorithm

39

ix

(3-8)

Signals needed to rotate the stepper motor in clockwise or

40

counter clockwise direction (3-9)

A flowchart of how to move the X, Y and Z axes in the

41

positive direction (3-10)

A flowchart of how to move the X, Y and Z axis in the

42

negative direction (3-11)

Moving between points with and without interpolation

44

(3-12)

A flowchart of making decision of which motor to run at

45

which direction and at which speed (3-13)

A flowchart of DC motor speed control technique using PWM

46

(3-14)

A flowchart of line drawing algorithm

48

(3-15)

Circle and its components

49

(3-16)

A flowchart of circle drawing algorithm

50

(3-17)

Arc and its components

51

(3-18)

A flowchart of arc drawing algorithm

(3-19)

Ellipse and arc of ellipse and their components

(3-20)

A flowchart of ellipse and arc of ellipse drawing algorithm

55-58

(3-21)

A flowchart of polyline drawing algorithm

60-61

(3-22)

A flowchart of lwpolyline drawing algorithm

61-62

(3-23)

A flowchart of client PC algorithms

64

(4-1)

CNC machine used in the thesis

71

(4-2)

CNC machine stepper motor driver and controller

72

(4-3)

Server program GUI

73

(4-4)

Login screen to broadcaster.html web page

74

x

52-53 55

(4-5)

Broadcaster.html web page that turn the web camera on and

75

transmit the captured video to the network (4-6)

Client program GUI

79

(4-7)

Receiver.html web page that received and display the live

80

video transmitted to Flash Media Server (4-8)

DXF file shows the first scenario

82

(4-9)

The first scenario is machined in a piece of wood

82

(4-10)

DXF file shows the second scenario

83

(4-11)

The second scenario is machined in a piece of wood

83

(4-12)

DXF file shows the third scenario

84

(4-13)

The third scenario is machined in a piece of wood

84

(4-14)

DXF file shows the fourth scenario

85

(4-15)

The fourth scenario is machined in a piece of wood

85

(4-16)

DXF file shows the fifth scenario

86

(4-17)

The fifth scenario is machined in a piece of wood

86

(4-18)

DXF file shows the sixth scenario

87

(4-19)

The sixth scenario is machined in a piece of wood

87

(4-20)

The fifth scenario is monitored from the client PC

88

xi

List of Symbols Symbols

Notations

V

Velocity

Vx

X axis moving velocity

Vy

Y axis moving velocity

X1

X coordinate of line starting point

Y1

Y coordinate of line starting point

X2

X coordinate of line ending point

Y2

Y coordinate of line ending point

Xc

X coordinate of circle, arc or ellipse center point

Yc

Y coordinate of circle, arc or ellipse center point

Xn

X coordinate of circle, arc or ellipse circumference point

Yn

Y coordinate of circle, arc or ellipse circumference point

R

Radius of circle or arc

ϴ

Angle between X axis and any point in circle, arc or ellipse circumference

MajorX

Distance from X axis center point to X axis of start point of an ellipse

MajorY

Distance from Y axis center point to Y axis of start point of an ellipse

A

Major axis of an ellipse

B

Minor axis of an ellipse

β

Angle of rotation of an ellipse

xii

Chapter One

Introduction 1.1 The History of Numerical Control It is known that the general-purpose manual machine tool was introduced after developing the steam engine in the late 18th century. Thereafter, Jacquard invented the method of automatic control of the weaving of fabrics with a loom machine by using punch cards and this method was the beginning of the concept of NC (Numerical Control) [1]. The concept of NC was actually emerged in the mid-20th century. It can be traced to the year of 1952, the U.S. Air Force, and the names of John Parsons and the MIT (Massachusetts Institute of Technology) in Cambridge. It was not applied in production manufacturing until the early 1960's. The real boom came in the form of CNC (Computer Numerical Control), around the year of 1972, and a decade later with the introduction of affordable microcomputers [2]. In the last three decades, PCs (Personal Computers) have found wide applications in industries. Due to dramatic increase in the capacity, improvement of the reliability and decrease of the cost of industrial PCs in recent years, PC- based CNC systems become the major trend in CNC system development [3].

1

1.2 Definition of NC [2] Many descriptions have been used during the years, to define what NC is. Many of these definitions share the same idea, same basic concept, just use different wording. The majority of all the known definitions can be summed up into a relatively simple statement: “NC can be defined as an operation of machine tools by the means of specifically coded instructions to the machine control system”. The instructions are combinations of the letters of alphabet, digits and selected symbols, for example, a decimal point, the percent sign or the parenthesis symbols. All instructions are written in a logical order and a predetermined form.

1.3 PC-Based CNC System There is a large exodus in the industry from the popular PLC (Programmable Logic Controller) (hardwired or softwired) to PC-based controller. PC-based control offers great advantages like faster design cycles, lower downtime using diagnostics and simulation tools, increased productivity and decreased maintenance costs [4]. Today’s increasing processor speeds and decreasing costs lure people to program most of the conventional hardware controller functions inside a PC. Such an approach can not only overcome problems like inflexibility, large physical space, time and costs of up-gradation present in conventional hardware

2

controllers; but also provide people with a better user interface and multiprogramming. With the present day high speed PCs loaded with one of the popular desktop operating systems like Windows XP would make a good control center for a CNC machine [4]. There are many PC-based machine tool controllers for CNC available in the market today, but they are proprietary and the customer needs to depend on the software vendor for maintenance and support [4].

1.4 Literature Survey Kim and Kim, in 1996 [5] proposed a proportional, integral, and derivative type iterative learning controller for precise tracking control of industrial robots and CNC machine tools performing repetitive tasks. The convergence of the output error by the proposed learning controller is guaranteed under a certain condition even when the system parameters are not known exactly and unknown external disturbances exist. The experimental results demonstrate that the proposed learning controller can improve machining accuracy when the CNC machine tool performs repetitive machining tasks. Hanafi et al., in 2003 [6] presented an active axis controller for a conventional CNC machine. To develop the system, a two-stage approach has been taken. In stage one; a generic external axis controller is designed to bring the machine under the real-time control of an external computer. Stage two is the design of the active axis controller. To achieve this, a sensor feedback loop is added to the external controller to enable visual servoing. The results presented compare the speed of response of the external axis controller with that of the speed of response of the original CNC controller in linear interpolation motion.

3

The accuracy and the performance of the active axis controller are demonstrated by presenting the results of active visual tracking. Wu et al., in 2006 [7] introduced briefly the characteristics and requirements of open-architecture CNC system. A method that develops the open-architecture CNC system based on PC and Windows XP embedded operating system was put forward. The structure of the open-architecture CNC system based on real-time serial communication bus is described briefly, and a software open-architecture CNC system based on Windows XP embedded is presented elementarily. Ren et al., in 2007 [8] described the architecture of CNC system which adopts Internet/Ethernet from higher management level to lower field device level. It defines the information types and the information flow feature, and presents the solutions which include the web-based remote process, TCP/IP (Transmission Control Protocol/ Internet Protocol) and socket based local process and collision avoidance based real-time communication process. The results show that the CNC system based on Internet/Ethernet can meet the requirement of the application. Yuan et al., in 2008 [9] developed a motion controller for CNC machining in accordance with OMAC (Open Modular Architecture Controllers) agreement and industry standards. The motion controller is a software package running on PC. This development based on modular structure adopting hierarchic organization mode.

4

Xu et al., in 2008 [10] structured a CNC system which was based on embedded processors and embedded-real-time-operating system. FPGA (Field Programmable Gate Array) module realizes system’s flexible manufacturing and reconfiguration. Due to the disadvantages of single task software structure, embedded real time operating system and software-layer-structure method are used to enhance CNC system’s stability. Feasibility of this method is certified through applications in NC machine. Dong et al., in 2009 [11] presented a novel CNC controller architecture using reconfigurable hardware. Several logic modules, including a new resampling module for threading, are designed to support the reconfiguration process. By employing different type of logic modules, the hardware logic of the controller can be changed to control various targets. An experimental system was built, and applied to a milling machine and a lathe machine to valid the proposed architecture. Jiawu et al., in 2010 [12] introduced a container-type interpolation algorithm for CNC trajectory. This method achieves two-axis or multi-axis interpolation operation and acceleration/deceleration control through careful selection of container capacity and the increasing value. It can simplify the process of interpolation, which improves the speed and accuracy of interpolation calculation. The algorithm has been successfully used in a number of CNC cutting machines’ control systems.

5

Bin and Chunxue, in 2010 [13] took the point-to-point comparison method of circular interpolation as an example, search its arithmetic, and realize the dynamic simulation of different quadrant circular interpolation process based on SciLab.

1.5 Aim of the Work The aim of the work is to design, implement and test a control system for a laboratory CNC milling machine, this system includes:  The machine used in this work is the one exists in the laboratory but its CNC controller is missing.  The sample needs to be machined is drawn using one of the CAD (Computer Aided Design) software such as AUTOCAD or 3D MAX.  This drawing is fed to the CNC controller that extracts the drawings and generates the commands used to operate the machine.  The system used in the thesis is in server-client mode. The server is the PC used as the CNC controller.  The server can be accessed remotely from a client PC connected to the server through LAN (Local Area Network) networks or through the internet.  The client can run the CNC by sending the drawings to the server.  A live video feed that transmits live video of the CNC to the client using a webcam installed on the server to monitor the CNC operation and to deal with any problem that could happen.

6

1.6 Thesis Organization This thesis is organized in five chapters. The contents of the following chapters are briefly reviewed here as follows:  Chapter 2: Includes the basics of the various techniques and methods used in this work. Detailed information was provided concerning the following subjects: o Elements of a CNC system and its principles o Parallel port interfacing o Sockets, flash and flash media server  Chapter 3: Illustrates the proposed CNC system, its design, and the algorithms used to implement it.  Chapter 4: Presents the system implementation, the Graphical User Interface, and the results of the experiment.  Chapter 5: Includes conclusions and suggestions for possible future work.

7

Chapter Two

Theoretical Concepts 2.1 Introduction To design a CNC milling machine control system, there is a need to know how the CNC works and how to connect it to the computer to control its operation. This can be done by having some basic knowledge concerning the following:  Elements of a CNC system and its principles.  Parallel port interfacing.  Sockets, flash and flash media server. The following sections will discuss each topic of the above in details.

2.2 Elements of a CNC System [14] CNC systems include the following six major elements listed below and shown in Fig. 2-1  Input Device  Machine Control Unit  Machine Tool  Driving System  Feedback Devices  Display Unit

8

Figure 2-1 Elements of CNC System [14]

2.2.1 Input Devices Input devices are used to insert the instructions and parameters used by the CNC to perform its operations. There are many types of input devices used with the CNC, some of these input devices are punched card reader, floppy disk drive, serial interface (RS232), USB (Universal Serial Bus) and Ethernet.

2.2.2 MCU (Machine Control Unit) The MCU is the heart of the CNC system. There are two sub-units in the MCU: the DPU (Data Processing Unit) and the CLU (Control Loop Unit).

9

2.2.2.1 Data Processing Unit On receiving a program, the DPU firstly interprets and encodes the part program into internal machine codes. The interpolator of the DPU then calculate the intermediate positions of the motion in terms of BLU (Basic Length Unit) which is the smallest unit length that can be handled by the controller. The calculated data are passed to CLU for further action.

2.2.2.2 Control Loop Unit The data from the DPU are converted into electrical signals in the CLU to control the driving system to perform the required motions. Other functions such as machine spindle on/off, coolant on/off, tool clamp on/off are also controlled by this unit according to the internal machine codes.

2.2.3 Machine Tool This tool used to convert the radial movement of the motors attached to each axis in the CNC to linear movement, example of machine tool used with the CNC is lead-screw driver.

2.2.4 Driving System The driving system is an important component of a CNC machine as the accuracy and repeatability depend very much on the characteristics and performance of the driving system. The requirement is that the driving system has to respond accurately according to the programmed instructions. CNC machines usually use electric motors although hydraulic motors are sometimes used for large machine tools. The motor is coupled either directly or through a gear box to the machine lead-screw to move the machine slide or the

10

spindle. Three types of electrical motors are commonly used DC (Direct Current) servo motor, AC (Alternating Current) servo motor and stepping motor.

2.2.5 Feedback Device In order to have a CNC machine operating accurately, the positional values and speed of the axes need to be constantly updated. Two types of feedback devices are normally used positional feedback device and velocity feedback device.

2.2.5.1 Positional Feedback Devices There are two types of positional feedback devices: linear transducer for direct positional measurement and rotary encoder for angular or indirect linear measurement. a. Linear Transducers - A linear transducer is a device mounted on the machine table to measure the actual displacement of the slide in such a way that backlash of screws, motors, etc. would not cause any error in the feedback data. This device is considered to be of the highest accuracy and also more expensive in comparison with other measuring devices mounted on screws or motors. b. Rotary Encoders - A rotary encoder is a device mounted at the end of the motor shaft or screw to measure the angular displacement. This device cannot measure linear displacement directly so that error may occur due to the backlash of screw and motor. Generally, this error can be compensated for by the machine builder in the machine calibration process.

2.2.5.2 Velocity Feedback Device The actual speed of the motor can be measured in terms of voltage generated from a tachometer mounted at the end of the motor shaft. DC tachometer is

11

essentially a small generator that produces an output voltage proportional to the speed. The voltage generated is compared with the command voltage corresponding to the desired speed. The difference of the voltages can be used to actuate the motor to eliminate the error.

2.2.6 Display Unit The display unit serves as an interactive device between the machine and the operator. When

the

machine

is

running,

the display unit displays

the

present status such as the position of the machine slide, the spindle RPM (Revolution Per Minute), and the feed rate. In an advanced CNC machine, the display unit can show the graphics simulation of the tool path so that part programs can be verified before the actually machining. Much other important information about the CNC system can also displayed for maintenance and installation work such as machine parameters, logic diagram of the programmer controller, error messages and diagnostic data.

2.3 CNC Principles In the previous sections, the main elements of the CNC are discussed briefly. It is important to know the coordinate system used in CNC programming, the type of the control system and finally, the tool positioning.

2.3.1 Cartesian Coordinate System Almost everything that can be produced on a conventional machine tool can be produced on a CNC machine tool, with its many advantages. The machine tool

12

movements used in producing a product are of two basic types: point-to-point (straight-line movements) and continuous path (contouring movements) [15]. The Cartesian, or rectangular, coordinate system was devised by the French mathematician and philosopher Rene’ Descartes. With this system, any specific point can be described in mathematical terms from any other point along three perpendicular axes. This concept fits machine tools perfectly since their construction is generally based on three axes of motion (X, Y, Z) plus an axis of rotation. On a plain vertical milling machine, the X axis is the horizontal movement (right or left) of the table, the Y axis is the table cross movement (toward or away from the column), and the Z axis is the vertical movement of the knee or the spindle [15]. CNC systems rely heavily on the use of rectangular coordinates because the programmer can locate every point on a job precisely. When points are located on a work-piece, two straight intersecting lines, one vertical and one horizontal, are used. These lines must be at right angles to each other, and the point where they cross is called the origin, or zero point as shown in Fig. 2-2 [15]. The three-dimensional coordinate planes are shown in Fig. 2-3[15]. The X and Y planes (axes) are horizontal and represent horizontal machine table motions. The Z plane or axis represents the vertical tool motion. The plus (+) and minus (-) signs indicate the direction from the zero point (origin) along the axis of movement.

13

Figure 2-2 Intersecting lines form right angles and establish zero point

Figure 2-3 A three-dimensional coordinate planes (axes) used in CNC

14

The four quadrants formed when the XY axes cross are numbered in a counterclockwise direction Fig. 2-4 [15]. All positions located in first quadrant would be positive (X+) and positive (Y+). In the second quadrant, all positions would be negative X (X-) and positive (Y+). In the third quadrant, all locations would be negative X (X-) and negative (Y-). In the fourth quadrant, all locations would be positive X (X+) and negative Y (Y-). In Fig. 2-4, point A would be two units to the right of the Y axis and two units above the X axis. Assume that each unit equals 1.000. The location of point A would be X + 2.000 and Y + 2.000. For point B, the location would be X + 1.000 and Y - 2.000. In CNC programming, it is not necessary to indicate plus (+) values since these are assumed. However, the minus (-) values must be indicated. For example, the locations of both A and B would be indicated as follows:

A X2.000 Y2.000

and

B X1.000 Y-2.000

Figure 2-4 The quadrants formed when the X and Y axes cross are used to accurately locate points from the XY zero, or origin point

15

2.3.2 Programming Systems Two types of programming modes, the incremental system and the absolute system, are used for CNC. Both systems have applications in CNC programming. Most controls on machine tools are capable of handling either incremental or absolute programming [15]. a. Incremental program locations are always given as the distance and direction from the immediately preceding point Fig. 2-5 [15]. Command codes which tell the machine to move the table, spindle, and knee are explained using a vertical milling machine as an example:

Figure 2-5 A work-piece dimensioned in the incremental system mode

b. Absolute program locations are always given from a single fixed zero or origin point Fig. 2-6 [15]. The zero or origin point may be a position on the machine table, such as the corner of the worktable or at any specific point on the work-piece. In absolute dimensioning and programming, each point or location on the work-piece is given as a certain distance from the zero or reference point.

16

Figure 2-6 A work-piece dimensioned in the absolute system mode

2.3.3 Positioning Types CNC programming falls into two distinct categories. The difference between the two categories was once very distinct. Now, however, most control units are able to handle both point-to-point and continuous path machining [15].

2.3.3.1 Point-to-Point Positioning Point-to-point positioning is used when it is necessary to accurately locate the spindle, or the work-piece mounted on the machine table, at one or more specific locations to perform such operations as drilling, reaming, boring, tapping, and punching. Point-to-point positioning shown in Fig. 2-7 [15] is the process of positioning from one coordinate (XY) position or location to another, performing the machining operation, and continuing this pattern until all the operations have been completed at all programmed locations.

17

Figure 2-7 The path followed by point-to-point positioning to reach various programmed points on the XY axis

In Fig. 2-7 the path from point 1 to point 2 requires the machine to move only along the X axis; but points 2 and 3 require that motion along both the X and Y axes takes place. As the distance in the X direction is greater than in the Y direction, Y will reach its position first, leaving X to travel in a straight line for the remaining distance. A similar motion takes place between points 3 and 4 [15].

2.3.3.2 Continuous Path (Contouring) Contouring, or continuous path machining, involves work such as that produced on a lathe or milling machine, where the cutting tool is in contact with the workpiece as it travels from one programmed point to the next. Continuous path positioning is the ability to control motions on two or more machine axes simultaneously to keep a constant cutter work-piece relationship. The programmed information in the CNC program must accurately position the cutting tool from one point to the next and follow a predefined accurate path at a

18

programmed feed rate in order to produce the form or contour required (Fig. 2-8 and 2-9) [15].

Figure 2-8 Simple contour

Figure 2-9 Complex contour

2.4 Control Systems CNC systems require motor drives to control both the position and the velocity of the machine axes. Each axis must be driven separately and follow the command signal generated by the controller. There are two ways to activate the motor drives, the open-loop system and the closed-loop system [16].

19

2.4.1 Open Loop Systems Programmed instructions are fed into the controller through an input device. These instructions are then converted to electrical pulses (signals) by the controller and sent to the motor amplifier to energize the motors. The cumulative number of electrical pulses determines the distance each motor will move, and the pulse frequency determines the velocity as shown in Fig. 2-10 [16]. The primary drawback of the open-loop system is that there is no feedback system to check whether the program position and velocity has been achieved. If the system performance is affected by load, temperature, humidity, or lubrication then the actual output could deviate from the desired output. For these reasons, the open-loop system is generally used in point-to-point systems where the accuracy requirements are not critical. Very few, if any, continuous-path systems utilize open-loop control [16].

Figure 2-10 Open Loop Control System

20

2.4.2 Closed Loop Systems The closed-loop system has a feedback subsystem to monitor the actual output and correct any discrepancy from the programmed input. The feedback system could be either analog or digital. The analog systems measure the variation of physical variables such as position and velocity in terms of voltage levels. Digital systems monitor output variations by means of electrical pulses. Closed-loop systems are very powerful and accurate because they are capable of monitoring operating conditions through feedback subsystems and automatically compensating for any variations in real-time [16]. Most modern closed-loop CNC systems are able to provide very close resolution of 0.0001 of a millimeter. Closed-looped system is shown in Fig. 2-11 would, naturally, require more control devices and circuitry in order to implement both position and velocity control. This, obviously, makes them more complex and more expensive than the open-loop system [16].

Figure 2-11 Close Loop Control System

21

2.5 Parallel Port Interface The parallel port is the interface of choice for many projects that require communications between a computer and an external device. Although newer interface ports are available, the parallel port remains popular because it is capable, flexible, parallel, and every PC has one [17]. The port is composed of four control lines, five status lines and eight data lines as shown in Fig. 2-12. It is found commonly on the back of a PC as a D-Type 25 pin female connector. Any interfaced circuit should have a D-Type 25 pin male connector [17].

Figure 2-12: The parallel port female connector and pin configuration

Generally, the parallel port has the capability of outputting data through twelve parallel lines simultaneously and inputting data through five parallel lines. In addition, the parallel port is available in most PCs, it is relatively simple, and capable of good data transfer rates [17].

22

2.6 Network Sockets By definition, a socket is one end of a two-way communication link between two programs running on the network. In other words, through sockets, clients access the network and transmit data [18]. On the server-side: Normally, the server runs on a specific computer and has a socket that is bound to a specific port number. The server just waits, listening to the socket, for a client to make a connection request on that port [18]. On the client-side: The client knows the hostname or IP (Internet Protocol) address of the machine on which the server is running and the port number on which the server is listening. To make a connection request, the client attempts to contact the server on the given hostname and port. The client also needs to give the server a way to contact it and so it binds to a local port number that will use during this connection. This is usually assigned by the system [18]. If everything goes fine, the server accepts the connection. Upon acceptance, the operating system on the server machine creates a new socket with its remote endpoint set to the address and port of the client and the same local endpoint. A new socket is used so that the server can continue to listen to the original port for connection requests while tending to the needs of the newly-connected client [18].

23

2.7 Flash and Flash Media Server On March 13, 2002, Macromedia unleashed one of the most important software releases in the history of the Internet, Macromedia Flash Player 6, which would quickly become the fastest adopted piece of software in the history of computing [19]. Flash introduced many benefits to internet users around the world, enabling streaming media, advanced graphics animation, and a great level of interactivity. Flash was greatly invested in advertisement and gaming industries. It is also widely used in streaming media services such as online TV, online radio stations, image galleries and chat rooms. In order to be able to use Flash services on the Internet, one must install Flash Player, which is a very popular plug-in for internet browsers [19]. When a webpage that contains a flash file is loaded, the web browser uses the plug in to interpret the file and display the results properly. Flash Media Server (previously named Flash Communication Server) is an enterprise-grade data and media server [19].

2.7.1 Uses of Flash Media Server [20] The goal of Flash Media Server is to be used in: • Video on Demand: streaming video stored on the server to the flash client. • Live Video: an application which allows user to broadcast their own video from a webcam live to other users or to the server for recording and on demand viewing later.

24

• Real Time Communication: an application which requires collaboration between multiple clients, such as a chat room or multiplayer game.

2.7.2 Flash Media Server Operation FMS (Flash Media Server) is a hub; flash based applications connect to the hub using RTMP (Real Time Messaging Protocol). The server can send and receive data to and from the connected users. Connected clients can call RPC (Remote Procedures) on the server side; similarly the server can call methods on specific clients [20]. A shared object can be used to synchronize complicated data structures and call remote methods on multiple clients in one go by having clients subscribe to a shared object. Standard actionscript objects are transported across the network connection using the AMF (Action Message Format) which is handled transparently by the server and flash client [20]. The server also allows users to receive and publish network streams. When viewing a net stream the user can either create their own to view a remotely stored FLV (Flash Live Video) or the server can instantiate a network stream and on which a video can be played, the latter method means that every user will be at the same point in the video to whom they subscribe, as they are all viewing the same stream [20].

25

Chapter Three

The Proposed Control System Design 3.1 Introduction The laboratory CNC machine used in the thesis consists of three axes and each axis has a stepper motor and its driver to move that axis. This CNC machine cannot be used to machine any sample because the controller used to control the CNC operations is missing. So, the aim of the thesis is to design the hardware and the software needed to create the CNC machine controller. The hardware to be designed is used to connect the CNC machine to a PC operated with software which is designed or that PC to make it work as controller. The system designed works as follows, the CNC operator draws the samples need to be machined by the CNC using any one of the drawing programs like AUTOCAD, 3D MAX or others and save the finished drawings in a well-known file format DXF (Data Exchange Format), these files are used as the input to the CNC controller which, in turn, uses these files to generate the commands needed to move the CNC axes to create machine parts exactly similar to the samples that were drawn. Also the system designed can work in server-client environment where the PC which is connected to the CNC machine is called server PC that works, in addition to its main job as CNC controller, in interchanging of information between it and other PCs connected to it so that these information can be used for remotely controlling and monitoring of the CNC.

26

The other PC in the system is called a client PC that is connected to the server PC so that the client can control the CNC by only sending the (DXF) files to the server which, in turn, receives these files and starts the CNC to machine the drawings in the received files. Since the client PC is not close to the CNC, there is a problem of how the client can know that the CNC works properly and if there is a problem of how the client can overcome that problem. The client PC can overcome those problems through remotely monitoring and controlling the machine. A web camera is connected to the server PC that is used to broadcast live video to the client PC through the network or the internet. This live video used by the client to remotely monitor the operation of the CNC. In this chapter, the general system architecture will be reviewed, and then, the whole system design will be discussed in details.

3.2 General System Architecture The CNC controller system consists of multiple PCs one of these PCs is known as the server PC which is connected to the CNC machine and work as a CNC controller and serves other PC that wants to use the CNC while the other known as client PC that wants to connect to the server PC then controls and monitors the CNC machine remotely. A block diagram of the system is shown in Fig. 3-1. The CNC machine is connected to the server PC through its parallel port and a client PC is connected to the server PC through a network or internet connection, also a web camera is connected to the server PC to capture video and broadcast it to the client PCs over the network.

27

Internet

Client PC

Server PC

Stepper Motor Driver and Limit Sensors

Z motor Drive Signal Web-Cam

X & Y motor Drive Signal

X & Y Limit Sensors Signal CNC Machine Figure 3-1 Architecture of the system

28

This system consists of the following hardware and software parts. The hardware of the system consists of:  Three axes milling machine model (Feedback CNC 932)  PC with parallel port interface  Interface circuit to drive the CNC stepper motors and feedback limit switch sensors  Web Camera The software used in the system consists of:  Microsoft Visual Basic 2005 Express Edition which is used to write the software of the controller.  Adobe Flash and Adobe Flash Media Server are used to capture video from the web camera and broadcast it in the network or the internet.

3.3 Hardware System Design The hardware design consists of

designing an interface circuit that

connects the server PC’s parallel port to the CNC stepper motors driver and to the CNC axes limit sensors, also designing a circuit which is used to control the speed and the rotation direction of the drill DC motor which is used for drilling purposes. The stepper motors of the laboratory CNC machine are not connected directly to the server PC through the interface circuit but instead of that they are connected to stepper motors driver and controller device unit that needs only three signals as an input for each motor, these signals are labeled as enable, clockwise rotation and counter clockwise rotation, and depending on these

29

signals level, the motors driver and controller device generates the signals that each motor needs to run.

3.3.1 The Standard Parallel Port The standard parallel port has three registers. Two output registers, data (eight bits) and control (four bits), and one input register (five bits). Different registers will be used to drive the CNC motors, eight bits from the data register and one bit from the control register will be used to drive the CNC three axes stepper motors, second bit from the control register used to control the drill DC motor speed and direction of rotation, while two bits from the status register will be used to read the status of the limit sensors.

3.3.2 Interface Circuit To interface a CNC stepper motors, the parallel port must be isolated from the circuit to avoid damage. This can be done by using a tri-state buffer. The one used here is known as octal bus transceiver that has bidirectional capability since the parallel port works in two directions. 74LS245 (shown in Fig. 3-2 [21]) is a well-known and widely used octal bus transceiver that has 20 pins, where pin 20 (Vcc) must be provided with +5v while pin 10 should be grounded to power the IC (Integrate Circuit). Pin 19 should also be grounded to enable the transceiver all the time, while pin 1 is used as direction pin, here this pin is tied to +5v to make pins 2-9 input lines, while pins 18-11 the output lines [21]. Experimentally known that the drill DC motor needs from 2 to 4 ampere to work correctly and the output of the 74LS245 is no more than 30 mA and this is not enough to turn the motor on. So, there is a need to convert the low current

30

supplied from the buffers to high current supplied from external power supply by using 2N3055 NPN transistor switching circuit.

Figure 3-2 74LS245 Octal Bus Transceiver [21]

Now the interface circuit is ready to be assembled, two 74LS245 transceivers receive signals from the PC parallel port, isolates the port from the circuit and buffers its output. The complete circuit is shown in Fig. 3-3.

3.4 Software System Design The software design can be divided into two parts, the server part and the client part, each of which consists of two separate programs. The first program is a visual basic program to control the operation of the CNC and to transfer data from server to client and vice versa. While the second one is a flash program to broadcast live video from the server to the client. Fig. 3-4 illustrates the general design of the software on each PC.

31

Figure 3-3 System Pin Diagram

32

Server PC

Client PC

Visual Basic program  

 

Receive dxf file from client Extracts the drawings and generate commands that are used to perform these drawings by the CNC. Sends these commands to the CNC through parallel port. Sends feedback signals to client PC to use it in remote monitoring.

Visual Basic program  Connect to the server PC. 

Data/ command

Flash program 

Capture video from web camera connected to the server PC and broadcast the video stream to the client PCs connected to the network or through the internet.

Draw the sample need to be machined using one of the drawing software, save it in dxf format and send it to the server PC.  Receives feedback signals from server PC and uses these information to redraw the drawings on the client screen for monitoring.

Flash program  Data/ command



Receives video streams transmitted by the server. Displays the received video on the client screen.

Figure 3-4 A General View of the Software Design

The system has three stepper motors and sometimes there is a need to move more than one motor at the time and this cannot be done if the software used executes its instructions sequentially. To overcome this problem, a multithreading technique is used. Threads are simply tasks that are needed to be executed at roughly the same time. That is, two or more parts of a program which run together concurrently. Threads run inside the same application, which means that they share the same memory space in the computer. This allows them to share information (such as variables) seamlessly.

33

Multithreading can be very useful. For example a program can draw the GUI (Graphical User Interface) and process user input at the same time. Another example is, when a program needs to do an operation twice and at the same time with different variables (like running two motors with different speed and direction), it can create a thread for each operation, using the same code. That means, each thread copies an instance of the code, applies its own variables and runs it concurrently with the other thread without interference. The programming language used to write the CNC controller program is visual basic 2005 express edition and the reason behind the use of this software is that this software has multithreading capability so, multiple stepper motors can be controlled concurrently. The visual basic is used to write two programs one is used to control the CNC and this program resides in the server PC. The other program used to command the CNC remotely and monitors its operation and resides in client PC.

3.5 Server PC Program The program written in the server PC is used to accomplish the following tasks:  Waiting for a client to connect for using the CNC remotely.  Receiving files from the client if it is connected or the CNC operator inserts these files manually, these files contain the samples need to be machined.  Extracts drawings from the files and generates the commands that operate the CNC.  Run flash program to broadcast live video to clients.

34

These tasks are laid down together in one flowchart that represents what the entire system can do as shown in Fig. 3-5 Start

Waiting for a client connection requests

is client connected to the server?

No

Server operator input file to be operate

Yes Receiving (DXF) file from client

Extract drawings from the file and generate commands that operate the CNC and also send feedback signals to client PC

Run flash program to broadcast live video

No

is server turned off? Yes End

Figure 3-5 A flowchart of server’s visual basic program

35

3.5.1 Connecting to Client PC The server program uses TCP (Transmission Control Protocol) socket to connect to clients. The server program prepares the socket to be ready to connect by assigning to it a port number then the socket starts to listen to that port for connection requests from clients and the socket accepts only one connection request from those requests received and that client with the accepted connection request become connected to server and be ready to control the CNC attached to the server.

3.5.2 Receiving Files from Client PC The server program needs a (DXF) file that contains the drawings to be machined by the CNC and this file can be either entered manually to the server by the CNC operator or can be received from remote clients over network connection or through the internet. The flowchart to receive files from clients is shown in Fig. 3-6.

3.5.3 Extracting Drawings from Received Files After receiving the file from a client or from the operator the controller starts to reads the file contents to know what type of drawings this file has. The file type used in this thesis is known as DXF. The DXF format is a tagged data representation of all the information contained in an AutoCAD ® drawing file. Tagged data means that each data element in the file is preceded by an integer number that is called a group code.

A group code's value indicates what type

of data element follows. This value also indicates the meaning of a data element for a given object (or record) type. Virtually all user-specified information in a drawing file can be represented in DXF format.

36

For example, in DXF files to represent a line starts at point (5, 7) and ends at point (13, 15), the following is a part from a DXF file that shows the example above: These two lines represent that there is a line drawing

ENTITIES 0 LINE 5 C2 330 1F 100 AcDbEntity 8 0 100 AcDbLine 10 5.0 20 7.0 30 0.0 11 13.0 21 15.0 31 0.0 0 ENDSEC

This is a start of drawing section

This part is not used

Group code 10 means that the X coordinate of the start point is 5 Group code 20 means that the Y coordinate of the start point is 7 Group code 30 means that the Z coordinate of the start point is 0 Group code 11 means that the X coordinate of the end point is 13 Group code 12 means that the Y coordinate of the end point is 15

Group code 31 means that the Z coordinate of the end point is 0

From the example above, the file is structured into two lines format, the group code in the first line and its value in the second, so to extract the drawings from the file, two lines at a time must be read as in the flowchart shown in Fig. 3-7.

37

Start Accept the connection request from the client and start receiving one byte after another from the connected client

No

is the received byte="FILE" ? Yes Receive another byte

is the received byte="SIZE" ?

No

Yes File Size=received byte

Open a temporary file to receive the information of the file sent by the client, let Count=0 Receive byte and write it down into the file Count=Count+1

is Count=File Size?

No

Yes End

Figure 3-6 A flowchart of receiving files from client

38

Start

Open the received or inserted file using binary mode Read two lines from the file each time and store the readings in line1 and line2 variables

is line1="0" and line2="LINE"

Yes

Draw line algorithm

No Yes

is line1="0" and (line2="CIRCLE" or line2="ARC")

Draw circle or arc algorithm

No is line1="0" and line2="LWPOLYLINE"

Yes

Draw lwpolyline algorithm

No is line1="0" and line2="POLYLINE"

Yes

No No

is end of file

Yes Close the file

End

Figure 3-7 A flowchart of open the dxf file algorithm

39

Draw polyline algorithm

3.5.4 Controlling the Movement of the CNC Axes The laboratory CNC has three moving axes through the movement of three stepper motors attached to those axes, so to control the axis movement the stepper motor attached to that axis must rotate in one direction by receiving signals as shown in Fig. 3-8. +5 v 0v

Enable Signal

+5 v 0v

Clockwise or Counter clockwise Signal

Figure 3-8 Signals needed to rotate the stepper motor in clockwise or counter clockwise direction

The speed of motors rotation can also be controlled through the duration length of the clockwise or counter clockwise signal, slower speed can be achieved with longer signal duration while faster speed can be achieved with smaller signal duration, the duration length of the signal can be achieved by using the delay subroutines inserted in the software that generate the signals. The laboratory CNC has axis with maximum of 100 mm distance to move so there is a need to determine the number of pulses needed to move the axis over the whole 100 mm and the reason behind this test is to determine the resolution of the CNC axis in other words how many pulses are needed to move the axis 1 mm length. After testing the CNC stepper motors used in the thesis, it is found that it is needed to apply 48 pulses to the motor to move the axis 1 mm length, so to move the axis 15 mm there is a need to apply 15*48=720 pulses to that motor.

40

The software that is used to move the X, Y and Z axis to the positive (clockwise) direction and negative (counter clockwise) direction with the required distance and with the required speed is written. The algorithms needed to perform the above tasks are shown in Fig. 3-9 and Fig. 3-10. These algorithms are used for the X, Y and Z axes. Start

Get the following information: Distance=the distance this axis must move Speed=the speed at which this axis must move, let count=0

Apply a +5 volt to the plus (clockwise) pin of the axis motor

Wait for a period equal to the value of the Speed variable by calling a delay subroutine

Apply a (0) volt to the plus (clockwise) pin of the axis motor

Wait for a period equal to the value of the Speed variable by calling a delay subroutine

count=count+1

is count=48*Distance ?

No

Yes End

Figure 3-9 A flowchart of how to move the X, Y and Z axes in the positive direction

41

Start

Get the following information: Distance=the distance this axis must move Speed=the speed at which this axis must move, let count=0

Read the state of the axis sensor

is sensor ON

Yes

No Apply a +5 volt to the minus (counter clockwise) pin of the axis motor

Wait for a period equal to the value of the Speed variable by calling a delay subroutine

Apply a (0) volt to the minus (counter clockwise) pin of the axis motor

Wait for a period equal to the value of the Speed variable by calling a delay subroutine

count=count+1

No

is count=48*distance ? Yes End

Figure 3-10 A flowchart of how to move the X, Y and Z axis in the negative direction

42

The algorithms of moving the CNC axes need to determine the distance between the current position and the required position and to determine which motor should run; also there is a need to determine the speed at which the motors should run. The following example shows why there is a need to determine the speed of the motors, let the current position is the point (10, 10) and to move to point (30, 20), if the speed of the X axis and the Y axis motors are at the maximum value the Y axis motor will reach its destination before the X axis motor and this causes not to draw a straight line between the start and the end points as shown in Fig. 3-11a. To overcome this problem, interpolation will be used. In interpolation the speed of each axis is determined as shown in equations (3.1) and (3.2) [22]. … (3.1)



… (3.2)



Where: X1 and X2 are the start point coordinate. Y1 and Y2 are the end point coordinate. V maximum velocity Vx and Vy are the X axis and Y axis motors speed.

43

For the example above the velocities of the X and Y axis are calculated by assuming the maximum speed is 60 mm/min as below: mm/min



mm/min



The X axis motor moves faster than Y axis motor so that the two motors reach their destination at the same time causing a straight line to draw between the two points as shown in Fig. 3-11b. Vx =60

Vx=53.665 (30, 20)

(30, 20) Vy=26.833

Vy=60 (10, 10)

(a)

(10, 10)

(b) Interpolate path

Non interpolate path

Figure 3-11 Moving between points with and without interpolation

The algorithm of how to use interpolation to determine the speed of motors required to reach the destination point at the same time and also the algorithm of how to determine which motor should run and at which direction are shown in flowchart in Fig. 3-12.

44

Start Get the new destination and store it at newXpos and newYpos variables, the current position is previously stored at curXpos and curYpos variables Send newXpos, newYpos and Up to client PC

Vx=V*(newXpos-curXpos)/sqrt((newXpos-curXpos)^2+(newYpos-curYpos)^2) Vy=V*(newYpos-curYpos)/sqrt((newXpos-curXpos)^2+(newYpos-curYpos)^2)

(newXpos-curXpos)>0 ?

Yes

Call X+ subroutine in a new thread with speed=Vx and distance=newXpos-curXpos

Yes

Call X- subroutine in a new thread with speed=Vx and distance=curXpos-newXpos

Yes

Call Y+ subroutine in a new thread with speed=Vy and distance=newYpos-curYpos

Yes

Call Y- subroutine in a new thread with speed=Vy and distance=curYpos-newYpos

No (newXpos-curXpos)0 ? No (newYpos-curYpos) EndAng?

read multiple lines in line1 and line2

No

No Xn=Xc+R*cos(StartAng) Yn=Yc+R*sin(StartAng)

is line1="20"? Yes Yc=line2

Turn drill OFF and call Z+ movement subroutine Call moving algorithm to point (Xn,Yn), Theta=StartAng, Up=false

read multiple lines in line1 and line2

No

is line1="40"?

Turn drill ON and call Zmovement subroutine

Yes R=line2

Xn=Xc+R*cos(Theta) Yn=Yc+R*sin(Theta) Theta=Theta+1

read multiple lines in line1 and line2

No

is line1="51"?

is line1="10"?

Call moving algorithm to point (Xn,Yn), Up=true

is line1="50"? Yes StartAng=line2

No

is Theta=EndAng? Yes

1

End

Figure 3-18 A flowchart of arc drawing algorithm

52

Yes

2

2

4

Xn=Xc+R*cos(StartAng) Yn=Yc+R*sin(StartAng)

Turn drill ON and call Zmovement subroutine

Turn drill OFF and call Z+ movement subroutine Call moving algorithm to point (Xn,Yn), Theta=StartAng, Up=false

Xn=Xc+R*cos(Theta) Yn=Yc+R*sin(Theta) Theta=Theta+1 Call moving algorithm to point (Xn,Yn), Up=true

Turn drill ON and call Zmovement subroutine Xn=Xc+R*cos(Theta) Yn=Yc+R*sin(Theta) Theta=Theta+1

No is Theta=EndAng? Yes

Call moving algorithm to point (Xn,Yn), Up=true

No

End

is Theta=360? Yes Xn=Xc+R Yn=Yc

Turn drill OFF and call Z+ movement subroutine Call moving algorithm to point (Xn,Yn), Theta=0, Up=false

4

Figure 3-18 A flowchart of arc drawing (continued)

53

3.5.6.4 Drawing Ellipse or Arc of Ellipse Algorithm To draw ellipse, the center point, the major axis start point, the start angle, the end angle and the ratio between the major and minor axis should be known, these information can be extracted from a DXF file as follows: The center point as in circle can be found after a group codes of 10 and 20 respectively, the major X coordinate and major Y coordinate can be found after a group codes of 11 and 21 respectively, the start and end angles can be found after a group codes of 41 and 42 respectively, while the ratio between the major and minor axis can be found after a group code of 40. After the above information is being extracted, there is a need to calculate the length of the major and minor axis, calculate the angle by which the ellipse is rotated; these calculations are shown in equations (3.5), (3.6) and (3.7) [25]. √

… (3.5) … (3.6) ⁄

… (3.7)

The ellipse drawn by CNC as in the circle by dividing the ellipse circumference in small lines connected to each other. The start and end points of these lines can be calculated using equations (3.8) and (3.9) [26]. If the start angle is equal to the end angle then, the draw is a full ellipse, while if the start angle is not equal to the end angle then; the draw is an arc of ellipse. … (3.8) … (3.9)

54

Components of ellipse and arc of ellipse are shown in Fig. 3-19 while a flowchart of drawing ellipse algorithm is shown in Fig. 3-20. Start angle

A

Major Y

B

(Xc, Yc) End angle

𝛽 Major X

Figure 3-19 Ellipse and arc of ellipse and their components Start

Read multiple lines from the opened file and store them in line1 and line2

No

is line1="10"? Yes Xc=line2

read multiple lines in line1 and line2

No

is line1="20"? Yes Yc=line2

read multiple lines in line1 and line2

1

Figure 3-20 A flowchart of ellipse and arc of ellipse drawing algorithm

55

1

2

read multiple lines in line1 and line2

read multiple lines in line1 and line2

No

No

is line1="11"?

is line1="41"? Yes

Yes MajorX=line2

StartAng=line2

read multiple lines in line1 and line2

read multiple lines in line1 and line2

No

No

is line1="21"?

Yes

Yes MajorY=line2

EndAng=line2

read multiple lines in line1 and line2

No

is line1="42"?

A=sqrt(MajorX^2+MajorY^2) B=A*Ratio Beta=arctan(MajorY/MajorX)

is line1="40"? 3

Yes Ratio=line2

2

Figure 3-20 A flowchart of ellipse and arc of ellipse drawing algorithm (continued)

56

3

is StartAng > EndAng?

Yes

4

No Xn=Xc+A*cos(StartAng)*cos(Beta)-B*sin(StartAng)*sin(Beta) Yn=Yc+A*cos(StartAng)*sin(Beta)+B*sin(startAng)*cos(Beta)

Turn drill OFF and call Z+ movement subroutine Call moving algorithm to point (Xn,Yn), Theta=StartAng, Up=false

Turn drill ON and call Zmovement subroutine Xn=Xc+A*cos(Theta)*cos(Beta)-B*sin(Theta)*sin(Beta) Yn=Yc+A*cos(Theta)*sin(Beta)+B*sin(Theta)*cos(Beta) Theta=Theta+1 Call moving algorithm to point (Xn,Yn), Up=true

No

is Theta=EndAng? Yes End

Figure 3-20 A flowchart of ellipse and arc of ellipse drawing algorithm (continued)

57

4

5

Xn=Xc+A*cos(StartAng)*cos(Beta)-B*sin(StartAng)*sin(Beta) Yn=Yc+A*cos(StartAng)*sin(Beta)+B*sin(StartAng)*cos(Beta)

Turn drill OFF and call Z+ movement subroutine Call moving algorithm to point (Xn,Yn), Theta=0, Up=false

Turn drill OFF and call Z+ movement subroutine Call moving algorithm to point (Xn,Yn), Theta=StartAng, Up=false

Turn drill ON and call Zmovement subroutine Xn=Xc+A*cos(Theta)*cos(Beta)-B*sin(Theta)*sin(Beta) Yn=Yc+A*cos(Theta)*sin(Beta)+B*sin(Theta)*cos(Beta) Theta=Theta+1

Turn drill ON and call Zmovement subroutine

Call moving algorithm to point (Xn,Yn), Up=true

Xn=Xc+A*cos(Theta)*cos(Beta)-B*sin(Theta)*sin(Beta) Yn=Yc+A*cos(Theta)*sin(Beta)+B*sin(Theta)*cos(Beta) Theta=Theta+1

No is Theta=EndAng?

Call moving algorithm to point (Xn,Yn), Up=true

Yes End

is Theta=360?

No

Yes Xn=Xc+A*cos(0)*cos(Beta)-B*sin(0)*sin(Beta) Yn=Yc+A*cos(0)*sin(Beta)+B*sin(0)*cos(Beta)

5

Figure 3-20 A flowchart of ellipse and arc of ellipse drawing algorithm (continued)

58

3.5.6.5 Drawing Polyline Algorithm There are two types of polyline in DXF [27], polyline and lwpolyline, these two types are similar in that each one has a sequence of points that connected to each other using straight lines and they are different in the way that these points are presented in the DXF file. The polyline points presented in the file after group codes of 10 and 20 respectively, where the X coordinate of these points can be found after a group code of 10 while the Y coordinate of these points can be found after a group code of 20, these point coordinates can be found between a group code of (VERTEX) and a group code of (SEQEND), a flowchart of drawing polyline algorithm is shown in Fig. 3-21. The lwpolyline points presented in the file after group codes of 10 and 20 respectively, as in the above polyline, these points presented sequentially one after another and their number can be found after a group code of 90, a flowchart of drawing lwpolyline algorithm is shown in Fig. 3-22. The lwpolyline can be either closed or open polyline and this property can be found by reading the value after a group code of 70. To draw the polyline in a CNC, the point coordinates are gotten and a straight line from one point to other point are drawn and doing this is continued until the end point is reached.

59

Start

1

Read multiple lines from the opened file and store them in line1 and line2

No

read multiple lines in line1 and line2

No

is line1="0" and line2="VERTEX"?

is line1="10"? Yes X=line2

read multiple lines in line1 and line2

read multiple lines in line1 and line2 No

is line1="10"?

No

Yes X=line2 xStart=X

Yes Y=line2 i=i+1

read multiple lines in line1 and line2

No

is line1="20"?

is line1="20"?

2

Yes Y=line2 yStart=Y Turn drill OFF and call Z+ movement subroutine Call moving algorithm to point (X, Y), i=0, Up=false

1

Figure 3-21 A flowchart of polyline drawing algorithm

60

2

Turn drill On Call Z- moving subroutine

is i >= 1?

No

1

Yes Call moving algorithm to point (X, Y), Up=true

is line1="0" and line2="SEQEND"?

No

Yes End

Figure 3-21 A flowchart of polyline drawing algorithm (continued) Start

Read multiple lines from the opened file and store them in line1 and line2

No

is line1="90"? Yes noVertex=line2

read multiple lines in line1 and line2

No

is line1="70"? Yes is line2="1"?

Yes

isClosed=true i=0

No isClosed=false i=0

1

Figure 3-22 A flowchart of lwpolyline drawing algorithm

61

1

2

read multiple lines in line1 and line2

Turn drill ON and call Zmovement subroutine

No

is line1="10"?

No Yes X=line2

is i > 1?

3

Yes Call moving algorithm to point (X, Y), Up=true

read multiple lines in line1 and line2

No No

is i = noVertex?

is line1="20"?

Yes Yes Y=line2 i=i+1

is i = 1?

isClosed ?

No

No

Yes Call moving algorithm to point (xStart, yStart), Up=true

3

End

Yes Turn drill OFF and call Z+ movement subroutine Call moving algorithm to point (X, Y) xStart=X yStart=Y, Up=false

2

Figure 3-22 A flowchart of lwpolyline drawing algorithm (continued)

62

3.6 A Client PC Program A client PC program starts by trying to connect to the server PC so that the client PC can control the CNC attached to the server PC and also can monitor remotely the CNC operations. The client sends a connection request to the socket running in the server PC and if that socket accepts the connection, the client sends a command to the server telling it that the client will send a file to the server. After the client finishes sending the file, it starts to receive feedback signals from the server and uses that signals to redraw what the CNC attached to the server is doing. The sending file algorithm operates as follows, the client sends “FILE” command to the server and wait until the command “OK” is received. The client opens the file needs to be sent, calculates the file size and send the size to the server and wait until “OK” command is received. After that the client sends to the server from the file one byte after another until the end of file is reached. When the client finishes sending file operation, it starts to receive feedback signals from the server, then the client extracts the information embedded into the feedback signals and stores that information into the X, Y and Z variables. Depending on the value of the Z variable, the client draws the point sent or not. The flowchart shown in Fig. 3-23 presents the algorithms used in client PC.

63

Start Send a connection request to server PC

No

is connection accepted?

Yes Send "FILE" command to server PC, count=0 Receive command from server PC

No

is command="OK"?

Yes Send the file size to be sent to server PC Receive command from server PC

No

is command="OK"?

Yes Read byte from the file and send it to the server PC, count=count+1

No

is count=file size?

Yes Receive feedback signals from server PC Extract the coordinate from the feedback signal and store them in X, Y and Z variables

No

is Z=true?

Yes Draw line from the current X and current Y to the new X and Y current X=new X, current Y= new Y

Figure 3-23 A flowchart of client PC algorithms

64

3.7 The Flash Programs The flash programs were designed to communicate with each other with the help of FMS. There are two files responsible for transmitting live video across the internet; a file that runs in the server (broadcaster.swf) which is responsible for capturing the video from a webcam connected to the server and sending it to the connected client and another file that runs in the client (receiver.swf) which is responsible for receiving the live video feed from the server and displaying it to the client.

3.7.1 The Flash Server Program (Broadcaster) The flash server program is a program that is written in flash’s actionscript language and then compiled into an SWF (Small Web Format) file. This file is then embedded inside a webpage stored on the server called (broadcaster.html). This page will be accessed automatically when the server gets started to load the (broadcaster.swf) file. This file provides a video panel for viewing the video captured from the webcam. This file communicates with FMS through a folder called (livecast) that resides in the application folder of FMS. The RTMP address should point to the folder (livecast) so that the application can use the FMS services. The stream can be given any name to use it to present the stream in the network. It is noted that the stream name in the receiver flash file should be the same name used in the broadcaster.

65

3.7.2 The Flash Client Program (Receiver) Like the server program, the client program is also compiled into a flash file called (receiver.swf). This file is embedded inside a webpage called (receiver.html). When a client is trying to access the webpage (receiver.html), the page first asks the client to enter a login information (user name and password) and if the client enters correct information the page loads the (receiver.swf) so that the client will be able to receive live video from the server, while if the client enters incorrect information the page reloaded itself and tells the client to re-enter the login information. The RTMP address of the media server application folder should be in the form of (rtmp://ServerIP/ApplicationName) which in this work is chosen to be (rtmp://ServerIP/livecast). It must be noted that the broadcaster should be run and broadcast before the receiver tries to access it. The receiver has a video panel to display the received stream.

66

Chapter Four System Implementation and Results 4.1 Introduction In this chapter: a proposed laboratory CNC system will be assembled, and the overall system will be tested thoroughly.

4.2 CNC Controller Preparations To setup the proposed CNC, few requirements must be met in both the server and client PCs. These are: The server PC requires the following software and hardware to be installed: • Windows XP (or any other version of Windows) • A visual basic 2005 express edition software (for controlling the CNC) • FMS 3.5 (for streaming live video) • A web server (such as Apache or using the web server embedded in the FMS) • A custom written driver (to allow direct access to the parallel port) • A parallel port (to interface the CNC) • A USB port (to connect the webcam) • A webcam • The machine and its interface circuit Both the server and the client PCs require the following to be installed: • Internet or network connection • A web browser (such as Internet Explorer or Firefox) • A visual basic 2005 express edition software • Flash player add-on (enables the web browser to run flash files)

67

4.2.1 The Server PC Preparation 4.2.1.1 The Platform The server platform used in this project is an IBM compatible PC. Because of its availability, and it is relatively low cost. Even though the flash is platform independent, the functions used to interact with the parallel port were written in visual basic programming language (which is platform dependent), and since these functions were built to function under Windows operating systems, therefore, it is highly recommended to use Windows XP as the operating system for the server PC.

4.2.1.2 The Web Server This project is intended to run across the Internet, so it is essential to either use an actual server as the server PC, or to simulate a server behavior. Since the hardware must be interfaced with the server PC, so the server behavior must be simulated, this can be fairly easy and with much lower cost. To simulate a server, it is only needed to install web server software. A web server is software that manages clients’ requests and sends back results based on their entries. For example, when a webpage stored in a server is accessed, the web server processes the request and sends back the page to be displayed on the client’s browser. For that matter, Apache (a very popular free web server) was chosen to be installed on the server PC.

68

4.2.1.3 The Media Server Live video is an essential part of a CNC control system. It gives the user the ability to see the effects of his actions in real time and to act accordingly if any problems occur. The live video transmission requires a dedicated media server to be responsible for sending the live video to the clients. In this thesis, Adobe Flash Media Server 3.5 (a free popular media server) was chosen to handle the live video transmission.

4.2.1.4 Accessing the Parallel Port A problem that occurs when interfacing the parallel port using Windows NT/2000 and Windows XP is the strict control over I/O ports. Unlike Windows 95 & 98, Windows NT/2000/XP will cause an exception (Privileged Instruction) if an attempt is made to access a port that is not privileged to talk to. An error window will appear and no change will occur on the parallel port pins. That’s because Microsoft has prohibited usermode access to I/O ports for security reasons. To work around this issue, a custom written driver made especially to solve this problem will be used to make the restricted ports available to the average user. Inpout32.dll is a DLL (Dynamic Link Library) that has a kernel mode driver for Windows NT/2000 that gives usermode programs access to I/O ports. This makes it possible to access hardware directly from a normal executable in the same way as under Windows 95/98/ME. This driver does not work on Windows 95/98/ME and there is no need to run it anyway because I/O ports are always granted to usermode programs on these operating systems.

69

This DLL file (inpout.dll) contains two functions, a function to read a byte from a specific register, and another one to write a byte to a specific register. These functions are called from within the program to drive the interface circuit. This (DLL) file should be copied to the (system 32) directory inside the windows directory or to any other directory that is included in the system path variable. When this DLL is loaded by calling one of the above functions, the embedded kernel mode driver is automatically installed, configured and the parallel ports (usually 0x278 to 0x27B and 0x378 to 0x37B) are opened.

4.2.1.5 Hardware Requirements The server PC is the one connected to the CNC machine; therefore, it should have the hardware needed to interface the machine. The needed hardware consists of the CNC machine model (Feedback CNC 932) shown in Fig. 4-1, the stepper motors driver and controller with the same model of the CNC machine as shown in Fig. 4-2, the parallel port (normally at address 0x378h) to interface the server PC to the machine and a USB port to plug in the webcam.

4.2.2 General Preparations There are more preparations to make the project ready. Since the programs were written to run in server-client mode, there must be either a network or an Internet connection available to both PCs. That is to supply a proper media for the server and client PCs to connect to each other. To make the transmitting of live video from the web camera connected to the server PC possible, there is a need to write programs used to access the transmitted video and store these programs in the server PC so that these programs can be accessed by the client PCs through the using of web browser.

70

Also, the web browsers should be able to understand the programs once they are accessed and downloaded. This is done by installing flash plug-ins into the browsers on each PC. It’s noted that there is no special type of web browser required in particular to run the programs, any browser that has the appropriate plug-ins installed should be able to run the programs properly.

Figure 4-1 CNC machine used in the thesis

71

Figure 4-2 CNC machine stepper motor driver and controller

4.2.3 Installing Project Files All the programs used to transmit and receive the live video feed and their related files should be copied into a directory named (webroot) inside the flash media server directory. For this work, two directories are created, the first with the name of broadcast and the second with the name of receive. Also after the writing of the CNC controller program is finished and after the program is compiled the visual basic software will generate an auto executing file that can be used at any PC even if these PCs have not visual basic software installed. So, the CNC can be controlled using any PC by only copying the auto executing file to any location in that PC.

72

4.3 The System GUI The system has a server and a client, each has a different GUI. This section will illustrate each interface by trying to explore all the possible scenarios.

4.3.1 Server PC GUI The server program should be the first to run. (CNC Operator.exe) is an auto executable file that is designed to control the operation of the CNC as shown in Fig. 4-3. If the button is pressed an open file dialogue appeared to select the (dxf) file that contain the sample need to be machined If the button is pressed the CNC starts to operate

Start

If the button is pressed the CNC stops its operations If the button is pressed the CNC will go to the zero reference point (X=0 Y=0 Z=0) If the button is pressed the program will finished Figure 4-3 Server program GUI

The first operation that the server program implements after its starting is to start the web camera to capture the live video and broadcast it to the network and this is done by opening a web page with the following address (http://localhost/broadcast/index.html) this page first load a login screen that asks

73

the user to enter the login information (user name and password) as shown in Fig. 4-4. After the user enters the correct user name and password the server loads a new page called (broadcaster.html) that will turn the web camera on as shown in Fig. 4-5. When this page is loaded by the web browser, a file named (broadcaster.swf) is called by the page to run. This file is a flash file that contains the action-scripts needed to turn the web camera on, connecting to the FMS and transmits the captured live video to the network.

Figure 4-4 Login screen to broadcaster.html web page

74

Figure 4-5 Broadcaster.html web page that turn the web camera on and transmit the captured video to the network

The action-scripts embedded in the (broadcaster.swf) flash file starts by creating the connection to the FMS (live) directory then after this connection is established, the flash file sends a command to the connected web camera to turn it on and starts capturing. This captured video is embedded into a stream called (livestream) that will be sent to the (live) directory so that it can be seen by authenticated PC connected to the server through the network or the internet. When (CNCOperator.exe) finished the starting of the (broadcaster.html) web page, it starts to listen for connection requests from a client PC that wants to operate the attached machine.

75

The server PC uses a TCP (Transmission Control Protocol) socket to listen to the connection requests through any opened and not occupied port; here the used port is (8888), if there is a connection request to the server through that port the server can either accepts or rejects the request depending on whether the server is busy or not. While if there is a connection request and that request is accepted by the server then the CNC will be operated by the connected client through the network. The client will command the server by sending the required part to be machined by the CNC embedded into a file in (DXF) format. After the server receives the file sent by the client or entered by the CNC operator, the server software starts a subroutine that used to move the CNC axes to the zero reference point so that the software can measure each point in the required sample needed to be machined from the zero reference point as in absolute positioning and also the software can calculate how many pulses each stepper motor needs to move the required position since there is no feedback information tells the software about its current position (open loop controller). After the machine moves to the zero reference point the server software opens the received (dxf) file and interprets its contents and depends on the file contents, the software moves the CNC machine to machine one or more of the following shapes line, circle, arc, ellipse, polyline or lwpolyline and the results of these shapes in different status machined on pieces of wood will be displayed one after another in the next section. When the server software calculates the new position, the CNC machine should move to, it sends a copy of the new (X, Y and Z) positions to the

76

connected client in a message has the format (POSX, Y, Z) so that this information can be used to redraw what the CNC done in the client screen to overcome any problems could happen if there is no operator stands near to the CNC.

4.3.1 Client PC GUI The client starts by running (ClientDrawer.exe) executable file that should be installed in any PC needs to work as CNC operator’s client, the software GUI is shown in Fig. 4-6. To connect to the server, each client should have a TCP socket programmed as a client socket with the ip address of the server here (192.168.1.1) and with port as in the server (8888). The client user who needs to connect to the server must press the (Connect) button found in the client GUI shown in Fig. 4-6. When this button is pressed the socket sends a connection request to the server ip address using the port at which the server listen to it, and if the request is accepted, the connection between the server and the client is established and the information can be interchange between them. When (Disconnect) button is pressed, the established connection between this client and the server is terminated, while if (Send File) button is pressed an open file dialogue appears telling the user to select the file needs to be send to the server. Now, if the user wants to stop the operation of the CNC because a problem happened with the CNC the client user should press (Stop) button that sends a command to the server to stop the CNC immediately. If the client user needs to see the CNC while it is in operation, then the button (Camera) can be pressed. When this button is pressed the client software

77

will open the web browser and open web page with the address of (http://192.168.1.1/receive/index.html), this page is a login screen as the one shown in Fig. 4-4 and if the user enters the correct (user name and password) the (receive.html) page will be loaded in the browser as shown in Fig. 4-7. When the (receive.html) page is loaded, the (receive.swf) flash file starts and the action-scripts that embedded in runs. These action-scripts create a connection to the (live) directory found in the FMS directory that runs in the server PC. After the connection is established, every stream having the name (livestream) will be received by the client and displayed in the web browser using video player component. The empty area in the client GUI will be used to redraw what the CNC operate so that the client can monitor the CNC, and if problems are happened the client user can stop the CNC in order to overcome the problems. The client PC receives the feedback information sent by the server PC, and if this information starts by the command (POS), then the client knows that this information has the coordinates where the CNC is reached. The client software takes this information and extracts the coordinates from it and puts them in the X, Y and Z variables and depends on the value of the Z variable, the software will draw in the screen or not.

78

If the button is pressed the client send a connection request to the server If the button is pressed the client will be disconnected from the server

If the button is pressed the client sends the selected file to the server If the button is pressed a command will be sent to server to stop the CNC If the button is pressed the client will connect to the FMS and display the video received from the server web camera

This area used to redraw what the CNC operate

If the button is pressed the client program will be finished

Figure 4-6 Client program GUI

If the value of the Z variable is (true) then the client draws a straight line from the current X and Y position to the new received X and Y position, then interchanges the new received X and Y with the current X and Y, while if the value of the Z variable is (false) then only interchanges the current X and Y with the new received X and Y.

79

Figure 4-7 Receiver.html web page that received and display the live video transmitted to Flash Media Server

4.4 Testing Results Six scenarios were used to test the developed CNC controller, the first scenario contains a set of lines that have different lengths and with different angles, these lines are drawn in a DXF file, as shown in Fig. 4-8, and then this file is applied to the machine and its result is shown in Fig. 4-9. The second scenario contains a set of circles that have different radii but with the same center, these circles are drawn in a DXF file, as shown in Fig. 4-10, and then this file is applied to the machine and its result is shown in Fig. 4-11.

80

The third scenario contains a set of arcs that have different radii and different start and end angles but with the same center, these arcs are drawn in a DXF file, as shown in Fig. 4-12, and then this file is applied to the machine and its result is shown in Fig. 4-13. The fourth scenario contains a set of ellipses that have different major and minor axes, different rotation angles and different centers, these ellipses are drawn in a DXF file, as shown in Fig. 4-14, and then this file is applied to the machine and its result is shown in Fig. 4-15. The fifth scenario contains a polyline example that has number of vertices, these vertices are drawn in a DXF file, as shown in Fig. 4-16, and then this file is applied to the machine and its result is shown in Fig. 4-17. The sixth scenario contains LWpolyline example that has number of vertices, these vertices are drawn in a DXF file, as shown in Fig. 4-18, and then this file is applied to the machine and its result is shown in Fig. 4-19. The fifth scenario is used to the second time to test the client program that is connected to the server, a picture to the client program that display the CNC machine operation is shown in Fig 4-20.

81

Figure 4-8 DXF file shows the first scenario

Figure 4-9 The first scenario is machined in a piece of wood

82

Figure 4-10 DXF file shows the second scenario

Figure 4-11 The second scenario is machined in a piece of wood

83

Figure 4-12 DXF file shows the third scenario

Figure 4-13 The third scenario is machined in a piece of wood

84

Figure 4-14 DXF file shows the fourth scenario

Figure 4-15 The fourth scenario is machined in a piece of wood

85

Figure 4-16 DXF file shows the fifth scenario

Figure 4-17 The fifth scenario is machined in a piece of wood

86

Figure 4-18 DXF file shows the sixth scenario

Figure 4-19 The sixth scenario is machined in a piece of wood

87

Figure 4-20 The fifth scenario is monitored from the client PC

88

Chapter Five Conclusions and Suggestions for Future Work 5.1 Conclusions The rapid spreading of CNC machines is enabling the researchers to find new methods or algorithms that control these machines operations. CNC machines are widely used in production fields since they can create similar samples at a very high rate. While working in CNC control system, the following conclusions can be noted:  The algorithms that are used to control the machine are working properly and after testing them in the laboratory machine the results were accepted with error less than 0.1 mm.  During the design and test of the controller with shapes like circle, arc or ellipse a problem took place causing the resulted shapes to be distorted in their quarter, and after debugging the controller software to find the source of the problem, it is found that one of the machine X or Y axis stepper motor stop turning because the required speed calculated by interpolation for one of the axis stepper motor in the quarter of these shapes exceeds the maximum speed the stepper motor can turn with. To overcome this problem, a threshold value is identified (the maximum speed at which the stepper motor can turn), and if the calculated speed exceeds the threshold value, the calculated speed is replaced with the threshold one.  Using the AUTOCAD® to draw the sample needs to be machined by the CNC and feeding the resulted DXF file to the machine, simplifies the

89

operator work and reduces the errors happened from feeding manually each point in the sample to the CNC as in the not PC-based CNC machine.  By using flash and flash media server technologies, live video transmission can be achieved by capturing the video from a web camera connected to the server and broadcasting to other client connected to the server over network or over the Internet and that client receives the video and displays it on the screen. This means that the CNC runs by the server is under the monitoring of the remote client and if any problem will happened the client can stop the running of the CNC until the problem is being corrected. 

The video transmission is secured with a login page that uses a basic security method to prevent unauthorized persons from accessing the video being broadcast by the server.

 The live video and audio transmission require a capable internet or network connection with relatively fast speed rates.  The client can interactively control the CNC machine and obtain the corresponding outputs (including feedback messages and live video/audio streams) in browser-based and visual basic-based GUIs.

5.2 Suggestions for Future Work  The CNC system can be enhanced by developing new algorithms that control the system but with faster speed of moving and with error less than the algorithms already used.  Developing new control system that can work with CNCs having axes more than three, like four, five or six axes CNC machines.

90

 The system can be enhanced by adding a chat panel, so that the client can communicate with the CNC operator.  The system can be enhanced so that it can control more than one machine at a time to perform similar tasks.  System security can be enhanced with a more sophisticated security method to enable registration by email, password recovery and user banning.  The hardware used to interface the devices can be enhanced, for example, the parallel port can be replaced with USB to enhance the system speed and increase the compatibility and ease of use.

91

References [1]

Suk-Hwan Suh, Seong-Kyoon Kang, Dae-Hyuk Chung, Ian Stroud “Theory and Design of CNC Systems”. Springer series in advanced manufacturing, 2008.

[2]

Peter Smid “CNC Programming Handbook” Second ed. Industrial Press Inc., 2000.

[3]

Dr. Gong Zhiming, Huang Sheng, Zeng Hao “Development of PC-based Adaptive CNC Control System”. Automated Material Processing Group, Automation Technology Division, Singapore Institute of Manufacturing Technology, 2001.

[4]

Surya Kommareddy, Yamazaki Kazuo, Kagawa Yoshihito “Pc-Based Open Architecture Servo Controller For CNC Machining”. IMSMechatronics Laboratory, 1997.

[5]

Dong-I1 Kim and Sungkwun Kim “An Iterative Learning Control Method with Application for CNC Machine Tools”. IEEE Transactions on Industry Applications, Vol. 32, No. 1, p.p. 66-72, 1996.

[6]

Daniel Hanafi, Michal Tordon and Jayantha Katupitiya “An Active Axis Control System for a Conventional CNC Machine”. IEEE/ASME International Conference on Advanced Intelligent Mechatronics, 2003.

[7]

Hongen Wu, Chengrui Zhang, Guili Li, and Baoren Wang “Windows XP Embedded based Open Architecture Computer Numerical Control System”. National Natural Science Foundation of China, Shandong University, Jinan, P.R.China. 2006.

92

[8]

Qingrong Ren, Jihong Chen, Xiaoqi Tang and Xiangli Zhang “Internet/Ethernet-Based

Computer

Numerical

Control

System”.

International Conference on Automation and Logistics, Jinan, China, 2007. [9]

LID Yuan, WANG Yong-zhang, FU Hong-ya “An Open Architecture Motion Controller for CNC Machine Tools”. School of Mechatronics Engineering, Harbin Institute of Technology Harbin, Heilongjiang Province, China, IEEE, 2008.

[10] Yue Xu, Taiyong Wang, Yanju Zhao, Jingchuan Dong “Design of Reconfigurable CNC System Based on Embedded Technology”. The 7th World Congress on Intelligent Control and Automation, Chongqing, China, 2008. [11] Jingchuan Dong, Xingzhao Yang, Qingjian Liu, Zijing Wang and Taiyong Wang “Design and Implementation of CNC Controllers using Reconfigurable Hardware”. IEEE International Conference on Control and Automation, Christchurch, New Zealand, 2009. [12] Bu Jiawu, Zhou Min, Ying Kun, Liu Yi “A New Container-Type Interpolation Algorithm and Acceleration/Deceleration Control”. IEEE, 2010. [13] Huang Bin and Wu Chunxue “The Research and Realization of Circular Interpolation Track based on the Point-to-point Comparison Method of CNC in Scilab”. International Conference on Networking and Digital Society, 2010.

93

[14] Innovative Creative ”Computer Numerical Control (CNC)”. IC Professionals Training Series, Industrial Centre, The Hong Kong Polytechnic University, 2009. [15] Steve Krar, Arthur Gill “Computer Numerical Control Programming Basics”. Industrial Press, Inc., 200 Madison Avenue, New York, 1999. [16] Dov Maor, “Virtual Machine Shop”. http://www.kanabco.com/vms/cnc_control/cnc_control_03.html.

Last

visit 3/12/2010. [17] Jan Axelson, “Parallel Port Complete Programming, Interfacing, & Using the PC's Parallel Printer Port”. Lakeview Research, 1996. [18] “Introduction to Sockets”. Brown University, Computer Science, 2010 www.cs.brown.edu/courses/cs032/docs/labs/socketslab.pdf.

Last

visit

2/12/2010. [19] Kevin Towes, “Macromedia Flash Communication Server MX”. New Riders Publishing, 2002. [20] Wikipedia “Adobe Flash Media Server”. http://en.wikipedia.org/w/index.php?title=Adobe_Flash_Media_Server [21] 74LS245 Octal Bus Transceiver datasheet. http://www.datasheetcatalog.com/datasheets_pdf/7/4/L/S/74LS245.shtml [22] R.A. Mahdavinejad, “Introduction of serial architecture for small CNC facilities”, Journal of Achievements in Materials and Manufacturing Engineering, Vol. 36, Issue 1, p.p. 57-64, 2009. [23] Michael Barr, “Introduction to Pulse Width Modulation (PWM)”, Netrino, The Embedded Systems Experts, Elkridge, Maryland USA, 2010.

94

[24] Wikipedia “Circle in general parametric form”. http://en.wikipedia.org/wiki/Circle [25] Engineering Knowledge, Free software, projects, tutorials and more. http://engknowledge.com/dxf2bmp_algorithm.aspx [26] Wikipedia “Ellipse in general parametric form”. http://en.wikipedia.org/wiki/Ellipse [27] “AutoCAD 2007 Developer Help”, Microsoft corporation, 2007.

95

‫الخالصة‬ ‫تستخدم المكائن ذات السيطرة الرقمية بالحاسبة بشكل واسع في مجاالت اإلنتاج وذلك لألنيا تنتج‬ ‫عينات متماثمة بأقل وقت وبسرعة عالية وبأقل خطأ ممكن‪.‬‬ ‫تم تصميم وتنفيذ وفحص نظام السيطرة الرقمية بالحاسبة ليستخدم في السيطرة عمى عمميات ماكنة‬ ‫تفريز مختبرية تتكون من ثالثة محاور يتم تحريكيا من قبل محرك خطوي لكل محور‪.‬‬ ‫أن نظام السيطرة المصمم يتضمن حاسوبين شخصيين (الخادم والزبون)‪ .‬يربط حاسوب الزبون‬ ‫الى الماكنة مباشرة من خالل منفذ متوازي وباستخدام دائرة موائمة مصممة سمفا‪.‬‬ ‫يقوم حاسوب الزبون بالسيطرة عمى عمميات الماكنة والمراقبة عن بعد‪ ،‬ويستخدم الشبكة المحمية أو‬ ‫الدولية لألتصال مع جياز الحاسوب الخادم لمسيطرة عمى الماكنة‪.‬‬ ‫أن الشكل المراد تصنيعو يرسم باستخدام أحد برامج الرسم المعروفة مثل (‪ )AutoCAD‬أو ( ‪3D‬‬ ‫‪ ،)MAX‬ويتم خزن الرسم في ممف يعرف ب(‪ ،)DXF‬بعد ذلك يتم إدخال الممف في مسيطر الماكنة أما‬ ‫عن طريق المشغل أو من خالل جياز حاسوب الزبون المتصل‪.‬‬ ‫أن مسيطر الماكنة يستخدم خوارزميات متطورة تقوم بقراءة ممف (‪ )DXF‬المدخل الى الماكنة‪،‬‬ ‫وتستخمص األشكال مثل الخطوط أو الدوائر أو األقواس أو األشكال البيضوية أو األشكال متعددة الخطوط‬ ‫من ىذا الممف وتولد األوامر التي تحرك محاور الماكنة بحيث تستطيع تصنيع ىذه األشكال‪.‬‬ ‫لقد تم استخدام برامج (‪ )Flash and Flash Media Server‬لغرض تشغيل كامي ار الويب‬ ‫المرتبطة بالحاسوب الخادم والتقاط فيديو حي واذاعتو لمشبكة بحيث يستطيع حاسوب الزبون المرتبط من‬ ‫استالم الفيديو الحي المذاع وعرضو عمى شاشتو ألغراض المراقبة‪.‬‬ ‫أجري اختبار لمماكنة ذات المسيطر الرقمي بالحاسبة عن طريق إدخال مجموعة مختمفة من‬ ‫ممفات (‪ )DXF‬إلييا لغرض تصنيعيا‪ ،‬وقد تم قبول األجزاء المصنعة وذلك لكون األخطاء الناتجة كانت‬ ‫أقل من عشر الممميمتر‪.‬‬

‫شكر و تقدير‬ ‫أود أن أعبر عن خالص شكري و امتناني الستاذي الجميل الدكتور فراس عبداهلل الساعدي‬ ‫لما قدمو لي من توجييات ونصح التمام ىذه االطروحة‪.‬‬ ‫كما اتقدم بالشكر الجزيل الى االستاذ الفاضل الدكتور محمد زكي الفائز رئيس قسم ىندسة‬ ‫الحاسوب وعمادة كمية اليندسة الستعدادىم الدائم لمدعم والتوجيو‪.‬‬ ‫واود ان اعبر عن خالص امتناني وشكري لجميع افراد عائمتي وباالخص والدي العزيزين‬ ‫وكافة زمالئي لما قدموه من تشجيع ودعم عمى كافة االصعدة خالل سنوات دراستي‪.‬‬

‫تصميم و تنفيذ وحدة سيطرة عن بعد لماكنة تفريز‬ ‫ثالثية المحاور‬

‫رسالة‬ ‫مقدمة الى كمية الهندسة في جامعة النهرين‬ ‫وهي جزء من متطمبات نيل درجة ماجستير عموم‬ ‫في هندسة الحاسوب‬

‫من قبل‬ ‫حيدر سعدي رديف‬ ‫(بكموريوس عموم في هندسة الحاسوب ‪2002‬م)‬

‫ذوالحجة‬

‫‪1431‬هـ‬

‫تشرين الثاني‬

‫‪2010‬م‬