Design of the most popular SPC3 protocol chip

2022-08-08
  • Detail

Using SPC3 protocol chip to design PROFIBUS

Introduction

IEC of the International Electrotechnical Commission voted to adopt the international standard of Fieldbus IEC61158 on January 4, 2000. IEC61158 includes seven fieldbus standards. Pro will realize the first production and marketing of high molecular composite materials for automobiles in China for Xinda and officially join IEC61158 as type 3. The structure of profirus protocol is based on the Open System Interconnection Reference Model OSI of iso7498 international standard

profibus consists of two or three parts: PROFIBUS · FMS, PROFIBUS DP and profibus-pa. FMS is mainly used for workshop level control network, which is a token structure and real-time multi main network. DP is a high-speed and low-cost communication connection, which is used for equipment level control system and decentralized communication; PA is specially designed for process and has intrinsic safety specifications. Here, we mainly introduce the PROFIBUS-DP (distributed process) protocol. PROFIBUS-DP uses the first, second and user interfaces of the 0SI reference model, and the third to seventh layers are undefined. PROFIBUS-DP is mainly used for high-speed data transmission at the sensor and actuator level. It is based on the first part of DLN 19245. The master station periodically reads the input information of the slave station and periodically sends the output information to the slave station. How can it respond in hundreds μ S ~ hundreds of MS, the data transmission rate is 96 Kbps ~ 12mbps, the data capacity transmitted is up to 244 bytes per message, and the transmission medium is shielded twisted pair or optical fiber, etc

this paper mainly discusses the method of developing intelligent slave by using the slave protocol chip of slemen. The block diagram of intelligent slave is shown in Figure 1. It includes microcontroller, watchdog, EEPROM, SPC3, photoelectric isolation, driver and dial switch, etc

1 SPC3 protocol specific chip

1.1 SPC3 main technical indicators

◇ support PROFIBUS-DP protocol

◇ the maximum data transmission rate is 12mbps, which can automatically detect and adjust the data transmission rate

◇ compatible with 80C32, 80x86, 80c165, 80c166, 80c167 and HCII, hcl6, hc916 series chips

◇ 44 pin PQFP package

◇ can independently process PROFIBUS-DP communication protocol.

◇ integrated watchdog (WDT).

◇ external clock interface 24MHz or 48mhz

◇ 5V DC power supply

1.2 introduction to the internal structure of SPC3

spc3 is an intelligent communication chip developed for slave stations. It supports PROFIBUS-DP protocol. SPC3 is internally integrated with 1.5kb dual port RAM. Internal latches/registers are located in the first 21 address units. It mainly includes mode register L, 0, interrupt control register, status register, and status registers of input, output buffer and diagnostic buffer

tissue parameters are located in RAM units starting from 16h. The whole buffer structure (belonging to DP SAPS) is written based on these parameters. In addition, common parameters set data in these units (including station address, address allowed to change, user watchdog value, equipment identification number, etc.). The status display is stored in these units (general control commands, etc.)

the user buffer area is located in the unit starting from 40H. Among them, the mode register o sets the operation mode of PROFIBUS-DP, such as sync, free, etc. The mode register 0 must be assigned in the offline state and cannot be modified once powered on. Mode register 1 can set and reset each bit after power on

spc3 has 14 interrupt sources. Each interrupt source has no priority - it realizes interrupt through interrupt mask register and interrupt response register. However, "new parameter data" interrupt and "new configuration data" interrupt can respond without interrupt response register. The polarity of the interrupt signal is set by the user

diagnosis is divided into external diagnosis and state diagnosis. In case of external diagnosis, the user must write user data in the unit starting from the 7th byte. In case of status diagnosis, it is only necessary to write 00h in the 1st byte without filling in the user data starting from the 7th byte

the address number of the slave station can be fixed or set by the master station. If the station address number cannot be changed, in the initialization phase, make "real no add change=0ffh" "r-ssa buf-ptr=00h"

the user watchdog counter is an internal memory unit of L 6 bits, and the initial value is determined by R user WD_ The value unit is given. For each data message received, the counter will decrease by L. When it is reduced to 0000H, SPC3 enters the state of "waiting for parameterization", and DP state machine executes the command of "leaving the master station"

in addition, SPC3 also integrates a watchdog counter after the machine is applied for a period of time. It can work in three different states: baud rate monitoring, baud rate control and DP control. SPC3 can automatically identify the bus baud rate (9.6kbps ~ 12mbps)

1.3 SPC3 hardware circuit design

cpu uses AT89S52 and adopts Intel working mode. The interface circuit between CPU and SPC3 is shown in Figure 2

for AT89S52, SPC3 is equivalent to an external RAM it expands. Moreover, SPC3 has an internal address decoding circuit. Therefore, ab8 ~ ab10 are grounded. At this time, db7~db0 is the data address multiplexing bus. It can generate the data and address of the lower 8 bits, the address of the upper 4 bits is generated by Ab0 ~ AB3, and the chip selection signal of SPC3 is generated by ab4 ~ AB7. SPC3 is selected only when ab4 ~ AB7 are both 0. In Figure 2, the chip selection signal of SPC3 is 1000h, and the internal RAM of SPC3 is located in 1000h ~ l5ffh units. The development of this slave station adopts assembly language programming. It occupies less memory units and does not need to expand external RAM. If you program in C language, you must expand enough ram or use a CPU with enough ram

