# HX711 mV/V information needed

#### baileychic

I am making a HX711 based Weighing Scale using PIC16F877A.

The datasheet

https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf

mentions that for input channel A that is A+ and A- then gain can be 64 or 128 and if 128 is chosen as gain then differential input can be +/-40mV.

Does it mean that input can be -40mV to +40mV = 80 mV range?

80 mV = 2^24 = 0 to 16777215?

My AVDD, VDD and Excitation voltage is 5V.

So, if I choose a Load Cell with 1000 Ohms bridge resistance and 5mV/V then for 5V I get Load Cell output = 5mV * 5 = 25mV?

Currently I am simulating in Proteus and I am displaying just the raw ADC value of HX711 and for 1000 Ohms bridge resistance and 5mV/V Load Cell I am getting 16777215. How am I getting 2^24 for 25mV?

#### Attachments

• 178.7 KB Views: 11
Last edited:

#### baileychic

My Load Cell Capacity is 30 Kgs and Bridge resistances are 1000 Ohms +/-20 and sensitivity is 2mV/V.
My Load Cell Excitation voltage is 5V clean DC.

I am using HX711 with 25 Clocks.

2mV * 5V = 10mV

So, for 30 Kgs my Load Cell give 10mV, right?

What will be the HX711 output for 10mV?
What is the range of mV I can input into INA+ and INA- pins of the HX711?

#### FvM

##### Super Moderator
Staff member
The load cell should be supplied with ADC AVDD to achieve ratiometric operation, otherwise you generate additional error and drift.

I presume you read the HX711 datasheet thoroughly and understand that the specified input ranges are valid for AVDD of 5V.

#### baileychic

@FvM

This is my circuit. See the voltmeters in the HX711 circuit. Should I connect AVDD pin to E+ pin of Load Cell?

This is my almost finished projects test files (not c code as client doesn't allow me to post the c code and also I don't have any code issues).

This is the Proteus simulation video.

https://mega.nz/#!2AB0ESbA!AzwLF2k93eBgPGNRSXcvhzHRnp1o1FpbzW9_3UOxgtc

TARING feature (shown in video) has some issue and I will fix it later.

- - - Updated - - -

In hardware, I am using SparkFun's HX711 module with 5 kg Load Cell with Mecahnical setup.

- - - Updated - - -

This is my code for getting weight.

Code C - [expand]1
2
weighingScale.weight = (double)weighingScale.wt * weighingScale.capacityInKgs / Adc_Resolution;

#### Attachments

• 68.9 KB Views: 3
• 403.1 KB Views: 8
Last edited:

#### KlausST

##### Super Moderator
Staff member
Hi,

* don't leave any unused inputs of any IC floating.
* use analog filters referenced to clean GND
* use high speed ceramics capacitors instead of high ESR electrolytics
* use a capacitor on every supply pin of every IC.

Klaus

baileychic

### baileychic

points: 2

#### baileychic

@FvM and @Klaus

Okay, done.

I connected AVDD pin of HX711 to E+ of Load Cell. Power supply is fine and clean and low noise.

@Klaus

Where to put analog filters?

Can I use movingAverage filter in software for getting noLoadCounts?

Should I configure all PIC's unused pins as inputs and pull them up?

How to connect the unused output pins of MAX7219?

#### KlausST

##### Super Moderator
Staff member
Hi,

Where to put analog filters?
Can I use movingAverage filter in software for getting noLoadCounts?
You have an ADC, thus you have to take care about nyquist to avoid alias frequencies.
Alias frequencies neither can be avoided nor suppressed with software.

Unused inputs just must not be left floating. How you do this is not important. Microcontroller: programming as input with pullup or as output. In doubt read the datasheet.

Outputs are not critical.

Klaus

#### baileychic

Why should I use a filter on INA+ and INA- pins of HX711 module? I am using SparkFun's HX711 module and not HX711 circuit built on the mainboard. The filter will attenuate the signal level. How should I compensate for it?

#### KlausST

##### Super Moderator
Staff member
Hi,

Why should I use a filter on INA+ and INA- pins of HX711 module?
Why: I told you about alias frequencies
INA pins: I didn't talk about INA pins.

In post#5 I told you my recommendations. You are free to follow them or not.

Klaus

baileychic

### baileychic

points: 2

#### baileychic

Okay, I am using HX711 module? Where should I put the filter? On HX711's power pins? I know that HX711 has an internal 24-bit ADC. If I have to put the filter for ADC then how, because ADC connects to INxy pins through MUX and it is internal to the4 chip.

#### KlausST

##### Super Moderator
Staff member
Hi,

