Skip to content

Instantly share code, notes, and snippets.

@dariosalvi78
Last active December 21, 2023 08:23
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save dariosalvi78/f2e990b4317199d235bbf5963c3486ae to your computer and use it in GitHub Desktop.
Save dariosalvi78/f2e990b4317199d235bbf5963c3486ae to your computer and use it in GitHub Desktop.
Simple library for ADS1256 to be used with Arduino. It does not implement the whole set of features, but can be used as a starting point for a more comprehensive library.
/* ADS1256 simple library for Arduino
ADS1256, datasheet: http://www.ti.com/lit/ds/sbas288j/sbas288j.pdf
connections to Atmega328 (UNO)
CLK - pin 13
DIN - pin 11 (MOSI)
DOUT - pin 12 (MISO)
CS - pin 10
DRDY - pin 9
RESET- pin 8 (or tie HIGH?)
DVDD - 3V3
DGND - GND
*/
#define ADS_SPISPEED 1250000
#define ADS_RST_PIN 8 //ADS1256 reset pin
#define ADS_RDY_PIN 9 //ADS1256 data ready
#define ADS_CS_PIN 10 //ADS1256 chip select
// 11, 12 and 13 are taken by the SPI
void initADS(){
pinMode(ADS_CS_PIN, OUTPUT);
pinMode(ADS_RDY_PIN, INPUT);
pinMode(ADS_RST_PIN, OUTPUT);
digitalWrite(ADS_RST_PIN, LOW);
delay(1); // LOW at least 4 clock cycles of onboard clock. 100 microsecons is enough
digitalWrite(ADS_RST_PIN, HIGH); // now reset to deafult values
delay(150);
digitalWrite(ADS_CS_PIN, LOW); // select ADS
delayMicroseconds(50);
while (digitalRead(ADS_RDY_PIN)) {} // wait for ready_line to go low
SPI.beginTransaction(SPISettings(ADS_SPISPEED, MSBFIRST, SPI_MODE1));
delayMicroseconds(10);
//Reset to Power-Up Values (FEh)
SPI.transfer(0xFE);
delayMicroseconds(100);
byte status_reg = 0 ; // address (datasheet p. 30)
byte status_data = 0x01; //status: Most Significant Bit First, Auto-Calibration Disabled, Analog Input Buffer Disabled
//0x03; //to activate buffer
SPI.transfer(0x50 | status_reg);
SPI.transfer(0x00); // 2nd command byte, write one register only
SPI.transfer(status_data); // write the databyte to the register
delayMicroseconds(10);
//PGA SETTING
//1 ±5V 000 (1)
//2 ±2.5V 001 (2)
//4 ±1.25V 010 (3)
//8 ±0.625V 011 (4)
//16 ±312.5mV 100 (5)
//32 ±156.25mV 101 (6)
//64 ±78.125mV 110 (7) OR 111 (8)
byte adcon_reg = 2; //A/D Control Register (Address 02h)
byte adcon_data = 0x20; // 0 01 00 000 => Clock Out Frequency = fCLKIN, Sensor Detect OFF, gain 1
//0x25 for setting gain to 32, 0x27 to 64
SPI.transfer(0x50 | adcon_reg);
SPI.transfer(0x00); // 2nd command byte, write one register only
SPI.transfer(adcon_data); // write the databyte to the register
delayMicroseconds(10);
//Set sampling rate
byte drate_reg = 3; // Choosing Data Rate register = third register.
byte drate_data = 0b11000000; // 11000000 = 3,750SPS
SPI.transfer(0x50 | drate_reg);
SPI.transfer(0x00); // 2nd command byte, write one register only
SPI.transfer(drate_data); // write the databyte to the register
delayMicroseconds(10);
//done with settings, can close SPI transaction now
digitalWrite(ADS_CS_PIN, HIGH); //unselect ADS
delayMicroseconds(50);
Serial.println("ADS1256 configured");
}
long readADS(byte channel) {
long adc_val = 0; // unsigned long is on 32 bits
digitalWrite(ADS_CS_PIN, LOW);
delayMicroseconds(50);
SPI.beginTransaction(SPISettings(ADS_SPISPEED, MSBFIRST, SPI_MODE1)); // start SPI
delayMicroseconds(10);
//The most efficient way to cycle through the inputs is to
//change the multiplexer setting (using a WREG command
//to the multiplexer register MUX) immediately after DRDY
//goes low. Then, after changing the multiplexer, restart the
//conversion process by issuing the SYNC and WAKEUP
//commands, and retrieve the data with the RDATA
//command.
while (digitalRead(ADS_RDY_PIN)) {} ;
byte data = (channel << 4) | (1 << 3); //AIN-channel and AINCOM
SPI.transfer(0x50 | 1); // write (0x50) MUX register (0x01)
SPI.transfer(0x00); // number of registers to be read/written − 1, write one register only
SPI.transfer(data); // write the databyte to the register
delayMicroseconds(10);
//SYNC command 1111 1100
SPI.transfer(0xFC);
delayMicroseconds(10);
//WAKEUP 0000 0000
SPI.transfer(0x00);
delayMicroseconds(10);
SPI.transfer(0x01); // Read Data 0000 0001 (01h)
delayMicroseconds(10);
adc_val = SPI.transfer(0);
adc_val <<= 8; //shift to left
adc_val |= SPI.transfer(0);
adc_val <<= 8;
adc_val |= SPI.transfer(0);
//The ADS1255/6 output 24 bits of data in Binary Two’s
//Complement format. The LSB has a weight of
//2VREF/(PGA(223 − 1)). A positive full-scale input produces
//an output code of 7FFFFFh and the negative full-scale
//input produces an output code of 800000h.
if (adc_val > 0x7fffff) { //if MSB == 1
adc_val = 16777216ul - adc_val; //do 2's complement, discard sign
}
delayMicroseconds(10);
digitalWrite(ADS_CS_PIN, HIGH);
delayMicroseconds(50);
SPI.endTransaction();
Serial.print("Got measurement from ADS ");
Serial.println(adc_val);
return adc_val;
}
long readADSDiff(byte positiveCh, byte negativeCh) {
long adc_val = 0; // unsigned long is on 32 bits
digitalWrite(ADS_CS_PIN, LOW);
delayMicroseconds(50);
SPI.beginTransaction(SPISettings(ADS_SPISPEED, MSBFIRST, SPI_MODE1));
delayMicroseconds(10);
while (digitalRead(ADS_RDY_PIN)) {} ;
byte data = (positiveCh << 4) | negativeCh; //xxxx1000 - AINp = positiveCh, AINn = negativeCh
SPI.transfer(0x50 | 1); // write (0x50) MUX register (0x01)
SPI.transfer(0x00); // number of registers to be read/written − 1, write one register only
SPI.transfer(data); // write the databyte to the register
delayMicroseconds(10);
//SYNC command 1111 1100
SPI.transfer(0xFC);
delayMicroseconds(10);
//WAKEUP 0000 0000
SPI.transfer(0x00);
delayMicroseconds(10);
SPI.transfer(0x01); // Read Data 0000 0001 (01h)
delayMicroseconds(10);
adc_val = SPI.transfer(0);
adc_val <<= 8; //shift to left
adc_val |= SPI.transfer(0);
adc_val <<= 8;
adc_val |= SPI.transfer(0);
delayMicroseconds(10);
digitalWrite(ADS_CS_PIN, HIGH);
delayMicroseconds(50);
if (adc_val > 0x7fffff) { //if MSB == 1
adc_val = adc_val - 16777216; //do 2's complement, keep the sign this time!
}
Serial.print("Got diff measurement from ADS ");
Serial.println(adc_val);
return adc_val;
}
@Matej1006
Copy link

