Linux Python Example: MCC 118 + USB-QUAD08

A customer posed the question: Is it possible to use a MCC 118 (DaqHat) on a Raspberry Pi® and a USB-QUAD08 (UL for Linux) in a single integrated application? Using the clock output of the MCC 118 to provide clocking on the USB-QUAD08, in a continuous background scan, in Python. On a Raspberry Pi® model 3B+.

Yes it is!

First, I loaded the 2 sets of drivers and examples files from the Measurement Computing website: For the MCC 118: For the USB-QUAD08: Following the installation instruction on their respective pages.

I used Geany since it comes with my Raspberry Pi® 3B+ installation of Raspbian™ and a 32 GB micro SD card.

I'm a firm believer in leveraging of provided examples as a good starting point for a lot of the sample applications I create so I started with examples from each library; for the MCC 118, and from the UL for Linux for the USB-QUAD08, and created a new app entitled

After confirming I could make each work independently while running Geany© as my IDE, I saved a copy of to a new location in my Documents folder knowing this would be the basis of my new combo-app. Then I added pieces of the MCC 118 example into the new app. The goal was to get these 2 devices running indepenently to operate in one app and feed the collected data up to the screen. Once that was accomplished, I tweaked the app so that the USB-QUAD08 would use the MCC 118's output clock. As it turns out, the MCC 118's CLK terminal defaults to output so there was nothing to do there, but I did have to make a small change to the scan options of the USB-QUAD08.

Line 36 of the attached file was originally: scan_options = ScanOption.CONTINUOUS

scan_options = ScanOption.CONTINUOUS | ScanOptions.EXTCLOCK.

There was also a requirement to make a physical connection from the CLK terminal of the MCC 118 to the XPCR terminal on the USB-QUAD08. As both devices are connected via the same ground of the Raspberry Pi®, there was no need to run a ground wire.

Attached is the Python Script save in a .zip file.

Raspberry Pi is a trademark of the Raspberry Pi Foundataion Geany is licensed under the terms of the GNU General Public License