Train Communication Network IEC 61375 - 2 Real Time Protocols Process Variables
Real-Time Protocols 1. General Principles 2. Variables 1. Principle of cyclic Process Data broadcast 2. Traffic Stores principle and implementation 3. Process Variables and Datasets 4. Software structure 5. Application Layer Interface for Process Variables 6. Networking 3. Messages 1. Principle of Message Data communication 2. Link Layer Interface 3. Networking and Routing 4. Transport protocol 5. Software structure 6. Application Interface
TCN Data Traffic Two traffics share the same bus: Process Data Message Data short and urgent data items infrequent, sometimes lengthy carrying the trains's state messages reporting events, for: ... motor current, axle speed, operator's • Users: diagnostics, status commands,... • System: initialisation, down-loading, ... Since variables are refreshed Since messages represent state periodically, there is no need for changes, they may not get lost a retransmission protocol in a protocol recovers transmission case of transmission error. errors. Periodic Transmission Sporadic Transmission basic period basic period event time sporadic periodic sporadic periodic phase phase phase phase
Application Sight Of Communication Periodical Tasks Event-driven Tasks R1 R2 R3 R4 E1 E2 E3 Variables Services Message Services Traffic Store Queues (Process Data Base) Supervisory Message Data Process Data Data (destination-oriented) (Broadcast) station bus controller bus
Principle of Cyclic Source-Addressed Broadcast 1. General Principles 2. Variables 1. Principle of cyclic source-addressed broadcast 2. Traffic Stores principle and implementation 3. Process Variables and Datasets 4. Software structure 5. Application Layer Interface for Process Variables 6. Networking 3. Messages 1. Principle of Message Data communication 2. Link Layer Interface 3. Networking and Routing 4. Transport protocol 5. Software structure 6. Application Interface
Cyclic Data Transfer plant Poll List devices 1 2 3 4 5 6 bus master Address The master polls addresses in a fixed sequence, according to its Poll List. N participants Individual period 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 time [ms] The duration of each poll is the sum of 2 · Tpd the transmission time of address and data (bit-rate dependent) Address Data Address 10 µs/km (4) (4) (5) and of the reply delay of the signals (independent of bit-rate). time [µs] read transfer
Cyclic Operation Cyclic operation is used to transmit the state variables of the train. Periodically transmitted state variables are called Periodic Data. Periodic Data are transmitted at fixed intervals , whether they changed or not. Their delivery delay (refresh rate) is deterministic and constant. The bus is under control of a central master. There is no need for error recovery since a fresh value will be transmitted in the next cycle. Only states may be transmitted, not state changes. The cycle time is limited by the product of the number of data transmitted by the duration of each poll. (e.g. 100 µs /point, 100 points => 10 ms) To keep a low poll time, only small data items may be transmitted (<256 bits)
Optimizing Cyclical Operation Cyclic operation uses a fixed portion of the bus's time The poll period increases with the number of polled items The response time slows down accordingly Solution : introduce subcycles for less urgent data: 2 ms period 4 ms period 1 2 4a 8 16 1 4b 1 2 3 64 1 4a time 1 ms period 1 ms 1 ms (basic period) group with period 1ms Cyclic polling need tools to configure the poll cycles. Poll cycles should not be modified at run-time (source of non-determinism)
Subscription Principle A device exports many process data (state variables) with different priorities. If there were only one poll type per device, a device should be polled at the frequency required by its highest-priority data. Rather than poll a device, the master polls the process data. Each device is subscribed as source or as sink for a number of process data. Only one device may be source of a certain process data (collision). The replicated traffic stores can be considered as "caches" of the plant state. The application accesses them in the same way as a process database. The bus becomes an on-line data base. Each station monitors the bus and snoops the variables it is interested in . Each station needs an associative memory to recognize its variables.
Process Data Transmission Process Data are transmitted by source-addressed broadcast : Phase1: The bus master broadcasts the identifier of a variable to be transmitted: subscribed subscribed device device subscribed devices BUS devices MASTER sink source sink sink (slaves) BUS variable identifier Phase 2: The device which sources that variable responds with a slave frame containing the value, all devices subscribed as sink receive that frame. subscribed subscribed subscribed devices device device BUS devices sink source sink sink MASTER (slaves) BUS variable value
Traffic Stores cyclic cyclic cyclic cyclic algorithms algorithms algorithms algorithms application application application application cyclic poll 1 2 3 4 bus source master port Ports Ports Ports Ports Traffic Periodic Stores List sink sink port port bus bus bus bus bus controller controller controller controller controller bus port address port data The bus traffic and the application cycles are asynchronous to each other. The bus master scans the identifiers at its own pace. Bus and applications interface through a shared memory, the traffic store.
Traffic Stores 1. General Principles 2. Variables 1. Principle of cyclic Process Data broadcast 2. Traffic Stores principle and implementation 3. Process Variables and Datasets 4. Software structure 5. Application Layer Interface for Process Variables 6. Networking 3. Messages 1. Principle of Message Data communication 2. Link Layer Interface 3. Networking and Routing 4. Transport protocol 5. Software structure 6. Application Interface
MVB Traffic Store Implementation 12-bit port address 0 unused = 0 PCS Page0 Page1 0 trash trash 1 dock2 2 3 4096 dock4 4 entries 5 6 7 dock8 1234 8 9 port index 9 ... 4095 255 4 octets 8 octets 8 octets port index port control ports ports table & status odd page even page 4K ports 256 PCS 256 docks 256 docks x 1 octet x 4 octets x 8 octets x 8 octets = 4K octets = 1K octets = 2K octets = 2K octets
MVB Traffic Store, Ports And Docks Traffic stores are divided into Ports, each Port corresponding to one identifier A device has normally a small number of Ports (e.g. 256), but a supervisory device may have the full range of 4096 Ports. A Port may be up to 1024 bit wide (256bits on the MVB) A Port is divided into Docks of 32 bits for better memory usage. Its Port Control and Status register indicates if a Port is source or sink. The Port Index Table forms an associative memory, which indicates for each identifier if it is subscribed to that device, by pointing to the PCS. The former contents of a Port is overwritten (buffered, not queued). To provide simultaneous and consistent access by either application or bus, each Port is stored in two independent pages, written alternately. The PCS performs additional functions like freshness supervision and interrupt generation.
Freshness Supervision Process Data are not retransmitted explicitely in case of transmission error, they will be retransmitted anyhow at the next poll. The application must tolerate an occasional loss of data. To protect the application from using obsolete data, each Port in the traffic store has a freshness counter. This counter is reset by writing to that Port. It is incremented regularly, either by the application processor (BAP) or by the bus controller (MVBC). The application should always read the value of the counter before using the Port data and compare it with its tolerance level. The freshness supervision is evaluated by each reader independently, some readers may be more tolerant than others. Bus error interrupts in case of severe disturbances are not directed to the application, but to the device management.
Implementation of Port Control And Status (BAP controller) function code (size) reserved SRC SINK TMP Port Port Store Active Active Check Source Sink Octet size in 16 bit words IE3 IE2 IE1 IE0 Enable Enable Enable Enable Interrupt Interrupt Interrupt Interrupt 3 2 Event 1 Event 0 unused VP BNI TERR STO Valid Bus Not Transfer Slave Page Idle Error TimeOut T7 T6 T5 T4 T3 T2 T1 T0 sink time supervision counter The PCS depends both on the traffic store and on the bus controller
Traffic Store Access Restriction t1 t2 starts time ends writer reader 1 error ! (slow) reader 2 page0 traffic store page1 page 1 becomes valid page 0 becomes valid • there may be no semaphores to guard access to a traffic store (real-time) • there may be only one writer for a port, but several readers • a reader must read the whole port before the writer overwrites it again • this time is equal to the basic period in the worst case ( 1ms) • therefore, the processor must read ports with interrupt off.
Process Variables And Datasets 1. General Principles 2. Variables 1. Principle of cyclic Process Data broadcast 2. Traffic Stores principle and implementation 3. Process Variables and Datasets 4. Software structure 5. Application Layer Interface for Process Variables 6. Networking 3. Messages 1. Principle of Message Data communication 2. Link Layer Interface 3. Networking and Routing 4. Transport protocol 5. Software structure 6. Application Interface
all door closed lights on heat on air condition on Datasets It is economical to transport several variables in the same frame as a dataset. A dataset is treated as a whole for communication and access. A variable is identified within a dataset by its offset and its size Variables may be of different types, types can be mixed. Dataset binary variables analog variables wheel air line motor speed pressure voltage current 0 16 32 48 64 66 70 bit offset size
Variable Types Data representation may be different according to the processor (e.g. Intel's Little-Endians and Motorola's Big-Endians) However, there may be no ambiguity on the bus Therefore, each transmitted variable has a defined type associated with it. This type is agreed beforehand between the applications during configuration To guarantee consistency, the type of the variable is part of the variable's name TCN specifies a number of standard network variable types. The format obeys to the Big-Endian convention (most significant first)
Predefined Variable Types 0 = FALSE BOOLEAN1 1 = TRUE 10= forced 00 = network error ANTIVALENT2 11 = data undefined 01 = ok BITSETn (array of n boolean) INTEGERn (2's complement) SB SB = sign bit UNSIGNEDn FRACTIONALn 0 SB 2 REAL32 (IEEE) exponent SB mantissa ARRAY n OF CHARACTER8 char 0 char 1 TIMEDATE48... Application data types have been defined in ROSIN
Configuration Change And Errors Reconfiguring the whole bus to include new variables is normally not allowed in a running project, since this can affect the time behaviour of all applications. E.g. in the Train Bus, old coaches cannot be modified to consider new variables. It also may be that a variable is invalid when produced, e.g. by a defective unit. The producer may not modify the structure of data sets to exclude failed data Mechanisms are provided to protect against production and transmission errors: Freshness Supervision at reception Check Variable: production supervision Dedicated variables (Lifesigns) let all devices monitor the other's health
Check Variable TCN relies on the invalidation of stale data at the source through a check variable: TCN does not rely on a source freshness supervision value check publisher application subscriber application value check freshness value check set to 00 if stale or wrong source port sink port Traffic Store Traffic Store
Variable Extension And Invalidation To allow later extension, room is left in the datasets for additional variables. Since the type of these future data is unknown, unused fields are filled with '1". To signal that a variable is invalid, the producer overwrites the variable with "0". Since both an "all 1" and an "all 0" word can be a meaningful combination, each variable can be supervised by a check variable, of type ANTIVALENT2: Dataset variable value check correct variable 0 1 0 1 1 1 0 0 0 1 error 0 0 0 0 0 0 0 0 0 0 undefined 1 1 1 1 1 1 1 1 1 1 00 = network error chk_offset 01 = ok var_offset 10 = forced 11 = data undefined A variable and its check variable are treated indivisibly when reading or writing The check variable may be located anywhere in the same data set.
Example: Train Bus Frames Extension Vehicle Status Traction Status Cab Commands 40 octets 40 octets 48 octets locomotive with 1992 1995 free 1992 free 1992 free attended cab steering coach with 1992 free free 1992 free attended cab unattended 1992 1995 free free free steering coach locomotive with 1992 free 1992 free 1992 free unattended cab motor coach 1992 free 1992 free (no cab) coach (no cab, no 1992 free traction) old vehicles understand the new vehicle's 1992 data and ignore 1995 variables. new vehicles understand the old vehicle's 1992 data and ignore undefined fields.
PV_Name Each Process Variable is identified by a unique PV_Name dataset identifier (DS-Name) traffic port address size variable offset type check offset store 4 12 6 10 6 10 traffic n port address store PV_Name n+2 size bit_offset type check_offset n+4 this is how it look in memory, independently if the processor is little-endian or big-endian. To each variable, the application associates a value location and a check location Sink variables have in addition the freshness argument
Scope Of The PV-name traffic offset dataset store 1234 8 3 device x device y 8 1 1234 application application application B C traffic A dataset offset store traffic store1 traffic store2 traffic store3 traffic store1 bus 1234 process data frame (dataset) 8 1234 port offset the port identifier and the offset within the port identifies a variable within a bus or within a traffic store
Process Variables Instances publisher application instance device traffic store instance bus instance bus subscribers application instances applications device device There exist a number of (inconsistent) instances of the same Process Variable
Software Structure For Process Variables 1. General Principles 2. Variables 1. Principle of cyclic Process Data broadcast 2. Traffic Stores principle and implementation 3. Process Variables and Datasets 4. Software structure 5. Application Layer Interface for Process Variables 6. Networking 3. Messages 1. Principle of Message Data Communication 2. Link Layer Interface 3. Networking and Routing 4. Transport protocol 5. Software structure 6. Application Interface
Application Access To Process Variables Application Interface Application ap_ Program Application APA AVA Process Link Interface PTA lp_ Traffic Store dataset with a variable, its check variable and its freshness counter bus Link Process controller bus applications access the traffic store directly, as a shared memory. (there may be only writer for a given port)
Several Applications, One Traffic Store Application Program Application Application Program APA AVA Program APA AVA PTA APA AVA PTA PTA same process Traffic Store bus Link Process controller bus several processes may access the traffic store in parallel
One Application, Several Traffic Stores Application Application Interface ap_ Program APA AVA Link Interface lp_ PTA1 PTA2 traffic traffic store store 2 1 link link Link 1 Link 2 process 1 process 2 Bus 1 Bus 2
Access To Several Traffic Stores PV_Name traffic store port typesize var_offset port index table 2 traffic MVB store index traffic store descriptor PCS page 0 page 1 port index table 5 WTB PCS page 0 page 1
Forcing Variables can be forced individually for debugging and commissioning get/put force bus mask ports substitute ports even ports odd ports Port Index Table if a source variable is forced, its substitute value is copied to the bus and to every (local) application which reads it if a sink variable is forced, its substitute value is read by local applications, remote appplications are not affected
Forcing Operation port offset binary 1234:21 analog 1234:6 Mask Port 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 Substitute Port x x x x x x 1 0 1 0 1 0 1 0 x x x x x x x 1 x x x x x x Even Traffic Port 1 1 1 1 1 0 x x x x x x x x 1 0 1 1 0 1 0 0 1 0 1 0 1 0 Odd Traffic Port 1 1 1 1 1 0 x x x x x x x x 1 1 1 1 0 1 0 0 1 0 1 0 1 0 For each bit set to 0 in the Mask Port, the corresponding bit of the Substitute port is copied to the variable location
Application Interface For Process Variables 1. General Principles 2. Variables 1. Principle of cyclic Process Data broadcast 2. Traffic Stores principle and implementation 3. Process Variables and Datasets 4. Software structure 5. Application Layer Interface for Process Variables 6. Networking 3. Messages 1. Principle of Message Data communication 2. Link Layer Interface 3. Networking and Routing 4. Transport protocol 5. Software structure 6. Application Interface
AVA Procedures individual access apd_put_variable (pv_name, producer) write a variable apd_get_variable (pv_name, consumer, check) read a variable apd_force_variable (pv_name, substitute) force a variable to a value apd_unforce_variable (pv_name) restore bus communication apd_unforce_all same for all variables apd_init initialize traffic store cluster access ap_put_cluster (pv_list) read a cluster of variables ap_get_cluster (pv_list) write a cluster of variables pv-set access ap_put_set (pv_list) read a set of variables ap_get_set (pv_list) write a set of variables dataset access (link layer) ds_received (ds_name) signals reception of dataset signals emission of dataset ds_sent (ds_name) ds_subscribe_sent (ds_name, sent_ind) corresponding subscriptions ds_subscribe_received (ds_name, received_ind)
Individual Access Variable may be accessed individually, together with their check variable Variable may be forced individually to a certain value (for test purpose) publisher subscriber application application local local substitute substitute p-instance s-instance apd_force apd_put_var apd_get_var apd_force lp_init apd_unforce apd_unforce lp_init sink port traffic store traffic store sink port source port bus transfer ( triggered by master) apd_put_variable apd_force_variable apd_get_variable apd_unforce_variable
Individual Access Procedures data structures struct STR_ APD_PV_NAME struct STR_ APD_PV_DESCRIPTOR (TYPE_APD_PV_NAME) (TYPE_APD_PV_DESCRIPTOR) (ds_name) ts_id prt_addr ts_id prt_addr (pv_format) (APD_PV_NAME) size size val-offset val-offset type type chk-offset chk-offset p_var points to variable (void *) p_chk points to checker (void *) procedures TYPE_APD_RESULT apd_get_variable( const struct STR_PV_DESCRIPTOR* var, unsigned short* fresh) TYPE_APD_RESULT apd_put_variable( const struct STR_PV_DESCRIPTOR* var) example: my_result = apd_get_variable( &apd_cpu1_b1, &frs_cpu1_t1)
Cluster Access Procedures It is fast and convenient to access groups of variables, from different ports. publisher export import subscriber cluster list application cluster list application PV loc_adr PV loc_adr local local output input variable variable apd_put_cluster apd_get_cluster apd_put_set apd_get_set APA APA source port sink port Traffic Store Traffic Store bus transfer
PV_Set A PV_set groups variables of the same port data structures struct STR_ APD_PV_DESCRIPTOR (TYPE_APD_PV_DESCRIPTOR) ts_id prt_addr (APD_PV_NAME) size val-offset type chk-offset array of pv_descriptors p_var (void *) p_chk (void *) procedures TYPE_APD_RESULT apd_get_set( const struct STR_PV_DESCRIPTOR* pvset, unsigned short* fresh, int nr_variables) TYPE_APD_RESULT apd_put_set( const struct STR_PV_DESCRIPTOR* pvset, int nr_variables) example: my_result = apd_get_set( &ads_cpu1_t1, &frs_cpu1_t1, 5)
Dataset Access Procedures struct STR_ APD_DS_NAME (TYPE_APD_DS_NAME) array of dataset identifiers for refresh timer ts_id prt_addr To supervise their freshness, data sets are grouped in a time-out set With the BAP, the set must be explicitely refreshed. This operation is not needed anymore with the MVBC.
Synchronization Ports of a traffic stores can be configured to raise an interrupt when addressed for sending or for receiving. This feature is not intended to transmit Process Data by events, but to synchronize applications, e.g. for time distribution. The same mechanism is used for message data To this purpose, an application subscribes a procedure to the bus, which will be called when the port is written (or read). DS_NAME apd_subscribe apd_desubscribe DS_NAME apd_pass_subscription DS_NAME
Process Data Networking from T1 All busses operate cyclic train bus process data frames T1 frame cyclically. from T2 T2 frame Train Bus gateway gateway sink ports source ports sink ports source ports import export import export list list list list gateway filters & forwards Process Data = application-dependent marshalling source ports sink ports source ports sink ports Vehicle Bus Vehicle Bus stop The total delay is the cyclic polling speed cyclic polling speed sum of 5 delays: 2 gateway delays and 3 bus delays stop