HX711 Bridge Sensor Digital Interface Module (HCMODU0073)

Modules for various types of sensors including accelerometers. gyro's, IR motion, etc
Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

HX711 Bridge Sensor Digital Interface Module (HCMODU0073)

Post by admin » Mon Nov 17, 2014 2:50 pm

Image

A very low cost module incorporating with a very high precision 24 ADC and differential high gain inputs designed to be interfaced with many common types of bridge sensors. E.g. pressure, strain, weight sensors.

Based on Avia Semiconductor’s patented technology, HX711 is a precision 24-bit analogue to-digital converter (ADC) designed for weigh scales and industrial control applications to interface directly with a bridge sensor. The input multiplexer selects either Channel A or B differential input to the low-noise programmable gain amplifier (PGA). Channel A can be programmed with a gain of 128 or 64, corresponding to a full-scale differential input voltage of ±20mV or ±40mV respectively, when a 5V supply is connected to AVDD analogue power supply pin. Channel B has a fixed gain of 32. On-chip power supply regulator eliminates the need for an external supply regulator to provide analogue power for the ADC and the sensor. There is no programming needed for the internal registers. All controls to the HX711 are through the pins.


Features:

• Two selectable differential input channels
• On-chip active low noise PGA with selectable gain of 32, 64 and 128
• On-chip power supply regulator for load-cell and ADC analogue power supply
• On-chip oscillator requiring no external component with optional external crystal
• On-chip power-on-reset
• Simple digital control and serial interface: pin-driven controls, no programming needed
• Simultaneous 50 and 60Hz supply rejection
• Current consumption including on-chip analogue power supply regulator: normal operation < 1.5mA, power down < 1uA
• Operation supply voltage range: 2.6 ~ 5.5V
• Operation temperature range: -40 ~ +85oC


Example:
Image


Schematic:
Image


Example Arduino Sketch:

Code: Select all

/* FILE:    HX711_Bridge_Sensor_Digital_Interface_Module
   DATE:    28/08/14
   VERSION: 0.1
   AUTHOR:  Andrew Davies

This is a basic example of how to use the HX711 dual channel bridge sensor interface 
module (HCMODU0073). By default the sketch will configure the module to take 
measurements from the channel A input with a gain of 64. These measurements will be 
repeatedly triggered at its maximum rate and the result output to a serial terminal.

PINOUT:

Module.....Uno/Nano
GND........GND
DT.........D9
SCK........D8
VCC........+5V


You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute any part of 
this code. This software may not be used for the purpose of promoting products
that directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.
*/


/* Define digital pins used for the clock and data signals. */
#define PD_SCK 8
#define DOUT 9

/* Define the various gain and input options */
#define CHAN_A_GAIN_128 1
#define CHAN_B_GAIN_32 2
#define CHAN_A_GAIN_64 3


void setup()
{
  Serial.begin(9600);
  
  /* Set the clock pin to and output and the digital pin to an input */
  pinMode(PD_SCK, OUTPUT);
  pinMode(DOUT, INPUT);
  
   /* Take the device out of power down mode (clock pin low) */
  digitalWrite(PD_SCK, LOW);
  
  /* Trigger a conversion so that the module is in the correct mode for 
     the next measurement */
  ReadConversion(CHAN_A_GAIN_64);
}

/* Main program loop */
void loop()
{
  /* Read in the last measurement and output to the serial port */
  Serial.println(ReadConversion(CHAN_A_GAIN_64));
}


/* Function to read a measurement from the module. 
   The result is returned as a 32 bit signed integer */
long ReadConversion(byte ConversionMode)
{
  byte index;
  long ConversionData = 0L;
  
  /* Read in the 24 bit conversion data */
  while(digitalRead(DOUT));
  for (index = 0; index < 24; index++)
  {
    digitalWrite(PD_SCK, HIGH);
    ConversionData =  (ConversionData << 1) | digitalRead(DOUT);
    digitalWrite(PD_SCK, LOW);
  }
  
  /* Output some extra clock cycles to set the gain and input options */
  for (index = 0; index < ConversionMode; index++)
  {
    digitalWrite(PD_SCK, HIGH);
    digitalWrite(PD_SCK, LOW);
  }
  
  /* Number is returned as a 24bit 2's compliment but we need to 
     convert it to convert to 32 bit singed integer */
  if (ConversionData >= 0x800000)
    ConversionData = ConversionData | 0xFF000000L;
  
  return ConversionData ;
}

