A Quick Look at LabPro Programming

This document introduces the use of low-level commands to program the LabPro. Using these commands you can program the LabPro for data collection or digital or analog output. In some programming languages, commands like this are the only way to program LabPro. In other programming languages, such as LabVIEW and REALbasic, we have developed a lot of sample code which can simplify LabPro programming. In other words, instead of using these low-level commands, you call methods, subroutines, or subVIs to get a task done. In general, this kind of programming is much faster and easier.

Analog Real-Time (RT) Data Collection

Here are some examples of commonly used commands for programs reading analog sensors.

s{0}            All Clear, reset

s{1,1,1}      Channel Setup

s{3, 1,-1,0}  Control Sampling


The command starts with the command number (usually 0, 1, or 3), followed by other numbers called parameters. The parameters each have special meanings, depending on what command you are using. There are default values for some of these parameters. If you leave the parameter off the list, the default value will be used. All of this is explained in detail in the LabPro Technical Reference Manual. In these sections, we will only use parameters that are important for simple programs and leave off the others (so their default values are used).

Programs for reading analog sensors connected to LabPro usually follow this basic pattern:

·   Use Command 0 to rest the LabPro.

·   Use a Command 1 to set up the channels to which the sensors are connected.

·   Use a Command 3 to set up and start data collection.

·   Get and process the data.


Here is a specific example of a LabPro data-collection program that we will explain in some detail. This program takes readings from any analog Vernier autoID sensor. It will take readings repeatedly, 0.5 seconds apart. This will continue until the 6 command tells LabPro to stop data collection.

s{0}                                             reset LabPro

s{1,1,1}                                       set up channel

s{3,0.5,-1,0}                                 start data collection


[Get one data point at the

serial port of the computer.]              Repeat this retrieval of data as long as you want.


s{6,0}                                          stops data collection


We will go over the various commands in more detail here.

The 0 command resets the LabPro. It stops data collection, resets all channels, and clears the LabPro memory.

The 1 command specifies a number of things about how data is to be handled. The syntax for this command, when used with analog sensors is:

s{1, channel, operation, post-processing, statistics, conversion}

Some of these are parameters are rarely used. You can leave them off, so the default value is used. Here are the most important parameters:

channel = The input channel is specified with the second number in the list. For analog sensors, you can use 1, 2, or 3, or 4 (for CH1, CH2, CH3, or CH4).

operation = The third number in the command should be 1 to read a signal from an Auto ID probe like the Stainless Steel Temperature probe, voltage, or light probe, or any autoID probe. It should be a 14 for other Vernier analog sensors without Auto ID.

The 3 command controls the actual data collection. The 3 command from the sample program we are studying specifies taking readings every 0.5 seconds and repeating that until told to stop.



The syntax for this command is:

s{3, samptime, numsamp, trigtype, trigch, trigthres, prestore, extclock, rectime}

Most of these are not essential and you should just use the default value, by leaving them off of your command. Here are the most important parameters—the ones we have used in our sample program:

samptime = the time between samples (in seconds). The range is 0.00002 to 16000 seconds.

NumPoints = the number of readings to be made. The number of readings can be any integer up to 12,000. Setting this number to –1, as we have in the program above, puts LabPro into Real-Time data collection mode so data is returned after every reading.

Trigtype = this specifies if the program should wait for a triggering event before starting the actual data collection. 0 means no. 1 means wait for the Start/Stop button on LabPro) to be pressed. Other numbers can be used to specify triggering on a certain signal level. The default is 1, which you usually do not want, so you should almost always put a zero here.

If we successfully send the commands above from a computer to a LabPro, with a Vernier autoID sensor connected to CH1, LabPro will start taking calibrated readings from the sensor and sending them to the serial port of the computer every 0.5 seconds. These data are stored in the serial buffer and can be read by the programming language. In most situations a loop is set up in the programming language so that as soon as data appears in the serial buffer, it is read and graphed, put in a data table or processed in some way.

When RT data collection is to stop, we send a s{6,0} to LabPro.

NRT Data Collection

The example above assumes that you want to take data rather slowly and send readings to the computer one at a time for processing. For fast data collection we use NRT (Non-Real Time) data collection. This is really not a good name for this style of data collection, since the data is always taken exactly at the time we ask for it to be taken, but it is sent to the computer later (after the data is collected), and that is where the name comes from.

Here are the commands for a second sample program, similar to the first, but with NRT data collection:

s{0}                                             initialize LabPro

s{1,1,1}                                       set up channel

s{3,.25,50,0}                                start data collection

