Jump to content
  • 0

mcc118 unstable performance


Servelop

Question

Folks, i noticed a strange behavior of the MCC118 with my Pi Zero 2W.  Upon installation of the library, it reported "Expected I2C bus (i2c-3) not found." (Note, i2c and spi were enabled with raspi-config.) Trying to run sudo single_value_read resulted in "Error: There was a timeout while obtaining a resource lock".  After some experiments, I executed sudo daqhats_read_eeproms, it successfully read the eeprom and subsequent sudo single_value_read produced adequate voltage readings.  After turning the Pi (and the hat) off, then turning back on after several days, same problem: sudo single_value_read resulted in "Error: There was a timeout while obtaining a resource lock".  Calling sudo daqhats_read_eeproms produced expected results, but the sudo single_value_read still no-goAfter rebooting sudo single_value_read is working.  After brief turning off and on - still working.  It seems that it is somehow failing after being off for a while.  Not sure what's going on...

Alex.

 

Edited by Servelop
fix typos ad grammar
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

Included with the daqhats software is a control panel called the MCC DAQ HAT Manager.  It is installed in the Accessories of the Raspbian start menu.

Please run it.  When it pops up, click on Read EEPROMs button, and follow the onscreen prompts.  Click OK

Then click on the List devices button.  It should show you your MCC 118 and other information.  Click OK.

Now, click on the MCC 118 App button.  It should show you the number of devices found or the address of the device.  If a device is found, click on Open button.  The display will show you the data being read by your MCC 118.  Does it?

If not,  Something to check:

 Click on the “Start Raspberry”,

Click on Preferences >> Raspberry Pi Configuration,

Click on Interfaces tab,

 Are SPI and I2C enabled?  If not, enable them and click OK.

 Try running single_value_read.py again.

 Did resolve the issue?

If not, do you have any other HATs or software running in your Pi Zero 2W?  If so, for the purpose of testing, please remove the HATs and terminate the apps while working this issue.

Link to comment
Share on other sites

  • 0

Jeffrey, my Pi is "headless" - no GUI, mouse, keyboard :-)  Hence I can't follow the steps you suggested.  Nevertheless, here are some answers.  1.  I do not have any other hats. 2. SPI, I2C are enabled  via raspi-config (see config.txt attached). This morning i reproduced the errors after the system being OFF overnight.  See below:

$ sudo bin/single_value_read

MCC 118 single data value read example
    Function demonstrated: mcc118_a_in_read
    Channels: 0 - 3
    Options: OPTS_DEFAULT

Press 'Enter' to continue

Acquiring data ... Press 'Enter' to abort

  Samples/Channel     Channel 0     Channel 1     Channel 2     Channel 3

Error: There was a timeout while obtaining a resource lock.

$ sudo daqhats_read_eeproms
Expected I2C bus (i2c-3) not found.
$ sudo daqhats_read_eeproms
Reading...
Found EEPROM at address 0
Done
$ sudo bin/single_value_read

MCC 118 single data value read example
    Function demonstrated: mcc118_a_in_read
    Channels: 0 - 3
    Options: OPTS_DEFAULT

Press 'Enter' to continue

Acquiring data ... Press 'Enter' to abort

  Samples/Channel     Channel 0     Channel 1     Channel 2     Channel 3

Error: There was a timeout while obtaining a resource lock.
$ sudo reboot
$ sudo bin/single_value_read
[sudo] password for alexpozhitkov:

MCC 118 single data value read example
    Function demonstrated: mcc118_a_in_read
    Channels: 0 - 3
    Options: OPTS_DEFAULT

Press 'Enter' to continue

Acquiring data ... Press 'Enter' to abort

  Samples/Channel     Channel 0     Channel 1     Channel 2     Channel 3
               12     1.75180 V     1.74712 V     1.74700 V     1.74693 V
 

config.txt

Link to comment
Share on other sites

  • 0

Do not run the examples as root (i.e., don’t call ‘sudo bin/single_value_read’, just call ‘bin/single_value_read’).  The lockfiles used for synchronization for the hats do not work well for root.

Also, this daqhats_read_eeproms issue is new to bullseye (maybe only on the slower processors.)  The script calls modprobe i2c_dev to load the I2C bus driver, then detects the available buses.  It seems that bullseye changed modprobe so it returns before the load is complete, so the first time you call daqhats_read_eeproms it won’t see the i2c bus.  The second time you call it, modprobe has already finished and the bus is visible.

