qtfp
Posts: 36
Joined: Sat May 25, 2013 2:00 pm

Pigpio HX711.py will hang

Mon Feb 19, 2018 3:36 pm

I used the example from the official website
http://abyz.me.uk/rpi/pigpio/code/HX711_py.zip
and modified the """if __name__ == "__main__":""" part as follow:

Code: Select all

if __name__ == "__main__":

   import time
   import pigpio
   import HX711

   def cbf(count, mode, reading):
      W =round((reading-(-295705.0))*50/(-317687-(-295705)),2)
      print(count, mode, reading,W)
      
   #pi = pigpio.pi()
   pi = pigpio.pi("192.168.1.76",8888)
   if not pi.connected:
      exit(0)

   print("start with CH_B_GAIN_32 and callback")

   s = HX711.sensor(pi, DATA=9, CLOCK=10, mode=CH_B_GAIN_32, callback=cbf)
   '''
      time.sleep(5)
   
      s.set_mode(CH_A_GAIN_64)
   
      print("Change mode to CH_A_GAIN_64")
   
      time.sleep(5)
   '''
   s.set_mode(CH_A_GAIN_128)

   print("Change mode to CH_A_GAIN_128")

   time.sleep(5)

   s.pause()

   print("Pause")

   time.sleep(5)

   s.start()

   print("Start")

   time.sleep(5)

   s.set_callback(None)

   print("Cancel callback and read manually")

   stop = time.time() + 50

   c, m, r = s.get_reading()
   max_=0
   min_=10000
   print(c)

   while time.time() < stop:
      count, mode, reading = s.get_reading()
      if count != c:
         c = count
         W =round((reading-(-295705.0))*50/(-317687-(-295705)),2)
         if W>max_:
            max_=W
         if W<min_:
            min_=W
         print(count, mode, reading, W, max_, min_,max_-min_)
      time.sleep(0.5)

   s.pause()

   s.cancel()

   pi.stop()
There will be unexpected hang. Sometimes, I will re-enter the program, it will work agian for a while. While sometimes, I need to reboot to make it work again. This example is really inspiring for bit-banging with chip by callback, but I am still too new to fixed the problem.

The program ran well until it hang:

Code: Select all

(4199, 1, -297205, 3.41, 4.15, 2.83, 1.3200000000000003)
(4203, 1, -297066, 3.1, 4.15, 2.83, 1.3200000000000003)
(4208, 1, -297240, 3.49, 4.15, 2.83, 1.3200000000000003)
(4213, 1, -297035, 3.03, 4.15, 2.83, 1.3200000000000003)
(4217, 1, -297146, 3.28, 4.15, 2.83, 1.3200000000000003)
(4222, 1, -297098, 3.17, 4.15, 2.83, 1.3200000000000003)
(4226, 1, -297206, 3.41, 4.15, 2.83, 1.3200000000000003)
(4231, 1, -297089, 3.15, 4.15, 2.83, 1.3200000000000003)
(4233, 1, -297150, 3.29, 4.15, 2.83, 1.3200000000000003)    <====Stop here
After it hang, I may encounter this situation and it need a reboot:

Code: Select all

start with CH_B_GAIN_32 and callback
Change mode to CH_A_GAIN_64
Change mode to CH_A_GAIN_128
Pause
Start
Is there anything I need to notice when I use the callback?

User avatar
joan
Posts: 15939
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pigpio HX711.py will hang

Mon Feb 19, 2018 4:12 pm

Could you post the complete amended code which hangs. If I get some time I'll give it a go and see if I can replicate the issue.

Which version of pigpio are you using? (pigs pigpv).

qtfp
Posts: 36
Joined: Sat May 25, 2013 2:00 pm

Re: Pigpio HX711.py will hang

Mon Feb 19, 2018 4:48 pm

joan wrote:
Mon Feb 19, 2018 4:12 pm
Could you post the complete amended code which hangs. If I get some time I'll give it a go and see if I can replicate the issue.

Which version of pigpio are you using? (pigs pigpv).
I don't actually amend anything important, I just prolong runtime and add some calculation for weights and it will hang.
pigs pigpv=64
I use wifi ssh to pi.

I also find that this program hang almost at begin when I start from remote computer and use like:

Code: Select all

pi = pigpio.pi("192.168.1.76",8888)



Code: Select all

#s = HX711.sensor(pi, DATA=9, CLOCK=11, mode=CH_B_GAIN_32, callback=cbf)
s = HX711.sensor(pi, DATA=6, CLOCK=5, mode=CH_B_GAIN_32, callback=cbf)

