Тёмный

HX711 Excitation Voltage and What You Need to Know 

Подписаться
Просмотров 14 тыс.
% 210

If you want to minimize noise on the output data I would recommend understanding how to ensure the external transistor is fully used.
This video explains the potential divider used to control the excitation voltage (E+) and the corrected equation for calculating resistances. Data sheet is incorrect and should be VAVDD=VBG*(R1+R2)/ R2 or E+ = 1.25*(R1+R2)/R2
Example code to get you started, demonstrating features from the previous video. Edit out what you don't need if you just want to get the HX711 working.
Copy and paste into a blank sketch in Arduino IDE or similar. Unfortunately RU-vid won't allow greater than symbol near end of code so you will need to replace it in the IDE. Just try to compile the code and it will find it for you.
//Uses HX711 library by Bogde github.com/bogde/HX711
//Timer and PWM setup works for Uno or Nano only (ATmega328P)
#include "HX711.h"
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 4; //Can be another pin
const int LOADCELL_SCK_PIN = 5; //Can be another pin
const int RATE = 8;
HX711 scale;
long reading;
unsigned long previousMillis = 0;
int counter = 0;
int sampleTime = 0;
float samplePerSec = 0;
bool rate = 0;
void setup() {
Serial.begin(115200);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); // (Dout PIN, SCK PIN, gain) Channel A 128 or 64, Channel B 32.
//Set up PWM on pin 3
TCCR2A = bit(COM2A1) | bit(COM2B1) | bit(WGM21) | bit(WGM20);
TCCR2B = bit(WGM22) | bit(CS20);
OCR2A = 2; // 14 for 1MHz min recommended, 1 for 8MHz
OCR2B = 1; // half of OCR2A for 50% duty, 0 for 8MHz
pinMode(3, OUTPUT); // Output pin 3 for OCR2B connected to XI via 20pF capacitor
pinMode(RATE, OUTPUT); //Change sample rate with pin 8
digitalWrite(RATE, LOW); //set HX711 sample rate to slow
}
void loop() {
if (scale.is_ready()) {
//reading = (scale.read() / 100) + 3214; //can be used to remove noise and offset
reading = scale.read();
counter ++;
}
if (counter == 10) { // average over 10 samples can be changed for high or low sample rates but change value 4 lines below from 10000.0
counter = 0;
sampleTime = millis() - previousMillis;
previousMillis = millis();
samplePerSec = 10000.0 / sampleTime; // 10000 = 1000 x counter
//Serial.print (",");
Serial.print(sampleTime);
Serial.print (",");
Serial.print(samplePerSec);
Serial.print (",");
Serial.println(reading);
digitalWrite(RATE, rate);
}
if (Serial.available() *greater than* 0) { //receive rate from serial
rate = (Serial.parseInt());
}
}

Опубликовано:

 

