The CP-IO22-A4-2 is an IO board accessory for the ComfilePi consisting of 22 digital IO (11 inputs, 11 outputs), 4 16-bit analog inputs, 2 12-bit analog outputs, screw terminals, and indicator LEDs. It can be mounted to the rear panel of the CPi-A/B/S series panel PCs.
This product cannot be mounted on CPi-C070WR4C.
The following is an example project illustrating how to program the CP-IO22-A4-2 in C# using the Mono Framework.
.NET 6 drivers can be found at the .NET IoT Libraries API Reference.
The pigpio library also has a Python interface.
The following is an example illustrating digital inputs and outputs:
import pigpio pi = pigpio.pi() pi.set_mode(4, pigpio.INPUT) pi.set_mode(17, pigpio.OUTPUT) while True: if pi.read(4): pi.write(17, 1) else: pi.write(17, 0) pi.stop()
We also have an example using CODESYS demonstrating digital IO and analog inputs.
For analog outputs, please try the MCP4725 driver posted at the CODESYS Forge.
CP-IO22-A4-2 pins are connected to the ComfilePi's GPIO header as shown below.
It may be necessary to modify the ComfilePi's initial GPIO output state to prevent the ComfilePi from turning the outputs ON when the ComfilePi boots.
Modify the ComfilePi's /boot/config.txt file with the following configuration to set the initial IO state. See GPIO control in config.txt for more information.
gpio=4-13=ip gpio=16=ip gpio=17-27=op,np,dl
To initialize the digital-to-analog outputs to 0 when powering on, run the following commands in a terminal.
pigs i2co 1 0x62 0 pigs i2cwi 0 0x60 0 0 pigs i2cc 0 pigs i2co 1 0x63 0 pigs i2cwi 0 0x60 0 0 pigs i2cc 0