====== CP-IO22-A4-2 Digital and Analog I/O Board for the ComfilePi 40 pin header ====== The CP-IO22-A4-2 is an IO board accessory for the [[comfilepi:index|ComfilePi ]] consisting of 22 digital IO (11 bipolar 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. If you need PNP outputs, please use the [[:cpio:cp-io22pnp:index|CP-IO22 PNP]]. {{ :cpio:cp-io22-a4-2:cpio22a4front.jpg?nolink |}} [[http://comfiletech.com/new-products/cp-io22-a4-2-io-board-accessory-for-the-comfilepi/|Buy]] {{ :cpio:cp-io22-a4-2:cpio22a.png?nolink |}} ===== C# Control Example ===== The following is an example project illustrating how to program the CP-IO22-A4-2 in C# using the [[:comfilepi:index#net_c_vbnet|Mono Framework]]. {{ :cpio:cp-io22-a4-2:cp-io22-a4-2.mp4?700x400 |}} [[https://github.com/COMFILE-Technology/ComfileTech.ComfilePi.CP_IO22_A4_2.Demo|Source Code]] This example application uses the following .NET libraries to control the digital inputs, outputs, and I2C devices. * [[https://www.nuget.org/packages/System.Device.Gpio/|System.Device.Gpio]] * [[https://www.nuget.org/packages/Iot.Device.Bindings/|Iot.Device.Bindings]] ===== Python Example ===== The pigpio library also has a [[https://abyz.me.uk/rpi/pigpio/python.html|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() ===== CODESYS Example ===== We also have [[comfilepi:codesys:index|an example using CODESYS]] demonstrating digital IO and analog inputs. For analog outputs, please [[https://forge.codesys.com/forge/talk/Runtime/thread/8981ce928a/?limit=25#7b36|try the MCP4725 driver posted at the CODESYS Forge]]. ===== Pin Map ===== CP-IO22-A4-2 pins are connected to the ComfilePi's GPIO header as shown below. * INPUT : GPIO 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16 * OUTPUT : GPIO 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 * AD IN/OUT : I2C1 SDA, I2C1 SCL {{ :cp-io22-a4-2:cpio22a42back.png |}} ===== Specifications and IO Circuitry ===== * Input Voltage: 5VDC (powered by ComfilePi's 5V pin) * Current Rating: 500mA or more * Humidity: 35 ~ 85% RH * Temperature: -30 ~ 60 ℃ * Size: 128mm X 78mm {{ :cpio:cp-io22-a4-2:cpio22a42schematic.png |}} ==== Analog Inputs ==== * IC: [[http://www.ti.com/lit/ds/symlink/ads1113.pdf|ADS1115]] * Interface : I2C * Address: 0x48 * Input Voltage Range : 0 ~ 5Vdc * Resolution : 187.5uV / 1bit (-26,666 ~ 0 ~ 26,666) * Sample Rate : 1.62mS ==== Analog Outputs ==== * IC: [[http://ww1.microchip.com/downloads/en/DeviceDoc/22039d.pdf|MCP4725]] * Interface : I2C * Address: Ch1-0x62, Ch2-0x63 * Output Voltage: 0 ~ 5Vdc * Resolution : 1.22mV / 1bit (0 ~ 4094) * Sample Rate : 12uS * Maximum Output Current : 20mA ==== Digital Inputs ==== * Bipolar relative to COM x 11 * Voltage Range: 12 ~ 24V * Absolute Min/Max Voltage Range: 3.3 ~ 28V * Response Time: 5ms * Input OFF Level: <1.8VDC * Input ON Level: >2.5VDC * Indicator LED OFF Level: <4.5V * Indicator LED ON Level: >5.0V ==== Digital Outputs ==== * DC Output Sink (NPN) x 11 * Maximum Output Voltage: 30VDC * Response Time: 10ms * Current: 150mA ===== Setting the Initial IO State ===== 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 [[https://www.raspberrypi.com/documentation/computers/config_txt.html#gpio-control|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 [[:index|COMFILE Technology's Documentation Library]]