Serial Peripheral Interface (SPI) Exercises

 

Microchip's MCP4231 Digital Potentiometer.

Part A. Hardware I.

  1. Click on the pin diagram to the right (to enlarge) and confirm a mapping between the Arduino pin numbers and the MCP4231 pin numbers.
  2. Checking the features of this digital device (highlighted, below) reveals that you have control over 129 steps of resistance between 0 and 10 kΩ over a maximum operating range of 2.7 to 5.5 V.
  3. If the chip has a supply of precisely 5 V, determine the ΔV for each step.
  4. What conversion process is being undertaken within this device: ADC or DAC?
  5. Wire the Arduino and MCP4231 Potentiometer 0 together.
  6. Place an LED on Potentiometer 0's Wiper pin.

Part B. Software 1.

  1. Load the SPI Example sketch, DigitalPotControl. Save the sketch as SPIDigitalPotMCP4231 to your Arduino folder.
  2. This sketch is designed to control the 6-channel AD5206 digital potentiometer. Modify the code as necessary to control the MCP4231 to create a contiunous breathing LED effect on P0W, changing steps only every 100 ms. Modify the comments to fit the new IC and make any code efficiciency improvements (there are a number).
  3. Have your code write each value of the byte-size step data [0,128] to the Serial Monitor with every loop iteration and compare the value to the relative brightness of the LED.
  4. Upload and debug your code as necessary.

Part C. Hardware II and Software II

  1. Since the turn-on voltage of an LED is above 0 V, perhaps we should not waste power at these levels. Run your sketch a few more times, noting the approximate upward and downward threshold (step value) at which the LED transistions to OFF. Let's call this transition step.
  2. Assuming we are running our system at exactlly 5 V, what voltage level does the transition step correspond to?
  3. How could we modify our hardware and software efforts to address the transition so we ensure EVERY step of our digital pot influences a visible change in brightness?
  4. Perform these enhancements and note any performance improvements.


SPI Reference Material

Blum Chapter 9: The SPI Bus
SPI, SPISettings

The SPI Bus

SPI Bus