More error correction, aka the attiny reference voltage sucks.

After much curve fitting and data analysis, I decided that the fluctuations in the readings were too much, and i had to find another way of fixing things.

I had previously made up my mind that the attiny board i made was the source of the error, not the scale itself. After working on it one evening, I saw the readings move quickly, then stabilize after i put the unit back in the garage (in the cold) from the nice warm house. The scale stayed out there the whole time.

So i figured it was the resistors changing and affecting the gain on the amplifier.

I ran some calculations and determined that the gain should not have changed anywhere near what it did in reaction to the temperature fluctuations, and the changes in resistance that might bring. So that leaves one thing: the ADC unit on the attiny85 itself.

I have been using the 1.1V reference voltage on the attiny as the basis for the readings. It’s a ‘bandgap’ based thing, which sounds fancy and accurate, but let’s give it a test. To test it, i got a 5k potentiometer and put the end pins on +5v and GND, and the wiper was set so it read about 1 volt. I connected the 1volt output to a spare pin on the attiny, and started taking readings to see if it would exhibit the same pattern as the scale.

About a day later, i’m pleased to report that the constant voltage varies EXACTLY the same way the scale does.

Here’s a picture:

After some analysis and curve-fitting, the coefficient is -1.0, which means that the error in the voltage reading is exactly the same as the scale reading, just opposite (which is to be expected, since i am storing the scale reading as 1024 – raw_reading). So it’s basically a matter of adding them together then subtracting an offset.

As you can see, it works really well, and the total range is just 2 ticks!

Also note that I was able to use a potentiometer (could easily have been 2 resistors) as a MUCH more effective temperature sensor than the internal temperature sensor of the attiny itself. That is somewhat sad.

For extra accuracy, i may someday try using an external VREF input, and see if it’s the ADC itself or if it’s the bandgap voltage moving around. For now, this is good enough.

About these ads

3 Responses to “More error correction, aka the attiny reference voltage sucks.”

  1. FractalBrain Says:

    Ok, I’m not going to pretend that I have combed through all of your stuff, but here are some things I encountered that have helped me with temperature related drift:
    1. Resistors: I had to use low temperature coefficient resistors in my summation and amplification stages.
    2. Voltage ref: I think I used a voltage reference to stabilize the voltage to my op-amps. I used linear regulator along with the reference. It helped a lot, but I’m sure there was a better component I could have used. I didnt need to bother with a reference for the AD since it was an NI DAQ board.

    Here are some things I noticed and just decided to work around instead of fixing:
    1. Wire wrap: Yip, I used wire wrap for everything. Ill bet the resistance of my wires changed as a function of temperature and I am suspecting at least a few of those wires were carrying enough current to heat up a bit too much. Next time, PCB.
    2. I built a peltier cooler around the entire balance assembly to control the temperature. It was controlled by a PID controller and came complete with anti-EMF shielding paint.
    3. Signs and lights everywhere warning people not to use their cell phones, slam the doors, or keep the doors open. Yip, no cell phones.

    Dunno if any of that will help, but at least it might give you some ideas about making it as complicated as possible. Hmmm, do the strain gauges drift with temperature? If you haven’t already, you might measure the temperature where they are as well.

    Nice work and a great example of engineering, science, and practicality!!

  2. If no fixed references and same type resistors are used everywhere in the analog section things are proportional to ambient Then thermistors or platinumelements etc. stand out as required variables. That has worked for me at least.

  3. Francisco Says:

    Thanks for sharing this experience! Now I understand the problems I have in my project. When temperature increases, the reading decreases

    Could you please show some code with the correction? Thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: