Overview

This page provides the User's Guide for the Pi-Plates DIGIplate. The DIGIplate is compatible with all of our other products (except the TINKERplate). And as many as eight DIGIplates can be stacked together to provide a maximum of 64 isolated, IEC61131-2 compliant inputs.

Board Layout

Getting Started

If you haven't already done so, visit the Getting Started page to set up the interfaces on your Raspberry Pi and to install the Python modules.

Address Selection

Locate the address selection header on the right side of the board and move the jumpers as shown below to select the desired address. If you only have a single DIGIplate, there is no need to change the address from the default value of 0.

Input Type Selection

The DIGIplate supports three different input types on each channel. These include IEC61131-2 type 2, IEC61131-2 type 3, and digital logic. Below is a summary of the measured characteristics of each input type:

Type VIH min/max VIL min/max IIH min/max (mA) IIL min/max (mA)
IEC61131-2 type 2 11/30 0/11 7/8 0/2
IEC61131-2 type 3 11/30 0/8 2/2.2 0/1.5
Digital 2.75/5 0/2.5 0.5/2.2 0/0.75

For more details on each mode, see the specifications section on the DIGIplate product page. When shipped, each input is set to type 3. To change the input type, locate the eight 2 X 3 headers that run horizontally across the board (the green outline in the photo at the top of this page). Use the following diagram to position the jumpers for each input type:

Connecting Inputs

The DIGIplate can be used with a variety of sensor output types. In the descriptions below, we show connection diagrams for each going into DIN6. For clarity, the labeling has been removed from the connector.

PNP

The majority of industrial digital sensors rely on a PNP output driver. To interface one of these to the DIGIplate, route the PNP output from the sensor to the positive input and connect the negative input to the ground lead from the sensor. The diagram below shows an example of this:

NPN

Many industrial sensors use NPN transistors on their output drivers. To interface one of these to the DIGIplate, route the power source for the sensor on the positive input (24V is shown in this example) and the NPN output from the sensor on the negative input. The diagram below shows an example of this:

Digital Logic

The DIGIplate also supports inputs from logic gates. After setting the Input Type jumpers to Digital, connect the output of the logic signal to the positive input and the negative input back to the ground of the device generating the signal. Ensure that your logic gate can source at least 2mA.

Open Drain

And finally, the DIGIplate can be driven by an open drain transistor. The connections for this setup are very similar to the NPN transistor. First, set the Input Type jumpers to Digital - this will allow high side voltage as high as 30 volts and as low as 3.3V. Then connect the open drain signal of the logic signal to the positive input and the negative input back to the ground of the device generating the signal. Ensure that your transistor can sink at least 2mA.

Functions

Definitions

addr: the DIGIplate has a set of jumpers on board that allow its address to be set to a value between 0 and 7.
bit: each DIGIplate has eight individually addressable input channels numbered 1 through 8 referred to as 'bits'.

Data Read

The DIGIplate supports two basic read functions:

getDINbit(addr,bit) - returns the value of the digital input on the specified bit input. The returned value is 1 for a high input and 0 for a low input.
getDINall(addr) - returns all of the digital inputs as an 8-bit number. Bit1 is the least significant bit (LSB) and bit 8 is the most significant bit:
—————————————————
|8|7|6|5|4|3|2|1|
—————————————————

In the example below, we perform a bit read of DIN4 ten times and measure the execution time followed by reading all of inputs ten times:

The output generated by the above script is:

pi@raspberrypi:~ $ python DIGIreads.py
Pi-Plate DIGIplate
Index: 0 DIN4: 1 Measurement Time: 0.0002932548522949219
Index: 1 DIN4: 1 Measurement Time: 0.00028204917907714844
Index: 2 DIN4: 1 Measurement Time: 0.0002810955047607422
Index: 3 DIN4: 1 Measurement Time: 0.0002815723419189453
Index: 4 DIN4: 1 Measurement Time: 0.0002791881561279297
Index: 5 DIN4: 1 Measurement Time: 0.00027942657470703125
Index: 6 DIN4: 1 Measurement Time: 0.0002791881561279297
Index: 7 DIN4: 1 Measurement Time: 0.0002799034118652344
Index: 8 DIN4: 1 Measurement Time: 0.000278472900390625
Index: 9 DIN4: 1 Measurement Time: 0.00027871131896972656
Index: 0 DIN all: 0x28 Measurement Time: 0.00030612945556640625
Index: 1 DIN all: 0x28 Measurement Time: 0.00028061866760253906
Index: 2 DIN all: 0x28 Measurement Time: 0.0002777576446533203
Index: 3 DIN all: 0x28 Measurement Time: 0.00027942657470703125
Index: 4 DIN all: 0x28 Measurement Time: 0.000278472900390625
Index: 5 DIN all: 0x28 Measurement Time: 0.000278472900390625
Index: 6 DIN all: 0x28 Measurement Time: 0.00027823448181152344
Index: 7 DIN all: 0x28 Measurement Time: 0.0002789497375488281
Index: 8 DIN all: 0x28 Measurement Time: 0.0002779960632324219
Index: 9 DIN all: 0x28 Measurement Time: 0.0002779960632324219