i get error in this line
SPI.beginTransaction(SPISettings(ADS_SPISPEED, MSBFIRST, SPI_MODE1));
error is:
'SPI' was not declared in this scope

@quetzacoal
Copy link

Hello @dariosalvi78, could you help me trying to readout a simple sensor located in AIN0?

Thank you

Quetza

@ronikucink
Copy link

how to read all 8 channels?

can you find the code ?

@ronikucink
Copy link

i get error in this line
SPI.beginTransaction(SPISettings(ADS_SPISPEED, MSBFIRST, SPI_MODE1));
error is:
'SPI' was not declared in this scope

excactly same with me
, already find way ?

@dariosalvi78
Copy link
Author

this is not an Arduino sketch, it's a library. In the sketch you need to import SPI.h to make it work and program the setup() and loop() according to your needs. If you want to see an example where this is used, check this repo.

@chepo92
Copy link

chepo92 commented Aug 13, 2019

@gokul12051997
Copy link

I followed the exactly same code in my project, but in a stm32f302r8 (nucleo - f302r8 board) micro controller. Its not working. I'm new to this environment. Can you please help me. I've also shared my code, kindly pinpoint the error.
`

  • USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/

/* USER CODE BEGIN PTD */

uint8_t receive[2];

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/

/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/

/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/

SPI_HandleTypeDef hspi3;

UART_HandleTypeDef huart2;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_SPI3_Init(void);

static void MX_USART2_UART_Init(void);

/* USER CODE BEGIN PFP */

void adc_write(uint8_t address, uint8_t value)

{

            uint8_t data[3];

            data[0] = 0x50|address;

            data[1] = 0x00;

            data[2] = value;

            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_RESET);

            HAL_SPI_Transmit(&hspi3, data,3, 50);

            //DWT_Delay(10);

            HAL_Delay(1);

            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_SET);

}

void adc_write_command(uint8_t command)

{

            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_RESET);

            HAL_SPI_Transmit(&hspi3,&command,1,50);

            HAL_Delay(1);

            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_SET);

}

/*

float freq(float volta)

{

            int value= 0, tim_val[100];

            float frequency;



            for(int i=0;i<100;i++)

            {

                            if(volta<0.1 && volta>0)

                            {

                                            //start timer

                                            while(!(volta<0.1 && volta>0));

                                            //stop timer



                            }

                                            //tim_val[i] = timercount_value;

                            value += tim_val[i];

            }

            value = value/100;

            value = value*2;

            frequency = 1/value;

            return frequency;

}

*/

int adc_read()

{

            uint8_t datacon;

            uint32_t convert = 0x00;

            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_RESET);

            adc_write_command(0x01); //read



            for(int i=0;i<3;i++)

            {

                            HAL_SPI_Receive(&hspi3,&datacon,1,50);

                            convert |= datacon;

                            convert<<=8;

            }



            //DWT_Delay(10);

            HAL_Delay(1);

            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_SET);

            return convert;

}

float volt(uint32_t data2)

{

            float v;

v =(float) data2*0.000000596046; // 8388607 = +5.000v reference voltage

            return v;

}

void adc_read_regis(uint8_t address1)

{

                            uint8_t data1[3];

                            data1[0] = 0x10|address1;

                            data1[1] = 0x00;

                            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_RESET);

                            HAL_SPI_Transmit(&hspi3, data1, 2, 50);

                            HAL_Delay(5);

                            HAL_SPI_Receive(&hspi3,&data1[2],1,50);

                            //DWT_Delay(10);

                            HAL_Delay(1);

                            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_SET);

}

void adc_reset()

{

            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_RESET);

            HAL_GPIO_WritePin(GPIOC, RESET_Pin, GPIO_PIN_RESET);

            HAL_Delay(1);

            HAL_GPIO_WritePin(GPIOC, RESET_Pin, GPIO_PIN_SET);

            HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_SET);

}

void adc_init()

{

            adc_write(0x00, 0x03); //status

            adc_write(0x02, 0x20); //adcon

            adc_write(0x03, 0x82); //drate 100sps

            adc_read_regis(0x03); //verification

            adc_write_command(0xF0); //selfcab of adc

            adc_write(0x01, 0x0F); //mux for channel 0 positive

            adc_write_command(0xFC); //sync

            adc_write_command(0x00); //wake up

            HAL_Delay(500);

}

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/

/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**

*/

int main(void)

{

/* USER CODE BEGIN 1 */

            uint32_t adc_data_ch0, adc_data_ch1;

            float voltage_ch0, voltage_ch1;

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */

HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */

SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */

MX_GPIO_Init();

MX_SPI3_Init();

MX_USART2_UART_Init();

/* USER CODE BEGIN 2 */

MX_GPIO_Init();

HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_RESET);

adc_reset();

HAL_Delay(500);

MX_SPI3_Init();

HAL_Delay(500);

adc_write_command(0xFE); //reset to power up values

adc_write_command(0xFC); //sync

adc_write_command(0x00); //wake up

//DWT_Delay(10);

HAL_Delay(1);

adc_init();

HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET); //confirm configuration

MX_USART2_UART_Init();

HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_RESET);

                            //while(HAL_GPIO_ReadPin(DRDY_GPIO_Port,DRDY_Pin));

                            adc_write(0x01, 0x1F); //mux for ch1 positive channel

                            adc_write_command(0xFC); //sync

                            adc_write_command(0x00); //wake up

                            adc_data_ch0 = adc_read();

                            voltage_ch0  = volt(adc_data_ch0);



                //while(HAL_GPIO_ReadPin(DRDY_GPIO_Port,DRDY_Pin));

                adc_write(0x01, 0x0F);  //mux for ch0 positive channel

                adc_write_command(0xFC); //sync

                adc_write_command(0x00); //wake up

                adc_data_ch1 = adc_read();

                voltage_ch1  = volt(adc_data_ch1);

                //frequency_in_ch1 = freq(voltage_in_ch1);

/* USER CODE END 2 */

/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

              HAL_Delay(100);





                HAL_Delay(100);



                HAL_GPIO_WritePin(GPIOC, CHIP_SELECT_Pin, GPIO_PIN_SET);

}

/* USER CODE END WHILE */



/* USER CODE BEGIN 3 */

/* USER CODE END 3 */

}

/**

*/

void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct = {0};

RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

/** Initializes the CPU, AHB and APB busses clocks

*/

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

RCC_OscInitStruct.HSIState = RCC_HSI_ON;

RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;

RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL8;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

Error_Handler();

}

/** Initializes the CPU, AHB and APB busses clocks

*/

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

                          |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)

{

Error_Handler();

}

}

/**

*/

static void MX_SPI3_Init(void)

{

/* USER CODE BEGIN SPI3_Init 0 */

/* USER CODE END SPI3_Init 0 */

/* USER CODE BEGIN SPI3_Init 1 */

/* USER CODE END SPI3_Init 1 */

/* SPI3 parameter configuration*/

hspi3.Instance = SPI3;

hspi3.Init.Mode = SPI_MODE_MASTER;

hspi3.Init.Direction = SPI_DIRECTION_2LINES;

hspi3.Init.DataSize = SPI_DATASIZE_8BIT;

hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;

hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;

hspi3.Init.NSS = SPI_NSS_SOFT;

hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;

hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;

hspi3.Init.TIMode = SPI_TIMODE_DISABLE;

hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

hspi3.Init.CRCPolynomial = 7;

hspi3.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;

hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;

if (HAL_SPI_Init(&hspi3) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN SPI3_Init 2 */

/* USER CODE END SPI3_Init 2 */

}

/**

*/

static void MX_USART2_UART_Init(void)

{

/* USER CODE BEGIN USART2_Init 0 */

/* USER CODE END USART2_Init 0 */

/* USER CODE BEGIN USART2_Init 1 */

/* USER CODE END USART2_Init 1 */

huart2.Instance = USART2;

huart2.Init.BaudRate = 38400;

huart2.Init.WordLength = UART_WORDLENGTH_8B;

huart2.Init.StopBits = UART_STOPBITS_1;

huart2.Init.Parity = UART_PARITY_NONE;

huart2.Init.Mode = UART_MODE_TX_RX;

huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;

huart2.Init.OverSampling = UART_OVERSAMPLING_16;

huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

if (HAL_UART_Init(&huart2) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN USART2_Init 2 */

/* USER CODE END USART2_Init 2 */

}

/**

*/

static void MX_GPIO_Init(void)

{

GPIO_InitTypeDef GPIO_InitStruct = {0};

/* GPIO Ports Clock Enable */

__HAL_RCC_GPIOC_CLK_ENABLE();

__HAL_RCC_GPIOF_CLK_ENABLE();

__HAL_RCC_GPIOA_CLK_ENABLE();

__HAL_RCC_GPIOB_CLK_ENABLE();

/*Configure GPIO pin Output Level */

HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */

HAL_GPIO_WritePin(GPIOC, RESET_Pin|CHIP_SELECT_Pin, GPIO_PIN_SET);

/*Configure GPIO pin : B1_Pin */

GPIO_InitStruct.Pin = B1_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : LD2_Pin */

GPIO_InitStruct.Pin = LD2_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : DRDY_Pin */

GPIO_InitStruct.Pin = DRDY_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(DRDY_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : RESET_Pin CHIP_SELECT_Pin */

GPIO_InitStruct.Pin = RESET_Pin|CHIP_SELECT_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**

  • @brief This function is executed in case of error occurrence.

  • @RetVal None

*/

void Error_Handler(void)

{

/* USER CODE BEGIN Error_Handler_Debug */

/* User can add his own implementation to report the HAL error return state */

/* USER CODE END Error_Handler_Debug */

}

`

