Profibus-DP communication interface based on MSP430 microcontroller

Publisher:清晨微风Latest update time:2010-10-22 Source: 现代电子技术Keywords:Profibus-DP Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

O Introduction

Profibus is an open standard that has nothing to do with manufacturers and has no intellectual property protection. Therefore, anyone in the world can obtain the standard and design their own software and hardware solutions. There are two options for the development of the Profibus-DP communication interface: single-chip microcomputer + software; single-chip microcomputer + Profibus communication chip ASIC.

In solution 2, the Profibus-DP protocol is completely implemented by the Profibus communication ASIC, and the microcontroller mainly processes the user program. Therefore, the development cycle of solution 2 is relatively much shorter. This article will use the microcontroller + Profibus communication ASIC to implement the design of the Profibus communication interface.

1 Basic characteristics of Profibus-DP

Profibus includes three compatible series: Profibus-FMS, Profibus-DP, Profibus-PA. FMS provides a large number of communication services for completing cyclic and non-cyclic communication services at medium transmission speed; DP is an optimized high-speed and low-cost communication connection, suitable for occasions with high real-time requirements, mainly used for communication between automatic control and distributed peripherals; PA is designed for process automation, has intrinsic safety, and is used in occasions with high safety requirements and bus-powered stations.

1.1 Protocol Structure

The Profibus-DP protocol uses the first layer (physical layer) and the second layer (data link layer) of the ISO/OSI model, removes layers 3 to 7, and customizes the user interface layer. This protocol structure ensures fast and effective data transmission.

1.2 Message Structure

Profibus-DP data encoding uses asynchronous non-return-to-zero system, and the no-load level of the transmission line is "1". In order to avoid data loss caused by conflicts during data transmission, a 33-bit (synchronous time) no-load state must be guaranteed before each request message is sent. There is no gap when all data is transmitted between single characters, that is, seamless. The formats of various messages are shown in Figure 1.


1.3 Profibus-DP slave state machine

Figure 2 is a simple diagram of the DP slave state machine. The various ovals represent different states, the lines with arrows represent the transitions between states, and the text on the lines represents the conditions that must be met for the state transitions.

Only in the Power_on state can the slave station receive the "Set_Slave_Address" message from the Class II master station to change the slave station address. The slave station should have a non-volatile memory to store the slave station address. After internal startup, the slave station enters the wait_Prm state and waits for the "Wait_Prm" message. The parameterization message is given by the user during configuration, including some standard information, such as identification number, synchronization locking capability, and some user-defined data. In addition, in this state, the slave station can also receive the "Get_Cfg" message and the "Slave_Diag" message, but refuses to process other messages and cannot communicate data. If Set_Prm is correct, the slave station enters the wait_Cfg state and waits for the "Check_Cfg" message, which specifies the master station's configuration information for it, that is, the number of input and output bytes in data exchange. In addition, the "Get_Cfg" message and the "Slave_Diag" message can also be received. When the parameterization and configuration communicate correctly, in this state, the slave can receive the following messages: Data_Exchange_Ok, Writing_outputs, Reading_Inputs, Global_Control, Slave_Diag, Get_Cfg, etc. After receiving the status request from the master, the slave responds with a high-priority diagnostic message. The diagnostic information includes standard diagnostic information and user-related information.

2 Communication Interface Hardware Design

The Profibus-DP communication protocol chip selected in this article is SPC3. SPC3 integrates all Profibus-DP protocols. SPC3 will complete all DP-SAP settings in DP mode. SPC3 integrates 1.5 KB of dual-port RAM, including parameter registers, mode registers, status registers, interrupt controllers, etc. The watchdog timer integrated in SPC3 has three working states: baud rate detection, baud rate control and slave control. The internal USART can realize the mutual conversion between parallel data streams and serial data streams. The micro-sequence controller controls the entire working process. The idle timer directly controls the timing of the serial bus.

Considering the speed requirements of Profibus, this paper selects the high-speed, low-power 16-bit MSP430 microcontroller and adopts the Intel working mode. The CPU and SPC3 interface circuit is shown in Figure 3. For the MSP430 microcontroller, SPC3 is equivalent to an external RAM that it expands. The microcontroller can access the register of SPC3 by accessing the external RAM. One end of the RS 485 driver is connected to SPC3, and the other end is connected to the bus through a 9-pin D-type plug. The RS 485 driver selects SN75SLS176 to meet high-speed data communication.

3 Communication interface software design

Software design is an important part of developing the Profibus-DP communication interface. Since SPC3 integrates the complete DP protocol, the MSP430 microcontroller does not need to participate in processing the DP state machine during communication. The main task is to transfer the data received by SPC3 according to the interrupt generated by SPC3, organize the data to be sent through SPC3, and organize external diagnosis according to requirements.

