Jump to content
  • 0

MCC 172 daqhat device open problem


TET

Question

Hi

I have 2 Mcc 172 daqhats which I have installed as described in the github to Raspberry pi 4. They are in address 0 and 1. I have installed the daqhat library. After that when I call daqhats_list_boards command I have 

the error "can't open device" for the daqhat at address 1. When I  update the firmware for this daqhat, it corrects the problem. However if I shutdown the device and open again the same problem persists. The firmware update command is not successful for all attempts. There is no problem for the device at address 0. It is always detected appropriately. The same problem exists for other boards I have so it is not an isolated board specific problem. How can we resolve this problem?

Thanks

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Well Spi is enabled but i2c is not I suppose (does not matter tried different versons). After digging into problem, here are my additional comments. The problem is not hardware related, it is software problem. I have changed the SD card with my backup and it worked. Temporary solution for this problem is to make remote GPIO (in raspberry menu) "on" or "off" and try firmware update again. In my case i was able to update the firmware and the second board is identified. But that is somewhat temporary since the problem repeats after a shutdown. I believe that the main root of the problem comes from the MCC daqhat program termination style. I used to terminate the program with a ctrl+c. This does not close MCC 172 appropriately and some registers are corrupted further destabilizing the daqhat installment together with the OS. So the next problem becomes how are we going to terminate a daqhat program gracefully if a shutdown command is executed?

Thanks

Link to comment
Share on other sites

  • 0

I2C must be enabled because it is used to update EEPROMs; SPI must be enabled because it is used for board control and data.

I'm sorry, but I am unable to reproduce this issue. The ctrl-c keystroke causes an exception which is trapped by the except routine and it stops the scan and performs a cleanup.

except KeyboardInterrupt:

      hat.a_in_scan_stop()

      hat.a_in_scan_cleanup()

....

When the program exits, Python frees any remain objects to be used again.

Best regards,

John

Link to comment
Share on other sites

  • 0

Thank you John. For the I2c I was referring the config.txt where there are specific lines belonging to I2c commented. Probably Raspberry pi still enables I2C by default.

Since I am using C, ctrl+c is not handled as in the case of python. Nevertheless, it was my guess about the weird behaviour as "cant open device" error. The true cause is yet to be found but it is definitely a very disturbing error. Note that other people also reported similar problems before but they also did not find the root cause.

Best

 

Link to comment
Share on other sites

  • 0

Hello,

The "can't open device" error is typically one of the following  issues:

1. Trying to access a board with an incorrect address

2. Either or both SPI and I2C got disabled

3. The board has a hardware problem and should be replaced.

Could you provide the following: Raspberry PI model and operating system; if it is a headless system and what you're using for C programming.

I didn't understand what you meant by Temporary solution for this problem is to make remote GPIO (in raspberry menu) "on" or "off" and try firmware update again. The MCC 172 uses the following resources:

image.png

If you have other non MCC HAT boards attached, make sure they don't use these.

The daqhats installation installs a program called MCC DAQ HAT Manager. With it you can update the board list with Read EEPROMS and List the devices or boards found. It makes it easier to test each board.

My suggest is to execute:

sudo apt full-upgrade

sudo reboot

then run the following which assumes the two boards are using address 0 & 1

mcc172_firmware_update 0 ~/daqhats/tools/MCC_172.fw

mcc172_firmware_update 1 ~/daqhats/tools/MCC_172.fw

Best regards,
John

Link to comment
Share on other sites

  • 0

Thanks for the detailed information. I believe the board does not have hardware problem since it worked after I switched with the backup SD card. The other 2 causes are plausible. In Raspberry Pi OS I2C is not on by default. However after daqhat installment GPIO3 pin can not be claimed to initiate shutdown with a button. Probably after daqhat installment GPIO3 is claimed and not usable for any other task. The problem is observed as follows. When I use either DAQ manager or execute daqhats_list_boards command, it lists the two boards. But hat 2( address 1) has "can't open device" error. After I got this error, when I try to firmware update, it fails and it gives different error at each try for the address 1. 

Then I did what you suggested. I uninstalled daqhat and did full-upgrade, reboot , re-install daqhat and run "daqhats_list_boards" command. The same error is observed.

Firmware update may be successful on some tries rarely  but does not hold after a shutdown.  As I said before the only way I could get rid of it for the time being is to start with a new SD card. Both MCC hats are Mcc 172. Currently my daqhat stack works. My pi 4 does not have I2c enabled in its configuration (still works though). Maybe that was the problem to start with. I hope that the same problem does not repeat. If it does İ will let you know. Thanks for the help.

Best regards

 

Link to comment
Share on other sites

  • 0

Hi

Here is the update from last time. The problem is chronic and is repeated every one of three shutdown-restart cycle. I believe that the main cause of the error is either daqhat firmware or the daqhat installed programs . The error "can't open device" comes from the daqhat_list_boards which calls mcc172_open() function. Error is created since mcc172_open does not successfully communicate with the Atmel microcontroller in the board. When we look at the mcc172_open() function, there is this comment,

           // Initial prototypes had active low reset, and the GPIO signal
            // defaults to low. This causes the micro to be held in reset if
            // the library has not been opened since booting. In that case, add
            // an extra delay for the micro to start.

I think my previous trick (remote GPIO on/off) works since it changes the state and microcontroller is out of reset state.

Below I give you the screen shots for the error. The first one shows the error and the unsuccessful attempt of the firmware update. The second one shows the GPIO states. On the left when there is the error, on the right when the board works appropriately. There are some changes but I am not sure if I can catch any abnormality. The SPI, I2C are both on for all times. Would be great if this problem is solved! I am also giving the links for previously reported same/similar problems.

https://forums.raspberrypi.com/viewtopic.php?t=248153

https://github.com/mccdaq/daqhats/issues/26

https://github.com/mccdaq/daqhats/issues/3

 

Best Regards

 

Error2.png

GPIO2.png

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...