Application of C8051F064 single chip microcomputer in remote measurement and control device

Publisher:巳午未Latest update time:2011-09-28 Keywords:C8051F Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This paper introduces the application of C8051F series microcontrollers in remote measurement and control devices, gives the structure of the entire system, including hardware configuration and system network composition, and also makes a detailed explanation of some technical issues.

System Introduction

The remote control device is a field programmable controller that can complete data collection and control, and upload data to the central station or receive remote control commands from the central station through remote communication methods (such as radio, CDMA, dial-up, etc.). It is often installed in a relatively scattered, harsh environment, without power supply guarantee (frequent power outages or using solar energy) and unattended places, so its operating reliability and power consumption are particularly important. The industrial-grade operating temperature (-40℃~+84℃), low voltage, low power consumption, built-in watchdog and multiple reset sources of the C8051F microcontroller meet the requirements of this system.

Based on the positioning of this system, C8051F064 is selected as the master control part and C8051F236 is selected as the slave part. The system requires the performance of flexible configuration of input/output points, multiple communication ports, and field-modifiable configuration.

The system structure is shown in Figure 1. The system is powered by 220VAC or 24VDC. The main unit consumes 3.3W of power, and each slave unit consumes 2.2W of power. Up to 8 slave units can be expanded.

Two main unit structure

The main unit structure is shown in Figure 2. According to the characteristics of the system, the functions of C8051F064 are configured as follows:

Memory

C8051F064 has 4352 bytes of RAM and 128 bytes of Flash. Since the system does not require high real-time data and uses remote communication, in order to reduce power consumption, a large amount of data is often cached and sent in a certain period of time, so a relatively large data storage area is required. The 32KB RAM can be expanded using the external data and address bus. In addition, as a field programmable device, a large number of parameters need to be set, and these parameters need to be maintained after power failure. Therefore, in addition to using the 128-byte non-volatile RAM inside the microcontroller, an 8KB E2PROM is also expanded.

Utilization of address and data buses

The address and data bus are multiplexed. C8051F064 supports 64KB of external storage space and 32KB of extended RAM. Therefore, the remaining address line A15 is free. Using A15 and other low-order data lines, a chip select signal can be formed with a NAND gate to select the device on the bus. A real-time clock is also externally connected to the bus to serve as the time mark of the system. Since this chip has a battery-retained RAM, data that is frequently operated and needs to be maintained can be stored here, thus avoiding the complex operation of the internal non-volatile RAM and E2PROM. In addition, the digital I/O on site can also be formed by the bus and chip select through photoelectric isolation, which can greatly reduce the pins of the microcontroller.

[page]

Serial Port

C8051F064 has two UARTs inside, of which serial port 0 is converted to RS-485 signal through photoelectric isolation, which is used to connect with other devices on site, and serial port 1 plus 6 GPIO ports are converted into full-function standard RS-232 interface after level conversion, which is used to connect with modem, radio, CDMA, etc. The SPI port of C8051F064 is expanded into UART through MAX3100, and converted into RS-232 or RS-485 signal through external optional accessories.

Analog

The analog input of C8051F064 does not exceed 3.6V, so pay attention to its range when connecting the signal. For this system, since most of the field signals are 4mA~20mA current, a 100Ω precision resistor is used with a 2.5V precision voltage source to adjust the accuracy of the analog quantity to 1‰. In addition, starting the window detection function of the internal ADC0 can easily realize the upper and lower limit alarm function of the analog quantity.

Digital quantity

Most of the digital quantities are directly connected to the bus. In addition, there are two switch inputs that are directly connected to the microcontroller pins, and these two pins are internally allocated as timer/counter inputs. These two pins can also be used as pulse quantities.

MCU Resource Allocation

The port function allocation of C8051F064 uses a cross switch method with priority. This method is very flexible, but requires designers to prepare the internal function allocation when designing the circuit. In other words, the cross switch cannot be modified at will after the circuit board is processed.

Reset

In addition to the traditional RESET signal reset, C8051F064 also has reset functions such as power-on, power-off, external signal, software command, comparator 0, clock loss detection and watchdog, a total of 7 reset methods. After the microcontroller is reset, the cause of the reset can be found by querying the register, which is very useful for data processing and fault analysis. This system uses power-on, software command, clock loss and watchdog. The reason for adding software command reset is: since the installation locations of these devices are relatively remote, when the central station detects that the device is abnormal, it can be restarted to solve some abnormal problems.

3. Some technical issues

Data storage

