SAADC results unclear.

Using the NRF5 SDK V17.0.2

Once again finding myself struggling to understand the structure of the SDK as a result of lacking documentation, there seem to be so many layers of abstraction used accross the example code. functions using nrf/nrfx/nrf_drv prefixes & endless redirect header files. I'm trying to review one of the SAADC example projects. There are less than 10 annotations accross the main.c file & it's not made clear why functions are called at given times.

In my own code, I am inputting to a single ended channel of the SAADC peripheral, a sinusoid that is centred about -30mv (or sometimes 0V). The signal has been AC coupled, but in future this coupling will be removed. For now i must try to conduct some testing regardless, the negative voltage doesn't go anywhere near the -0.3V absolute maximum & features plenty of positive components.

I am using a single ended ADC channel, with a gain of 1 & resolution of 14 bits. Reference voltage 0.6V internal. The SAADC samples are coming out around 8000 (~0.3V).

When i try adjusting the resolution to 12 bits, i get samples around 2000 (again, ~0.3V).

Why is it my samples are centered around the 0.3V region. When i know they are in fact centred around 0V...

It's worth noting that the waveforms i'm seeing, while centred around the wrong value, are roughly correct & in keeping with what i would expect).

I have also noticed that if i invert my signal (signal is an ECG type signal, that i can invert by swapping chest electrodes), the ADC results, do NOT invert to match.

Am i converting the sample values to voltages correctly? (I'm following the standard equations shown on the infocentre).

Parents
  • Hi,

    The nrf saadc driver should be tightly coupled with the saadc hardware description, so I suggest to read it if you haven't already
    https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html

    The analog input must be in the range VSS - VDD, ref for instance:
    "Inputs AIN0 through AIN7 cannot exceed VDD or be lower than VSS."

    The -0.3V you refer to is related to when the part can take damage if you go below this.

    If you are using single ended input then make sure you have a common ground, and ensure the analog signal input is within the VSS - VDD range. If you have simply connected a series capacitor on the input it likely will be measuring a value in the middle of the range.

    Best regards,
    Kenneth

  • Hi Kennith,

    Thanks for answering, i've read the above documentation a number of times, the top half is informative, but the lower half of the document refers to what i presume is classes as register level programming. While i've normally no issue programming at register level, i'd prefer to maintain a consistent level of abstraction throughout the project & continue using the SDK functions. Which is where the disconnect in documentation seems to sit. All the examples follow bits of the SDK & offer little explanation as to why such funtions are run.

    I was aware of the input ranges being an issue (thanks anyhow), & that the -0.3V is an absolute maximum characteristic, i was hoping someone might have some insight into the likely behaviour of the chip when it is exposed to conditions outside of the specified input range? So i could have some explanation as to it's behaviour. As i mentioned before, these are not ideal conditions, i'm working on a bespoke board that i cant modify at the moment & subsequently dont have much of a choice about the negative voltages.That said, I am currently attempting to remove the coupling.

    I do have a common ground present & no ive not just connected a series capactitor, the AC coupling is technically a 0.3Hz high pass filter, as the circuit required a current path to GND to be preset, hence the use of an RC filter.

    I'm curious, (even though this is not the case) what makes you say it would likely meave a middle of the range value?

    -S

Reply
  • Hi Kennith,

    Thanks for answering, i've read the above documentation a number of times, the top half is informative, but the lower half of the document refers to what i presume is classes as register level programming. While i've normally no issue programming at register level, i'd prefer to maintain a consistent level of abstraction throughout the project & continue using the SDK functions. Which is where the disconnect in documentation seems to sit. All the examples follow bits of the SDK & offer little explanation as to why such funtions are run.

    I was aware of the input ranges being an issue (thanks anyhow), & that the -0.3V is an absolute maximum characteristic, i was hoping someone might have some insight into the likely behaviour of the chip when it is exposed to conditions outside of the specified input range? So i could have some explanation as to it's behaviour. As i mentioned before, these are not ideal conditions, i'm working on a bespoke board that i cant modify at the moment & subsequently dont have much of a choice about the negative voltages.That said, I am currently attempting to remove the coupling.

    I do have a common ground present & no ive not just connected a series capactitor, the AC coupling is technically a 0.3Hz high pass filter, as the circuit required a current path to GND to be preset, hence the use of an RC filter.

    I'm curious, (even though this is not the case) what makes you say it would likely meave a middle of the range value?

    -S

Children
  • Any difference if you simply ground the input? If not, then I think you may have configured the ADC channel wrong (e.g. it is sampling the wrong input pin).

    Kenneth

  • Hi Kenneth

    I went down a similar thought pattern:
    I disabled my input signal entirely (it has a switchable supply, that i can control from the CPU). I then used the ADC config to connect resistor_p, the single-ended input to a PULLDOWN resistor.

    This gave ADC readings of around -40...which i found odd, either way it was a marked difference from the middle-of-the-range values.

    I then attached the internal PULLUP to the input, this gave readings around 16380 I.E., max value.

    With the regards to the pin, I've checked this too. Regardless, the pin must be right, as under the a few variations of my test, i'm seeing ROUGHLY the right readings coming through, i mentioned the input signal is an ECG signal, i can clearly pickout a cardiovascular signal in the readings (i have some basic SW that lets me graph the signals). But these tests are so inconsistent in terms of results VS adc config, all they really clarify is that the correct pin is connected.

  • I am starting to think it must be the ADC config as you suggest, i've now managed to un-couple the input signal, so it's now a sinusoid centered around 1V, with 0.5V pk-pk ish. No more negative voltages.

    PS, apologies for mis-spelling your name in my first reply.

  • SeanHowsonTB said:
    so it's now a sinusoid centered around 1V, with 0.5V pk-pk ish. No more negative voltages.

    For an unconnected pin? Is it possible you are picking up some noise from the power grid or USB? What is the frequency?

    Kenneth

  • This this is a mis-communication here.

    The only time the pin has been unconnected was while i was trialing the effects of the internal pullup's & pull downs.

    I've removed the AC coupling, from the board & replaced it with a 0603 sized peice of copper, IE the filter no longer exists. The output of the ECG circuit now runs through a single mains-noise filter as it always had & straight into the SAADC pin.

    There are no usb related components on the board.

    This 1V offset, 0.5V pk-pk is my desired signal, this is the ECG signal i'm trying to measure. The difference is that it is no longer centered around 0V, instread it has a positive offset voltage to keep it within the input range of the SAADC.

Related