A change has been made to daqhats_read_eeproms to wait until i2c_dev is loaded before detecting the buses and it fixes the issue on a Pi Zero.  Please download a fresh copy of DAQHats software and let me know if that resolves the problem.

Link to comment
Share on other sites

  • 0
On 11/1/2022 at 7:06 AM, Jeffrey said:

Do not run the examples as root (i.e., don’t call ‘sudo bin/single_value_read’, just call ‘bin/single_value_read’).  The lockfiles used for synchronization for the hats do not work well for root.

Without the root, none of the examples work at all, a bunch of errors are thrown.... 

OK, i'll make a fresh clone of the repository, reinstall and test.  I'll report in a day or two.

Link to comment
Share on other sites

  • 0

Jeffrey, i tried your suggestions. No changes in the behavior, see below:

sudo ./uninstall.sh
mv daqhats/ daqhats_old
git clone https://github.com/mccdaq/daqhats.git
sudo ./install.sh

Reading DAQ HAT EEPROMs

Expected I2C bus (i2c-3) not found.

sudo reboot

bin/single_value_read
Can't open /dev/gpiomem.
Can't open /dev/gpiomem.
Can't open /dev/gpiomem.

Error: A needed resource was not available.

Error: An incorrect parameter was passed to the function.

sudo bin/single_value_read

MCC 118 single data value read example
    Function demonstrated: mcc118_a_in_read
    Channels: 0 - 3
    Options: OPTS_DEFAULT

Press 'Enter' to continue

Acquiring data ... Press 'Enter' to abort

  Samples/Channel     Channel 0     Channel 1     Channel 2     Channel 3

Error: There was a timeout while obtaining a resource lock.

#trying my old trick
sudo daqhats_read_eeproms
Expected I2C bus (i2c-3) not found.
sudo daqhats_read_eeproms
Reading...
Found EEPROM at address 0
Done
sudo bin/single_value_read
...
Error: There was a timeout while obtaining a resource lock
sudo reboot
sudo bin/single_value_read

MCC 118 single data value read example
    Function demonstrated: mcc118_a_in_read
    Channels: 0 - 3
    Options: OPTS_DEFAULT

Press 'Enter' to continue

Acquiring data ... Press 'Enter' to abort

  Samples/Channel     Channel 0     Channel 1     Channel 2     Channel 3
               11     1.75180 V     1.75223 V     1.75211 V     1.75204 V

#back to the same behavior
 

Link to comment
Share on other sites

  • 0

I sent this on to one of our DAQHats developers, here is his response, 

"I found another thing that returns early on bullseye (the dtoverlay command to load the i2c-gpio driver to create the I2C bus for reading the EEPROMs) so I modified daqhats_read_eeproms some more to wait for that to complete.  I left the revision at 1.4.0.6 and just changed the command on github.

Have the user download and install this latest version, it should fix the eeprom issue.

For the single value read, have them run “~/daqhats/examples/c/mcc118/single_value_read/single_value_read” as the standard user (not sudo).  If that does not work right, we need to see the complete output (cut & paste from the terminal, etc.)"

Please give this a try.

Link to comment
Share on other sites

  • 0

Better, but still hiccups.

Here it is what's going on:

sudo ./uninstall.sh
git pull
sudo ./install.sh
#no errors!

cd ~/daqhats/examples/c/mcc118/single_value_read 
./single_value_read
Can't open /dev/gpiomem.
Can't open /dev/gpiomem.
Can't open /dev/gpiomem.

Error: A needed resource was not available.

Error: An incorrect parameter was passed to the function.

sudo ./single_value_read

MCC 118 single data value read example
    Function demonstrated: mcc118_a_in_read
    Channels: 0 - 3
    Options: OPTS_DEFAULT

Press 'Enter' to continue

Acquiring data ... Press 'Enter' to abort

  Samples/Channel     Channel 0     Channel 1     Channel 2     Channel 3
               27     1.62402 V     1.74712 V     1.75211 V     1.75204 V

-----------------

Well, at least there are no more issues with i2c and the example runs well with sudo, unlike earlier.  Still sudo is needed...

 

Link to comment
Share on other sites

  • 0

Ah, I think this answers the question. After I installed my Pi a few months ago, I purposefully created a regular user account, which is not "pi"! I am using this account for all my work that doesn't require the superuser. According to the raspberry pi documentation, pi is the superuser (as far as I remember). So in fact when I am doing sudo with the mcc hat, it is not different that running it from the pi account. How shall I add my regular account to the gpio group?

Edited by Servelop
Fixed the question
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...