@chepo92
Copy link

chepo92 commented Nov 12, 2019

You can attach files to avoid making a mess of code in comments
Try https://github.com/chepo92/ADS1256-1

@gokul12051997
Copy link

@chepo92 Sorry for the trouble, and I will follow your advice from next time. The provided link is no different from the one I'm using. I want it to be done in stm32f302r8 board and not on arduino. Can you please help.

@mimamrafi
Copy link

how complext that program. can you give me a simple program for ads 1256 to Arduino

@LAMSTREAM
Copy link

LAMSTREAM commented Jul 14, 2021

It truly working!Really thank you my dear dariosalvi78.And it work very good even on my arm's Arduino.Maybe I should fork a simple library for those newbie like me to use ADS1256 in all kinds of Arduino. Pretty appreciation for you my dear! :)

@chepo92
Copy link

chepo92 commented Jul 14, 2021

It truly working!Really thank you my dear dariosalvi78.And it work very good even on my arm's Arduino.Maybe I should fork a simple library for those newbie like me to use ADS1256 in all kinds of Arduino. Pretty appreciation for you my dear! :)

@LAMSTREAM

https://github.com/ADS1xxx-Series-ADC-Libraries/ADS1255-ADS1256

@LAMSTREAM
Copy link

LAMSTREAM commented Jul 14, 2021