The main program flow chart is shown in Figure 4. Before SPC3 works normally, it needs to be initialized to configure the required registers, including setting the interrupt enable of the protocol chip, writing the slave identification number and address, setting the SPC3 mode register, setting the diagnostic buffer, configuring the buffer, address buffer, initializing the length, and deriving the pointers of each buffer and the auxiliary buffer according to the above initial values. According to the determination of the output buffer, input buffer and pointer, the initialization flow chart is shown in Figure 5. The initialization includes: SPC3 hardware reset, hardware mode, setting the SPC3 interrupt mask register, SPC3 internal watchdog, device identification number, and buffer initialization.

The interrupt program flow chart is shown in Figure 6. In Profibus-DP, the following interrupt events are mainly processed: new parameter message event, global control command message event, entering or exiting data exchange state event, new configuration message event, new address setting message event, baud rate detected event, and watchdog event.

4 Conclusion

The selected MSP430 microcontroller has the characteristics of high speed and low power consumption, and the SPC3 chip integrates all the Profibus-DP protocol content. The whole system function is relatively complete and the method of use is simple. This solution is used for the development of Profibus-DP communication interface, which can reduce the development cycle and simplify the development.

Keywords:Profibus-DP Reference address:Profibus-DP communication interface based on MSP430 microcontroller

Previous article:CRC algorithm and working principle
Next article:Design of resistive touch screen interface based on ADS7846

Recommended ReadingLatest update time:2024-11-16 16:32

Design of digital frequency meter based on MSP430F449
Abstract : This paper mainly introduces the performance characteristics of the MSP430F449 single-chip microcomputer. Combining the typical application of the pre-dual-mode divider SAB6456A and the high-speed digital divider 74HC390, this paper gives the hardware design and main program flow of the radio freque
[Microcontroller]
Design of digital frequency meter based on MSP430F449
Features of MSP430 MCU
Strong processing capability   The MSP430 series microcontroller is a 16-bit microcontroller that uses a reduced instruction set (RISC) structure, with a variety of addressing modes (7 source operand addressing, 4 destination operand addressing), concise 27 core instructions and a large number of simulation instructi
[Microcontroller]
MSP430 MCU 1602 LCD display program
MSP430 MCU 1602 LCD display program #include "msp430x22x4.h"  #define uint unsigned int  #define keyin (P2IN&0x0f) //Hardware connection P4 data port P3.7---E P3.6---RW P3.5----RS  //P2 lower 4 bits connected to keyboard 1*4 pull-up resistor power supply external power supply 5V common terminal connected to power ne
[Microcontroller]
MSP430G2553 WDT timer mode example
#include "MSP430G2553.h" int main( void ) {   WDTCTL = WDT_ADLY_1000; //The timing period is 1000ms    IE1 |= WDTIE; //Enable WDT interrupt    P1DIR |= 0x01; // P1.0 output    _EINT(); //Equivalent to _EINT(), system total interruption is allowed    while(1) //Loop waiting for timer overflow interrupt    {      LPM3
[Microcontroller]
MSP430F149 and 1602LCD module program
/*****************MSP430F149 and 1602LCD module program***************************/ /* ShangYu */     /**************************Pins defination***************************/ /* RS P4.4 register selection signal H-data register L-instruction register */ /* RW P4.5 read/write signal H-read L-write */ /* E P4.
[Microcontroller]
Photoelectric encoder position detection system solution based on MSP430F149 microcontroller
  1. Principle of photoelectric encoder   The photoelectric encoder is a digital sensor that integrates optical, mechanical and electrical technologies. Its basic principle is to arrange grating patterns on a special code disk according to a certain rule, read these patterns with a photoelectric head, and convert the
[Microcontroller]
Photoelectric encoder position detection system solution based on MSP430F149 microcontroller
Design of a multifunctional multi-rate three-phase electric energy meter based on MSP430F449 single chip microcomputer
1 Introduction   With the development of the national economy, the electricity consumption of enterprises and individuals has increased significantly. Now the electricity consumption time of users is relatively concentrated, so that the load curve of the power system varies greatly. In order to adjust the load curve
[Microcontroller]
Design of a multifunctional multi-rate three-phase electric energy meter based on MSP430F449 single chip microcomputer
Development of a multi-probe nuclear radiation dose rate meter based on MSP430
Abstract: In order to meet the requirements of portability and intelligence of nuclear radiation detectors, the software and hardware implementation methods of a multi-probe nuclear radiation dose rate meter with MSP430F169 single-chip microcomputer as the core are discussed. On the basis of introducing the entire s
[Microcontroller]
Development of a multi-probe nuclear radiation dose rate meter based on MSP430
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号