ElliottWaterman / ADS1015

Device agnostic library for the ADS1015 (4 channel ADC) written in C (compatible with C++).
MIT License
0 stars 1 forks source link

Initialization issue #1

Open maunns opened 1 year ago

maunns commented 1 year ago

Hello, I am trying to use this library on a SAMD21 platform but after a quick review i realized that default config is not set anywhere and not initalized

Should i be calling the following as part of my initialization?

ads1015_config_default_get ads1015_config_to_uint16_t ads1015_config_set

Thanks in advance

ElliottWaterman commented 1 year ago

Hello, The chip powers on with a default config of 0x8583 (page 15 datasheet) The ads1015_config_reg_t struct can be set to default using either; a function:

ads1015_config_reg_t config;
ads1015_config_default_get(&config);

or a macro: ads1015_config_reg_t config = ADS1015_DEFAULT_CONFIG();

or manually set up by setting the struct fields individually:

ads1015_config_reg_t config;
config.mode = ADS1015_MODE_SINGLE;
config.pga = ADS1015_PGA_4;
config.mux = ADS1015_MUX_1;
config.dr = ADS1015_DR_250HZ;
//etc

. The ads1015_measurement_get(&ctx, config, &result) function sends the config to the chip and requests a measurement using that config. Therefore if you have mutliple devices connected to the ADS1015 they can each have their own config (gain, data rate, etc)