Hx711 driver

The HX711 is a 24-bit A/D converter chip designed for high-precision electronic scales. The interface and programming of the chip with the back-end MCU chip is very simple, all control signals are driven by pins, no need to program the internal registers of the chip. The input selector switch can be used to select either Channel A or Channel B to connect to its internal low noise programmable amplifier. Channel A has a programmable gain of 128 or 64, and the corresponding full-scale differential input signal amplitude is ±20mV or ±40mV, respectively. Channel B is a fixed 32 gain for system parameter detection. The regulated power supply provided on the chip can supply power directly to the external sensor and the A/D converter in the chip, and no additional analog power supply is required on the system board. The clock oscillator inside the chip does not require any external devices. The power-on auto-reset feature simplifies the boot process.

Hx711 driver

The following is a brief introduction to the reference driver for hx711 (assembly and C language):

Hx711 driver (assembly)

/*------------------------------------------------ -------------------

Called in ASM: LCALL ReaAD

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 cannot be modified.

-------------------------------------------------- -*/

ReadAD:

CLR ADSK //Enable AD (PD_SCK is set low)

SETB ADDO //51CPU quasi-bidirectional I/O input enable

JB ADDO, $ //Judge whether the AD conversion is over, if not, wait or start reading

MOV R4, #24

ShiftOut:

SETB ADSK //PD_SCK is set high (send pulse

) NOP

CLR ADSK //PD_SCK is 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 / / determine whether to move into 24BIT

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; //Non-51 MCU, omit this line

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);

}

N Connector

Series N type connect are widely used in communication systems. which have the excellent performances of virbration prooff, high reliability, uperior electrical and mechanical propertie.

We produce all kinds N type, for Semi-rigid connctors, Straight Cable plugs, Right Angle Cable Plug, Straight Flange Jacks and Plugs.

The interface dimensions and technical characteristices are in accord with the specifications of MIL-STD-348A-304, IEC 60169-16 and CECC 22210.

N Type Cable Mount Connectors,N Type Bulkhead Mount Connectors,N Type Flange Mount Connectors,N Type PCB Mount Connectors

Xi'an KNT Scien-tech Co., Ltd , https://www.honorconnector.com

Posted on