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++; _asmnop; } 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.
Previous article:TEC9503AM/FM receiving frequency display module and its application
Next article:Development of new ultra-high sensitivity Super-HARP camera tube
- Popular Resources
- Popular amplifiers
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- MLCC Noise Howling and Countermeasures
- Design of brushless DC motor driver based on hardware FOC TMC4671
- [ART-Pi Review] VI: Review of ATT-Pi's onboard Flash file system and FTP functions in RTT Studio environment
- Use transistor + MOS tube to control battery output
- Contemporary IoT smart antenna design trends | Review TE's exciting live broadcast, write a comment and win a gift!
- VLSI Digital Signal Processing Systems: Design and Implementation
- A foreign guy pranked: using ESP32 microcontroller disguised as GPU to infect his friend's computer with "ransomware"
- 13 Rules You Must Read for RF Circuit Power Supply Design
- Agilent6684A power supply maintenance method - Antai Instrument Maintenance
- General frequency converter technology of DSP