High-Precision AD HAT
| ||
Overview
High-Precision AD HAT For Raspberry Pi, ADS1263 10-Ch 32-Bit ADC
Specification
- Resolution(Bits): 32
- Input channels: 10
- Sample rate(MAX): 38kSPS
- PGA Magnification(MAX): 32
- BUS: SPI
- Structure: Delta-Sigma
- Input type: differential, single-end
- Reference voltage: internal, external
- Input voltage range (MAX): 2.5V,5V
- Input voltage range(MIN):-2.5V, 0V
Fatures
- Adopts ADS1263 chip, low noise, low-temperature drift, 10-ch 32-bit high precision ADC (5-ch differential input), 38.4kSPS Max sampling rate
- with embedded 24-bit auxiliary ADC, internal ADC test signal, IDAC, 2.5V internal reference voltage, 8x multiplexing GPIO, PGA (32 times Max)
- Onboard AD header input, compatible with Waveshare sensor pinout, for connecting sorts of sensor modules
- Onboard AD screw terminal input, allows connecting analog signal and analog power supply, general-purpose interface
- Onboard control header, make it easy to control the module by other hosts in addition to Raspberry Pi
- Three-wire RTD (resistor temperature detector) circuit, enabled by soldering 0R resistor
Pinout
PIN | Raspberry Pi(BCM) | Raspberry Pi(WiringPi) | Description |
DRDY | P17 | P0 | ADS1263 data output ready, low active |
RESET | P18 | P1 | ADS1263 reset input |
CS | P22 | P3 | ADS1263 chip select, low active |
DIN | P10 | P12 | SPI data input |
DOUT | P9 | P13 | SPI data output |
SCK | P11 | P14 | SPI clock |
Hardware configuration
Configure single-end
This board is set to the single-end mode by default. That is AVDD is connected to 5V, AVSS is connected to GND, and COM is connected to GND and set as negative end input.
You can connect the GND (or COM) and any IN pin to the target device for measuring.
Configure differential
If you want to measure a differential signal, you need to configure the board:
- Remove the 0ohm resistors of ACSS-GND, AVDD-5V which are on the backside. Remove the jumper of COM-GND.
- Power the AVSS(-2.5V) and AVDD(+2.5V) pin from the terminal.
- Modify the codes and connect IN0&IN1 or other pins to measure differential signals.
Configure RTD
If you need to use the RTD function, please configure it as below:
- Solder four 0ohm resistors on the "RTD 0R" pads which is on the backside.
- Remove the jumpers of COM-GND
- Connect the positive end of the three-wire RTD module to IN7 and the less two to IN6 and IN4.
- Modify the codes
Communication protocol
SPI Protocol
The AD HAT uses an SPI interface, for more information about the protocol, you can refer to datasheet Page 11-12
SPI timing:
CS is chip select. The chip is active when the cs is low;
SCLK is the clock pin of SPI;
DIN is the data input pin, that is MOSI, master output, and slave input;
DOUT is the data output pin, that is MISO, master input, and slave output;
DRDY is the data ready output pin, when the data of ADC1 is ready to output, it is low.
SPI communication has data transfer timing, which is combined by CPHA and CPOL.
- CPOL determines the level of the serial synchronous clock at the idle state. When CPOL = 0, the level is Low. However, CPOL has little effect on the transmission.
- CPHA determines whether data is collected at the first clock edge or at the second clock edge of the serial synchronous clock; when CPHL = 0, data is collected at the first clock edge.
There are 4 SPI communication modes. SPI0 is commonly used, in which CPHL = 0, CPOL = 0.
As you can see from the figure above, data transmission starts at the first falling edge of SCLK, and 8 bits of data are transferred in one clock cycle. Here, SPI0 is in used, and data is transferred by bits, MSB first.
C examples and Python examples are provided for quick starting.
Configure interface
Enable SPI interface
- Open the terminal, and use the command to enter the configuration page.
sudo raspi-config Choose Interfacing Options -> SPI -> Yes to enable the SPI interface
sudo reboot
Make sure that the SPI is not occupied by other devices, you can check in the middle of the /boot/config .txt.
Install libraries
Install Library
If you use the bookworm system, you can only use lgpio library, bcm2835 and wiringPi can't be installed and used.
BCM2835
#Open the Raspberry Pi terminal and run the following command wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz tar zxvf bcm2835-1.71.tar.gz cd bcm2835-1.71/ sudo ./configure && sudo make && sudo make check && sudo make install # For more, you can refer to the official website at: http://www.airspayce.com/mikem/bcm2835/
WiringPi
#Open the Raspberry Pi terminal and run the following command cd sudo apt-get install wiringpi #For Raspberry Pi systems after May 2019 (earlier than that can be executed without), an upgrade may be required: wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v # Run gpio -v and version 2.52 will appear, if it doesn't it means there was an installation error # Bullseye branch system using the following command: git clone https://github.com/WiringPi/WiringPi cd WiringPi . /build gpio -v # Run gpio -v and version 2.70 will appear, if it doesn't it means there was an installation error
lgpio
#Open the Raspberry Pi terminal and run the following command wget https://github.com/joan2937/lg/archive/master.zip unzip master.zip cd lg-master sudo make install # You can refer to the official website for more: https://github.com/gpiozero/lg
- python
sudo apt-get update sudo apt-get install ttf-wqy-zenhei sudo apt-get install python-pip sudo pip install RPi.GPIO sudo pip install spidev
Download demo codes
Open a terminal and run the follow commands to download demo codes:
sudo apt-get install p7zip-full wget http://www.waveshare.net/w/upload/6/64/High-Pricision_AD_HAT_Code.7z 7z x High-Pricision_AD_HAT_Code.7z -r -o./High-Pricision_AD_HAT_Code cd High-Pricision_AD_HAT_Code/
Examples
C
- Compile the codes
cd ~/High-Pricision_AD_HAT_Code/c sudo make clean sudo make
- If you want to use other libraries, you need to modify the Makefile file.
sudo vim Makefile Change USELIB_RPIwhich is on line 13-15
- main file is generated after compiling, then you can run the file
sudo ./main
Python
- Open a terminal and run the python codes
cd ~/High-Pricision_AD_HAT_Code/python sudo python main.py or sudo python3 main.py
Documents
Demo codes
Github (wait for uploading)