Giter Site home page Giter Site logo

ads1220's Introduction

ADS1220

This is a C library for using ADS1220
Please read the .h file documentation.

How to use

You should initialize handler structure first. (ADS1220_Handler_t)
Then you should call initialize function. (ADS1220_Init)
Then you can use other functions.
NOTE: Information about handler structure, init function and others are in .h file.

Example

STM32 HAL
#include "ADS1220.h"
void CS_UP(void)
{
    // GPIO_CS_GROUP and GPIO_CS_PIN depend on your schematic.
    HAL_GPIO_WritePin(GPIO_CS_GROUP, GPIO_CS_PIN, GPIO_PIN_SET);
}
void CS_DOWN(void)
{
    // GPIO_CS_GROUP and GPIO_CS_PIN depend on your schematic.
    HAL_GPIO_WritePin(GPIO_CS_GROUP, GPIO_CS_PIN, GPIO_PIN_RESET);
}
void TRANSMIT(uint8_t data)
{
    // SPI_DRIVER depends on your configuration.
    HAL_SPI_Transmit (SPI_DRIVER, &data, sizeof(uint8_t), HAL_MAX_DELAY);
}
uint8_t RECEIVE(void)
{
    uint8_t dataR = 0;
    // SPI_DRIVER depends on your configuration.
    HAL_SPI_Receive (SPI_DRIVER, &dataR, sizeof(uint8_t), HAL_MAX_DELAY);
    return dataR;
}
void DELAY(uint32_t us)
{
    // DELAY_US depends on your code.
    DELAY_US(us);
}
ADS1220_Handler_t Handler = {0};

void main (void)
{
    // Initialize all STM32 peripherals including SPI needed for ADS1220 with desire configuration before call ADS1220 init function.

    Handler.ADC_CS_HIGH = CS_UP;
    Handler.ADC_CS_LOW = CS_DOWN;
    Handler.ADC_Transmit = TRANSMIT;
    Handler.ADC_Receive = RECEIVE;
    Handler.ADC_Delay_US = DELAY;
    
    // Passing Parameters as NULL to use default configurations.
    ADS1220_Init(&Handler, NULL);

    // Default conversion mode is Single-shot
    ADS1220_StartSync(&Handler);

    // GPIO_DRDY_GROUP and GPIO_DRDY_PIN depend on your schematic.
    while(HAL_GPIO_ReadPin(GPIO_DRDY_GROUP, GPIO_DRDY_PIN) == GPIO_PIN_SET){}

    int32_t ADC_Data;
    ADS1220_ReadData(&Handler, &ADC_Data);

    // 2.048 is internal voltage reference and is used as default config.
    // 1 is default adc gain value and it must be equivalent to the gain config in ADS1220_Parameters_t.
    printf("ADC Raw: 0x%X | ADC Voltage : %f\r\n", ADC_Data, ADCValueToVoltage(ADC_Data, 2.048, 1));

    while(1)
    {
    }
}

ads1220's People

Contributors

alimoal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ads1220's Issues

HELLO

Hello, is there an example related to stm32?

Read Temperature

Hello, first of all, big fan of the library. I need a way to read the temperature sensor permanently. How does everything need to be set up to make this work? I have enabled the temperature sensor mod by setting

#define CELSIUS_PER_LSB 0.0078125f

ADS1220_Parameter_t Parameter = {0};
...
Parameter.TempeSensorMode = 1;
...
ADS1220_Init(&Handler, &Parameter);
...
int32_t ADC_Data;
ADS1220_ReadData(&Handler, &ADC_Data);

Then in the while(1) I set everything like this.

float temp = ADCValueToTemperature(ADC_Data, CELSIUS_PER_LSB);
printf("ADC Raw: 0x%lx | Temperature in C : %f\r\n", (unsigned long)ADC_Data, temp);
HAL_Delay(4000);

The hardware is on AIN0-AIN3 and REFN0 and REFP0 are not connected. Could you give me an example? I work with the Cube IDE from STM

Thank you,
Henri

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.