Skip to content

Conversation

@brendanmatkin
Copy link

This is my attempt to fix #5.

  • Moved the input pin selection from readADC1() to startADC1(pos,neg). This seems to be working well on ADS1262, but is not testing on ADS1263. I am getting the expected sample rates reading multiple inputs. See below for results example timing.
  • Added a dataReady() function and corresponding setDrdyPin(uint8_t pin) (matches start pin architecture). Without drdy pin this always returns true.
  • Added getGain() helper function. This gets the value of the constant used in setGain. Call uint8_t realGain = 1 << adc.getGain() to get actual gain V/V )
  • added _ads126x_delaymicro(uint16_t us) hardware definition to dial in the start_pin timing behaviour (as per datasheet section 9.4.1 conversion controls1)
  • updated basics.ino
  • updated readme
  • no longer need to call any methods twice to get a single result 🤘

My logic is that we want to prep which pins to read BEFORE we start a conversion. When pin selection is in readADC, you are selecting pins after a conversion is already in the output register, but then reading that previous conversion immediately. This is therefore the result of whichever pins you had selected before, and you have to call it a second time to get the result of the pins you now have selected.

Results Example

This is 20SPS + FIR + CHOP (chop roughly doubles conversion time). Pins 0-1 are shorted together, and pins 3-4 are shorted together. Times are in microseconds and are captured at:

  1. analog ready (dataReady was true in loop - i.e. time since startADC +/- loop time)
  2. after readAdc
  3. after stopAdc
  4. after startAdc (with new pins)
    (reset timer here and continue loop)
[ADC] gain:1 crc:OK time:103950,+57,+1,+63 input:3,4        value:            565   V:0.000000657746568
[ADC] gain:1 crc:OK time:103946,+55,+1,+66 input:0,1        value:            327   V:0.000000380678102
[ADC] gain:1 crc:OK time:103961,+78,+2,+63 input:3,4        value:            -29   V:-0.000000033760443
[ADC] gain:1 crc:OK time:103951,+76,+2,+73 input:0,1        value:            -50   V:-0.000000058207661
[ADC] gain:1 crc:OK time:103954,+56,+2,+62 input:3,4        value:            125   V:0.000000145519152
[ADC] gain:1 crc:OK time:103946,+57,+1,+63 input:0,1        value:            584   V:0.000000679865479

When CHOP is off, time 1 is roughly 51890us - ends up being ~19SPS. You loose a little bit of time flipping between pins, but I think these are really positive results considering there is also multi-stage filtering happening. CHOP is obviously way slower but getting that voltage offset down is so nice.

Special thanks to this fantastic review article: https://xdevs.com/review/ti_ads1262_p1/.

Footnotes

  1. pulses should be 4x tCLK which tCLK = 1/fCLK = 1/7.3728Mhz = 1.35633681e-7... ≃ 5.43e-7 ≃ 0.5us. I rounded up to 2uS to be super generous with timing but it could probably be tightened up more.

@he77PC011
Copy link

Add multiple sensors
Can provide sample code

@brendanmatkin
Copy link
Author

@he77PC011 are you saying you are going to do this? Or you want me to do this?

Are you a maintainer?

@Molorius
Copy link
Owner

Molorius commented Jan 2, 2024

Thank you for these commits. My only concern is that this is a breaking change, I'm not sure the best way to communicate this in an Arduino library.

he77PC011 is not a maintainer.

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

Successfully merging this pull request may close these issues.

Problem adding multiple sensors

3 participants