g                                                 this “g” sent to LabPro tells LabPro to return all the data

[Get all the resulting data]               

This program is the same as the previous sample through the first two lines. After that, the data collection portion is different. Notice that the 3 command has 50 for the third number, as the number of samples. This tells the LabPro to take 50 readings. No data is returned during data collection. The time between readings in this example is 0.25, so readings will be taken four times a second.

In NRT data collection programming, we typically have the program do a time-based delay while the data collection goes on. This delay would be the time for each reading multiplied by the number of readings. After this delay we send a “g” character to the LabPro. This tells it to return all the data. The data are stored in the serial buffer of the computer, where the program can read it.

Motion Detector Data Collection

Using a motion detector is very similar to using an analog sensor as described above, with either real-time readings or NRT data collection. The change is in the 1 command. With a motion detector, the format of the 1 command is:

s{1, channel, operation, post-processing}

where the channel can be either 11 for Dig/Sonic 1 or 12 for Dig/Sonic 2. The next number, operation, is usually 1 for autoID motion detectors. The post-processing can be:

0 - for getting just distances from the LabPro

1 - for getting back distance and velocities (calculated in LabPro)

2 - for getting back distance, velocities, and accelerations (calculated in LabPro)

Other Commands that are often used with LabPro:

Other than the ones used in the sample programs above, the commands below are probably the most frequently used.. We list them here just to give you an idea of other possibilities. For details on these and all commands, refer to the LabPro Technical Reference Manual. Go to http://www.vernier.com/mbl/labpro.html

7 - Request Status: Command s{7} Requests that the LabPro report on its status: firmware version, battery state, and most importantly, whether it received the command.

9 - Request Channel Data: Command s{9}tells LabPro to take one reading from the specified channel and return the value. The channel used must have been previously set up. This command can be used for any analog channel (CH1-CH4) or a Motion Detector channel.

12 – Digital Data Capture: for collecting data from photogates, radiation monitors, and rotary motion sensors..

102· Power Control: Sending s{102,-2} sets the LabPro power to always on, so that it will not power down, if not receiving commands.

401            · Analog Output Setup: This command s{401, [waveform], [amplitude], [offset], [period]} allows you to set the analog output for a steady output or to start the function generator built into LabPro.

2001· Digital Out Control: Controls the output of the digital out lines, or the Digital Control Unit.

LabPro Command Summary


The table below lists all of the commands you can use in writing programs for LabPro. Detailed explanations of each command and its syntax can be found in the LabPro Technical Reference Manual.



Command Number

Command Description


Reset: Resets all channels to default conditions.


Channel Setup: sets up a channel for data collection.


Trigger Setup: Sets up the trigger parameters for an experiment.


Conversion Equation Setup (Analog Channels): Sets up parameters to convert physical units measured by LabPro into a more useful measurement unit such as Newtons or °C.

Sonic Temperature Compensation (Sonic Channel): Sets up parameters to compensate for speed of sound in air under different temperature conditions.


Data Control: Selects the type of data to be retrieved, as well as the starting and ending data points to be retrieved.


System Setup: Turns sound on or off; sets an ID number for LabPro; selects a filter to be applied to data.


Request System Status: Generates and prepares to return status information.


Request Channel Status: Generates and prepares to return sensor type, last valid data, and last valid data position for the requested channel.


Request Channel Data: Generates and prepares to return one data point before sampling starts. Used to verify that setup is correct.


Advanced Data Reduction: Sets up LabPro to process certain time-intensive algorithms instead of processing them in the calculator.


Digital Data Capture: Sets up the capture or measurement of motion data from the digital input channel.


Power Control Command: Sets the power to always on; power-saving; or designated power up.


ACK: Specifies whether LabPro will send acknowledgement on receipt of some commands


Set Baud Rate: for serial communication


Check Set-up Information: Returns status information for the designated channel.


Check Long Sensor Name: Returns long sensor name.


Check Short Sensor Name: Returns short sensor name.


Archive Operations Command: Allows the calculator to determine the contents of LabPro’s FLASH memory.


Analog Output Setup: This command sets up parameters to control the analog output driver in LabPro.


Set LED Command: Turns LEDs on and off on command.


Sound Command: Specifies length and frequency of LabPro sounds.


Direct Output to Digital-Out Port: Outputs data to the digital output port during a sampling run.


Direct Output to Digital-Out Port with Mask


Direct Output to Digital-Out Port, DG/Sonic 1 Lines only


Direct Output to Digital-Out Port, DG/Sonic 2 Lines only