It truly working!Really thank you my dear dariosalvi78.And it work very good even on my arm's Arduino.Maybe I should fork a simple library for those newbie like me to use ADS1256 in all kinds of Arduino. Pretty appreciation for you my dear! :)

@LAMSTREAM

https://github.com/ADS1xxx-Series-ADC-Libraries/ADS1255-ADS1256

Thank you bro,I have watch yours library yesterday.It can work well on my Aruino Nano,and I know your code is cross optimize.But it can't work on Arduino DUE or NANO 33 IOT which based on ARM's ,cause they are 32bit.Your pins' denfine couldn't use on them.But still thank for your reply and work for ADS1256. :)

@Pilot5860
Copy link

Hello, first of all I would like to congratulate you for your work. I'm also trying to use firebeetle esp32 card on ide. I've been trying to promote ads1256 libraries for a while, but in vain. After all, when I installed the library you shared above, I was very happy to see the "ADS1256.h" line in red in the ide interface.
Unfortunately I am getting the following errors while compiling. What can I do about it? I'm so fed up. I will be glad if you help

LF-Antenna1:22:9: error: no matching function for call to 'ADS1256::ADS1256()'
ADS1256 ADS; //initialize ADS as object of the ads12xx class
^
In file included from C:\Users\Hp\Documents\Arduino\LF-Antenna1\LF-Antenna1.ino:1:0:
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS1255-ADS1256-master/ADS1256.h:128:3: note: candidate: ADS1256::ADS1256(float, float, bool)
ADS1256(float clockspdMhz, float vref, bool useresetpin);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS1255-ADS1256-master/ADS1256.h:128:3: note: candidate expects 3 arguments, 0 provided
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS1255-ADS1256-master/ADS1256.h:126:7: note: candidate: constexpr ADS1256::ADS1256(const ADS1256&)
class ADS1256 {
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS1255-ADS1256-master/ADS1256.h:126:7: note: candidate expects 1 argument, 0 provided
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS1255-ADS1256-master/ADS1256.h:126:7: note: candidate: constexpr ADS1256::ADS1256(ADS1256&&)
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS1255-ADS1256-master/ADS1256.h:126:7: note: candidate expects 1 argument, 0 provided
C:\Users\Hp\Documents\Arduino\LF-Antenna1\LF-Antenna1.ino: In function 'void loop()':
LF-Antenna1:103:7: error: 'class ADS1256' has no member named 'Reset'
ADS.Reset(); //Reset the AD chip. Every time you see the message on the Serial Terminal, everything is set to default!
^
LF-Antenna1:108:10: error: 'class ADS1256' has no member named 'SetRegisterValue'
ADS.SetRegisterValue(STATUS, B00110100); //Autocal is ON
^
LF-Antenna1:108:33: error: expected primary-expression before ',' token
ADS.SetRegisterValue(STATUS, B00110100); //Autocal is ON
^
LF-Antenna1:109:10: error: 'class ADS1256' has no member named 'SetRegisterValue'
ADS.SetRegisterValue(MUX, B00001000); //
^
LF-Antenna1:109:27: error: 'MUX' was not declared in this scope
ADS.SetRegisterValue(MUX, B00001000); //
^
LF-Antenna1:110:10: error: 'class ADS1256' has no member named 'SetRegisterValue'
ADS.SetRegisterValue(ADCON, B00000000); //
^
LF-Antenna1:110:27: error: 'ADCON' was not declared in this scope
ADS.SetRegisterValue(ADCON, B00000000); //
^
LF-Antenna1:111:10: error: 'class ADS1256' has no member named 'SetRegisterValue'
ADS.SetRegisterValue(DRATE, B11010000); //7500 SPS
^
LF-Antenna1:111:27: error: 'DRATE' was not declared in this scope
ADS.SetRegisterValue(DRATE, B11010000); //7500 SPS
^
LF-Antenna1:112:10: error: 'class ADS1256' has no member named 'SetRegisterValue'
ADS.SetRegisterValue(IO, B11101111); //
^
LF-Antenna1:112:27: error: 'IO' was not declared in this scope
ADS.SetRegisterValue(IO, B11101111); //
^
LF-Antenna1:113:10: error: 'class ADS1256' has no member named 'SendCMD'
ADS.SendCMD(SELFCAL); //run self calibration
^
LF-Antenna1:113:18: error: 'SELFCAL' was not declared in this scope
ADS.SendCMD(SELFCAL); //run self calibration
^
LF-Antenna1:120:21: error: 'class ADS1256' has no member named 'SendCMD'
ADS.SendCMD(SELFCAL); //Self calibration
^
LF-Antenna1:122:21: error: 'class ADS1256' has no member named 'SetRegisterValue'
ADS.SetRegisterValue(MUX, B00000001);//AIN0+AIN1 -- CH0
^
LF-Antenna1:125:28: error: 'class ADS1256' has no member named 'GetConversion'
Serial.println(ADS.GetConversion());
^
LF-Antenna1:132:12: error: 'class ADS1256' has no member named 'SetRegisterValue'
ADS.SetRegisterValue(DRATE, B01100011);
^
LF-Antenna1:133:13: error: 'class ADS1256' has no member named 'SendCMD'
ADS.SendCMD(SELFCAL); //Self calibration
^
LF-Antenna1:145:13: error: 'class ADS1256' has no member named 'SetRegisterValue'
ADS.SetRegisterValue(MUX, B00000001);//AIN0+AIN1 -- CH0
^
LF-Antenna1:146:26: error: 'class ADS1256' has no member named 'GetConversion'
Serial.print(ADS.GetConversion());
^
LF-Antenna1:147:20: error: 'class ADS1256' has no member named 'GetConversion'
pop[o]=ADS.GetConversion(); // saving signal value to a variable array
^
exit status 1
no matching function for call to 'ADS1256::ADS1256()'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment