Measurement Computing   Easy to Use | Easy to Integrate | Easy to Support catalog banner

Measurement Computing Data Acquisition Knowledgebase

Welcome Guest ( )

Linux Python example: MCC 118 + USB-QUAD08

Expand / Collapse
 

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 USB-QUAD08:  https://github.com/mccdaq/uldaq
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; continuous_scan.py for the MCC 118, and c_in_scan_with_encoder.py from the UL for Linux for the USB-QUAD08, and created a new app entitled mcc118_and_usbquad08.py.

After confirming I could make each work independently while running Geany© as my IDE, I saved a copy of c_in_scan_with_encoder.py 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 continuous_scan.py 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

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


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






Rate this Article:

Attachments


mcc118_and_usbquad08.zip mcc118_and_usbquad08.zip (4.56 KB, 94 views)

Add Your Comments


For comments email TechSupport@mccdaq.com.

Details
Article ID: 50774

Last Modified:7/23/2019 7:10:58 AM

Article has been viewed 398 times.

Options