labquest-examples

Official examples for Vernier LabQuest® interfaces in Python

This project is maintained by VernierST

Getting Started with Vernier LabQuest® and Python

This guide shows you how to get started writing Python programs for your Vernier LabQuest®. The guide contains the following topics:

If you are new to Python you should look over all of the steps. If you are familiar with Python you might just focus on installing the labquest package and downloading the examples.

Getting Started Requirements

We have developed a Python package called labquest that allows you to communicate with Vernier LabQuest devices via USB. This requires the following:

Install the Windows Drivers

To communicate with LabQuest devices on Windows computers a driver must be installed. If you already have Vernier Graphical Analysis or Logger Pro software installed, you have the driver. If you do not have this Vernier software, the driver can be installed with either the free trial of Graphical Analysis Pro or the free demo version of Logger Pro software.

Install Python 3

The labquest package is designed to work with Python 3, it is not compatible with Python 2. In some cases, Python is pre-installed and shipped with your operating system. Use the following steps to check for Python 3 on your machine, and to install Python 3 if needed:

Choose an IDE

With Python installed, you need to choose an application that you will use to write and run your Python programs. You can write your programs in a simple text or code editor, or you can use an Integrated Development Environment (IDE). An IDE is a software application that provides all of the tools to write, comment, edit, debug, develop and run software programs. Python has an IDE bundled with it called IDLE that is cross-platform, and suitable for beginners. If you are new to Python and programming, we recommend that you start with this tool.

Later, you may want to research the various IDEs, learn about the different features, and give one a try. For example, Visual Studio Code is a free IDE available for Windows and Mac. There are many other choices, and you can find more information at python.org

Install the labquest Package

Once you have Python 3 installed, you will use a tool called pip (a Python 3 package manager) to install the labquest package. Python automatically includes pip, so this tool is ready to use. Note that we will be using the pip3 command, rather than just pip, to ensure that the Vernier files will be associated with Python 3, and not Python 2.

The pip3 commands are executed by running them in your operating systems’ tool for executing commands (Powershell, Command Prompt, or Terminal window). There are slight differences in the required steps to install the labquest module for Windows, and macOs. Follow the steps outlined below for your platform.

Run the following command:

pip3 install labquest

Confirm Installation of the labquest Package

At this point, you should have Python 3 installed and have the labquest package installed. Before moving to examples, confirm the installation of the labquest package by showing the version information. Run the following command in the terminal:

pip3 show labquest

Running the pip3 show command will provide information about the installed package, including the version number. Should you need to update to a newer version in the future, run the following command in the terminal:

pip3 install labquest --upgrade

Download and Run an Example

With the labquest package installed, it is time to run an example.

Clone labquest-examples

About the Examples

The examples demonstrate how to collect data from LabQuest analog and digital sensors, as well as how to control the output lines of a Vernier Digital Control Unit (DCU). These examples all use the labquest package to communicate with the LabQuest device.

A typical example program to collect periodic, single point data from analog sensors, motion detector, rotary motion, and photogate counting would include the following functions:

lq.open()
lq.select_sensors()
lq.start()
lq.read()
lq.stop()
lq.close()

A simple program using these functions looks like this:

from labquest import LabQuest

lq = LabQuest()

lq.open()
lq.select_sensors(ch1='lq_sensor')    
lq.start(100)

for x in range(10):
    ch1_measurement = lq.read('ch1')
    if ch1_measurement == None: 
        break 
    print(ch1_measurement)

lq.stop()
lq.close()

LabQuest analog sensors, motion detector, rotary motion, and photogate counting will all follow this format (with slight changes to configure data collection from the correct channel and the correct sensor).

Performing fast data collection (a packet of samples in a short time frame), and performing photogate timing will each use a different read function (this is described below).

In addition, there are examples to show how to control the output from a Digital Control Unit (DCU) connected to LabQuest’s digital channels. The DCU allows you to control small electrical devices such as servo motors, dc motors, fans, buzzers, and such.

Notes Regarding the labquest Functions

Here is some more information about the functions:

from labquest import LabQuest
lq = LabQuest()

lq.open()

lq.select_sensors()

lq.start()

measurement = lq.read()

measurements = lq.read_multi_pt()

measurements = lq.photogate_timing()

lq.stop()

lq.close()

Troubleshooting and Notes

Support

Python

Pip

Installing Python on Windows

Python3 Modify

Python 3 Next

Python 3 Install

License

All of the content in this repository is available under the terms of the BSD 3-Clause License.

Vernier products are designed for educational use. Our products are not designed nor are they recommended for any industrial, medical, or commercial process such as life support, patient diagnosis, control of a manufacturing process, or industrial testing of any kind.