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.
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.
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
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- MCU Principles and Interface Technology C51 Programming (Edited by Zhang Yigang)
- Example interpretation of 51 single chip microcomputer complete learning and application
- Practice of Serial Communication between Single Chip Microcomputer and Computer (Zhang Xiuguan)
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
- MPLAB X display issues
- (Transfer) Overview of CC2640R2F BLE5.0 Bluetooth Protocol Stack
- IP Design Specifications in the 2021 Standard for Very Large Scale Integrated Circuit (VLSI) Design Flow
- Qorvo Online Design Conference - Rapid Customization of Power ICs Using ActiveCiPS Technology
- [Perf-V Review] + Button Control RGB_LED Color Change
- MSP430 Program Library --- 12864 LCD Program Library
- TMS320F28027 ADC zero offset calibration
- Live broadcast at 14:00 this afternoon [Introduction and application of TI C2000 built-in programmable logic module CLB] (200 gifts)
- After the stepper motor is powered on according to the timing, it just shakes left and right and does not rotate. I would like some guidance.
- TI TMS320C6678 DSP + Xilinx Kintex-7 FPGA LED indicators and buttons