Code: Select all

#stop = time.time() + 5
 stop = time.time() + 5000

User avatar
joan
Posts: 15939
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pigpio HX711.py will hang

Mon Feb 19, 2018 5:46 pm

As I say, if you post the complete code that you are using I will have a look. I am not going to speculate though.

qtfp
Posts: 36
Joined: Sat May 25, 2013 2:00 pm

Re: Pigpio HX711.py will hang

Mon Feb 19, 2018 6:06 pm

joan wrote:
Mon Feb 19, 2018 5:46 pm
As I say, if you post the complete code that you are using I will have a look. I am not going to speculate though.
Thanks for your help!!!
I am stuck here for a while

Code: Select all

#!/usr/bin/env python

# HX711.py
# 2016-05-01
# Public Domain

CH_A_GAIN_64  = 0 # Channel A gain 64
CH_A_GAIN_128 = 1 # Channel A gain 128
CH_B_GAIN_32  = 2 # Channel B gain 32

import time

import pigpio # http://abyz.co.uk/rpi/pigpio/python.html

class sensor:

   """
   A class to read the HX711 24-bit ADC.
   """

   def __init__(self, pi, DATA, CLOCK, mode=CH_A_GAIN_128, callback=None):
      """
      Instantiate with the Pi, the data GPIO, and the clock GPIO.

      Optionally the channel and gain may be specified with the
      mode parameter as follows.

      CH_A_GAIN_64  - Channel A gain 64
      CH_A_GAIN_128 - Channel A gain 128
      CH_B_GAIN_32  - Channel B gain 32

      Optionally a callback to be called for each new reading may be
      specified.  The callback receives three parameters, the count,
      the mode, and the reading.  The count is incremented for each
      new reading.
      """
      self.pi = pi
      self.DATA = DATA
      self.CLOCK = CLOCK
      self.set_mode(mode)
      self.callback = callback

      self._paused = False
      self._data_level = 0
      self._clocks = -1
      self._value = 0
      self._reading = None
      self._count = 0

      pi.set_mode(CLOCK, pigpio.OUTPUT)
      pi.set_mode(DATA, pigpio.INPUT)

      pi.write(CLOCK, 1) # Pause the sensor.

      pi.wave_add_generic(
         [pigpio.pulse(1<<CLOCK, 0, 20), pigpio.pulse(0, 1<<CLOCK, 20)])

      self._wid = pi.wave_create()

      self._cb1 = pi.callback(DATA, pigpio.EITHER_EDGE, self._callback)
      self._cb2 = pi.callback(CLOCK, pigpio.FALLING_EDGE, self._callback)

      self._valid_after = time.time() + 0.4

      pi.write(CLOCK, 0) # Start the sensor.

   def get_reading(self):
      """
      Returns the current count, mode, and reading.

      The count is incremented for each new reading.
      """
      return self._count, self._mode, self._reading

   def set_callback(self, callback):
      """
      Sets the callback to be called for every new reading.
      The callback receives three parameters, the count,
      the mode, and the reading.  The count is incremented
      for each new reading.

      The callback can be cancelled by passing None.
      """
      self.callback = callback

   def set_mode(self, mode):
      """
      Sets the mode.

      CH_A_GAIN_64  - Channel A gain 64
      CH_A_GAIN_128 - Channel A gain 128
      CH_B_GAIN_32  - Channel B gain 32
      """
      self._mode = mode

      if mode == CH_A_GAIN_128:
         self._pulses = 25
      elif mode == CH_B_GAIN_32:
         self._pulses = 26
      elif mode == CH_A_GAIN_64:
         self._pulses = 27
      else:
         raise ValueError

      self._valid_after = time.time() + 0.4

   def get_mode(self):
      """
      Returns the current mode.
      """
      return self._mode

   def pause(self):
      """
      Pauses readings.
      """
      self._paused = True
      self.pi.wave_tx_stop()
      self.pi.write(self.CLOCK, 1)
      self.pi.set_watchdog(self.CLOCK, 0) # Cancel any timeout.

   def start(self):
      """
      Starts readings.
      """
      self.pi.write(self.CLOCK, 0)
      self._clocks = -1
      self._value = 0
      self._paused = False
      self._valid_after = time.time() + 0.4

   def cancel(self):
      """
      Cancels the sensor and release resources.
      """
      if self._cb1 is not None:
         self._cb1.cancel()
         self._cb1 = None

      if self._cb2 is not None:
         self._cb2.cancel()
         self._cb2 = None

      if self._wid is not None:
         self.pi.wave_delete(self._wid)
         self._wid = None

      self.pi.set_watchdog(self.CLOCK, 0) # cancel timeout

   def _callback(self, gpio, level, tick):

      if gpio == self.CLOCK:

         if level == 0:

            self._clocks += 1

            if self._clocks < 25:

               self._value = (self._value << 1) + self._data_level

         else: #  timeout

            self.pi.set_watchdog(self.CLOCK, 0) # cancel timeout

            if self._clocks == self._pulses:
               if self._value & 0x800000:
                  self._value |= ~0xffffff

               if not (self._paused) and (time.time() > self._valid_after):
                  self._reading = self._value
                  self._count += 1
                  if self.callback is not None:
                     self.callback(self._count, self._mode, self._reading)

            self._clocks = 0
            self._value = 0

      else:

         self._data_level = level

         if (level == 0) and (self._clocks == 0):

            if not self._paused:
               self.pi.wave_chain([255, 0, self._wid, 255, 1, self._pulses, 0])
               self.pi.set_watchdog(self.CLOCK, 2) # 2 ms timeout

