ADC calculations in firmware

Discussion in 'The Projects Forum' started by danielb33, Apr 1, 2014.

  1. danielb33

    Thread Starter Member

    Aug 20, 2012
    This problem is involved. Thanks for even taking the time to read it! This is not for school. I am an electronics technician, rusty on my math apparently.

    I have a 12 bit adc that is computing position of two motors via feed back from a POT. I have a great 2.5V reference for the MCU, but a lousy reference to the POT. The pot is ratiometric. I am attenuating the 5VDC to the POT and reading it at the 12 bit ADC to determine the voltage at the POT for high resolution.

    The POT is 0.088 degree resolution, 360 degrees.

    I will be measuring feedback from two POTs in two actuators. As the actuator extends, the pot will turn.

    Here is the tricky part. I need to use the incoming ADC data from feedback from the POT, and for the voltage at the POT to normalize the position of the motor to any given voltage at the POT. If I have 5.5VDC at the POT, I want to normalize the data to as if it were 5VDC at the POT, and same for 4.5 or any other voltage. I am having trouble calculating the position in my code. The voltage output from the pot is a total of 92% of the span of the POT excitation voltage and this corresponds to a full 360 degrees.

    This gives 0.92*VCC/360 degrees or 0.92*VCC/(360*0.067) for volts per inch.

    Getting position for a fixed excitation is simple. I am finding it very difficult to normalize for a varying excitation. I cannot change the design.
    Thanks for the help.

    120.8/1 gear ratio

    1 turn on screw is 0.2 inches

    1 bit = 2.5/2^12 volts

    1 deg of pot is .067” of travel
  2. crutschow


    Mar 14, 2008
    You multiply the pot reading by the ratio of 5V to the measured 5V supply reading [5V / (5V measured)].