Design of laser engraving machine control system based on microcomputer

Publisher:TranquilGazeLatest update time:2006-05-07 Source: 电子技术应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    Abstract: This article describes the design and implementation of PC-based laser engraving machine motion trajectory interpolation control software and its peripheral interface characteristics.

    Keywords: control CNC interpolation principle computer parallel port

    Laser is a new technology that emerged in the early 1960s. Due to its characteristics of good monochromaticity, high brightness and good directionality, it has had a huge impact on various technical fields. In recent years, laser engraving machines based on CNC (Computer Numerical Control) have also appeared on the market as a high-tech product that combines machinery, light, electricity, and computing. They are widely used and have great market demand. Since most of this product is imported from abroad, its price is so high that it is difficult for ordinary domestic consumers to accept it. The main similar products include Japan's MIMAKI PRO professional cutting plotter, Shanghai Changjiang Huizhong Enterprise Development Co., Ltd.'s Yangtze laser engraving machine and Beijing Kaitian Technology Company's FC-15 laser engraving machine. This article mainly introduces the software design of the control system of the laser engraving machine and the interface characteristics of the main ports. In the control system of this laser engraving machine, a digital control system based on a PC is mainly used to control the stepper motor through a parallel port and a stepper motor driver to achieve the purpose of controlling the direction and speed of the workbench (or laser beam).

1 Design of control software

1.1 Principle of interpolation

    In order to control the laser engraving machine, the vectorization method is mainly used to divide the control into different types of basic vectors, including three basic vectors: straight line, arc, and ellipse. The interpolation principle is then used to achieve digital approximation of these three basic vectors. The control system of the laser engraving machine is required to achieve high speed and accuracy, so the calculation of the control software cannot be too complicated and cannot take too much time. This is the reason for using the interpolation principle. The point-by-point comparison interpolation algorithm used in this system is used. The so-called point-by-point comparison interpolation algorithm means that each step must be compared with the coordinate value on the given trajectory to make the point above or below the given trajectory, or inside or outside the given trajectory, thereby determining The next feed direction will make it approach the processing trajectory. Take one step like this, compare once, decide the next step, and gradually approach the given trajectory. The point-by-point comparison method uses a broken line to approximate a straight line or arc curve. The maximum error between it and the specified straight line or arc does not exceed one pulse equivalent, as long as the pulse equivalent (that is, the distance of each step) is made small enough. , you can meet the processing accuracy requirements. The following takes a straight line as an example to illustrate the interpolation principle. As shown in Figure 1.

    The deviation calculation formula assumes that the straight line OA in the first quadrant is processed, the starting point of the straight line is taken as the coordinate origin O, and the coordinates of the straight line end point A (Xe, Ye) are known. M (Xm, Ym) is the processing point (moving point). If M is on the straight line OA, then according to the relationship between similar triangles:

    Xm/Ym=Xe/Ye

    Take Fm=YmXe-XmYe as the deviation discriminant of linear interpolation.

    If Fm=0, it means that point M is on the straight line OA.

    If Fm>0, it means that point M is at M′ above the straight line OA.

    If Fm<0, it means that point M is at M″ below the straight line OA.

    For the first quadrant straight line starting from the starting point (that is, the origin of the coordinates),

    If Fm>=0, take one step along the +X axis.

    If Fm<=0, take one step along the -X axis.

    When the number of steps taken in both directions is equal to the end point coordinates (Xe, Ye), an end point arrival signal is sent and interpolation stops. Assuming that Fm>=0 appears at a certain processing point, one step should be taken in the +X direction. The coordinate value after one step is: X m+1 = X m+1 , Y m+1 = Ym

    The new deviation is : Fm+1=Ym+1Xe-X

    If Fm<=0, one step should be taken along the +Y direction. The coordinate value after one step is: X m+1 = Xm, Y m +1 = Y m +1

    The new deviation is: F m+1 = Y m +1 X e - X m +1 Y e = F m + X e

    The above formula is a simplified deviation calculation formula. There are only addition and subtraction operations in the formula. As long as the deviation value of the previous point is equal to the above-mentioned end point coordinate value. Of course, different quadrants and different vector interpolation formulas are different, but the basic principles are similar and will not be described again here.

1.2 Control of motor running speed

    Since the maximum starting frequency of domestic stepper motors is generally 1 to 2kHz, generally stepper motors cannot suddenly reach the required maximum frequency, and they cannot stop immediately at the maximum operating frequency of the motor, otherwise the motor will lose steps. affect the accuracy of the system. This requires acceleration and deceleration control of the motor in the program. The basic idea is as follows:

    Assume that the time of each step of the motor is t. t is inversely proportional to the running speed of the motor. When the motor is in the acceleration stage, the next step of the motor should make the time t - t is calculated based on the acceleration of the motor. The amount of time reduction is calculated as follows:

    n=l/δ,δt=t 0 -t 1 / nl,tsum=n(t 0 +t 1 ) / 2