if __name__ == "__main__":

   import time
   import pigpio
   import HX711

   def cbf(count, mode, reading):
      W =round((reading-(-295705.0))*50/(-317687-(-295705)),2)
      print(count, mode, reading,W)
      
   pi = pigpio.pi()
   #pi = pigpio.pi("192.168.1.76",8888)
   if not pi.connected:
      exit(0)

   print("start with CH_B_GAIN_32 and callback")

   s = HX711.sensor(pi, DATA=6, CLOCK=5, mode=CH_B_GAIN_32, callback=cbf)
   
   time.sleep(5)
   
   s.set_mode(CH_A_GAIN_64)
   
   print("Change mode to CH_A_GAIN_64")
   
   time.sleep(5)
   s.set_mode(CH_A_GAIN_128)

   print("Change mode to CH_A_GAIN_128")

   time.sleep(5)

   s.pause()

   print("Pause")

   time.sleep(5)

   s.start()

   print("Start")

   time.sleep(5)

   s.set_callback(None)

   print("Cancel callback and read manually")

   stop = time.time() + 50

   c, m, r = s.get_reading()
   max_=0
   min_=10000
   print(c)

   while time.time() < stop:
      count, mode, reading = s.get_reading()
      if count != c:
         c = count
         W =round((reading-(-295705.0))*50/(-317687-(-295705)),2)
         if W>max_:
            max_=W
         if W<min_:
            min_=W
         print(count, mode, reading, W, max_, min_,max_-min_)
      time.sleep(0.05)

   s.pause()

   s.cancel()

   pi.stop()



User avatar
joan
Posts: 15939
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pigpio HX711.py will hang

Mon Feb 19, 2018 6:29 pm

I can't see anything obvious.

I'll need to find my HX711 and hook it up. Not sure how long this will take.

qtfp
Posts: 36
Joined: Sat May 25, 2013 2:00 pm

Re: Pigpio HX711.py will hang

Thu Feb 22, 2018 4:02 pm

joan wrote:
Mon Feb 19, 2018 6:29 pm
I can't see anything obvious.

I'll need to find my HX711 and hook it up. Not sure how long this will take.
Right now, I use raspi <pigpio bb_serial< arduino nano <HX711. And it work fine, but still looking forward to know what's wrong~~
In the logic analyzer, The 25 pulses sending from raspi.pigpio will suddenly disappear or be stopped.
Thanks for pigpio :D :D :D

User avatar
joan
Posts: 15939
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pigpio HX711.py will hang

Thu Feb 22, 2018 4:44 pm

I haven't forgotten but I can't find my HX711. I'm using the opportunity to try to get all my components into some sort of order. Hopefully I'll find the HX711 during that process.

User avatar
joan
Posts: 15939
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pigpio HX711.py will hang

Sun Feb 25, 2018 5:53 pm

I wonder if it is the transition between channels causing the problem. The example script reads the two A channels and the B channel.

Could you comment out the example __main__ code channels you are not using so it is not switching between channels for no reason.

User avatar
joan
Posts: 15939
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pigpio HX711.py will hang

Mon Mar 05, 2018 4:30 pm

I think I know why it hangs. I have updated the code at

http://abyz.me.uk/rpi/pigpio/examples.h ... n_HX711_py

Only tested on a HX711 configured for 10 samples per second.

