Modern CNC machining first uses CAD / CAM software to draw the machining sketch of the parts, then makes appropriate attribute settings according to the sketch, generates G code, and then transmits the G code to the CNC system in some way to interpret and convert it into actual axis movement. However, since the amount of G code data actually generated is large compared to the storage resources of the ARM embedded CNC system, it is impossible to transmit all the G codes to the ARM CNC system for storage and then interpret and process them one by one. Therefore, there should be a flow control problem in the process of data transmission. Although there are many ways to transmit PC G code to ARM CNC system code, the serial port of ARM is relatively easy to operate, so this design uses the serial port to transmit data. Although the serial port is convenient to operate, there are some problems in the data transmission process. For example, the PC transmits 9 data to the ARM, but only receives 8. If the data to be transmitted is large, more data will be lost. If the amount of data is large, a high baud rate is required for transmission. However, a high baud rate will not only cause data omissions, but also make the transmitted G code unable to be processed in time by the CNC system. If the baud rate is too low, the transmission time will definitely be very long, reducing the processing efficiency.
What is the reason for so many problems? After analysis, a method is proposed to improve the data transmission speed and the code processing ability of the CNC system while ensuring the correctness of the data. The 32-bit ARM controller, mainly the LPC series, has the advantages of fast speed, large capacity, stable performance, and convenient online debugging. ARM has broad prospects in the field of industrial control as an intelligent controller. In the application of ARM in the field of industrial control, data transmission and processing with the host computer software is a problem that often needs to be solved.
2. ARM serial port initialization settings and interrupt service routine
The LPC2292 processor has two serial ports, each with a 16-byte receive FIFO and a 16-byte transmit FIFO. The register position complies with the I6C550 industrial standard. The receiver FIFO trigger point can be set to 1, 4, 8, or 14 bytes. It has a built-in baud rate generator. There are four interrupts: data available interrupt, character reception timeout interrupt, THRE interrupt, and Rx line status interrupt. When the serial port receives data, a buffer queue is designed to store the received data.
(1) Data cache queue data structure design
QUEUE_DATA_TYPE represents the data type of the transmission. Whenever data is transmitted from the serial port to ARM, the data is queued through the In pointer. When data needs to be processed, the Out pointer is used to dequeue the data. As for the queue size, it depends on factors such as the baud rate and the serial port interrupt frequency. It is also necessary to implement two functions uint8 QueueWrite(void *Buf, QUEUE_DATA_TYPE Data) and uint8QueueReadQUEUE_DATA_TYPE *Ret, void *Buf), which are mainly used to write data to and retrieve data from the data queue, using the first-in-first-out (FIFO) method.
(2)Serial port initialization procedure:
U0IER = 0x05; /* Enable receive and transmit interrupts*/
}
(3) Interrupt Service Routine
Specific implementation of interrupt handling function
1. Data available interrupt processing
For(i=0;i<8;i++) //Because the serial port is initialized with 8-byte interrupt
{QueueWrite (Buf, UARBR); }
2. Data timeout interrupt processing:
While(1)
{
If (UALSR&0x00000001= =1)
{QueueWrite (Buf, UARBR);}
Else Break;
}
3. Theoretically, the THRE interrupt can be shielded, but the interrupt can also be processed by filling data into the FIFO.
For(i=0;i<16;i++)
{
QUEUE_DATA_TYPE data;
QueueRead(&data, Buf)
U0THR = data;
}
4. Similarly, line interrupts can be masked and processed. The processing method only requires reading the U0TSR register Data = U0TSR;
The timeout interrupt is handled in the interrupt service program, so the serial port interrupt trigger byte can be set larger to ensure that data will not be lost, while reducing the number of system interrupts, reducing system load, and improving processor processing speed.
3. Design of host computer software and ARM serial port data transmission software
A serial port data receiving queue buffer is opened in the ARM system, so the host computer serial port sending software is required to be able to cooperate with the ARM processing capability to control the flow of data transmission.
In the program, NUM indicates the total number of characters in the file. It is sent to ARM as a signal to start sending the file when the code data is transmitted, and is also used as the basis for judging the end of the file transmission. SUM indicates the number of characters that have been transmitted in the code. Its initial value is 0.
IV. Conclusion
The serial port settings are: baud rate 115200, 8 data bits, 1 stop bit, no parity check, no flow control. Through the serial port debugging assistant, select send file and send the processing file (size 182K) generated by the CAM software CAXA manufacturing engineer on the PC. Send it to the ARM CNC system for processing through the serial port. The system can well ensure that the ARM CNC system correctly processes the G code and transmit the G code data at high speed.
Tests show that a large number of G codes of CNC systems can complete processing very well and have been applied to the design of CNC systems. Practice has shown that this method can improve the processing efficiency of CNC systems.
Previous article:Detailed introduction and technical knowledge of STM32 microcontroller
Next article:STM32 CAN bus basics
Recommended ReadingLatest update time:2024-11-16 01:36
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- Ask a Question
- Cost less than 5 yuan, reliable single-fire power supply solution (using NP101A chip, including PDF...
- The romance and art of electronic engineers
- 【AT-START-F425 Review】Interpretation of I2C i2c_application.c
- Based on TI Da Vinci series TMS320DM8148 floating-point DSP C674xRGMII Gigabit Ethernet port, HDMI output interface
- Distinguishing the real from the fake: A guide to chip procurement
- Can two RSL10s be connected via Bluetooth?
- [TI recommended course] #In-depth understanding of the principle and control of brushless DC motor (BLDC) #The entire brushless motor drive process is suitable for beginners
- Anlu SparkRoad Development Board Review (8) MCU Soft-core RISC-V Programming
- ADS LNA