Overview
The MCP4241 chip is a digital pot. Digital pots are versatile devices that can be used to control a variety of circuits, replacing traditional potentiometers.
The MCP4241 uses an SPI bus. The Teensy LC can be used to control the MCP4241 chip in a straightforward manner.
The MCP4241-104E is a chip with 100k
digitally controlled pots that are accessed via an SPI bus.
Additionally, the chip features both volatile and non-volatile memory
and a number of other useful functions. The pots have 7-bits of
resolution (i.e. 128 steps of resistance). It can be powered from 2.7V to 5.5V.
The MCP4241 comes from a larger family of chips, the MCP414X/416X/424X/426X family. More information can be found here.
The SPI Bus
The MCP4241
connects and communicates with a microcontroller (such as an Arduino or
a Teensy) via the SPI Bus. SPI is a protocol that allows
microcontrollers to interface easily with a large number of external
chips and sensors.
SPI is a host / slave type bus. A single host microcontroller can interface with one or more slave chips or sensors.
SPI uses up to four pins for communication:
- CS (may also be called SS): chip select:
Used
by the microcontroller to select each device. The host microcontroller
has a CS output pin for every slave device that is to be used.
- SCK: serial clock:
Used
by the host microcontroller to time the data that is moved to and from
the slave device. There is one SCK connection that is shared amongst all
SPI devices.
- SDI: slave data in:
Used by the
host microcontroller to send data to a slave device. There is one SDI
connection that is shared amongst all SPI devices.
- SDO: slave data out:
Used
by the host microcontroller to receive data from a slave device. There
is one SDO connection that is shared amongst all SPI devices.
All
SPI slave devices require the CS and SCK pins. However, many device may
not require both the SDI and SDO connections, as they might only either
send or receive data.
With the MCP4241 chip, we want
to set the resistance of a digital potentiometer using data from a host
microntroller. As a result, we only need CS, SCK and SDI, because the
information needs to travel only from the host to the slave device.
If you are using a Teensy, the following table shows the CS, SCK, SDI and SDO pins to use:
If you are using an Arduino, the following table shows the CS, SCK, SDI and SDO pins to use:
If you are using a Teensy, the following table shows the pins to us:
MCP4241 Physical Layout
The
above diagram shows the layout of the 14-pin MCP4241 chip. Pin 1 is to
the left of the half-circle indent. Pin 14 is to the right of the
half-circle indent.
Pin 1 - CS - SPI Bus Chip Select
Pin 2 - SCK - SPI Bus Serial Clock
Pin 3 - SDI - SPI Bus Slave Digital In
Pin 4 - Vss - Connect to Ground
Pin 5 - P1B - Potentiometer Number 1, Terminal B
Pin 6 - P1W - Potentiometer Number 1, Wiper
Pin 7 - P1B - Potentiometer Number 1, Terminal A
Pin 8 - P0B - Potentiometer Number 0, Terminal A
Pin 9 - P0W - Potentiometer Number 0, Wiper
Pin 10 - P0B - Potentiometer Number 0, Terminal B
Pin 11 - WP - Write Protection - Connect to VCC for normal operation
Pin 12 - SHDN - Shutdown - Connect to VCC for normal operation
Pin 13 - SDO - SPI Bus Slave Digital Out
Pin 14 - Vdd - Connect to VCC
Connecting to Teensy LC
MCP4241 Pin 1 - CS - SPI Bus Chip Select - connect to Teensy LC digital pin 10 - green wire
MCP4241 Pin 2 - SCK - SPI Bus Serial Clock - connect to Teensy LC digital pin 13 - green wire
MCP4241 Pin 3 - SDI - SPI Bus Slave Digital In - connect to Teensy LC digital pin 11 - green wire
MCP4241 Pin 4 - Vss - Connect to Ground - connect to Teensy LC ground
Pin 5 - P1B - Potentiometer Number 1, Terminal B
Pin 6 - P1W - Potentiometer Number 1, Wiper
Pin 7 - P1B - Potentiometer Number 1, Terminal A
Pin 8 - P0B - Potentiometer Number 0, Terminal A
Pin 9 - P0W - Potentiometer Number 0, Wiper
Pin 10 - P0B - Potentiometer Number 0, Terminal B
Pin 11 - WP - Write Protection - connect to Teensy LC 3V
Pin 12 - SHDN - Shutdown - connect to Teensy LC 3V
Pin 13 - SDO - SPI Bus Slave Digital Out - not required for basic operation
Pin 14 - Vdd - connect to Teensy LC 3V
Programming
The MCP4241 is easily programmed. Please see below for an example that increases the resistance of the pot by a value of 1 every 100 milliseconds.
The pot can be tested by uploading this program to the Teensy LC, and then measuring the resistance between 6 and 7.
Monday, May 30, 2016
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment