IO Pi Performance
The IO Pi Plus is a 32 channel MCP23017 GPIO expander for the Raspberry Pi
30/12/2016
Posted by:
voodoo_dev
30/12/2016
Posted by:
andrew
With the python library, each instance of the iopi is stored as an object which contains variables for the status of the pins on the IO Pi. When you write to a single pin the python library updates the variable and then writes that to the IO Pi.
As C is not an object-orientated language we wrote the C version of the library so the write_pin function reads the values from the port before updating a single bit and writing the value back to the port. This is more reliable if you have more than one program writing to the IO Pi as it will always check the status of the port before updating it. The downside is it requires two I2C packets to be sent to the IO Pi whereas the python library only needs one which is why the C library is half the speed of the python library.
One way of improving the performance would be to use the write_port function instead of write_pin. write_port updates all 8 pins on the port at the same time so it does not need to read the status of the pins first. This means it only has to send a single I2C packet to the IO Pi so performance should be the same as the python version.
Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.