I didn't use HX711....
But nyquist and alias frequency problem applies to all ADConversions.
Decide whether you can live with alias frequencies ... and what magnitude you expect..
Then decide if ... and what AAF you implement.

Klaus

Don't get me wrong. There are different strategies to design a circuit.
I'm no low cost designer, I'm a high precision designer.
And I doubt ... without proper design ... you get better results with your 24 bit ADC than with a 16 bit ADC (because the lower 8 bits toggle because of noise and alias frequencies).

baileychic

### baileychic

points: 2

#### baileychic

@Klaus

Leave the filter for now. I will discuss it later after a few days when building the final hardware where the HX711 circuit will be put on the mainboard.

For now, I am testing in Proteus and my noLoadCounts is stable.

My new question is:

I set the Load Cell model to 0.0 reading and its output in Proteus is 0mV. For 100% Load Cell value I am getting 10mV output.

My equation is

So, If I set 30 Kgs as Capacity for the machine then after calibration I have to get 30 Kgs for 10mV input (100% Load Cell scale)?

Load Cell Bridge resistance is set to 1000 Ohms and sensitivity to 2mV/V and E+ (excitation voltage) to Load Cell is supplied from AVDD.

I am not getting 30.000 Kgs as result. I am not even getting 10.000 Kgs as a result.

What is the issue? Code is fine.

For my setup what will be the max input mV into INA+ and INA- pins, +/-10mV or +/-40mV?

How to do the hardware side calculations?

HX711's RATE and XI pins are grounded and I am using 25 Clocks for HX711 that is gain of 128. HX711's internal Osc is 11.0592 MHz.

After getting the weight value correct In Proteus, I will test on hardware.

I have to setup the hardware with Load Cell. Display and other non-HX711 parts of the codes I have tested on hardware and working fine. Here are there videos.

https://mega.nz/#!6VZEgCyY!42_W2XtwO2hOoVsxQ3r4XJm9vLeHiJGiarGJzEoQvzA

https://mega.nz/#!PcJ2jCyb!lWt1s1j1Mq8JEcdz5ReH2pzSyVoYUFsw7c6Vp8g538g

Last edited:

#### KlausST

##### Super Moderator
Staff member
Hi,

I am not getting 30.000 Kgs as result. I am not even getting 10.000 Kgs as a result.
What do you get?

You say you use simulation....so a sraight forward debugging method is to follow the signal from sensor to display.... step by step.
Decide/calculate what you expect .... then check against simulation values.

Usually the hardware manufacturers provide application notes and other informations. Did you go through them?

Klaus

baileychic

### baileychic

points: 2

#### baileychic

I am getting 6.4 as the weight value for 10mV.

- - - Updated - - -

I am getting 6.4 as the weight value for 10mV (edited, sorry for 8.6mV because now AVDD is 4.3V, instead of 5V which gives 10mV)

HX711 datasheet tells that for 128 Gain (25 Clocks) Channel A has a differential input range of +/-20mV that is equal to 40mV, right? and that is for 5V AVDD.

It also tells that for 64 Gain Channel A has a differential input range of +/-40mV that is equal to 80mV range, right? and that is for 5V AVDD.

My AVDD = 4.3V

For 5V AVDD my Load Cell model gives 10mV for 100% load (1000 Ohms BR, 2mV/V)

For 4.3V AVDD it is 8.60V which is correct and I am getting this at Load Cell output in Proteus.

So, if I am getting 6.4 Kgs (for 4.3V AVDD) as weight for capacityInKga = 30.0 and voltage is 10mV (100%) then it is near to 7.5 Kgs which is for 5V AVDD.

So, if I consider my Load Cell output to be 8.6mV * 4 = 34.4mV then weight will be 6.4 Kgs * 4 = 25.6 Kgs (for 4.3V AVDD)

If it is assumed my Load cell output to be 10mV for 100% load with AVDD = 5V then 10mV * 4 = 40mV (full scale value for gain 128) and 7.5 Kgs * 4 = 30 Kgs.

Are my calculations correct?

If yes, then I am getting correct value.

Staff member
My equation is

#### baileychic

ADC of HX711 is 24 bit and so it is

Code:
#define Adc_Resolution 16777216.0
For 8.6mV (AVDD = 4.3V) I am getting not 6.4 Kgs but (6.45 Kgs) with Load Cell load = 100%, Capacity = 30.0 Kgs, Bridge resistance = 1000 Ohms and Sensitivity 2mV/V.

6.45 Kgs * 4 = 25.8 Kgs (8.6 mV, AVDD = 4.3V) because full scale range is 8.6mV * 4 = 34.4mV. (corrected)
7.5 Kgs * 4 = 30 Kgs (10mV, 5V AVDD) because full scale range is 10mV * 4 = 40mV.

