[title]MCP4131 Digital SPI Potentiometer[/title]
This library is for the Digital Potentiometer found at Sparkfun Electronics: http://www.sparkfun.com/products/10613
Using this chip is not easy. For me it worked fine at 5Volt but I couldn’t get a solid read on the (multiplexed) SDI/SDO pin when running at 3.3V. Due to the limited number of pins available on the chip (why couldn’t they just add two more pins???) both MISO and MOSI data lines are on the same pin. Using a 4.7k resistor to the MISO port worked in 5V mode but not in 3.3V mode. I tried several other resistors (including the full range of the pot itself which is ~1k-10k) but didn’t get it to work. It’s ok to be used on the FEZ boards as they are 5V tolerant but on the ChipWorkX using 5V can kill the SPI interface unless you use voltage regulators. I had to use two Logic Level Converter (http://www.sparkfun.com/products/8745) because only two of the 4 ports on each of those is bi-directional. For my next order I will be getting these instead: http://www.sparkfun.com/products/10403
The orginal version was developed by declanshanaghy and rewritten by Dennis Liang (11/19/2011).
The code was ported to C# / netmf by Christian Ehlers (12/2011).
All versions are released into the public domain.
Please check the attached Visual Studio 2010 project for the full source code as well as the necessary using statements and assemblies. For any further questions or comments please check this thread: http://tinyurl.com/btzrwns starting on page 4.
The usage example will start at the highest resistance and will go all the way down to the lowest resistance and all the way back up. You can either use the setTap method to any value between 0 and 128 or you can use the increment and decrement methods which are commented in the example. Simply uncomment these two methods (//myMCP4131.increment(); and //myMCP4131.decrement() and comment the myMCP4131.setTap(i); call below each of them.
For each step all the register values are shown on the Debug channel.
P.S. Technically you can use this chip as a DAC and can program a Signal Generator. I’ve been thinkin about that and will get to it when I have some time. I’m not sure of the speed that thing supports though so it’ll be fun to try out. If you do have any plans in that direction let me know in the support thread.