it can be seen from Figure 2 that one side of RS485 bus driver is connected with 9-pin D-type plug-in eagle. The other side is connected to SPC3 through optocoupler. At present, the drive chips that can meet the baud rate of 12m BP s include Sn 65al s176, sn65alsi 176, sn75asll76, adml-485, sn65hvdl 176, etc. photoelectric isolation is mainly used to eliminate interference from the outside world. The optocouplers that can meet the baud rate of 12mbps include hcpl77720, hcpl0720hcpl772l, hcpl072l, hcpl7710, etc. In addition, isolation measures shall also be taken for the power supply, such as adding transformer for isolation or using DC-DC module

2 PROFIBUS-DP state machine

according to the PROFIBUS-DP protocol, the state machine of PROFIBUS-DP describes the behavior of DP slave station in each case to ensure its consistency. SPC3 has an internal integrated state machine. The user's control of the state machine is very limited. The state machine of PROFIBUS-DP is shown in Figure 3

in power_ In the on state, the slave station can receive the set slave add message from the class 2 master station to change its address, and then enter the wail from the slave station_ P RM status, waiting for parameterization. The slave station in this status can also receive get_ CFG and slave_ Dlag message. After parameterization, enter the wait from the station_ CFG status, waiting for chk_ CFG message. In addition, slave can be received_ Diag、Set_ PRM and get_ CFG message. If chk_ After CFG is completed, the slave station will enter data_ Exch status. Data communication. At this time, the slave station can also receive writing_ Outputs、Reading_ lnputs、Global_ Control、Slave Diag、Chk_ Diag and get_ CFG message, if the configuration and data exchange are not successful, will return to the parameterization stage. Wait_ When PRM configures the slave station, it must write its GSD file. The so-called GSD is the function function (such as I/O points, diagnostic information, baud rate, time monitoring, etc.) provided in the form of electronic device database file in order to integrate different PROFIBUS products together. Only the GSD file can be configured for the slave station under the comproflbus configuration software, otherwise the master station cannot recognize the slave station

3 software design

the software operation of SPC3 mainly includes two parts: SPC3 initialization and SPC3 interrupt processing. The flow charts of main program and interrupt program are shown in Figure 4 and figure 5 respectively

spc3 initialization program should be placed in front of the main program, and the interrupt processing program completes the CPU's response to SPC3 interrupt output. After SPC3 is powered on and reset, initialization must be carried out before normal operation to configure each register. The interrupt handler is used to handle various events occurring in SPC3, including new parameter message events: global control command message events, entry or exit data exchange status events, new configuration message events: new address setting message events; Baud rate events and watchdog overflow events are detected. Data input and output processing (input and output relative to the master station) and user diagnostic data input can be placed in the main loop of the application. In an application cycle, the application refreshes the data in the input buf to ensure that all input data is the latest updated data. When SPC3 receives different output data transmitted by the Profibus master station, it will generate output flag bits (also located in the interrupt request word unit), and the CPU will receive the master station data by polling the flag bits in the application cycle. Diagnostic information for specific applications needs to be transmitted to the master station in real time. The main application determines whether there is an available diagnostic buf in the application cycle. When there is an idle buf, the application enters diagnostic information and requests an update. For systems with strict real-time requirements, interrupt mode should be used to process output data and diagnostic data

4 introduction to GSD file

pro flbus devices have different performance characteristics. In order to achieve a simple plug and play configuration of PROFIBUS, the characteristics of PROFIBUS devices are specified in the electronic device database file (GSD). Standardized GSD data extends communication to the operator control level. Using the configuration tool based on GSD, the equipment produced by different manufacturers can be integrated into the same bus system. It is simple and convenient for users. 3 Torque measurement range: 1% ⑴ 00% friendly

4.1 composition of GSD file

gsd file can be divided into three parts:

◆ general specification this part includes the name of the manufacturer and equipment, the version status of hardware and software, the baud rate supported, its intermediate interval during possible monitoring, and the signal distribution of the bus plug

◆ specifications related to DP master station. This part includes various parameters only applied to DP master station (such as the maximum number of connected slave stations or upper and lower loading capacity). There are no regulations on the slave station in this part

◆ specifications related to DP slave station this part includes all specifications related to the slave station (such as the number and type of input/output channels, the specifications of interrupt test and the information of input/output data consistency)

4.2 GSD file format

gsd files are ASCII files. You can use any kind of ASCII files, such as Notepad, UltraEdit, etc. you can also use the program gsdedit provided by PROFIBUS user organization. GSD file is composed of several lines, each of which starts with a keyword, including keywords and parameters (unsigned numbers or strings). The keywords in the GSD file can be standard keywords (defined in the Profibus standard) or custom keywords. Standard keywords can be recognized by any PROFIBUS configuration tool, while custom keywords can only be recognized by specific configuration tools

an example of a GSD file is as follows

#Pr0fibus DP ; The GSD files of DP equipment all exist with this key

gsd revision=1; GSD file version

vendorname= "Meglev"; Equipment manufacturer

model name= "DP slave"; Product name, product version

revision= "version 01"; Product version number (optional)

revisionntmber=01; Product identification number

idemnumber=0x01; Protocol type (indicating DP)

protocoi ident=0; Station type (0 means slave station)

stationtype=0; FMS is not supported. Pure DP slave

fms supp=0; Hardware

Copyright © 2011 JIN SHI