Among them, l is the length of a certain distance, δ is the resolution of the system, that is, the minimum step distance, n is the total number of pupils traveled, tsum is the total time required to walk, and t0 is the cost of walking each pupil at the initial speed. time, t1 is the time it takes for each walk to reach the required distance (that is, when the maximum speed is reached). According to the specific requirements, we can calculate various values.

    In PC-based control systems, a very important issue is how to obtain precise control of time. In the Windows operating system, the time function provided by the system can only achieve millisecond-level accuracy, and it is difficult to achieve microsecond-level control accuracy. For PCs with different configurations, the execution time of the same statement will not be the same. To this end, we use the GetTickCount() function provided by the system and use a loop including the _nop statement to achieve microsecond-level control accuracy. The following is the specific implementation method usage:

    Construct the CMicroSecond class:

    Implement the number of _nop statement loops per microsecond in the class initialization function.

    voidCMicroSecond::Initialize

    {

    DWORD dwStart = 0;

    DWORD dwStop = 0;

    int nLoopSeed = 100000;

    do{

    m_dwLoopCounter1 = 0;

    dwStart = GetTickCount;

    for(int i=0;i

    {

    m_dwLoopCounter1++;

    _asmnop;

    }

    dwStop = GetTickCount();

    nLoopSeed + = 100000;

    }while ( dwStop - dwStart < 50 );

    m_dwLoopCounter1 = 0;

    dwStart=GetTickCount;

    for(int i=0; i

    {

    m_dwLoopCounter1++;

    _asm{nop}

    }

    dwStop = GetTickCount();

    //Number of cycles per millisecond

    m_dwLoopCounter1=m_dwLoopCounter1/dwStop-

dwStart;

    //Number of cycles per microsecond

    m_nLoopCount

Counter 1/1000;

    }

    To implement a fixed time delay:

    void CMicroSecond::MicroDelay( int uSec )

    {

    n=0;

    for(int i=0;i

    {

    n++;

    _asm{nop}

    }

    }

    Since assignment statements, for statements, function calls, etc. take time, the time obtained is not very accurate. But for a general PC, it can achieve an accuracy of tens of microseconds, and for a general control system, this accuracy is enough to meet the control requirements.

2 Peripheral interface characteristics

    In this system, we control the stepper motor driver through the parallel port of the computer. We know that the specific forms of parallel port adapters are various, but in PC series microcomputers, up to four ports are allocated to it, and three ports are commonly used. Its address is: 03BCH - 03BEH: Parallel port one (LPT1) , 0378H - 037AH: Parallel port two (LPT2), 0278H - 027AH: Parallel port three (LPT3). Here you can see that each parallel port includes three port addresses, the first of which is the base address, because a parallel port has a data port status port and a control port. However, it is worth noting that it is best not to directly use the address of the above port to read and write the parallel port, because in actual applications it is rare for three parallel ports to be valid at the same time, and the parallel port addresses on multi-function cards and monochrome display cards There is a difference. The parallel port address on a monochrome display card is generally 03BCH, while the parallel port base address on a multi-function card can generally be selected between 0378H and 0278H. Therefore, if you directly operate a certain parallel port address, something will go wrong if the parallel port adapter on the PC does not use this port address.

    Readers who are familiar with PCs know that the three words 40:08H, 40:0AH, and 40:0CH in the lowest-end BIOS data area of ​​PC memory are designed to store the base addresses of the above three parallel ports, 40:08H. - 09H LPT1 base address; 40: 0AH - 0BH LPT2 base address; 40: 0CH - 0DH LPT3 base address. The base address in these three words is stored according to the actual parallel port address during the PC startup process. Using them to read and write the parallel port will not cause errors, so you must check these three words when using it. Get the base address of the parallel port. The statements used in reading and writing operations on the parallel port are _outp (parallel port address, data) and _inp (parallel port address) (the return value of _inp is the read data).

3 System characteristics and result analysis

    In the laser engraving machine system described in this article, we control the system through a dynamic link library. We encapsulate the control of basic vector elements in a dynamic link library, so that the system control software has certain reliability. Portability. This method of controlling the laser engraving machine through the PC parallel port is simple and easy to implement, and can greatly shorten the development cycle. If we add the corresponding laser engraving machine drawing software, it can become a commercial product.

Reference address:Design of laser engraving machine control system based on microcomputer

Previous article:TEC9503AM/FM receiving frequency display module and its application
Next article:Development of new ultra-high sensitivity Super-HARP camera tube

Latest Power Management Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号