0 Introduction
Thermal error is the biggest error source of CNC machine tools. Temperature test of CNC machine tools provides a basis for compensation of thermal error of machine tools. The traditional temperature measurement scheme is to transmit analog signals to data acquisition cards through cables for A/D conversion and processing. In practice, problems such as long-line transmission and analog sensor wiring must be solved. This paper introduces a new design scheme. The controller uses SAMSUNG's 32-bit ARM microcontroller S3C44BOX, and the temperature sensor uses a single-bus digital temperature sensor DS18B20. The use of digital temperature sensors completes the digitization of signals at the test point, improves the reliability of transmission, simplifies the peripheral circuit, and facilitates the arrangement and installation of sensors on machine tools. The ARM processor controls the acquisition of digital temperature signals and communicates with the upper PC. At the same time, other hardware resources provide other functions of the thermal compensation system. Based on the introduction of the digital temperature sensor DS18B20, this paper gives the system's hardware and software design scheme and makes detailed annotations on the key points in the software implementation.
1 Introduction to the digital temperature sensor DS18B20
1.1 Structure of DS18B20
DS18B20 is a networkable digital temperature sensor launched by DALLAS, USA. DS18B20 has only one data input/output port and is a single bus dedicated chip. When DS18B20 is working, the measured temperature value is directly transmitted in a single bus digital manner.
DS18B20 is small in size and has a wide voltage application range (3V-5V). It can be programmed to achieve 9-12-bit temperature readings, that is, it has an adjustable temperature resolution. The temperature measurement range is -55℃~+125℃, and the accuracy is ±0.5℃ at -10℃~+85℃. Its optional packages include TO-92, SOIC and CSP packages.
Each DS18B20 has a unique 64-bit serial number when it leaves the factory, so multiple DS18B20 can be connected to a bus at the same time without confusion. DS18B20 includes a temporary RAM and an E2RAM. The temporary memory RAM is used to store working parameters and measured values. Its function is to ensure the integrity during single-line communication. It includes 8 bytes. E2RAM is used to set the non-volatile temperature alarm upper and lower limits TH and TL (still saved after power adjustment). The internal structure is shown in Figure 1.
The first two bytes represent the measured temperature readings. The data format is shown in Figure 2:
When S=1, it indicates that the temperature is negative, and when S=0, it indicates that the temperature is positive. The remaining low bits are expressed in binary complement form, and the lowest bit is 1, indicating 0.0625℃.
The fifth byte of the internal memory is the structure register, which is mainly used for the digital conversion resolution of the temperature value.
1.2 DS18B20 working sequence
DS18B20 strictly follows the single bus protocol. When working, the host first sends a reset pulse to reset all DS18B20 on the bus, and then sends a ROM operation instruction to activate the DS18B20 with matching serial number encoding, ready to accept the following RAM access instruction. The RAM access instruction controls the working state of the selected DS18B20 and completes the entire temperature conversion, reading and other tasks. Before the ROM command is sent, the RAM command command does not work. Table 1 lists all the operation commands.
The entire operation mainly includes three key processes: the host searches for the DS18B20 serial number, starts the online DS18B20 to do temperature conversion, and reads the temperature value.
Its workflow is shown in Figure 3:
DS18B20 has high requirements for timing and electrical characteristic parameters, and must be operated strictly in accordance with the timing requirements of DS18B20. Its data reading and writing are mainly completed by the host reading and writing specific time slices, including reset (initialization), read time slices and write time slices.
(1) Reset Timing
When using DS18B20, it must be reset first before other commands can be executed. During reset, the host pulls the data line to a low level and maintains it for 480μs to 960μs, then releases the data line, and then the pull-up resistor pulls the data line up for 15 to 60μs, waiting for DS18B20 to send a presence pulse. The presence pulse is valid for 60 to 240μs, and the reset operation is completed. Its reset timing is shown in Figure 4.
(2) "Write" timing
When the host writes data to DS18B20, the data line is first set to a high level and then to a low level. The low level should be greater than 1μs. Within 15μs after the data line becomes a low level, the data line is made high or continues to be low according to writing "1" or writing "0". DS18B20 will sample the data line within 15μs to 60μs after the data line becomes a low level. The data duration required to be written to DS18B20 should be greater than 60μs and less than 120μs, and the time interval between two writes should be greater than 1μs. The timing of the write time slot is shown in Figure 5. The "read" timing mechanism is similar and will not be repeated.
2 System software and
hardware design 2.1 Hardware design
The controller we use is SAMSUNG's 32-bit ARM microcontroller S3C44BOX, which is a cost-effective and high-performance microcontroller solution provided by Samsung for general applications, with low power consumption and high reliability. It uses the ARM7TDMI core and operates at 66MHz. The ARM controller used will serve the entire thermal error compensation system and complete the implementation of multiple tasks including data processing, communication, and control. The machine tool temperature measurement system only uses a small part of the on-chip resources.
We mainly complete the single bus communication by reading and writing the level of the I/O pin, and use the ARM internal timer to generate interrupts to complete the work with time slot requirements. Since the timing value unit generated by the pre-scaling reaches 1μs, it can fully meet the needs of timing work. The
interface between DS18B20 and the controller is very simple. You only need to connect the signal line of DS18B20 to a bidirectional port of the controller. The system connection is shown in Figure 8:
2.2 Software Design
Following the DS18B20 single bus communication protocol, the software process of temperature conversion and reading can be expressed as Figure 9 (this process is after a selected DS18B20 has been selected and activated. The software principle of the selected activation process is similar and is omitted here).
It can be seen that the communication with DS18B20 mainly completes the following three basic subroutines: initialization program (reset program), 'read' subroutine, and 'write' subroutine. The system is designed in C language. The following is the initialization (reset) subroutine, which is designed as follows:
U8 resetpulse(void) //Reset function definition
{
U8 RX=1; //Function return value setting
rPCONF=0x01; //PF0 output port
rPDATF=0x0; //PF0 outputs 0, pulls down
rTCNTB1=0x1f4; //Timing buffer setting, delay 500us
rTCON=0x0200; //Timing controller setting, manually update timer 1
rTCON=0x0100; //Timer is turned on, manually update and turn off
while(TIME); //Step and wait before the timing interrupt is generated (we change this flag value in the interrupt)
rPDATF=0x01; //Low pulse time 500us has passed, PF0 is set high
TIME=1; //Restore TIME value
rTCON=0x0; //Turn off timer
rTCNTB1=60; //Delay 60us
rTCON=0x0200;
rTCON=0x0100;
while(TIME);
TIME=1;
rTCON=0x0;
rPCONF=0x0; //Change to input port and read value
if((rPDATF & 0x01)==0) //When PF0 port is read as low, it means there is a pulse received
{RX=0;}
rTCNTB1=0x0190; //Delay 400us
rTCON=0x0200;
rTCON=0x0100;
while(TIME);
TIME=1;
rTCON=0x0;
return(RX); //The function returns the RX value, RX is zero when a pulse is received
}
Calling this initialization program can achieve the reset requirement. The implementation mechanism of the "read" subroutine and the "write" subroutine is similar, and the code will not be repeated. Under the single bus protocol, by calling these subroutines for corresponding control, the communication between the host and DS18B20 can be completed, and the temperature collection can be realized.
3 Conclusions
The interface circuit of this system is simple, the communication is reliable, the integrated system runs well, the test accuracy is high, and the test proves that it can complete the predetermined test tasks.
Previous article:Design of intelligent navigation cane system based on ARM
Next article:In-system programming design of Flash memory in single-chip microcomputer system
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- WeChat group voice Q&A at 2pm: Vicor power experts answer netizens' power design questions
- Ti's C28x series ADC experience
- How to judge whether an oil chromatograph is suitable for selection?
- Battery interface problem
- About CC2640 power consumption test problem
- stm32 and AD7732 help
- Playing with Zynq Serial 14 - Using GIT for Project Backup and Version Management 6
- Selection of solid state relays
- Access to register of unclocked peripheral at 0x40010C00 cause BUS_FAULT What...
- FAQ_How to quickly confirm the power consumption in different modes of S2-LP