PlanB
Posts: 109
Joined: Tue Oct 28, 2014 6:44 am

Re: Pigpio HX711.py will hang

Tue May 01, 2018 8:43 am

There is a nice little differential pressure breakout board (https://www.ebay.com.au/itm/Digital-Bar ... 2749.l2649) using the HX711s sibling the H710B. My reading of the data sheets is that they are sufficiently similar that HX11_py might have worked with it but alas no. So near & yet so far!

User avatar
joan
Posts: 15939
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pigpio HX711.py will hang

Tue May 01, 2018 10:17 am

PlanB wrote:
Tue May 01, 2018 8:43 am
There is a nice little differential pressure breakout board (https://www.ebay.com.au/itm/Digital-Bar ... 2749.l2649) using the HX711s sibling the H710B. My reading of the data sheets is that they are sufficiently similar that HX11_py might have worked with it but alas no. So near & yet so far!
Do you have a link to an English translation of the datasheet?

PlanB
Posts: 109
Joined: Tue Oct 28, 2014 6:44 am

Re: Pigpio HX711.py will hang

Wed May 02, 2018 1:08 am

The translators I tried mashed the .PDFs pretty bad but it was the same 2s complement output & clocking methodology @ 10/40Hz. I'm loath to email you the dogs breakfast I waded through, I'll see if I can come up with a more legible translation.

User avatar
joan
Posts: 15939
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pigpio HX711.py will hang

Wed May 02, 2018 7:27 am

Did you get no readings or just no readings which made sense? Perhaps use piscope to capture what the device is spitting out. If you save the data in piscope format it can be played back and used as an input to test software. If you do capture data try to capture at least 30 seconds worth.

PlanB
Posts: 109
Joined: Tue Oct 28, 2014 6:44 am

Re: Pigpio HX711.py will hang

Thu May 10, 2018 12:17 am

I got https://www.ebay.com.au/itm/Digital-Bar ... 2749.l2649 working with this https://hackaday.io/project/25848-a-che ... ython-code for the time being.

I'm puzzed by the results. Since this is a differential pressure sensor I expected the output to be stable with no airline connected but it wanders around randomly to the tune of about 4% over 24 hours. When I applied a static source at about half range (20kPa) I get this weird sawtooth where the reading gradually drops over a period of hours then jumps up to the original value to repeat the decay. The variation is ~15%

My only experience with strain gauges to date has been with off-the-shelf submersible pressure sensors. I've notice they have long settling times with a typically ~1% drift over the first few minutes after power up. But this thing is unusable as is. Am I missing something? Should I be recycling power to it after each reading?

Am I missing the point completely? Are these chips not meant to have any long term stability? Is the idea that you take a tare reading, then your source reading then divide the two? If that's the case, it's hopeless as a pressure sensor because it requires you to disconnect the source for each tare reading.

istanbul234
Posts: 6
Joined: Mon Sep 03, 2018 4:51 pm

Re: Pigpio HX711.py will hang

Sun Feb 14, 2021 10:05 pm

I'm having difficulty with the code hanging or simply taking very variable amounts of time to complete the same task.

I have 4 load cells each connected to their own HX711 which then connects to a Raspberry Pi 3B+.

The HX711 module I use is immediately below.

Code: Select all

#!/usr/bin/env python

# HX711.py
# 2018-03-05
# Public Domain

CH_A_GAIN_64  = 0 # Channel A gain 64
CH_A_GAIN_128 = 1 # Channel A gain 128
CH_B_GAIN_32  = 2 # Channel B gain 32

DATA_CLKS = 24
X_128_CLK = 25
X_32_CLK  = 26
X_64_CLK  = 27

PULSE_LEN = 15

# If the data line goes low after being high for at least
# this long it indicates that a new reading is available.

TIMEOUT = ((X_64_CLK + 3) * 2 * PULSE_LEN)

# The number of readings to skip after a mode change.

SETTLE_READINGS = 5

import time

import pigpio # http://abyz.co.uk/rpi/pigpio/python.html
         
class sensor:

   """
   A class to read the HX711 24-bit ADC.
   """

   def __init__(self, pi, DATA, CLOCK, mode=CH_A_GAIN_128, callback=None):
      """
      Instantiate with the Pi, the data GPIO, and the clock GPIO.

      Optionally the channel and gain may be specified with the
      mode parameter as follows.

      CH_A_GAIN_64  - Channel A gain 64
      CH_A_GAIN_128 - Channel A gain 128
      CH_B_GAIN_32  - Channel B gain 32

      Optionally a callback to be called for each new reading may be
      specified.  The callback receives three parameters, the count,
      the mode, and the reading.  The count is incremented for each
      new reading.
      """
      self.pi = pi
      self.DATA = DATA
      self.CLOCK = CLOCK
      self.callback = callback

      self._paused = True
      self._data_level = 0
      self._clocks = 0

      self._mode = CH_A_GAIN_128
      self._value = 0

      self._rmode = CH_A_GAIN_128
      self._rval = 0
      self._count = 0

      self._sent = 0
      self._data_tick = pi.get_current_tick()
      self._previous_edge_long = False
      self._in_wave = False

      self._skip_readings = SETTLE_READINGS

      pi.write(CLOCK, 1) # Reset the sensor.

      pi.set_mode(DATA, pigpio.INPUT)

      pi.wave_add_generic(
         [pigpio.pulse(1<<CLOCK, 0, PULSE_LEN),
          pigpio.pulse(0, 1<<CLOCK, PULSE_LEN)])

      self._wid = pi.wave_create()

      self._cb1 = pi.callback(DATA, pigpio.EITHER_EDGE, self._callback)
      self._cb2 = pi.callback(CLOCK, pigpio.FALLING_EDGE, self._callback)

      self.set_mode(mode)

   def get_reading(self):
      """
      Returns the current count, mode, and reading.

      The count is incremented for each new reading.
      """
      return self._count, self._rmode, self._rval

   def set_callback(self, callback):
      """
      Sets the callback to be called for every new reading.
      The callback receives three parameters, the count,
      the mode, and the reading.  The count is incremented
      for each new reading.

      The callback can be cancelled by passing None.
      """
      self.callback = callback

   def set_mode(self, mode):
      """
      Sets the mode.

      CH_A_GAIN_64  - Channel A gain 64
      CH_A_GAIN_128 - Channel A gain 128
      CH_B_GAIN_32  - Channel B gain 32
      """
      self._mode = mode

      if mode == CH_A_GAIN_128:
         self._pulses = X_128_CLK
      elif mode == CH_B_GAIN_32:
         self._pulses = X_32_CLK
      elif mode == CH_A_GAIN_64:
         self._pulses = X_64_CLK
      else:
         raise ValueError

      self.pause()
      self.start()

   def pause(self):
      """
      Pauses readings.
      """
      self._skip_readings = SETTLE_READINGS
      self._paused = True
      self.pi.write(self.CLOCK, 1)
      time.sleep(0.002)
      self._clocks = DATA_CLKS + 1

   def start(self):
      """
      Starts readings.
      """
      self._wave_sent = False
      self.pi.write(self.CLOCK, 0)
      self._clocks = DATA_CLKS + 1
      self._value = 0
      self._paused = False
      self._skip_readings = SETTLE_READINGS

   def cancel(self):
      """
      Cancels the sensor and release resources.
      """
      self.pause()

      if self._cb1 is not None:
         self._cb1.cancel()
         self._cb1 = None

      if self._cb2 is not None:
         self._cb2.cancel()
         self._cb2 = None

      if self._wid is not None:
         self.pi.wave_delete(self._wid)
         self._wid = None

   def _callback(self, gpio, level, tick):
      current_edge_long = False                                                                                         #I corrected this not surre tis is correct
      if gpio == self.CLOCK:

         if level == 0:

            self._clocks += 1

            if self._clocks <= DATA_CLKS:

               self._value = (self._value << 1) + self._data_level

               if self._clocks == DATA_CLKS:

                  self._in_wave = False

                  if self._value & 0x800000: # unsigned to signed
                     self._value |= ~0xffffff

                  if not self._paused:

                     if self._skip_readings <= 0:

                        self._count = self._sent
                        self._rmode = self._mode
                        self._rval = self._value

                        if self.callback is not None:
                           self.callback(self._count, self._rmode, self._rval)

                     else:
                        self._skip_readings -= 1

      else:

         self._data_level = level

         if not self._paused:

            if self._data_tick is not None:

               current_edge_long = pigpio.tickDiff(
                  self._data_tick, tick) > TIMEOUT

            if current_edge_long and not self._previous_edge_long:

               if not self._in_wave:

                  self._in_wave = True

                  self.pi.wave_chain(
                     [255, 0, self._wid, 255, 1, self._pulses, 0])

                  self._clocks = 0
                  self._value = 0
                  self._sent += 1

         self._data_tick = tick
         self._previous_edge_long = current_edge_long

if __name__ == "__main__":

   import time
   import pigpio
   import HX711

   def cbf(count, mode, reading):
      print(count, mode, reading)

   pi = pigpio.pi()
   if not pi.connected:
      exit(0)

   s = HX711.sensor(
      pi, DATA=20, CLOCK=21, mode=HX711.CH_B_GAIN_32, callback=cbf)

   try:
      print("start with CH_B_GAIN_32 and callback")

      time.sleep(2)

      s.set_mode(HX711.CH_A_GAIN_64)

      print("Change mode to CH_A_GAIN_64")

      time.sleep(2)

      s.set_mode(HX711.CH_A_GAIN_128)

      print("Change mode to CH_A_GAIN_128")

      time.sleep(2)

      s.pause()

      print("Pause")

      time.sleep(2)

      s.start()

      print("Start")

      time.sleep(2)

      s.set_callback(None)

      s.set_mode(HX711.CH_A_GAIN_128)

      print("Change mode to CH_A_GAIN_128")

      print("Cancel callback and read manually")

      c, mode, reading = s.get_reading()

      stop = time.time() + 3600

      while time.time() < stop:

         count, mode, reading = s.get_reading()

         if count != c:
            c = count
            print("{} {} {}".format(count, mode, reading))

         time.sleep(0.05)

   except KeyboardInterrupt:
      pass

   s.pause()

   s.cancel()

   pi.stop()

This is my main code:

Code: Select all

if __name__ == "__main__":

   import time
   import pigpio
   import HX711

   def cbf(count, mode, reading):
      print(count, mode, reading)

   pipette = pigpio.pi("192.168.1.208")
   if not pipette.connected:
      exit(0)

   sensor1 = HX711.sensor(pipette, DATA=6, CLOCK=5, mode=HX711.CH_A_GAIN_128, callback=None)
   sensor2 = HX711.sensor(pipette, DATA=17, CLOCK=15, mode=HX711.CH_A_GAIN_128, callback=None)
   sensor3 = HX711.sensor(pipette, DATA=4, CLOCK=14, mode=HX711.CH_A_GAIN_128, callback=None)
   sensor4 = HX711.sensor(pipette, DATA=27, CLOCK=18, mode=HX711.CH_A_GAIN_128, callback=None)
   all_sensors = [sensor1, sensor2, sensor3, sensor4]


   try:
      for sens in all_sensors:
         sens.start()

         print("Start")
         time.sleep(2)
         t1 = time.perf_counter()
         for x in range(10):
            result = sens.get_reading()
            while result[0] == sens.get_reading()[0]:
               pass
            t2 = time.perf_counter()
            print(f"Sensor: {sens} result: {result[2]} time taken:{t2-t1}")

         sens.pause()

         sens.cancel()


   except KeyboardInterrupt:
      pass



pipette.stop()

The following is an example of a result I get.

Start
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 0 time taken:0.9955373000000001
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 129535 time taken:10.4054165
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 127231 time taken:10.4671392
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 129023 time taken:10.5555238
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 130303 time taken:10.7426572
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 126463 time taken:11.0009446
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 126927 time taken:11.159071899999999
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 127807 time taken:11.4898796
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 126735 time taken:12.5092944
Sensor: <HX711.sensor object at 0x000001FDCC7ADB20> result: 130175 time taken:12.555926
Start
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: -319911 time taken:0.8414417000000007
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: 5435 time taken:5.383816299999999
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: -319894 time taken:5.4353561
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: -318908 time taken:5.536401100000003
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: -319795 time taken:5.658232000000002
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: -319575 time taken:5.702394900000002
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: -114905 time taken:7.158136600000002
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: 4975 time taken:7.665401200000002
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: -160705 time taken:16.160488200000003
Sensor: <HX711.sensor object at 0x000001FDCC7ADAC0> result: -319750 time taken:16.2340569
Start

Why does it seem to hang? Why is there such variation between the time taken for each reading?

Any help would be much appreciated.

User avatar
joan
Posts: 15939
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pigpio HX711.py will hang

Sun Feb 14, 2021 10:17 pm

pigpio only supports one HX711. I'm doubtful it could be extended to support more than one HX711 at a time.

You need to find another solution.

istanbul234
Posts: 6
Joined: Mon Sep 03, 2018 4:51 pm

Re: Pigpio HX711.py will hang

Sun Feb 14, 2021 10:23 pm

That's unfortunate, thanks for the quick reply.

Return to “Python”