This manual shortly introduces the INTERAY IP-PROFI controller and the VxWorks version driver for it. Describe the principle of the PROFI CDI Driver and hints for its VxWorks user and EPICS user.
If you want add some new objects to an existing station, need only add more records to your EPICS database file.
If you want add some new station to an existing Profibus system, modify the file crl.txt (section 6.2.2 Communication Relationship List).
If you want change the baud rate of the physical layer or IP slot to install the IP-PROFI module, modify the start-up script file "startup_link" (section 6.3 Modify the Configuration of Your Client Station).
If you need change local station address, you need modify the startup script file and crl.txt.
This module is equipped with INTERAY RAPI (Registered Application Interface firmware). With the RAPI firmware the module functions as a buffered Profibus network controller, where there is direct access to the Profibus network with some special features such as on-module error handling and Profibus message receive and transmit fifo's.
For Profibus Level 7 this IP module is only used as a transport layer (FDL and LLI), the Level 7 functions (FMS and FMA7) are implemented by the software package which runs on the host computer (see section 4.0). A software interface between the RAPI and level 7 functions is provided and has only three simple functions: init_profibus, profi_snd_req_res and profi_rcv_con_ind. (See next section)
This RAPI of IP-PROFI builds up two virtual devices (register sets) in shared memory for Profibus bi-direction data communication, one is Transmit-device PROFI_L7_TDEV (tdev) and another is Receive-device PROFI_L7_RDEV (rdev). As described, they can work in a buffered ( RAPI_FIFO) and interrupt mode (RAPI_IRQ). Here the tdev is configured as NO-FIFO mode and NO-INTERRUPT mode and the rdev is FIFO mode and polling mode (NO-INTERRUPT. Interrupt mode is not available for the current version.).
As rapi devices, they both use the shared memory (dual port memory) so that accessing any of the two virtual devices by user applications must be exclusive. For example, there are four logical Profibus communication links (CRL). Each link has a spawned task to send out read/write requests and to deal with confirmation back from Profibus partners. They will use the same RAPI device tdev/rdev for send/receive. To avoid conflict of using the tdev here using of a semaphore is a solution.
The IP-PROFI is an IP class 1 module, which can be installed in one of the four IP slots on CPU board MVME162 or a VMEbus IP carrier board such as BVME61. To link with the Profibus you need a Profibus connector and a 5V power supply for opto isolated transceiver on the IP module. One solution is to make a customized VME board using the VMEbus power supply with a DC-DC converter. Our home made VME board is shown on APPENDIX A. And the Profibus SUBD-9 connector pinouts is shown on APPENDIX B.
The init_profibus function is used to reset the IP-PROFI Profibus controller board and to initialize the RAPI interface, search PROFI_L7_TDEV and PROFI_L7_RDEV and modify attributes of them (e.g. RAPI_TFIFO).
The profi_snd_req_res function is for sending FMS requests and responses. The profi_rcv_con_ind function can be used for polling FMS confirmations and indications. Both of them use RAPI interface (tdev and rdev) to communicate with Profibus partners.
Applications, which are waiting for confirmations to their requests, have to call the receive function to polling the RAPI receive buffer (rdev) periodically. Because of the polling mode of rdev they must suspend themselves for a while if no confirmation received yet.
Available FMS & FMA functions in this library are following:
fma7_event_ind();
fma7_profi_exit();
fms_initiate_req();
fms_initiate_cnf();
fms_initiate_ind();
fms_vfd_identify_req();
fms_vfd_identify_cnf();
fms_vfd_identify_ind();
fms_abort_ind();
fms_reject_ind();
fms_getov_req();
getovCnf();
fms_getov_ind();
fms_read_req();
readCnf();
fms_read_ind();
fms_write_req();
writeCnf();
fms_write_ind();
fms_status_req();
fms_status_cnf ();
CDI contains two parts, CDI servers and CDI users.
CDI server is a hardware dependent device driver, which waits for CDI commands from CDI users and executes these commands for data communication.
CDI user can be EPICS or any vxWorks applications. The most basic commands sent to the CDI server are REGIST, READ and WRITE. The most basic CDI functions are CDI_OPEN, CDI_CLOSE, CDI_IO and CDI_FAST_IO.
CDI supports multi-users and multi-cpus.
For details about CDI please read document "CDI Common Driver Interface User Reference Manual".
To describe an Profibus object (variable) needs a number of parameters, such as variable name, variable index, communication reference number (cr) used, data type (e.g. integer 16/float.), obj_code (e.g. Simple-Variable/Array-Variable.), length and so on.
The key of profi access is the cr (comm. ref.) and index (variable's index number), which are given in each EPICS database record. And all others can be got from its source station by function get_ov of profi level7 FMS service.
To support these features there are three kinds of tasks: CDI server task, wait for Profibus confirmation task and send request to Profibus and confirmation handler task.
PROFI_CC_REGIST, PROFI_CC_READ, PROFI_CC_WRITE
Before read/write a Profibus object use PROFI_CC_REGIST command to register a variable during initialization time of EPICS database records or others. All these three commands will be distributed to its service task according to their CR (logical link used) by means of vxWorks message queue mechanism. Each CR has one service task and so one message queue to get command and other message from the main CDI server task. The write operation has a higher priority than the read operation. And all read operations have the same priority. They will be passed in the request-message queue in a FIFO type except the write command.
So that each profibus logical communication connection has one task to send request to Profibus partner and to handle the correlative confirmation from another end of this connection. It is waiting for CDI commands sent by CDI server task through the request-message queue and waiting for confirmation message sent by the task below through the confirmation-message queue after send out the request. All other in indications or confirmations are handled by the task bellow.
The message flow between tasks is as follows:
CDI user ----> CDI server task ---> reqAndCnfTask ---> ProfibusCDI user <---- reqAndCnfTask <--- waitForCnfTask <---- Profibus
The configuration of a Profibus client station, which uses an IP-PROFI module as the Profibus interface, consists of the following actions:
0000,0000 - 007f,ffff (8 Mb) inboard memory
0080,0000 - efff,ffff VMEbus Master (A32/D32)
f000,0000 - f0ff,ffff F0 page (A24/D16) for BVME61 IP Carrier or IPIC
f0c0, 0000 - f0c7,ffff (512 Kb) IP_profi a
f0d0, 0000 - f0d7,ffff 512 Kb) IP_profi b
f0e0, 0000 - f0e7,ffff (512 Kb) IP_profi c
f0f0, 0000 - f0f7,ffff (512 Kb) IP_profi d
You need check the startup file if the slot number is the same as you installed
(see section 6.3).
The software will initiate the interface and configure it as a Profibus partner.
The software now is compiled for using 162 as an IP carrier. If you have to use a VME- bus IP carrier board, you need to change the macro CFLAGS to define BVME61 in the "Makefile" under directory ./interay/level7/engkit/ and re-make it.
If the IP module installed in one of the four IP slots in 162 CPU board, the software will invoke routine IPIC_init_profi() to initialize the chip IPIC according to the slot number and invoke routine VMEchip2_init() to re-initialize the VMEchip2's registers, disable to use the F0 page for VMEbus, which will be used by IPIC for IP_PROFI's memory.
The baudrate of all communication partners on the same bus must be the same. The available baudrate are 9.6/19.2/93.75/187.5/500 KBaud. And the address of local station must be unique on the same bus. The firmware will check it and you will get a error message if it is conflict with some others. For details please read the SECTION 1 "BUS PARAMETERS" of the manual "PROFIBUS CONFIGURATION PARAMETERS".
All bus parameters used here* are shown in the table 1.
TABLE 1. Bus Parameters
| BAUD Rate | Slot Time | Quiet Time | Min. Station Delay Time | Max. Station Delay Time | Setup Time | Target Rotatio n Time | Gap Update Factor | Max.Retry Limit |
| 9600 | 200 | 0 | 10 | 10 | 2 | 5000 | 2 | 2 |
| 19,200 | 400 | 0 | 10 | 14 | 4 | 9000 | 2 | 2 |
| 93,750 | 744 | 2 | 95 | 140 | 160 | 93750 | 1 | 2 |
| 187,500 | 2000 | 0 | 10 | 132 | 40 | 2500 | 20 | 2 |
| 500,000 | 4000 | 0 | 10 | 350 | 55 | 20000 | 20 | 2 |
* Now we use baud rate 93750.
25 25 24 255 7 0 0 0 32 3 1 3 60000 0 220 220 220 220 0x58 0x30 0xd8 0 0 0 0 0 0
The meaning of the values - in the same order - are:
;CR LSAP REMADDR REMSEGM DSAP TYPE LLI CONNATT SCC RCC SAC RAC CI MULT PDUSH PDUSL PDURH PDURL FMS0 FMS1 FMS2 FMS3 FMS4 FMS5 VFD-NO SYMNAME EXTEach connection needs a list like the up one. And all items need to be checked on both sides, local and remote station, carefully.
Some profibus devices have special relationship between station-address, sap and cr. For example, the device Unigyr from Landis & Gyr Building Control AG uses following algorithm:
KR: 2..33; TS = Address of local station; LSAP = KR; DSAP = TS + 1; Rem_ADD = KR -1; e.g. Client station Unigyr station station_addr = 6 station_addr = 24 CR 25: LSAP = 25 CR 7: LSAP = 7 Rem_ADD = 24 Rem_ADD = 6DSAP = 7 DSAP = 25
Most of the object description information can get from its source station by the fms7 function `get_ov' over the bus.
Get OD here can only by index because some devices do not support access_by_name.
Own SCC <= partner's RCC Own SAC <= partner's RAC
If partner's RCC=1 and RAC=0 e.g. SIEMENS SINEC (CP 5431 FMS, CPLL 928) means the maximum number of confirmed requests supported by partner is 1 and the partner does not support unconfirmed request. Then own station's SCC must be 1 and SAC=0. The own RCC must be greater than or equal to 1 if your station wants to support FMS/FMA7 indication. The own RAC can be 0 if your station does not support unconfirmed request/indication.
If the features supported are set higher than available, you will get Reject Indication, remote or local when you try to use it. For example, Remote station does not support Long Form Get-OD but you set FMS0=0X80. And if you want to be able to WRITE and READ the remote partner the FMS1 must be set to 0x30 and the remote one of course, should support the minimum service. [1]Page 3-11
These will be checked at connection set-up time (fms INITIATE).
If CI or SCC or SAC is not correct, you will get ABORT INDICATION, remote LLI context check negative.
void profi_generic_driver(
char *name, /* CDI device name */
USIGN16 role, /* 0: client, 1: server */
USIGN16 ip_slot, /* ip slot number: 0..3 */
USIGN16 Irq, /* intVector */
INT16 rate, /* 0..4 */
USIGN16 stationAddr) /* Profibus station address 0..HSA */
So this station is configured as:
Analog In (ai), Analog Out (ao), Long In (li), Long Out (lo)
The CDI device name for IP-PROFI module is " H1_0_B".
The device support routine for H1supports four EPICS record types: ai, ao, longin and longout. The new database should never use again the wi/wo record type, which are DESY exclusive.
The data type of a Profibus ai/ao object can be FLOAT too, but in this case no conversion will be done because the type of RVAL field is LONG integer and the type of VAL field is DOUBLE. In order to support FLOAT data transfer with PROFI/H1, the device support routine for ai copies return data directly to the VAL field and set NOCONVERT. For ao copies the output data in VAL field to output directly.
Remarks: present Profibus devices do not support DOUBLE type.
Following is an example when selected the "SINEC H1" as Device Type ( DTYP):
Enter Field Bus Info:
remote station addr.: 1 remote LSAP: 5 local LSAP: 6 local station addr.: 6--- local CI (Control Interval) is not identical with remote CI ---
INITIATE 0x7b5c40 (demo): Abort Indication //6.1.2 (FMS context man.) Abort 0x7b5c40 (demo): local : 0 // 0:remote 0x7b5c40 (demo): id : 2 // LLI 0x7b5c40 (demo): reason : 0 // LLI context check neg., remo te context in AD --- change rem_lsap of kbl to a not exist one (5->6) --- INITIATE 0x7b5c40 (demo): Abort Indication 0x7b5c40 (demo): local : 255 0x7b5c40 (demo): id : 3 0x7b5c40 (demo): reason : 3 //service not activated at remote sap on remote station there is no this sap service --- change comm_ref from KR(2) -> 3 (not exist) INITIATE 0x7b5c40 (demo): Abort Indication 0x7b5c40 (demo): local : 255 0x7b5c40 (demo): id : 1 //FMS 0x7b5c40 (demo): reason : 1 //user error FMS can not find the comm_ref table. --- change rem_add of kbl to 4 (not exist) -- INITIATE 0x7b5c40 (demo): Abort Indication //p6-10 0x7b5c40 (demo): local : 255 //Local 0x7b5c40 (demo): id : 3 //FDL 0x7b5c40 (demo): reason : 17 //no reaction from remotestation FMS can not find this station.
with wrong PDU size and Supported_features
---- set buffer size of rcv smaller than snd ---
kbl_req.id.kbl_static.max_pdu_snd_low = (USIGN8) 241;
kbl_req.id.kbl_static.max_pdu_rcv_low = (USIGN8) 200; /*MAX_FMS_
PDU_SIZE;
INITIATE
0x7ab9c0 (tShell): Negative initiate confirmation
0x7ab9c0 (tShell): error class code: 1
The error is different from the error caused by not identical in CI.
--- set supported_features = 0 0 0
READ VARIABLE 2 times...
0x79aaf0 (demo): Reject Indication
0x79aaf0 (demo): local : 255 //local
0x79aaf0 (demo): invoke id : 0
0x79aaf0 (demo): pdu type : 1 //confirmed request PDU
0x79aaf0 (demo): reason : 3 //feature not supported connection
oriented
--- set supported_features = 0 0x20 0
kbl_req.id.kbl_static.max_scc = (USIGN8) 0; /*MAX_S
CC;*/
kbl_req.id.kbl_static.max_rcc = (USIGN8) 1; /*MAX_RCC;*/
READ VARIABLE 2 times...
0x7b5c40 (demo): Reject Indication
0x7b5c40 (demo): local : 255
0x7b5c40 (demo): invoke id : 0
0x7b5c40 (demo): pdu type : 1
0x7b5c40 (demo): reason : 2 //maximum service overflow
max_scc = 0 means as a client the number of confirmed_request sent is 0!
change to 1. (OK!)
--- negative initiate confirmation when connect to the new profibus
station (UNIGYR) ---
INITIATE Communicate Connection (cr: 25)...
0x7aad88 (tShell): Negative initiate confirmation. (comm_ref: 25)
0x7aad88 (tShell): error class code: 1
use vxgdb to check the confirmation package:
(vxgdb) print *init_err_cnf
$5 = {
class_code = 1,
snd_len_h = 220 `\334',
snd_len_l = 220 `\334',
rcv_len_h = 220 `\334',
rcv_len_l = 220 `\334',
supported_features = {0,0,0,0x58,0x30,0xd8}
}
modify /applic/test/heravme50/DATABASE/crl.txt and then OK!
---- disconnect the profi cable (will cause bus timeout)--- 0x7b5c40 (demo): --- Initiate load kbl... 0x7b5c40 (demo): FMA7 Event Indication //7.1.10 FMA7-Event 0x7b5c40 (demo): comm_ref: 0 0x7b5c40 (demo): id : 3 //FDL (layer 2) 0x7b5c40 (demo): reason : 3 //timeout on bus detected INITIATE 0x7b5c40 (demo): Abort Indication //p6-10 0x7b5c40 (demo): local : 255 //Local 0x7b5c40 (demo): id : 3 //FDL 0x7b5c40 (demo): reason : 17 //no reaction from remotestation
Create three EPICS database records: profi_sinec0_li (LongIn), profi_sinec0_calc (Calculation) and profi_sinec0_lo (LongOut).
The li record reads a word from the profi partner SINEC module and adds one by the calc record and then sends it by the lo record. From the data value increased can find out the operation speed of the system.
Connect with one more station or use one more CR connection to the same data server station can find out the influence to the speed.
SCAN period: 0.01 sec.
Test time: 120 sec.
li readings: 1160
lo writings: 1160
I/O rate: 2*9.65/sec (19.30 /sec)
SCAN period: 0.1 sec.
I/O rate: 2*9.3 /sec (18.6 /sec)
CR2: profi_sinec0 li+calc+lo
CR3: svTestint16_ai
Test1: Scan period = 0.1 sec
CR2 I/O rate: 2 * 8.59 /sec (17.18 /sec)
CR3 I/O rate: 10 /sec
Total: 27.18 /sec
Test 2: CR2: Scan period = 0.01 sec
CR2 I/O rate: 2 * 8.92 /sec (17.84 /sec)
CR3 I/O rate: 17.87 /sec
Total: 35.71 /sec
Test 3: Add one variable reading to the cr2
CR2: + profi_sinec2_ai (0.1 sec)
CR2 I/O rate: (profi_sinec0 li+calc+lo) 2 * 5.86 /sec (11.72, slower)
CR3 I/O rate: 17.58 /sec (no big change)
Impression: the speed limit of one connection is 20/sec, which is decided by the
request--confirmation time. The bottle-neck perhaps is that the RAPI interface uses
scan-mode (interrupt mode is not available). The tick length of vxWorks is 1/60 second
(16.66 ms).
/applic/test/heraVME50/load/startup.profi
/applic/test/heraVME50/DATABASE/unigyr.database
CMF 12-09-96Do not read file "od_entries.txt" to get comm_ref and index information any more.
These information must be in your EPICS database files or short report files.
e.g.1 (unigyr.database)
(Field Bus Info) Line# : 0 Channel name : KL:P1:Frost_Wass Module name/Type : P1 Block/Module # : 23 Index/Offset # : 9346 length # : 4 e.g.2 (unigyr.report) INP #C0 V"KL:P1:Frost_Wass" M" " N23 I9346 W4 L0 H0