filmov
tv
HX711 Excitation Voltage and What You Need to Know
Показать описание
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 Youtube 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.
//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() {
//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() {
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
digitalWrite(RATE, rate);
}
}
}
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 Youtube 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.
//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() {
//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() {
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
digitalWrite(RATE, rate);
}
}
}
Комментарии