The HX711 is a high-precision 24-bit A/D converter chip specifically designed for use in electronic weighing systems. Its interface with the microcontroller unit (MCU) is straightforward, as all control signals are managed through pin inputs, eliminating the need to program internal registers. This makes it very user-friendly for developers looking to integrate it into their projects.
The chip features an input selector that allows users to choose between Channel A or Channel B, each connected to its internal low-noise programmable amplifier. Channel A offers two gain settings: 128 and 64, corresponding to full-scale differential input voltages of ±20mV and ±40mV, respectively. Channel B, on the other hand, has a fixed gain of 32, making it ideal for system parameter monitoring.
Additionally, the HX711 includes an internal regulated power supply that can directly power both the external load cell and the A/D converter within the chip, removing the need for an external analog power source on the main board. The internal clock oscillator requires no external components, further simplifying the design. The chip also supports power-on auto-reset, which streamlines the startup process and ensures reliable operation.
Below is a brief introduction to the reference driver for the HX711, written in both assembly and C language:
**HX711 Driver (Assembly)**
/*---------------------------------------------------*/
Called in ASM: LCALL ReadAD
Can be called in C: extern unsigned long ReadAD(void);
unsigned long data;
data = ReadAD();
/*---------------------------------------------------*/
PUBLIC ReadAD
HX711ROM segment code
RSEG HX711ROM
Sbit ADDO = P1.5;
Sbit ADSK = P0.0;
/*-----------------------------------------------*/
OUT: R4, R5, R6, R7
R7 = "LSB"
If called in C, R4, R5, R6, R7 should not be modified.
-----------------------------------------------*/
ReadAD:
CLR ADSK // Enable AD (PD_SCK set to low)
SETB ADDO // 51CPU quasi-bidirectional I/O input enable
JB ADDO, $ // Wait until AD conversion is complete
MOV R4, #24
ShiftOut:
SETB ADSK // PD_SCK set high (send pulse)
NOP
CLR ADSK // PD_SCK set low
MOV C, ADDO // Read data (one bit at a time)
XCH A, R7 // Move in data
RLC A
XCH A, R7
XCH A, R6
RLC A
XCH A, R6
XCH A, R5
RLC A
XCH A, R5
DJNZ R4, ShiftOut // Check if 24 bits have been read
SETB ADSK
NOP
CLR ADSK
RET
END
**HX711 Driver (C Language)**
sbit ADDO = P1^5;
sbit ADSK = P0^0;
unsigned long ReadCount(void)
{
unsigned long Count;
unsigned char i;
ADDO = 1; // For non-51 MCU, this line may be omitted
ADSK = 0;
Count = 0;
while (ADDO);
for (i = 0; i < 24; i++)
{
ADSK = 1;
Count = Count << 1;
ADSK = 0;
if (ADDO) Count++;
}
ADSK = 1;
Count = Count ^ 0x800000;
ADSK = 0;
return (Count);
}
Spark Plug
spark plug
Jinan Guohua Green Power Equipment Co.,Ltd. , https://www.guohuagenerator.com