Microchip’s MCP6S21/2/6/8 are programmable gain amplifiers that multiply an input voltage by a factor of 1, 2, 4, 5, 8, 10, 16, and 32. The MCP6S22/6/8 also have selectable input channels for working with different signal sources. The multiplication factor and input channel are configured through an SPI interface. This chip is useful for multiplying a small input signal, and selecting among several analog input sources. We demonstrate the six channel MCP6S26 below.
MCP6S26 programmable gain amplifier (Mouser search, Octopart search, $2.56) Datasheet (PDF).
We tested the chip in the circuit shown above with a 3.3volt power supply. A resistor voltage divider (R1-4) outputs a fraction of the supply on channels 0, 2, and 4. We used 5K resistors, but the value isn’t critical. The divider outputs 2.4volts on channel 0, 1.6volts on channel 2, and 0.8volts on channel 4.
Bus Pirate | DS1801 (pin #) |
ADC | VOUT (1) |
GND | VREF (8) |
GND | VSS (9) |
CS | CS (10) |
MOSI | SI (11) |
MISO | SO (12) |
CLOCK | SCK (13) |
+3.3V | VDD (13) |
We used our Bus Pirate universal serial interface to demonstrate this chip, but the transaction sequence will be the same for any microcontroller implementation. We connected the Bus Pirate to the MCP6S26 as shown in the table above. We setup the Bus Pirate for raw3wire mode (M, 8) with normal outputs, and enabled the on-board power supply (capital ‘W’).
RAW3WIRE>[0b01000001 0] d
CS ENABLED <–begin SPI transaction
WRITE: 0x41 <–change input channel command
WRITE: 0x00 <–change to channel 0
CS DISABLED <–end SPI transaction
VOLTAGE PROBE: 2.4VOLTS <–Vout voltage measurement
RAW3WIRE>
Writing 0b01000001 (0x41) followed by a channel number changes the active MCP6S26 input. ‘[‘ lowers the chip select line to start an SPI transaction. We send the change channel command (0x41) followed by 0 to select input 0. ‘]’ raises the chip select line to end the SPI transaction. ‘d’ takes a voltage measurement and shows that input 0 with 0 gain is 2.4volts.
We can’t amplify the input voltage beyond the power supply (2.4volts * 2 = 4.8, 4.8volts > 3.3volts), so we need to change to a lower channel to play with the gain features.
RAW3WIRE>[0b01000001 4] d
CS ENABLED
WRITE: 0x41 <–change input channel command
WRITE: 0x04 <–change to channel 4
CS DISABLED
VOLTAGE PROBE: 0.8VOLTS <–Vout voltage measurement
RAW3WIRE>
A measurement on channel 4 shows an output of just 0.8volts, plenty of room to test the gain features of the chip.
RAW3WIRE>[0b01000000 0b00000001] d
CS ENABLED
WRITE: 0x40 <–change gain command
WRITE: 0x01 <–gain setting (x2)
CS DISABLED
VOLTAGE PROBE: 1.6VOLTS <–Vout is now 0.8volts * 2
RAW3WIRE>
A two-byte sequence sets the amount of gain. The command 0b01000000 (0x40) addresses the gain register, the second byte sets the multiplication factor (0x01= gain of 2). Setting the gain to 2 multiplies the output voltage by 2, 0.8volts * 2 = 1.6volts.
RAW3WIRE>[0b01000000 0b00000010] d
CS ENABLED
WRITE: 0x40 <–change gain command
WRITE: 0x02 <–gain setting (x4)
CS DISABLED
VOLTAGE PROBE: 3.2VOLTS <–Vout is now 0.8volts * 4
RAW3WIRE>
This time we set a gain of 4, 0.8volts * 4 = 3.2volts.
RAW3WIRE>[0b01000000 0b00000011] d
CS ENABLED
WRITE: 0x40 <–change gain command
WRITE: 0x03 <–gain setting (x5)
CS DISABLED
VOLTAGE PROBE: 3.3VOLTS <–not enough headroom to reach 0.8volts * 5
RAW3WIRE>
The maximum output voltage is the chip’s power supply voltage. If we set the gain to 5, the output voltage can’t exceed the power supply of 3.3volts (0.8volts * 5 = 4volts, 4volts > 3.3volts).
RAW3WIRE>[0b00100000 0] d
CS ENABLED
WRITE: 0x20 <–sleep command
WRITE: 0x00 <–don’t care byte
CS DISABLED
VOLTAGE PROBE: 0.0VOLTS <–output is disabled
RAW3WIRE>
The MCP6S26 has a power-saving sleep mode. Shutdown the chip with the command 0x20, followed by any byte value. Leave sleep by sending any valid command.
Like this post? Check out the parts posts you may have missed. Want to request a part post? Please leave your suggestions in the comments.
As always, a great write-up. Keep ’em coming!
Can this be used as an audio volume control and selector?
tc: the problem with using this as a volume control is that you only have a limited number of gain settings to choose from, as opposed to a traditional volume knob that has a continuum of settings. You might be better off using a digital potentiometer for volume. This chip could be combined with that though so that you can have the capability of selecting multiple inputs, as well as having the benefits of a preamp.
One interesting use for the multiple inputs is that a series of filters can be created and the inputs can be chosen to switch various filters in and out of the circuit. I’m current working on a sort of “universal amplifier” that uses this technique.
One more thing, tc: if you want input selection in stereo a good chip is 74hct4052
Very nice! I was thinking about using something similar for my EEG design, so it doubles as an ECG.
nice chip, could be usefull as a preamp for slow oscilloscope
tc why not use dedicated audio preamp chip for that? like TDA8425? its SPI controlled and has 2 stereo input channels
I was curious. I’m trying to get together a custom MP3 player setup for a motorcycle and need some sort of amp to kick it up about 12 or 15dB (I use helmet speakers with earplugs) so the fact that it has limited settings doesn’t bug me. I’d still have a pot of some sort afterwards.
Of course, it turns out that the MP3 player I was looking at (“MOD-MP3”) doesn’t support SDHC, so that one is out the window. :(
Another reason that I ask is to get feedback and suggestions. Sometimes I’m not even sure about what I’m looking for. :)
@ the schematic pictured above: your grounds should always point *down* and one of your +3v3 tags is facing sideways too :P
glad to see you introducing this stuff to the hobby community :) i like the way things are going here
tc: It would probably not be appropriate to connect this chip directly to headphones if that is what you are considering. You need something that can deliver more power. The LM386 chip is the most common choice in this situation, although there are more modern chips that can do stereo, such as the TPA302D. If you use the LM386 you will need two to do stereo.
This web site is really quite good, but for some reason it does not display properly when trying to view on my Nintendo Wii. If it helps, the console uses the Opera web browser and am impelled to using the console for accessing the Net whilst my PC is away being restored.
Cool. I’m interested in this chip and was wandering if the gain is adjustable to 2.5? If not then one would have to lower the input voltage to a value that is acceptable for a gain of 2 for the desired output? I guess what I am asking is if the gain can be programmed to 2.5?
Thank you very much , it is a very good and useful writ up.