30 Kgs = 5V AVDD
x Kgs? = 4.3V AVDD

x = 4.3V * 30 Kgs / 5V = 25.8 Kgs.

So, my final code is this.

Code C - [expand]1
2
3
4
weighingScale.capacityInKgs = (double)weighingScale.capacity / 1000.0; //capacity stored in eeprom 30000 = 30 Kgs
weighingScale.weight = (double)weighingScale.wt * weighingScale.capacityInKgs * 4.0 / Adc_Resolution;
weighingScale.weight = weighingScale.weight * ((double)weighingScale.capacityInKgs / weighingScale.weight);

Lets say I got these in each step.

Code:
weighingScale.wt = HX711_Read_Average(8) - weighingScale.noLoadCounts;
weighingScale.capacityInKgs = (double)weighingScale.capacity / 1000.0; //capacity stored in eeprom 30000 = 30 Kgs
30.0 Kgs

Code:
weighingScale.weight = (double)weighingScale.wt * weighingScale.capacityInKgs * 4.0 / Adc_Resolution;
25.8 Kgs

Code:
weighingScale.weight = weighingScale.weight * ((double)weighingScale.capacityInKgs / weighingScale.weight);
weighingScale.weight = 25.8 * 30.0 / 25.8 = 30.0

Last edited:

#### baileychic

I made a major mistake in the code.

The below line results in weight value always 30.0 Kgs.

Code:
weighingScale.weight = weighingScale.weight * ((double)weighingScale.capacityInKgs / weighingScale.weight);
@FvM and Klaus

How to get the correct weight value? I need the scaling factor equation based on Sensitivity, AVDD value, and Capacity.
I am very near to complete the project.

From this step

Code:
weighingScale.weight = (double)weighingScale.wt * weighingScale.capacityInKgs * 4.0 / Adc_Resolution;
I got 25.8 Kgs in Proteus.

Now, how to get 30.0 Kgs from that value? It should be based on a scaling factor which is formed using Sensitivity of Load Cell and AVDD value.

- - - Updated - - -

Edit:

I found the equation myself. It is,

So, if

AVDD_For_Full_Scale / AVDD_Actual = 5.0V / 4.3V = 1.16279

and

= 25.8

then

25.8 * 1.16279 = 30 Kgs

if weight was 6.45 then

6.45 * 1.16279 = 7.499 = approx 7.5 Kgs.

- - - Updated - - -

I am done with the final equation.

Code C - [expand]1
2
3
4
5
6
7
8
9
#define AVDD_Recommended 5.0
#define AVDD_Actual 4.3

#define HX711_Full_Scale_value_mV_Per_V_For_Gain_128 40 //(+/-20 mV/V = 40 mV)
#define Load_Cell_Full_Scale_Value_mV_Per_V_Multiplied_By_Excitation_Voltage 10 //2 mV/V * 5V = 10mV)

weighingScale.capacityInKgs = (double)weighingScale.capacity / 1000.0; //capacity stored in eeprom 30000 = 30 Kgs
Load_Cell_Full_Scale_Value_mV_Per_V_Multiplied_By_Excitation_Voltage) * (AVDD_Recommended / AVDD_Actual) / Adc_Resolution;

- - - Updated - - -

I guess it should be

Code:
#define HX711_Full_Scale_value_mV_Per_V_For_Gain_128 40 //(+/-20 mV/V = 40 mV)
#define Load_Cell_Full_Scale_Value_mV_Per_V_Multiplied_By_Excitation_Voltage 10 //2 mV/V * 5V = 10mV)
or

Code:
#define HX711_Full_Scale_value_mV_Per_V_For_Gain_128 34.4 //(8.6mV * 4 = 34.4mV)
#define Load_Cell_Full_Scale_Value_mV_Per_V_Multiplied_By_Excitation_Voltage 8.6 //(2 mV/V * 4.3V = 8.6mV)

34.4mV / 8.6mV = 4 (the multiplier in my case).

#### FvM

##### Super Moderator
Staff member
You don't understand ratiometric operation. Load cell output and ADC range are both scaled with AVDD. There's no 1.16 factor.

#### baileychic

You don't understand ratiometric operation. Load cell output and ADC range are both scaled with AVDD. There's no 1.16 factor.
Then what is the equation?

How should I convert my 25.8 Kgs (6.45 Kgs * 4) obtained with AVDD 4.3V and Load Cell of Bridge resistance 1000 Ohms and Sensitivity 2mV/V?

- - - Updated - - -

I know that AVDD drops because of the transistor Vce voltage drop and I also know that E+ of Load Cell is connected to AVDD and hence Load Cell output also depends upon AVDD.

Now, what is wrong in my latest equation?

Staff member
Hi,