piadcs.ads126x package¶
Submodules¶
piadcs.ads126x.ads126x module¶
-
piadcs.ads126x.ads126x.
convert_data
(datain)[source]¶ converts the output of the ADC into a voltage
Parameters: datain (list) – A list of bytes (the raw output of the adc) Returns: a float indicating a voltage between 2.5v and -2.5v - This will not be adjusted for PGA gain. If you use a voltage reference other than midsupply (2.5v) which is what is used by the internal reference then you will need to adjust this accordingly Return type: float
-
piadcs.ads126x.ads126x.
init_GPIO_SPI
(STRT, DRDY, PWDN, connection, spiBus, spispeedHz, spidevice=0)[source]¶ initializes the GPIO pins and SPI bus on the Raspbery Pi
Parameters: - STRT (int) – The BCM number for the GPIO pin connected to the start pin of the ADC Pin 26 is used for this in the example wiring diagram
- DRDY (int) – The BCM number for the GPIO pin connected to the data ready pin of the ADC. Pin 4 is used for this in the example wiring diagram
- PWDN (int) – The BCM number for the GPIO pin connected to the power down pin of the ADC. Pin 27 is used for this in the example wiring diagram
- Connection (SpiDev object) – The spi connection you use to communicate with the ADC. See spidev documentation for more details (https://pypi.org/project/spidev/)
- spiBus (int) – The spi bus on the Raspberry Pi that you want to use to communicate with the ADS126x. bus 0 is is used for this in the example
- spispeedHz (int) – The speed in Hertz of the SPI clock. This should scale depending on your ADC datarate. Higher data rates will require faster SPI. communication
- spidevice (int, optional) – Sets SPI device if using multiple devices on the same SPI bus. Default is zero and can be left as such if you are only using the one device.
-
piadcs.ads126x.ads126x.
read_Continuous_CHK
(connection, DRDY)[source]¶ reads a 32 bit conversion from the ADC. Use for reading direct (ADS126x datasheet section 9.4.7.1)
Parameters: - Connection (SpiDev object) – The spi connection you use to communicate with the ADC. See spidev documentation for more details (https://pypi.org/project/spidev/)
- DRDY (int) – The BCM number for the GPIO pin connected to the data ready pin of the ADC. Pin 4 is shown for this in the wiring diagram
Returns: Returns a tuple containing a list of 4 bytes representing the raw output of the ADC, and an error check. If the error check is None that means that the checksum passed and the data is useable. If the checksum fails the list will be None, and the error check will be the string “Checksum Failed”. If you are getting a lot of this error, you may want to consider increasing SPI speed.
Return type: tuple
-
piadcs.ads126x.ads126x.
read_Data_By_Command_CHK
(connection)[source]¶ reads a single conversion from the ADS1262. Use for reading in pulse conversion mode See datasheet section 9.4.1.2.
Parameters: Connection (SpiDev object) – The spi connection you use to communicate with the ADC. See spidev documentation for more details (https://pypi.org/project/spidev/) Returns: Returns a tuple containing a list of 4 bytes representing the raw output of the ADC, and an error check. If the error check is None that means that the checksum passed and the data is useable. If the checksum fails the list will be None, and the error check will be the string “Checksum Failed”. If you are getting a lot of this error, you may want to consider increasing SPI speed. Return type: tuple
-
piadcs.ads126x.ads126x.
read_all_regs
(connection)[source]¶ reads the values of all the registers on the ADS1262. starting with the ID register (register 0)
Parameters: Connection (SpiDev object) – The spi connection you use to communicate with the ADC. See spidev documentation for more details (https://pypi.org/project/spidev/)
-
piadcs.ads126x.ads126x.
restart
(strt, pwdn)[source]¶ restarts the ADS126x
Parameters: - STRT (int) – The BCM number for the GPIO pin connected to the start pin of the ADC In the example wiring diagram this is pin 22
- PWDN (int) – The BCM number for the GPIO pin connected to the power down pin of the ADC. In the example wiring diagram this is pin 27
-
piadcs.ads126x.ads126x.
startCommand
(connection)[source]¶ Starts ADC1 conversions using the start command sent over SPI
Parameters: Connection (SpiDev object) – The spi connection you use to communicate with the ADC. See spidev documentation for more details (https://pypi.org/project/spidev/)
-
piadcs.ads126x.ads126x.
startConversions
(strt)[source]¶ Starts ADC1 conversions by pulling the START pin high
Parameters: STRT (int) – The BCM number for the GPIO pin connected to the start pin of the ADC Pin 26 is used for this in the example wiring diagram
-
piadcs.ads126x.ads126x.
stopCommand
(connection)[source]¶ Stops ADC1 conversions using the stop command sent over SPI
Parameters: Connection (SpiDev object) – The spi connection you use to communicate with the ADC. See spidev documentation for more details (https://pypi.org/project/spidev/)
-
piadcs.ads126x.ads126x.
stopConversions
(strt)[source]¶ Stops ADC1 conversions by pulling the START pin low
Parameters: STRT (int) – The BCM number for the GPIO pin connected to the start pin of the ADC Pin 26 is used for this in the example wiring diagram
-
piadcs.ads126x.ads126x.
write_all_regs
(connection, power=1, interface=5, mode0=0, mode1=0, mode2=4, inpmux=1, ofcal0=0, ofcal1=0, ofcal2=0, fscal0=0, fscal1=0, fscal2=64, idacmux=187, idacmag=0, refmux=0, tdacp=0, tdacn=0, gpiocon=0, gpiodir=0, gpiodat=0, adc2cfg=0, adc2mux=1, adc2ofc0=0, adc2ofc1=0, adc2fsc0=0, adc2fsc1=64)[source]¶ writes the default (or user specified) values to all the registers on the ADS126x.
Parameters: - Connection (SpiDev object) – The spi connection you use to communicate with the ADC. See spidev documentation for more details (https://pypi.org/project/spidev/)
- Registers (byte, optional) – This function has 26 optional arguments wich correspond to the 26 8-bit programming registers on the ADS126x.The default arguments are the default values for those registers. This is based on the ADS126x datasheet. Options for register settings can be found in the constants file. Use the setregister function to change multiple values. Please also refer to section 9.6 (register maps) of that datasheet before using these arguments.