alexander5398
New member
Hello,
I am trying to use a Teensy 4.0 board to get data from an ADS1220 24-bit ADC. When I try to run the code below, the serial terminal only prints one "Hello". It seems like whenever I try to use the Protocentral_ADS1220 object, the program stops running. When I uncomment all the functions with 'adc' in the setup code, nothing prints to the serial monitor.
I have included the pin connections in the comments at the top. I have run this same code with a different arduino board so there shouldn't be anything wrong with it. I know that the Teensyduino library has it's own SPI.h file. Do I need to specify which SPI.h file to use?
I am trying to use a Teensy 4.0 board to get data from an ADS1220 24-bit ADC. When I try to run the code below, the serial terminal only prints one "Hello". It seems like whenever I try to use the Protocentral_ADS1220 object, the program stops running. When I uncomment all the functions with 'adc' in the setup code, nothing prints to the serial monitor.
I have included the pin connections in the comments at the top. I have run this same code with a different arduino board so there shouldn't be anything wrong with it. I know that the Teensyduino library has it's own SPI.h file. Do I need to specify which SPI.h file to use?
Code:
/////////////////////////////////////////////////////////////////////////////////////////
//
// Demo code for the ADS1220 24-bit ADC breakout board
//
// Author: Ashwin Whitchurch
// Copyright (c) 2018 ProtoCentral
//
// This example gives differential voltage across the AN0 and AN1 pins in mVolts
//
// Arduino connections:
//
// |ADS1220 pin label| Pin Function |Teensy 4.0 Connection|
// |-----------------|:--------------------:|-----------------:|
// | DRDY | Data ready Output pin| 14 |
// | MISO | Slave Out | 12 |
// | MOSI | Slave In | 11 |
// | SCLK | Serial Clock | 15 |
// | CS | Chip Select | 10 |
// | DVDD | Digital VDD | +3.3V |
// | DGND | Digital Gnd | Gnd |
// | AN0-AN3 | Analog Input | Analog Input |
// | AVDD | Analog VDD | - |
// | AGND | Analog Gnd | - |
//
// This software is licensed under the MIT License(http://opensource.org/licenses/MIT).q
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// For information on how to use, visit https://github.com/Protocentral/Protocentral_ADS1220
//
/////////////////////////////////////////////////////////////////////////////////////////
#include "Protocentral_ADS1220.h"
#include <SPI.h>
#define PGA 64
#define PGA_GAIN PGA_GAIN_64
#define VREF 2.048 // Internal reference of 2.048V
#define VFSR VREF/PGA
#define FSR (((long int)1<<23)-1)
#define ADS1220_CS_PIN 10
#define ADS1220_DRDY_PIN 14
#define R_TOP 21.8e3
#define R_BOT 21.6e3
Protocentral_ADS1220 adc;
int32_t adc_data;
float Vout;
void setup()
{
Serial.begin(9600);
// adc.begin(ADS1220_CS_PIN,ADS1220_DRDY_PIN);
// adc.set_data_rate(DR_20SPS);
// adc.set_pga_gain(PGA_GAIN);
// adc.select_mux_channels(MUX_AIN0_AIN1); //Configure for differential measurement between AIN0 and AIN1
//
// adc.Start_Conv(); //Start continuous conversion mode
}
void loop()
{
Serial.println("Hello");
adc_data = adc.Read_WaitForData();
Serial.println("HEllo");
Vout = (float) ((adc_data * VFSR * 1000) / FSR); //In mV
Serial.println( String( (float) ( Vout * (R_TOP+R_BOT) / (3300.0 - Vout) ) ) );
delay(100);
}