modelHx711Read

Raw readings of an HX711 by the robert-hh MicroPython driver: gain 128, gain 64, power-down and wake-up

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

The microcontroller reads an HX711 with the MicroPython driver by Robert Hammelrath (robert-hh/hx711, hx711_gpio.py, placed unmodified next to the program hx711_read.py). The driver drives PD_SCK bit by bit and waits for each new data through an interrupt on the falling edge of DOUT: this is possible because each pin access takes 5 µs of simulated time (mcu.gpioOpTime).

The measurement chain is complete: a 1 kg mass (mass), its weight (g, weight), the 5 kg load cell body (loadCell), the gauge bridge (bridge, 1 mV/V at full load) and the converter (hx, without noise).

Expected codes: the bridge output is 1/5 of 1 mV/V, i.e. 0.2 mV/V; at gain 128, code = 0.2e-3 × 128 × 224 ≈ 429,497, and at gain 64, half of it (214,748). The program:

  1. reads a measurement at gain 128 (after the 400 ms settling time of the HX711);
  2. switches to gain 64 (set_gain(64): 27 pulses, the gain applies to the next conversion) and reads again;
  3. shows 128:429497 64:214748;
  4. powers the HX711 down (power_down(): PD_SCK high for more than 60 µs), wakes it up 200 ms later, and reads again: the chip has restarted at gain 128, hence wakeup:429497.

To watch: the icon of hx (gain, last code, "data ready" and "power-down" lights), mcu.GP6.v (the trains of 25 or 27 pulses of 5 µs), mcu.GP7.v (the bits of the data), and the log (the print() output of the program).

Components

TypeNameDefaultDescription
MCUmcuscriptPath = Resources/Scripts/MCU/hx711_read.py - imports the driver hx711_gpio.py placed next to it (robert-hh, unchanged)
MicroPythonMCU.Peripherals.DisplaydisplayCodes read by the microcontroller
MicroPythonMCU.Peripherals.Weighing.Hx711hxConverter, without noise: the codes read are exactly predictable
MicroPythonMCU.Peripherals.Weighing.WheatstoneBridgebridge
MicroPythonMCU.Peripherals.Weighing.LoadCellloadCell5 kg load cell body
Modelica.Mechanics.Translational.Sources.ForceweightThe weight of the mass placed
Modelica.Blocks.Math.GaingWeight = mass × g
Modelica.Blocks.Sources.ConstantmassMass placed: 1 kg
Modelica.Electrical.Analog.Basic.Groundground