Examples - Siemens SIMATIC PCIe DIO4 Compact Operating Instructions

Table of Contents

Advertisement

Available languages

Available languages

Examples and register assignments

4.2 Examples

4.2
Examples
Example 1: Setting input filter for input 2
Input 2 is to be sampled with a period of 1 ms and a threshold value of 3. This results in the
following values:
● INP2C.FSRATE = 0xF
● INP2C.FTHRES = 0x1
● INP2C.ENF = 1
INP2C = 0x3D02
● Calculating the configuration address: INP2C = BASE + 0x200 + (2 * 8) = BASE + 0x210.
● Program INP2C with "0x3D02".
Example 2: Reading in input 2
The current input value (after optional filtering and inversion) is available in the INP register
(BASE + 0x100), bit 2.
Example 3: Setting output 1
Output 1 can be controlled with OUTP (BASE + 0x400), bit 1, if the output configuration for
output 1 has not been changed at address
OUTP1C (BASE + 0x500 + (1 * 8) = BASE + 0x508).
Example 4: Triggering interrupt at input 0 with rising edge
An interrupt is to be triggered with a rising edge at input 0. Enable the corresponding input
interrupt and the global interrupts as follows:
● Calculate the configuration address:
● Enable the input interrupt with rising edge:
● Enable the input interrupts and global interrupts:
Example 5: Treating an incoming interrupt
We recommend the following approach for incoming interrupts:
Determine the interrupt source by reading the GSR (GSR.IIF, GSR.OIF, GSR.CIF,
GSR.EIF):
● GSR.IIF: Evaluate INPIF, INPIFR and INPIFF and delete these interrupt flags through
● GSR.OIF: Evaluate OUTPIF, OUTPIFR and OUTPIFF and delete these interrupt flags
18
INP0C =BASE + 0x200 + (0 * 8) = BASE + 0x200
Set INP0C.ENREI, INP0C |= 0x04
Set GCR.IIEN and GCR.IEN, GCR |= 0x06
writing (INPIF = INPIF deletes all input interrupts).
through writing (OUTPIF = OUTPIF deletes all output interrupts).
Compact Operating Instructions, 11/2011, A5E03493449-01
SIMATIC PCIe DIO4

Advertisement

Chapters

Table of Contents
loading

Table of Contents