In this system, there are multiple memories that can store data, such as 256 bytes of internal RAM, 4KB of internal expansion RAM, 32KB of external expansion RAM, 128 bytes of Flash, 114 bytes of battery-retained RAM in the real-time clock, and 8KB of external expansion E2PROM. With so many data storage areas, their uses must be carefully allocated in order to give full play to the functions and speed. This system is allocated as follows: 256 bytes of internal RAM has the fastest reading and writing speed, and it is occupied by the microcontroller core, so it should be used less. It is used in places with high speed requirements and frequent use, such as variables in interrupts; 4KB internal expansion RAM and 32KB external expansion RAM have the same status and are generally used as intermediate variables of the program; 128 bytes of Flash are modified as a whole chip, so before modification, all data should be read into the buffer, the bytes to be modified should be changed, and then the whole chip should be erased, and then the data should be written. Although it is troublesome to write, it is very convenient to read, so it is used to store some data that are not often changed and need to be retained after power failure, such as the correction value of analog quantity; the 114-byte RAM in the real-time clock has a fast read and write speed and is easy to access, so it is used to store intermediate variables that need to be retained after power failure, so that it can be read and written at will; the 8KB E2PROM is limited by the bus logic, and the reading and writing speed is slow, but the data area is large, which is used to store the set value of the function. It is read out and placed in the intermediate variable area when the program is initialized, and it will not be operated on later. Modification of internal data operations should not be performed during an interrupt to prevent the interrupt time from being extended.

Watchdog

This article uses a 22.1184MHz crystal oscillator, so the maximum watchdog monitoring time is only 47.4ms, which does not require high real-time performance. This article uses the interrupt feeding method. Generally speaking, simple interrupt feeding is not possible, because the main loop is in effect in the program, and when the main loop enters an abnormal state, the interrupt is often still in progress, so interrupt feeding requires the cooperation of the main loop. Here, 5ms interrupt feeding is used, and variable a is accumulated in the interrupt. When a accumulates to 100, the watchdog is no longer fed; and a is continuously cleared to 0 in the main loop, so that the watchdog time can be extended to 500ms.

Analog filtering

The ADC of C8051F064 is a successive approximation type. Although the speed is as fast as 1MSPS, the data jitter is particularly large. Therefore, when it is used in a hybrid system, a filtering circuit must be added to the periphery. If it is not considered in the hardware design, it does not matter. You can make full use of its speed and use software filtering internally. This system does not require high analog acquisition speed, but only seeks stability and accuracy. It uses 20-point median average filtering internally, and then uses 20 average value algorithms. In this way, even if there is no filtering measure in the periphery, it can also get a good effect. [page]

Serial Port

C8051F064 has two UARTs inside, of which serial port 0 is converted to RS-485 signal through photoelectric isolation, which is used to connect with other devices on site, and serial port 1 plus 6 GPIO ports are converted into full-function standard RS-232 interface after level conversion, which is used to connect with modem, radio, CDMA, etc. The SPI port of C8051F064 is expanded into UART through MAX3100, and converted into RS-232 or RS-485 signal through external optional accessories.

Analog

The analog input of C8051F064 does not exceed 3.6V, so pay attention to its range when connecting the signal. For this system, since most of the field signals are 4mA~20mA current, a 100Ω precision resistor is used with a 2.5V precision voltage source to adjust the accuracy of the analog quantity to 1‰. In addition, starting the window detection function of the internal ADC0 can easily realize the upper and lower limit alarm function of the analog quantity.

Digital quantity

Most of the digital quantities are directly connected to the bus. In addition, there are two switch inputs that are directly connected to the microcontroller pins, and these two pins are internally allocated as timer/counter inputs. These two pins can also be used as pulse quantities.

MCU Resource Allocation

The port function allocation of C8051F064 uses a cross switch method with priority. This method is very flexible, but requires designers to prepare the internal function allocation when designing the circuit. In other words, the cross switch cannot be modified at will after the circuit board is processed.

Reset

In addition to the traditional RESET signal reset, C8051F064 also has reset functions such as power-on, power-off, external signal, software command, comparator 0, clock loss detection and watchdog, a total of 7 reset methods. After the microcontroller is reset, the cause of the reset can be found by querying the register, which is very useful for data processing and fault analysis. This system uses power-on, software command, clock loss and watchdog. The reason for adding software command reset is: since the installation locations of these devices are relatively remote, when the central station detects that the device is abnormal, it can be restarted to solve some abnormal problems.

3. Some technical issues

Data storage

