raspberrynewbB
Posts: 12
Joined: Fri Sep 29, 2017 6:32 am

interfacing with PGA using SPI - Raspi3

Wed Oct 04, 2017 1:08 am

I am using a RPi3 and am attempting to read very small voltages (1-10mV) from an ADC (ADS1115 specifically).

Because my voltages are so low, I get very small readings, so I want to amplify the signal before sending to the ADC.

I have come across this PGA "MCP6S21" (link below) and on the data sheet (pg 18 section 5.0) it describes how to set the gain settings and change channels. It talks about interfacing with the PGA using SPI by sending it binary strings of numbers that mean something to the PGA.

Can anyone explain how I can actually do this? So I change the gain/channel on this PGA from the RPi3? This is way beyond my level of comprehension.

Alternatively if anyone can suggest an easier to use amplifier to read small voltages (1-10mV) on the RPi and ADS1115?

Best regards

http://ww1.microchip.com/downloads/en/D ... 21117B.pdf

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: interfacing with PGA using SPI - Raspi3

Fri Oct 06, 2017 8:26 pm

You should be able to connected that to /dev/spidev0.0 (CE0) or /dev/spidev0.1 (CE1)
https://pinout.xyz/pinout/spi

Then to program it send

0x41 and a value for the channel 0x00 to 0x07 (which on the 6S21 are all CH0)
or
0x40 and a value for the gain 0x00 (+1), 0x01 (+2), 0x02 (+4) 0x03 (+5), 0x04 (+8), 0x05 (+10), 0x06 (+16) to 0x07 (+32) based on the table on page #20 of the data sheet.

Send
0x20 and 0x00 to shutdown the PGA.

It should be relatively easy to do that in python with some thing like

Code: Select all

import spidev
spi = spidev.SpiDev()
spi.open(0,0)
r = spi.xfer2([0x40,0x05]) #set gain=+10
NOTE: that isn't tested, I don't have the hardware.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Interfacing (DSI, CSI, I2C, etc.)”