DIO stands for Digital Input/Output. It is a hardware device that receives or sends digital signals. Examples of applications that use DIO are alarms, control relays, fans, lights, horns, valves, motor starters, solenoids, etc. Recently I wrote a Python binding for the Axiomtek BSP to configure the DIO of EBOX, so that my AI program that runs on Python is able to control PLC through DIO.

Some industrial PC required users to enable and configure the DIO in BIOS first, but EBOX640-521-FL does not require users to enter BIOS to enable and configure DIO. Figure 1 shows the DIO pin number of EBOX based on Axiomtek BSP.

dio-pin-768x432
Figure 1: The DIO pin number of EBOX based on Axiomtek BSP

Step 0: Install the Axiomtek BSP (with Python bindings)

Please contact us to get a copy of this Python version Axiomtek BSP. The Axiomtek BSP that you found online only supports C code. Then follow the instructions in the README file to install.

 

Step 1: Load Axiomtek BSP

c_lib = ctypes.CDLL(“/usr/lib/libaxio.so”, mode = ctypes.RTLD_GLOBAL)
libname = pathlib.Path().absolute()/”libdio.so”
c_lib = ctypes.CDLL(libname, mode = ctypes.RTLD_GLOBAL)

 

Step 2: Configure the DIO mode.

All the pins can be configured as input or output, but we need to decide which pin becomes input and which pin become output based on the device that will connect to the EBOX. Figure 2 shows a DIO relay module that will be connected to the EBOX. Pin 0 to pin 3 of the DIO relay module are output pins, while pin 4 to pin 7 are input pins. Therefore, we need to set pin 0 to pin 3 of EBOX as output pins and pin 4 to pin 7 as input pins.

dio_mode=0xf0 # pin 0~3 is output, pin 4~7 is input
res = c_lib.set_dio_mode(ctypes.c_uint32(dio_mode))

dio-module-768x432
Figure 2: DIO relay module.

Step 3: Configure output pin to high or low

res = c_lib.set_low(1)
res = c_lib.set_high(1)

Step 4: Read signal from the input pin

The input pin of EBOX always gives 5V when there is no input signal from DIO relay module. When the DIO relay module output signal to EBOX, the input pin of EBOX will become 0V.

value = c_lib.read_input(7)

That’s all. Only 4 steps to configure the DIO of EBOX.