2 май 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@josemanuelriosgonzales
@josemanuelriosgonzales 2 года назад
Exelente trabajo desarrollado lo felicito y se aprende bastante gracias y adelante
@soup6483
@soup6483 2 года назад
rare gem
@carlos.csbr2
@carlos.csbr2 Год назад
Obrigado pela dica do gnd, no meu sistema esta placa estava se comportando de maneira diferente do esperado.
@TheSomar1991
@TheSomar1991 3 месяца назад
Thank you so much that was so helful
@Ed.R
@Ed.R 3 месяца назад
Glad I was able to help.
@asalaahmad9286
@asalaahmad9286 4 месяца назад
Hello, thank you so much for your video. I’m using the hx711 and inputting 5v from my arduino, but when I measure the E+ voltage output, it gives 0.4 ish volts, which is really low. I thought it might be the board, but I swapped it and it did the same thing. I’m using the chip with a half Wheatstone bridge and 2 strain gauges. I ended up hooking up the Wheatstone bridge to a 9V battery instead of connecting it to the E+ and E-. When it was connected to the E+ and E- and I tried calibrating to get a load cell output, it would give nan, or 0. After connecting it to the 9v battery, the load cell output gave me a reading but it was fluctuating a lot and did not give any consistent values. How can I fix this issue with the E+ and E-, and do u think that hooking it up to a 9V battery was ok to do? Do you think that is what’s contributing to the fluctuations?
@shoaibahmedsiddique
@shoaibahmedsiddique 2 года назад
@Ed R, is it possible to get correct readings within 1 seconds of time? I saw in many videos that it takes areound 2-2.5 sec to settle down and measure the load weight correctly.
@Ed.R
@Ed.R 2 года назад
That's not something I know anything about unfortunately. I always have the HX711 running continuously.
@sandratraandrianarisoa2978
@sandratraandrianarisoa2978 Год назад
Wouah, on peut avoir le montage final s'il vous plaît, merci beaucoup. J'avais eu ce problème de stabilité lors de la lecture de la sortie.
@user-hl6xf8dy7t
@user-hl6xf8dy7t 2 года назад
Thank you so much. I will try this later as I was trying to figure out why I had fluctuations in readings of a load cell. I don't know if that will help but it sounds like it will. I will try it tommorrow and let you know.
@Ed.R
@Ed.R 2 года назад
In theory it should help but knowing strain gauges you never know. Do let me know how you get on. Thanks for commenting.
@user-hl6xf8dy7t
@user-hl6xf8dy7t 2 года назад
@@Ed.R Today I modified my hx711 by lifting pin 15 off the board and shorting it to pin 16. I got the 80hz rate, but the measurements were inaccurate. Then I wanted to ground pin 5, but I went with a different approach. I grounded E- directly to the other side of the board to GND. It turned out that I made a mistake and I actually shorted DT to E- with gave me constant 0 readings. When I figured it out I reverted the mistaken connection between E- and DT, but I kept getting reading of 0 in serial monitor. I thought I might have damaged the hx711 so I hooked up another one modified in what should be the right way (pin 15 to pin 16 and E- to GND) but I keep getting reading of 0. What am I doing wrong and is this way of grounding pin 5 directly through E- the right way to go ?
@Ed.R
@Ed.R 2 года назад
@@user-hl6xf8dy7t Doesn't seem like you have done anything wrong with the modifications. Pin 15 to 16 or VCC is fine that gives the 80Hz sample rate. Was thinking you were going to change the excitation voltage E+. Connecting E- to GND is fine to because E- is connected to pin 5, nothing wrong there. Not sure about the readings being 0. Would suggest to me that either E+ is shorted to ground or the channel inputs are shorted together. If there was no excitation voltage or a missing connection I would expect a random value as output because the input is floating. What sort of strain gauge setup do you have? Have you checked the voltages across it?
@user-hl6xf8dy7t
@user-hl6xf8dy7t 2 года назад
@@Ed.R What do you mean by changing the excitation voltage? You mean by using the method you suggested and swapping r1 with 10k one? By the way does it matter how am I connecting the load cell? Because I am using two 3 wire load cells wired like so LC1 Black + LC2 white to E+, LC1 white + LC2 Black to E-, LC1 Red to A+, LC2 Red to A-.
@Ed.R
@Ed.R 2 года назад
@@user-hl6xf8dy7t Yes but I don't think it will solve your issue with 0 output. Never worked with load cells myself but appear to be half bridges. The way you have wired them seems to make sense even though the wiring colours don't. I'd check the voltages with a meter. The red wires should be half the voltage of E+.
@mindracing
@mindracing 2 года назад
Very useful! You say to fix the missing ground link, and I'm sure that you are correct, however, my device seems to work well and I've not implemented the fix. What would I notice to be different if I do?
@Ed.R
@Ed.R 2 года назад
For most applications it will work just fine as you have discovered however things to be aware of are. The analog ground will be around 0.7 - 0.8V above the digital ground. Means the onboard regulator is less likely to work if VSUP < 5V. Assuming AVDD (E+) is set to around 4.1V. If you change the rate the reading will step up or down noticeably. I perhaps worded it wrong and instead should have said it's worth doing to get the best out of the chip but not in many cases necessary.
@Ed.R
@Ed.R 2 года назад
I've relished this is already in the video so to better answer your question. If the onboard regulator isn't used you may not get as stable a reading for a couple of reasons. Some newer more efficient voltage regulators have noticable ripple which could create noise. Second you are relying on a regulator which will have other loads on it (such as an MCU) which may prevent it from supplying a stable voltage. If the excitation voltage changes it will disrupt the strain gauge output.
@mindracing
@mindracing 2 года назад
@@Ed.R Thank you. I have a spare board so I'll give one a try and see if I notice a difference.
@mindracing
@mindracing 2 года назад
@@Ed.R After some testing, I've noticed that the output slowly drifts downwards. Would your fix help correct this?
@mindracing
@mindracing 2 года назад
I tried it andit doesn't! I need to look elsewhere.
@svsv9
@svsv9 3 года назад
Thank for sharing this. I am just arduino hobbyist. I saw a uA meter based on this sensor. I don't understand nothing at all, but it is the only project to build a micro ammeter on the web I have found. Author does not answer at all my doubts. There's a way you may help me to build it? I need to sense load lines from a cellphone. I'd like to DYI instead of read under a common DMM without any possible way to send to a computer. Thank you so much if you are able to.
@Ed.R
@Ed.R 3 года назад
I'm still at hobby level to really but will have a go at helping. On the rare occasion I understand something I try and post a video. Had never thought of using an HX711 as an amplifier and ADC for a current shunt. Could see it having good potential. This video won't actually be of any help as I suspect you won't need an excitation voltage. Will have to be careful with the ground though. Mobile phones aren't really my area of interest so have little knowledge. What are the load lines?
@svsv9
@svsv9 3 года назад
@@Ed.R Yes, it seem to work great as uA meter. I have contacted members who built it, but any answer yet for helping. I have order all to build the meter from China still waiting, while I am studying it I don't understand almost nothing. Ground has been my enemy when I use sensor like INA219. or Shut resistor(Burden voltage is so high in that scheme) 5V arduino + 1.1 volt INA + 40mA...) Now I am thinking do it with a 0.1 Shunt and an ADS1115(15bits) 2^5= 6.11v/32767= 0.0001864681 for an Analog entry so resolution is extreme hi vs 1023 arduino MIC, but once again Ground load + Ground arduino + sensor. and noise.... if there is a way to "virtualize the ground" ? humm. that is engineering.... When a cellphone is turned off, does not charge or turn on at all, the first thing to do is disconnect Battery, interface any (+) line of the power connector put ground to ground and a DM in series at uA scale and take a look how much current is consuming with a Regulated power supply at 1V or 2V, 50mA. Any phone in good state never go up more than a few uA or mA, if it is turned off and consume 10ma or 50mA(max limited) something is wrong (short cut) bad PMIC, blow ceramic Caps. etc. It would be amazing to interface this test with an Arduino and send to a PC to collect that statics. That's the reason I would like to find a cheap solution. Thank you for your reply. if you want the files project and references just let me know.
@Ed.R
@Ed.R 3 года назад
@@svsv9 I've watched laptop repair videos and it was obvious that measuring current consumption is an important diagnostic tool. I can see now the usefulness of this for phone repair to especially with data logged on to a computer. Think I have found the website you posted on. From what I understand reading the other posts. It seems the current shunt can be floating. As in the GND of the HX711 is not connected to the shunt or phone or its supply GND in any way. Therefore in theory the voltage at the shunt shouldn't matter, the HX711 will only measure the voltage drop across the shunt. I've not got my electronics stuff with me at the moment so can't test it. I think its going to be something you'll have to experiment with.
@svsv9
@svsv9 3 года назад
@@Ed.R Thanks, if you find more utilities on this HX711 module, please let me know. I still waiting from Aliexpress my package, even I think I have lost my order, thinking to re order from elsewhere. Thank you for replying.
@ahmedmoustafa6829
@ahmedmoustafa6829 Год назад
Do you have any measurement result before and after the connection to compare ?
@Ed.R
@Ed.R Год назад
I don't, but maybe I should have done.
@gustavrsh
@gustavrsh Год назад
If I need actual 5V as excitation, and 3.3V vcc/logic levels, I need to use an external regulator, correct?
@Ed.R
@Ed.R Год назад
You would yes and the HX711 can take up to 5.5V. With a change of feedback resistor you should be able to get a 5V excitation voltage.
@Ed.R
@Ed.R Год назад
Having said this just be careful putting a regulator before another regulator as it has caused me serious drifting issues. I would really think about why the excitation voltage needs to be so high at 5V as this can create problems with stain gauge heating. Is the material you are measuring very stiff or the load very small, if not half the voltage will give you good results. If you want very high precision then the HX711 may not be the best choice and increasing the stain gauge voltage isn't a good way to compensate. Hope this helps.
@gustavrsh
@gustavrsh Год назад
It's as big and bulky 2 ton load cell haha, it's designed to be excited from 5 to 12. I also need a bit higher sample rate because it'll be measuring a rocket engine, so I'll use a generated PWM signal as clock. Thank you for your response. I'll analyse the datasheet and come up with a circuit.
@Ed.R
@Ed.R Год назад
@@gustavrsh Interesting in that case I see why you need 5V. Don't forget the capacitor in series with the PWM signal.
@mimechehoussam9234
@mimechehoussam9234 Год назад
sir please can you demonstrate why is vfb is equal to vbg
@Ed.R
@Ed.R Год назад
Everything I know I have already shared. I'm not knowledgeable on the design of the chip itself.