Datasheet:
HX711_AD_HCMODU0073_Datasheet.pdf
You do not have the required permissions to view the files attached to this post.

Markh2u
Posts: 2
Joined: Fri Sep 09, 2016 12:24 pm
Location: Wokingham

Re: HX711 Bridge Sensor Digital Interface Module (HCMODU0073

Post by Markh2u » Fri Sep 09, 2016 12:36 pm

Hi there,

Thanks for this code very helpfull to have an alternative to the HX711 lib's, I am having problems with the code my Teensy-LC seems to fail at the while loop

"while(digitalRead(DOUT));"

To me this seems wrong as the are no {} to encase the contents of the while loop and nothing to to compare DOUT to, or it my be the way Teensy handles the code?

I would have expected
while(digitalRead(DOUT) == something)
{
//do this, do that
}

It might just be me not understanding, as I am not very experienced with C!!

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HX711 Bridge Sensor Digital Interface Module (HCMODU0073

Post by andrew » Fri Sep 09, 2016 2:57 pm

To me this seems wrong as the are no {} to encase the contents of the while loop and nothing to to compare DOUT to, or it my be the way Teensy handles the code?
There are lots of little coding tricks that can be done in C++ that can sometimes confuse a beginner or even an experienced programmer! The while statement is actually correct and is acting as a 'wait until the HX711 is ready' command.

Before reading a conversion out of the HX711 the sketch needs to wait for the current conversion to complete. The HX711 signifies this by holding the data output pin high whilst it is doing a conversion and then pulling it low once the conversion has completed.

Each time the while function is executed is runs the the digitalRead() function contained within its brackets. The digitalRead() function then returns the state of the pin as either True (high) or False (low). The while function will keep executing until the contents within its brackets equate to a false. Although you are correct in that you could write the line as while(digitalRead(DOUT) == true); the statement between the brackets will still get evaluated as true or false, it's just adding an extra step.

Also as there is no additional code to run whilst the while function is being executed then there is nothing to put in between a set of {} brackets so they can be omitted.

I am having problems with the code my Teensy-LC seems to fail at the while loop
What do you mean by fail? Are you getting an error message or is the code just not getting past this point. If its getting stuck how have you determined this?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Markh2u
Posts: 2
Joined: Fri Sep 09, 2016 12:24 pm
Location: Wokingham

Re: HX711 Bridge Sensor Digital Interface Module (HCMODU0073

Post by Markh2u » Fri Sep 09, 2016 4:31 pm

Hi Andrew,

Thanks for the reply, I think I have just solved this :) my circuit included a mux chip to switch between two HX711 boards (im using 4 x pressure sensors) switching between the two IC's it seems they were going to sleep, the code ran "while(digitalRead(DOUT));" this was never satisfied (or maybe in the for loop) as there is no timeout (nore should there be) so the program stopped waiting to be satisfied (i just put serial.println's everywhere to find where it was stopping :roll: ). I have solved this by adding the wake up line after the mux logic to force the chip to wake every time, unfortunatly this probably means a time penalty for multiple readings.

Also had to call the reading twice to be able to change the PGA to use the other channel. I tried to call the gain options first but this did not work, I will hopefully make this more elegant and clean it up somewhat, but its working hurray!

Code: Select all

//**********************************************************************

/* Function to read a measurement from the module.
   The result is returned as a 32 bit signed integer */
long ReadPressure(int input, int channel)
{
  int index;
  long ConversionData = 0L;
Serial.print("*");
 if(channel == 1){                                                //checks to see if 2nd hx711 is selected
  digitalWrite(muxAPin, HIGH);
  digitalWrite(PD_SCK, LOW);                            //Take the device out of power down mode 
 }
 else{
  digitalWrite(muxAPin, LOW);
  digitalWrite(PD_SCK, LOW);                            //Take the device out of power down mode
 }
  //delay(1);
  while(digitalRead(DOUT));                                       // Read in the 24 bit conversion data
  //Serial.println("while");
  for (index = 0; index < 24; index++){
    //Serial.println("for loop");
    digitalWrite(PD_SCK, HIGH);
    ConversionData =  (ConversionData << 1) | digitalRead(DOUT);
    digitalWrite(PD_SCK, LOW);
  }

   for (index = 0; index < input; index++)                         //Output some extra clock cycles to set the gain and input options
  {
    digitalWrite(PD_SCK, HIGH);
    digitalWrite(PD_SCK, LOW);
  }
  
  ConversionData = 0;
  
  while(digitalRead(DOUT));                                       // Read in the 24 bit conversion data
  //Serial.println("while");
  for (index = 0; index < 24; index++){
    //Serial.println("for loop");
    digitalWrite(PD_SCK, HIGH);
    ConversionData =  (ConversionData << 1) | digitalRead(DOUT);
    digitalWrite(PD_SCK, LOW);
  }
  for (index = 0; index < input; index++)                         //Output some extra clock cycles to set the gain and input options
  {
    digitalWrite(PD_SCK, HIGH);
    digitalWrite(PD_SCK, LOW);
  }
  
  if (ConversionData >= 0x800000)                               //24bit 2's compliment but we need to convert it to convert to 32 bit singed integer
    ConversionData = ConversionData | 0xFF000000L;
 
  return ConversionData ;
  
}
Anyway thanks, problem solved for now just in time for the weekend! :D :D

Giannis_D
Posts: 3
Joined: Tue Mar 03, 2020 7:43 pm

Re: HX711 Bridge Sensor Digital Interface Module (HCMODU0073)

Post by Giannis_D » Thu Mar 05, 2020 12:07 pm

READING BENDING STRAIN IN TWO DIRECTIONS WITH HX711 AMPLIFIER

Hello,

I want to measure the strain of a bending beam in a battery supplied application. For this reason I am thinking of using HX711 amplifier shield before connecting the bridge to my Nucleo F334R8 microprocessor which has arduino uno connectors.

https://hobbycomponents.com/sensors/577 ... ace-module

I am thinking of using a half bridge configuration (thus 2 strain gages will be used in opposite sides of the beam)
half bridge.png
My question is whether HX711 amplifier will be able to identify the direction of the bending (which gage is stretched and which is compressed) ?

From what I understand Wheatstone bridge output voltage will be positive in one case and negative in the second case, right ? If yes, how is HX711 able to measure the change in the sign of the voltage?
(HX711 connects to one digital pin and one pwm pin)

Thanks
You do not have the required permissions to view the files attached to this post.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HX711 Bridge Sensor Digital Interface Module (HCMODU0073)

Post by andrew » Thu Mar 05, 2020 2:20 pm

From what I understand Wheatstone bridge output voltage will be positive in one case and negative in the second case, right ?
I can't see any problems with that, it should also double the sensitivity to strain.

If yes, how is HX711 able to measure the change in the sign of the voltage?
The HX711's bridge input is differential so it is able to detect a positive or negative voltage from the bridge circuit. It will then output a 2's compliment value which you can convert into a signed number. You can reference our example sketch on how this is done but you basically end up with a singed number that will represent the amount and direction of strain.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

RetroBoy
Posts: 73
Joined: Sat Feb 26, 2022 11:29 am
Location: U.K.

Re: HX711 Bridge Sensor Digital Interface Module (HCMODU0073)

Post by RetroBoy » Sun Oct 09, 2022 10:30 am

Hi,

Is the E+ & E- ( AVDD & GND ) pre-connected to the 711 ic ?

I have measured an Output of 3.8v on E+ with 5.20v applied to VCC, or will E+ vary dependant on A+/- Inputs.
I don't really want to connect the Wheatstone Bridge to AVDD if the voltage will vary - this is for a Pt100.

Simply trying to save an too many PSU feeds, too many PSUs too much EMI/RFI.

Regards S

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HX711 Bridge Sensor Digital Interface Module (HCMODU0073)

Post by andrew » Mon Oct 10, 2022 8:51 am

Is the E+ & E- ( AVDD & GND ) pre-connected to the 711 ic ?
Yes the E+ input is connected to the AVDD pin of the IC and the E- to GND.

I have measured an Output of 3.8v on E+ with 5.20v applied to VCC, or will E+ vary dependant on A+/- Inputs.
I don't really want to connect the Wheatstone Bridge to AVDD if the voltage will vary - this is for a Pt100.
Note that the internal regulator is only powered up whilst the clock (PD_SCK) pin is pulled low. So to get valid measurement you'll either need to pull this pin low or have your Arduino connected with the sketch running.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

RetroBoy
Posts: 73
Joined: Sat Feb 26, 2022 11:29 am
Location: U.K.

Re: HX711 Bridge Sensor Digital Interface Module (HCMODU0073)

Post by RetroBoy » Mon Oct 10, 2022 12:19 pm

Hi Andrew,

Makes sense, didn't want to power the Bridge only to get no reading.

Regards S.

Post Reply

Return to “Sensors”