3
\$\begingroup\$

I am facing some issues with the output values from an ADS7822.

The ADC is adequately bypassed and wired up, as follows. Please note that the inverted pins on the schematic are not an issue. I routed the proper wires between the ADC and the MCU.

Wiring diagram

The ADC is driven by a Teensy 3.6. It should be noted that I am using level shifters at the digital pins. The SPI speed is set at 100 KHz (with SPI mode 0) and has been tested at up to 1MHz, where the signal integrity is still good (due to the speed limitations from the level shifters).

The decoded SPI output is the following:

Decoded SPI

This output value is wrong since the voltage I am feeding to the ADC's input is a fixed 3.3V which should correspond to 0xA8E. The decoded value shown in the image matches perfectly with the Serial.print debugging outputs from my implemented code. The SPI capture portion of my code is the following. Please ignore the dumb comments and extra lines :P. I successfully tested both techniques for forming the 12-bit word through bit shifting.

enter image description here

To me, the timings are in line with those specified by the datasheet:

ADS7822 timings

I have tried with different input voltages and the decoded output voltage is always the digital equivalent between 4.1v and 4.6V (0xCFF is approx. 4.061V).

Any ideas on what I am missing or doing wrong?

I can elaborate on my explanation if need be.

EDIT: The Vref pin is connected to an LM4040-5 precision voltage reference, thus 5.0V is the voltage reference.

enter image description here

[EDIT 2] I want to clarify that the LM4040-5 is fed by an additional 15V rail that I forgot to edit in the schematic shown here.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ a) what is the reference voltage? b) you are aware that there are 3 bits to be discarded at the beginning? \$\endgroup\$
    – asdfex
    Mar 14, 2022 at 17:33
  • \$\begingroup\$ My apologies for the late reply. I rushed my question and did not specify this important parameter. Vref is 5V coming from a precision voltage reference LM4040-5. I will edit my post and include this \$\endgroup\$ Mar 14, 2022 at 21:43
  • \$\begingroup\$ Also, why 3 bits? Both the datasheet and my SPI result show only one null bit (when the pin is in Hi-Z). I configured the DSO as a 12-bit word and, as I mentioned, it matches with the word created by my code after bit shifting and merging the 2 bytes into a uint16_t. In any case, it should be ignoring 3 rising/falling edges, isn't it? \$\endgroup\$ Mar 14, 2022 at 22:02

3 Answers 3

4
\$\begingroup\$

The data sheet says pin 1 is a reference input, yet you have marked it as Vref_out, and it isn't shown as being connected to anything apart from a capacitor and a test point.

[edit] Your additional diagram shows the reference voltage coming from a 5 volt shunt regulator, fed from a 5 volt supply, via a 250K resistor. If this is actually correct, the series resistance is remarkably high, and the shunt regulator is doing nothing useful since its voltage is the same as the supply, but it might be dragging the Vref_out down a bit, since the supply current will be below the recommended minimum for regulation (65 uA)

Also the ADS7822 datasheet says the maximum reference current is 40 uA, so you'll be heavily reliant on the 10 uF capacitor to hold the reference voltage up during conversion. Try dropping the resistance by a factor of 100, and maybe use a shunt regulator with a lower voltage, so it has something to regulate.

You say you have checked the reference voltage, did you do this with a DVM (which will show you an average value) or an oscilloscope (which could be triggered to show the actual value during conversion)?

\$\endgroup\$
4
  • \$\begingroup\$ Vref_out was in a section of my circuit that I forgot to include. I have edited my post. This voltage exists at pin 1 from the ADC. Absolutely confirmed that this voltage is present. \$\endgroup\$ Mar 14, 2022 at 21:46
  • \$\begingroup\$ Thank you for your additional response. I measured it using a DVM (Fluke 289). I will measure it with mi DSO, though. Regarding the resistor from the LM4040-5 I did some final adjustments to my design and R1 is actually 20k as I also noticed that it was way too high on my original one. I will play around with it or inject an external voltage and see if there is any change. Cheers \$\endgroup\$ Mar 15, 2022 at 15:03
  • \$\begingroup\$ Also, I added clarification regarding the supply voltage from the LM4040-5. It is fed by an additional 15V supply present in my design (not shown here). My apologies for the frequent corrections and incomplete/inaccurate info \$\endgroup\$ Mar 15, 2022 at 16:42
  • 1
    \$\begingroup\$ "dragging the Vref_out down a bit" - there's a graph in the datasheet. It drops rapidly to something like ~1V. \$\endgroup\$
    – asdfex
    Mar 15, 2022 at 17:21
3
\$\begingroup\$

Your conversion of the value received on SPI is wrong.

This ADC needs the first two clock cycles to sample, then outputs a '0' bit and only then starts to transmit data. You record 0xCFF7, or 0b1100_1111_1111_0111 So, we have to skip three bits: The first (left-most) are during the sampling time, then a '0' marking the beginning of the transfer afterwards. I.e. the measured value is 0b0111_1111_1011 or 0x7FB.

That's still not the value you're searching for, but this is impossible to judge unless we can see the full and actual circuit and setup.

\$\endgroup\$
1
  • \$\begingroup\$ Your comment was certainly helpful. It made me think for a bit, take a step back and visualise my results bit by bit (pardon the pun XD). I will be sharing my results shortly. I think I got what I was looking for \$\endgroup\$ Mar 16, 2022 at 14:40
2
\$\begingroup\$

Alright, guys. I found the solution.

Basically, all of you gave me very useful hints on how to troubleshoot my problem.

As I told @asdfex, after evaluating the SPI data bit by bit, I realised that my ADC digital code was embedded into the serial stream captured by the MCU (and the DSO, of course).

If we take a closer look at the data, we have the following disection. Please keep in mind that we are injecting 3.36V or 0xAC0 (for those who speak 12-bit hexadecimal, We have to be inclusive here ;) ).

SPI Data analysis

Since we need to form a 12-bit word, where the MSB is transmitted right after the null bit (NB). The datasheet indicates a maximum of 2 clock cycles for the conversion time, before the NB. Then, we should count 12 bits however, we have 13. Therefore, the last bit (zero) should indicate that the conversion had already finished while CS was still low. The datasheet clearly stipulates this (see the first timings diagram that I shared).

Therefore, we must mask the upper 3 bits and do a shift right to get the final value.

Based on the results from the image, we have:

(0xD57A) & (0x1FFF) = 0x157A

then by shifting one position to the right we get:

0x157A >> 1 = 0xABD, obtaining our 12-bit word, which numerically corresponds to:

0xABD (HEX) = 2749/4095 (DEC) = (671.306E-3)(5V) = 3.356V. Et voila! Pretty close to the expected value. *Please read EDIT 2

Please also note that the serial decode is counting the absolute maximum of 16 clocks, which is in line with the datasheet.

I have confirmed this solution with different voltages and the next step is to feed an analog signal and start digitising some stuff.

[EDIT] I forgot to mention that the final serial values were captured after moving the input voltage to 2.5V

[EDIT 2] Thanks to @G36 who pointed out my mistake. The conversion value should be done over 4096 (2^12). Therefore, the actual measured voltage was: 3.355V.

Final SPI protocol and word formation

\$\endgroup\$
2
  • 1
    \$\begingroup\$ 0xABD (HEX) = 2749/ 4096 (DEC) is the correct conversion ratio. See the Table 2. page 13 in ADC datasheet. \$\endgroup\$
    – G36
    Mar 17, 2022 at 16:02
  • \$\begingroup\$ @G36 Of course! My bad. Thanks. I was off by a little bit. Ok, I will stop the puns \$\endgroup\$ Mar 17, 2022 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.