Note that the execution time for both functions is in the neighborhood of 3Khz which beats our specified value of 2Khz.

Events

The DIGIplate also supports a set of Event functions that signal the RPi when a change has occurred on one of the inputs. This eliminates the need to perform constant I/O reads of the DIGIplate which can potentially slow down other Pi-Plates on the stack. Instead, with event monitoring, the DIGIplate simply monitors a GPIO pin (GPIO22 - pin 15) for a low going signal. The following functions are provided for monitoring and responding to events:

eventEnable(addr) - DIGIplate will pull down on EVENT pin (GPIO22) if an enabled event occurs
eventDisable(addr) - DIGIplate will not assert events on GPIO22
enableDINevent(addr, bit, edge) - enable events for specified bit. The"edge" field requires a single character argument:
   'F' for falling edge
   'R' for rising edge
   'B' for both rising and falling edges
   Note that lower case characters are also allowed.
disableDINevent(addr, bit) - disable events on the specified bit
getEVENTS(addr) - returns the 16 bit EVENT flag register in DIGIplate. If enabled, the upper 8 bits indicate that a falling edge has been detected on a specific bit while the lower 8 bits will indicate that a rising edge has occurred.
   Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
   ———————————————————————————————————————————————————————————————————————————————
   | 8F | 7F | 6F | 5F | 4F | 3F | 2F | 1F | 8R | 7R | 6R |5R | 4R | 3R |2R | 1R |
   ———————————————————————————————————————————————————————————————————————————————
   Executing this function causes the DIGIplate to de-assert the event line (if enabled) and to clear the 16-bit EVENT flag register.
check4EVENTS() - reads the status of the enabled event pin and returns True if an event has occurred or a False if there is no change.

Using events requires a few extra lines of code which are shown in the example below:

We connected a 100Hz signal to DIN8 and ran the above script to produce the following output:

pi@raspberrypi:~ $ python DIGIevent.py
Pi-Plate DIGIplate
Sample: 1 Event Register: 0x80 Time between events: 0.006035
Sample: 2 Event Register: 0x80 Time between events: 0.010067
Sample: 3 Event Register: 0x80 Time between events: 0.009986
Sample: 4 Event Register: 0x80 Time between events: 0.010062
Sample: 5 Event Register: 0x80 Time between events: 0.009982
Sample: 6 Event Register: 0x80 Time between events: 0.009981
Sample: 7 Event Register: 0x80 Time between events: 0.009971
Sample: 8 Event Register: 0x80 Time between events: 0.01013
Sample: 9 Event Register: 0x80 Time between events: 0.009886
Sample: 10 Event Register: 0x80 Time between events: 0.010004

Note that because the state of the input signal is unknown at the start of the loop, the initial "Time between events" value is shorter than the ones that follow. The values reported after that are consistent with a 100Hz input clock.

LED Control

The green LED on the DIGIplate board can be controlled with the following functions:

setLED(addr) - turn on the LED
clrLED(addr) - turn off the LED
toggleLED(addr) - if LED is on, turn off. If LED is off, turn on.

System Functions

The DIGIplate supports the following functions that are common to all Pi-Plates:

help() - a helper function that shows all of the available DIGIplate functions along with a brief explanation
getID(addr) - return Pi-Plate descriptor string, "Pi-Plate DIGIplate"
getFWrev(addr) - return FW revision in decimal format
getHWrev(addr) - return HW revision in decimal format
getVersion() - returns revision of python module
getADDR(addr) - returns address of pi-plate. Used for polling available boards at power up.
RESET(addr) - set DIGIplate to power on state.