Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement continuous mode #2

Open
binomaiheu opened this issue Dec 1, 2022 · 3 comments
Open

Implement continuous mode #2

binomaiheu opened this issue Dec 1, 2022 · 3 comments

Comments

@binomaiheu
Copy link
Owner

Figure out how to propery handle the continuous mode & drdy pin, what goes in the library, what is µP responsibility

@SndrSchnklshk
Copy link

Would be good addition! Any update on that?

@binomaiheu
Copy link
Owner Author

Hi @SndrSchnklshk, thanks for your interest.I believe in the original library, which is partly based this on the continuous mode was implemented (https://github.com/OM222O/ADS1219/) using the interrupt. I wanted to poll the status register instead, hence i coded this up here, but I'll try to see if I can look at it the coming weeks (a bit busy at the moment :-s)

@SndrSchnklshk
Copy link

SndrSchnklshk commented Feb 20, 2023

Thanks for your reply. I also prefer to go for a polling-option.

If you got time; If feel it's not that hard if you just make sure to call the start/sync command once (ADS1219_CMD_START_SYNC).

After that, read the conversion results (from external loop/core/task), something like (make sure to take the start/sync command out of the read method):

int32_t ADS1219::readAvailableValue(uint8_t channel, uint8_t *err_code)
{
    uint8_t mux;
    switch (channel)
    {
    case 0:
        mux = ADS1219_MUX_SINGLE_0;
        break;
    case 1:
        mux = ADS1219_MUX_SINGLE_1;
        break;
    case 2:
        mux = ADS1219_MUX_SINGLE_2;
        break;
    case 3:
        mux = ADS1219_MUX_SINGLE_3;
        break;
    default:
        *err_code = ADS1219_INVALID_MUX;
        return 0x80000000;
    }
    *err_code = _modify_register(mux, ADS1219_CONFIG_MASK_MUX);
    if (*err_code)
        return 0x80000001;
    bool ready = false;
    delay(getConversionTime());
    unsigned long tstart = millis();
    while (!ready && ((millis() - tstart) < _timeout_ms))
    {
        delay(2);
        ready = conversionReady(err_code);
    }
    return _read_value(err_code);
}

Maybe it's useful ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants