Configurable Port Expander (CoPoX)
On several forums I've seen requests for a way to use the Raspberry Pi to read analog input and control other devices.
The Configurable Port Expander bridges this gap between the pi and real world in a single chip. It allows the user to program in any language they like and gain easy access to all the various input and outputs of a microcontroller.
The Configurable Port Expander provides easy access to up to 32 I/O pins over an easy-to-use standard (I2C) that provides maximum flexibility and allows for rapid prototyping.
No external components are needed. The chip can be connected to a Raspberry Pi using only 4 wires. (power, ground, clock and data)
Pulse count mode allows incoming pulses to be counted without looping in the main program. Quantity pulse mode allows a number of pulses to be sent asynchronously, so the main program can continue processing without waiting.
There are really two parts, the first is the specification the second is the implementation on a pic16f1827 demonstrated below.
Below are demonstrations
Video 10: Slow PWM Slow PWM operates at 50Hz so you can directly drive a servo.
Video 11: Analog Input Gives a 10-bit number indicating the voltage reading between ground and the chip supply
Video 8: Soft Start/Stop Soft start/stop uses PWM to slowly bring the pin to full on or off with a single command. You can start the on or off sequence at any point to speed up the process.
Video 1: Setup Shows the device hooked up to a Raspberry Pi for demonstration
Video 2: Login Logging into a pi to show the device responding
Video 4: Memory Dump and Pin Capability Showing a memory dump using i2cdump and reading a 16-bit register to show digital capabilities of one pin
Video 5: Digital Input Example of reading the digital state of one pin
Video 6: Internal Pull-up Turning on the weak internal pull-up and show how it changes the reading
Video 7: Digital Output The most basic. LED goes on, LED goes off
Video 9: QPM Quantity Pulse Mode Send a quantity of pulses (upto 65535) with one command
Video 12: Analog Output Coming soon, I have to re-shoot because of a simple mathematical error
Video 13: Pulse Count Mode You can set a pin to count 16 bits worth of pulses
Video 14: Fast PWM Had to break out the oscilloscope to show PWM at higher speeds