PSOC5 SAR ADC Trick(s)

This blog entry assumes some familiarity with A/D concepts. See the maxim tutorial linked below for more detailed information.

The PSOC5 ADC suite includes 2 SAR (Successive Approximation Register) Analog to Digital convertors. The PSOC5 SAR’s can digitize up to 1 million samples per second. The SAR component allows you to select the Full Scale Reference used for digitization from among several options.

A Most Interesting Problem

During this discussion, I will discuss values close to the calculated results. I am trying to convey the ideas, not the exact specifics. You can discover the specifics through calculation and experimentation, but first you need the overall picture. You need to really understand Hexadecimal notation.

For a brief tutorial on Hexadecimal, see https://www.techtarget.com/whatis/definition/hexadecimal#:~:text=Hexadecimal%20is%20a%20numbering%20system,%2C%20D%2C%20E%20and%20F.

For a brief tutorial on A/D units, see https://www.maximintegrated.com/en/design/technical-documents/tutorials/1/1080.html

Details

I needed to digitize a signal which will vary in its maximum presentation. Most of the time it will present less than a 1 volt maximum peak to peak reading. Sometimes it will present 1/10th that reading. Sometimes it may present double that.

To digitize down to 1 millivolt with a 12 bit A/D is not a problem (maximum hex reading 0xfff). The full scale reading is divided by 4096 (2^12) (0xfff), which gives you around 250 microvolts per count in the A/D. In other words, a value of 1 means there is 250 to 499 microvolts at the input of the A/D.

However, sometimes I need to digitize where I can see less than 250 microvolts (0.000250 volts). The typical way to do this is to add gain amplifiers in front of the A/D. When this is done, there are voltage offsets on the amplifiers that are presented to the A/D input, as well as other amplifier gain issues. Nothing is perfect, and resistors used to create gain will not give you exactly the resistance you think, so the amplifiers gain is almost what you calculated.

So, one other way to handle more accuracy for small signals is to change the Full Scale Voltage reference. If the 1.024 volts reference is changed to 0.512 volts, the volts per count is now 125 microvolts. Change the reference to 0.256 volts, and the minimum reading is 62.5 microvolts.

The PSOC 5 SAR Voltage Reference Choices

The PSOC5 SAR allows you to choose between internal or external references. Internal references can be 1/2 the voltage running the PSOC5 MCU System (i.e. 5 volts), or 1.024 volts in various combinations (VRef *2, single ended for example). It can also use external references, including one of the included 8 bit Voltage DAC’s. (Or for that matter, an external voltage DAC)

By using one of the included Voltage DAC’s, you can generate a voltage reference for the A/D that lets you digitize down to single microvolts or less. You simply stop the A/D, change the DAC output, then start the A/D. The new digitization will use the new value. You may wish to throw away the very first reading after the change, depending upon your personal testing results.

General Problems With IC’s

Nothing in electronics is for free. Way too many times I have “Let The Smoke Out (tm)” of a part and had to start over. It is interesting to note that the latest IC fabrication technology involves vaporizing pellets of pure tin (using lasers) to generate UV light to etch the patterns on the wafers.

That process creates smoke (eau de tin). Then, various other materials are vaporized and infused into the wafers. That is the smoke that creates the internal components.

So, smoke makes IC’s. When you over voltage IC’s, they usually break and start letting that original smoke out. When that smoke comes out, the part is useless. Don’t do that. The smoke has to stay in the part for it to keep working.

So, you also have to be careful with input voltages to A/D’s. If you don’t you may let some of the smoke out. This means you need to have a very good handle on the voltages you will be feeding to the A/D.

General Problems With Voltage References

Voltage References aren’t. What I mean to say, is they are never accurate. They are extremely close. In addition, SAR digitization is never accurate. It is extremely close.

The things that affect voltage references are fabrication issues (how much smoke went in), temperature changes (changes in temperature change the voltage reference’s output, as well as internal SAR resistor values), changes in supply voltage (which can change vref output), as well as environmental issues, such as humidity.

Problems with using DAC’s for a Voltage Reference

The DAC inside the PSOC is decently good, but it is only 8 bits. You can only get down to a level of 0.004 volts (4 mv), and each step is 4mv, if you are willing to settle for 1.02 volts out. If you need 4.08 volts out, each step is 16mv.

In addition to that, temperature affects the DAC’s output. Ugh. In addition, the SAR has an internal offset, which is affected by temperature. Also SARs use resistors, which change due to temperature (already noted).

Overcoming Problems with Voltage References and SAR’s

Fortunately, the inaccuracies are usually small enough to allow the PSOC5 to be used without worrying about these issues in a large segment of the problems it is used to solve.

If your problem(s) is/are such that you want extremely good accuracy, there are several things you can do:

  1. Create a set of measured compensation(s) (offsets) for the A/D readings, A/D offset, and DAC outputs and store these values in EEPROM. Use these with the ARM processor to compute the accurate reading. You may have to create tables, but I have found formulas often work well enough.
  2. Create a table of changes (percentages) for the DAC based on temperature and use the ARM processor to recompute values based on that table. You may be able to nudge, in real time, the DAC output one way or another, assuming the 4mv or 16mv threshold is an accurate enough change.
  3. Create a table of changes (percentages) for the A/D digitization based on temperature. For example, I have used the DieTemp (Die Temperature) component to index into a table and correct readings in real time to get accurate voltage measurements from off chip devices all the way up to 375F, (PSOC5 internal chip temperature).
  4. Use external parts that are much more stable and sensitive. Unfortunately, that involves extra cost and more circuit board area. Re-visit options 1 and 2 to finish the design.

Finally

In my experience, the changes to the A/D and DAC subsystems are repeatable as temperature changes. The information is often usable between parts.

So, if a table of percentage changes works with one PSOC5, it will generally work for all PSOC5’s. The level of accuracy needed will dictate the amount of attention applied to a specific part.

Enjoy!

Add a Comment

Your email address will not be published.