In this system, there are multiple memories that can store data, such as 256 bytes of internal RAM, 4KB of internal expansion RAM, 32KB of external expansion RAM, 128 bytes of Flash, 114 bytes of battery-retained RAM in the real-time clock, and 8KB of external expansion E2PROM. With so many data storage areas, their uses must be carefully allocated in order to give full play to the functions and speed. This system is allocated as follows: 256 bytes of internal RAM has the fastest reading and writing speed, and it is occupied by the microcontroller core, so it should be used less. It is used in places with high speed requirements and frequent use, such as variables in interrupts; 4KB internal expansion RAM and 32KB external expansion RAM have the same status and are generally used as intermediate variables of the program; 128 bytes of Flash are modified as a whole chip, so before modification, all data should be read into the buffer, the bytes to be modified should be changed, and then the whole chip should be erased, and then the data should be written. Although it is troublesome to write, it is very convenient to read, so it is used to store some data that are not often changed and need to be retained after power failure, such as the correction value of analog quantity; the 114-byte RAM in the real-time clock has a fast read and write speed and is easy to access, so it is used to store intermediate variables that need to be retained after power failure, so that it can be read and written at will; the 8KB E2PROM is limited by the bus logic, and the reading and writing speed is slow, but the data area is large, which is used to store the set value of the function. It is read out and placed in the intermediate variable area when the program is initialized, and it will not be operated on later. Modification of internal data operations should not be performed during an interrupt to prevent the interrupt time from being extended.

Watchdog

This article uses a 22.1184MHz crystal oscillator, so the maximum watchdog monitoring time is only 47.4ms, which does not require high real-time performance. This article uses the interrupt feeding method. Generally speaking, simple interrupt feeding is not possible, because the main loop is in effect in the program, and when the main loop enters an abnormal state, the interrupt is often still in progress, so interrupt feeding requires the cooperation of the main loop. Here, 5ms interrupt feeding is used, and variable a is accumulated in the interrupt. When a accumulates to 100, the watchdog is no longer fed; and a is continuously cleared to 0 in the main loop, so that the watchdog time can be extended to 500ms.

Analog filtering

The ADC of C8051F064 is a successive approximation type. Although the speed is as fast as 1MSPS, the data jitter is particularly large. Therefore, when it is used in a hybrid system, a filtering circuit must be added to the periphery. If it is not considered in the hardware design, it does not matter. You can make full use of its speed and use software filtering internally. This system does not require high acquisition speed of analog quantities, but only seeks stability and accuracy. It uses 20-point median average filtering internally, and then uses 20 average value algorithms. In this way, even if there is no filtering measure in the periphery, it can also get a good effect.

Keywords:C8051F Reference address:Application of C8051F064 single chip microcomputer in remote measurement and control device

Previous article:Summary of C51 pointer definition and application
Next article:Application example of AT88SC1604 card controlled by single chip microcomputer

Recommended ReadingLatest update time:2024-11-17 00:50

Design of Computer Network Experiment Platform Based on C8051F310 and CS8900A
  O Introduction   The course "Computer Network" is a computer and communication course offered by university computer and related majors. This course is very practical, and many teaching contents require a high-cost experimental environment to be implemented. In addition, network equipment is updated quickly and th
[Microcontroller]
Design of Computer Network Experiment Platform Based on C8051F310 and CS8900A
C8051F(330) precise delay program (24.5M)
//********************************************** // Function: C8051F(330) precise delay 24.5M //************************************************** #include c8051f330.h #include intrins.h //---------------------------------------------- void Reset_Sources_Init() {       RSTSRC      = 0x04; } void PCA_Init
[Microcontroller]
Design of timing acquisition and storage system based on microcontroller C8051F021 and clock chip
With the rapid development of science and technology, many applications in the field of modern industrial measurement and control require the regular collection and storage of large amounts of data. Taking the ocean current data acquisition and storage interface circuit designed for the ocean current meter as an examp
[Microcontroller]
Design of timing acquisition and storage system based on microcontroller C8051F021 and clock chip
Clock Synchronization Technology of C8051F120 and RS422 Bus
introduction As the speed of instructions continues to increase, the performance of microcontrollers has been greatly improved in various aspects, such as clock synchronization between multiple microcontrollers. The execution speed of Silicon Labs' C8051F series microcontrollers can reach up to 100MIPS, whi
[Microcontroller]
Airflow meter based on C8051F single chip microcomputer
introduction The cotton airflow meter studied in this project is based on the relevant provisions of the cotton fiber "micronaire value" test method GB6468-1992, combined with the current microcomputer monitoring system technology, using the single-chip microcomputer C8051F, with the characteristics of fast tes
[Microcontroller]
Airflow meter based on C8051F single chip microcomputer
Design and application of CAN bus isolator based on C8051F040
1 Introduction CAN (Controller Area Network), or controller area network, is one of the most widely used field buses. CAN bus can be applied to high-speed networks and low-cost line networks with its advantages of strong real-time performance, high reliability, simple structure, good interoperability, and l
[Industrial Control]
Blood Glucose Meter Based on C8051F Single Chip Microcomputer
Electrochemical Principles of Blood Glucose Measurement The electro-biochemical principle of blood glucose measurement is that when a certain voltage is applied to the blood after the enzyme reaction, the current generated will increase as the blood glucose concentration in the blood increases. By accurately me
[Microcontroller]
Blood Glucose Meter Based on C8051F Single Chip Microcomputer
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号