Introduction
In industrial control, in order to ensure the reliable operation of the system, it is necessary to detect the surrounding environmental variables (such as temperature, air pressure, humidity, etc.). The usual practice is to connect the signals collected by sensors distributed in various places to the monitoring center through their own lines. This method effectively completes the detection task but also causes a great waste of line resources. Therefore, the requirement of simplifying the line layout is proposed. CAN (Controller Area Network) is a serial communication protocol that can effectively support distributed real-time control with a high security level. At the same time, in theory, there is almost no limit on the nodes in the CAN bus network. Based on this, this design uses a CAN bus data acquisition system based on a digital signal controller as a CAN node, and places a CAN node in each area that needs to be monitored. Each node communicates with the monitoring center through the CAN bus. The overall block diagram of the system is shown in Figure 1.
1 Hardware composition
The data acquisition system consists of two parts: the control part, including the anti-aliasing filter of the front-end signal and the 12-bit analog-to-digital converter for signal acquisition; the CAN bus interface circuit part, which consists of the MCP2515 CAN protocol controller and the MCP2551 high-speed CAN transceiver. The system receives three signals, TEM, PRE, and RH are temperature, air pressure, and relative humidity respectively.
1.1 Control part
dsPIC30F3013 is a sensor series digital signal controller produced by Microchip. The controller adopts a 16-bit (data) modified Harvard structure with an enhanced instruction set, including strong support for DSP. The working speed can reach up to 30MIPS, and it integrates a 10-channel 12-bit analog-to-digital converter with a maximum conversion speed of 200 ksps.
In the industrial control system, due to the existence of various types of noise, it is necessary to add an anti-aliasing filter circuit at the signal acquisition end, as shown in Figure 2.
The anti-aliasing uses a Sallen Key second-order low-pass filter. Since the environmental variables are all slow variables, the filter bandwidth is set to 30 Hz. The values of R1, R2, C1, and C2 in the circuit determine the characteristic frequency f0 of the anti-aliasing filter, and also ensure 12-bit resolution at a 10 ksps analog-to-digital conversion rate. In order to ensure that the signal can pass well throughout the entire passband range, the quality factor Q of the Sallen Key filter needs to be adjusted. The Q value is determined by formula (1):
[page]
The amplitude-frequency characteristics of the Sallen Key filter show that the frequency characteristics are optimal when the quality factor is between 0.7 and 0.9. The Q value is selected as 0.8.
The 12-bit ADC module of dsPIC30F3013 is used for data acquisition. The three environmental signals are scanned cyclically, and an interrupt is generated every time 12 sampling/conversion processes are completed. During the interrupt process, 4 average value digital filtering and format adjustment of the corresponding parameters are completed, and then transmitted to the CAN protocol controller through the SPI interface.
1.2 CAN bus interface circuit part
The CAN bus interface circuit is shown in Figure 3.
The CAN protocol controller uses the MCP2515 produced by Microchip. The MCP2515 is an independent CAN controller with an SPI interface. It fully supports the CAN V2.0B technical specification and has a communication rate of 1 Mb/s. It includes 2 receive buffers, 6 29-bit acceptance filter registers, 2 29-bit acceptance mask registers, 3 transmit buffers with priority setting and transmission abort, and a high-speed SPI interface (10 MHz).
The interface between the MCP2515 and the MCU can be flexibly configured. It can be directly connected to the digital I/O pin of the MCU through a pin (such as TXORTS) to control the state of the MCP2515 using the read and write functions of the digital I/O; it can also directly use the SPI instruction set of the MCP2515 to implement all functions. The SPI instruction set used to control the MCP2515 is listed in Table 1.
The dsPIC30F3013 communicates with the MCP2515 through the SPI interface. The SPI module of the dsPIC30F3013 works in the master mode and the MCP2515 works in the slave mode. The dsPIC30F3013 accesses the internal registers of the MCP2515 by calling the SPI instructions.
The MCP2551 is a fault-tolerant high-speed CAN transceiver that fully complies with the ISO-11898 standard, including the 24 V voltage requirement. It can operate at a rate of up to 1 Mb/s.
2 Software Design
dsPIC30F3013 is the control core, which undertakes the tasks of data acquisition and CAN communication. The workflow of the data acquisition part is shown in Figure 4.
The 12-bit ADC module of dsPIC30F3013 contains a 16-word dual-port read-only buffer from ADCBUFO to ADCBUFF to buffer the ADC conversion results. This application samples 3 signals and uses scan input. After 12 ADC conversions, the data of each conversion is written to ADCBUF0 to ADCBUFB in sequence. That is, the AD-CBUFs coded 0, 3, 6, and 9 store the sampling values of the same signal at different times. By adding the results of these 4 buffers and then shifting them right by 2 bits, the 4-time average digital filtering of the signal can be achieved. The other two signals are stored in the related ADCBUF and the processing method is the same. [page]
The SPI interface of MCP2515 supports 0,0 and 1,1 operation modes. External data and commands are transmitted to the device through the SI pin, and the data is transmitted in at the rising edge of the SCK clock signal and transmitted out through the SO pin at the falling edge of SCK. After the CS chip select pin is set to low level, the first byte that MCP2515 hopes to receive is the instruction/command byte, which requires that when calling a command, the CS pin must be pulled high and then lowered to low level. Using the load TX buffer instruction, the 8-bit address required for the general write command is cancelled. Only one of the 6 addresses set by the address pointer can be selected to quickly write data to the transmit buffer.
The following takes the load TX buffer of MCP2515 as an example to illustrate the data transmission process. The timing of loading the TX buffer is shown in Figure 5. This application has 3 signals, and each signal requires accuracy to 2 decimal places, so the processed data format uses floating point type. A floating point number takes 4 bytes. In order to make the monitoring center easy to manage, a standard data frame containing 4 bytes of data length is used to send data. Now, a data transmission operation is described by taking loading TX buffer 0 as an example, as shown in FIG6 .
The SPI module of dsPIC30F3013 has two optional working modes: 8-bit and 16-bit when sending and receiving data. The SPI instructions, internal register addresses and data of MCP2515 are all 8-bit, so when initializing the SPI module, clear MODE16 (SPI1CON<10>) to configure the communication data to 8-bit width.
Conclusion
This article introduces a data acquisition system with Microchip's dsPIC30F3013 as the control core, MCP2515 as the CAN controller and MCP2551 as the CAN transceiver. The system and the sensor form a CAN node, which effectively improves the current situation of wide-range, messy wiring and poor anti-interference ability of the monitoring part of the industrial control system. At the same time, it makes the entire monitoring system easier to expand. Practice has proved that this design is reliable and high-performance. However, when the system works in a thunderstorm area, lightning accidents may occur. In the subsequent design, a high-speed optocoupler will be used to isolate the CAN controller and the CAN transceiver.
Previous article:Embedded CAN Intelligent Node Based on PIC Microcontroller and Its Communication with PC
Next article:Application of microprocessor dsPIC33F in microcomputer protection device
- Popular Resources
- Popular amplifiers
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
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- 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!
- GD32E231 analog IIC driver HTS221
- Showing off my products + bargains I found on Double 11 + a few Nuvoton boards
- USB TypeC training PPT materials from Tektronix Labs Open Day are here. Download for a limited time to get a gift (including training videos)
- LIS25BA can record, but there is "interference"
- How to expand NorFLASH using IAR?
- STM32 interrupt priority explanation
- Explaining Infineon's largest acquisition in history: the $10 billion cash acquisition of Cypress
- I found a very good 51 single-chip microcomputer introductory tutorial book and recommend it to beginners. It is suitable for beginners to learn programming by themselves.
- MSP430 timer controls PWM output
- Types and processing methods of abnormal interrupts in ARM system