HX711 Excitation Voltage and What You Need to Know

Описание к видео 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.



//Uses HX711 library by Bogde https://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());
}
}

Комментарии

Информация по комментариям в разработке