Design of infrared communication interface circuit controlled by single chip microcomputer

Publisher:EnchantedBreezeLatest update time:2011-10-10 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Reference address:Design of infrared communication interface circuit controlled by single chip microcomputer

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

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号