Why there is random reading in adc hx711 ?

Good evening arduino team,
I am using HX711 24 bit ADC for TCRT1000 reflective optical sensor. ADC is giving random output within a range of 10000 to 12000 variation when the sensor is not connected, and the ADC is giving same random values when the sensor is connected.

  1. Is randomness is common in ADC, if so how to reduce the range of randomness?
    i have attached the results of the ADC, please go through it and let me know the solution.

vinulakh:
I am using HX711 24 bit ADC for TCRT1000 reflective optical sensor. ADC is giving random output within a range of 10000 to 12000 variation when the sensor is not connected, and the ADC is giving same random values when the sensor is connected.

  1. Is randomness is common in ADC, if so how to reduce the range of randomness?

The following setup gives a good indication on the health condition of the HX711 Chip. Operate it and see the counts on the LCD/SM.
hx711cross.png

hx711a.png

hx711.png

hx711cross.png

hx711a.png

I tested the HX711 according to your suggested method it is giving the output values in decreasing order (shown in attachment)and randomness is same, i want to reduce the randomness as much as possible please suggest the solution

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you post a link to data/specs of the sensor please?

Why do you need to run a HX711 AtoD, when Arduino controllers have AtoD built in?

What model Arduino are you using?

Thanks.. Tom... :slight_smile:

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you post a link to data/specs of the sensor please?

Why do you need to run a HX711 AtoD, when Arduino controllers have AtoD built in?

What model Arduino are you using?

Thanks.. Tom... :slight_smile:

Thank you for the suggestions,

I am using TCRT1000 optical reflective sensor for detecting the niddle difflection in meter,its datasheet is

I am using HX711 ADC with arduino for testing only.

I have attached my code please go through it and do suggest why i am getting random values.

ADC_test.ino (936 Bytes)

vinulakh:
I tested the HX711 according to your suggested method it is giving the output values in decreasing order (shown in attachment)and randomness is same, i want to reduce the randomness as much as possible please suggest the solution

Please, post the codes that you have used for testing.

GolamMostafa:
Please, post the codes that you have used for testing.

int doutPin = A1;
int sckPin = A0;

unsigned long data = 0;
void setup(void)
{
  Serial.begin(9600);
  pinMode(sckPin, OUTPUT);
  pinMode(doutPin, INPUT);
 
  
}
void loop(void)
{
  read_ADC();
  Serial.print("adc:");
  Serial.println(data);
  //Serial.println(" ");
  delay(100);
}
unsigned long read_ADC()
{
  byte dout = digitalRead(doutPin); //check if conversion is ready
  if (!dout)
  {
    data = 0;
    uint8_t dout;
    int GAIN = 1;
    //  convRslt = 0;
    for (uint8_t i = 0; i < (24 + GAIN); i++)
    { //read 24 bit data + set gain and start next conversion
      
      digitalWrite(sckPin, 1);
      
      if (i < (24))
      {

        dout = digitalRead(doutPin);
        data = data << 1;
        if (dout)
        {
          data++;
        }
      }
      digitalWrite(sckPin, 0);
    }

    // time = micros() - time;
    //Serial.println(time, DEC);
  }
}

I have used this code for testing

@OP

Thank you for the codes; I will look into it later sometimes. In the meantime, please upload the following (tested sketch that I use) sketch to test the functionality of your HX711 Module. Kindly, keep the wiper position (of the Pot of the setup) in the mid-position.

/* This program takes 10 samples from LC + HX711B at
   2-sec interval and then computes the average.*/

unsigned long x = 0, y = 0;
unsigned long dataArray[10];
int j = 0;
void setup()
{
  Serial.begin(9600);
  pinMode(A1, INPUT); //data line  //Yellow cable
  pinMode(A0, OUTPUT);  //SCK line  //Orange cable
}

void loop()
{

  for (int j = 0; j < 10; j++)
  {
    digitalWrite(A0, LOW);//SCK is made LL
    while (digitalRead(A1) != LOW) //wait until Data Line goes LOW
      ;
    {
      for (int i = 0; i < 24; i++)  //read 24-bit data from HX711
      {
        clk();      //generate CLK pulse to get MSB-it at A1-pin
        bitWrite(x, 0, digitalRead(A1));
        x = x << 1;
      }
      clk();  //25th pulse
      Serial.println(x, HEX);
      y = x;
      x = 0;
      delay(1000);
    }
    dataArray[j] = y;
  }

  Serial.println("===averaging process=========");
  unsigned long sum = 0;

  for (j = 0; j < 10; j++)
  {
    sum += dataArray[j];
  }
  Serial.print("Average Count = ");
  sum = sum / 10;
  Serial.println(sum, HEX);
}

void clk()
{
  digitalWrite(A0, HIGH);
  digitalWrite(A0, LOW);
}

Hi,
Can you post a schematic, showing how you have the dectector connected to the HX711?

Thanks.. Tom... :slight_smile:

@GolamMostafa
The diagram from post#1.
You should power the voltage divider from E+ (and E-), not from 5volt.
E+ (excitation voltage) is regulated to ~4.2volt on the HX711 board, so should potentially be 'cleaner'.
More important, Vref of the A/D of the HX711 is also connected to E+.
Powering a load cell or voltage divider from 5volt instead of E+ will undo the ratiomatric compensation of the setup.
Leo..

Not sure why you use a ratiometric HX711 for an opto reflector setup.
That requires AFAIK an absolute A/D (like the ADS1115).
Leo..

Wawa:
@GolamMostafa
The diagram from post#1.
You should power the voltage divider from E+ (and E-), not from 5volt.
E+ (excitation voltage) is regulated to ~4.2volt on the HX711 board, so should potentially be 'cleaner'.
More important, Vref of the A/D of the HX711 is also connected to E+.
Powering a load cell or voltage divider from 5volt instead of E+ will undo the ratiomatric compensation of the setup.
Leo..

Thank you for the remarks as the diagram of Post#1 might mislead someone to have his sensor connected that way. I will revise the diagram to have bias points of the load/sensor connected at E+ and E- points.
hx711a.png

hx711a.png