erlerobot / smart_motor

4 stars 2 forks source link

Trouble with ADS 1115 16 bit #33

Closed jlamperez closed 8 years ago

jlamperez commented 8 years ago

I'm having some trouble when I get the ADC value from the turnigy servo potentiometer to move the motor to the seek position.

When I move the potentiometer to one side I'm getting negative values and I reach to an adc 0 measure when I have 520mV and not 0V so I can not cover all the potentiometer range. Have you experimented this?

Here some photos of the osciloscope and raspy when I am in 520mV when I go down this voltage I get negative values. rasp2 rasp1

My ADS configuration:


  // Configuration of the ADS1115
  uint16_t config = ADS1115_REG_CONFIG_CQUE_NONE    | // Disable the comparator 
                    ADS1115_REG_CONFIG_CLAT_NONLAT  | // Non-latching 
                    ADS1115_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low   
                    ADS1115_REG_CONFIG_CMODE_TRAD   | // Traditional comparator 
                    ADS1115_REG_CONFIG_DR_128SPS    | // 128 samples per second 
                    ADS1115_REG_CONFIG_MODE_SINGLE;   // Single-shot mode 
                    // Set PGA/voltage range
                   config |=ADS1115_REG_CONFIG_PGA_6_144V;
                   // measure from channel 0
                   config |= ADS1115_REG_CONFIG_MUX_SINGLE_0;
jlamperez commented 8 years ago

Solved.

When I was writing to the 16 bit config register with I2C, this was swapping the low 8 bit and the high 8 bits that I was sending to the register. So I was doing a differential reading betwean AIN0 and AIN1 instead of doing a single ended reading.