Quantcast
Channel: SparkFun Tutorials
Viewing all articles
Browse latest Browse all 1123

Vernier Shield Hookup Guide

$
0
0

Vernier Shield Hookup Guide a learn.sparkfun.com tutorial

Introduction

As a former high school physics teacher, I taught nearly every unit using Vernier sensors in my classroom. Vernier has an extensive suite of sensors, easy-to-use software, and amazing support for all of their products.

I had great success using Vernier in my physics class, but I was looking for a solution that would enable me to use these same sensors in other classrooms where I did not have direct access to computers with LoggerPro software or the Vernier LabPro hardware.

Part of this journey led me to developing this low-cost photogate timer project. I had conceived this idea before starting here at SparkFun, and, once here, I was able to start this project to develop an Arduino shield that would allow us to quickly connect any Vernier probe to an Arduino.

Vernier LabPro

alt text

Vernier LabPro Startup Beep

This green box is a classic in many science classrooms. It makes a very pleasant, instantly recognizable tone when it’s plugged into a computer.

In addition to the LabPro, Vernier also has a variety of other interfaces including the:

These interfaces are great solutions for data collection and automation in the classroom. They are simple to use and integrate directly with Vernier’s LoggerPro software platform. With the increased access to of low-cost micro-controllers in classrooms, we wanted to help provide an alternative for teachers to leverage their existing sensors, activities, and materials from Vernier with Arduino.

We have developed this Arduino Shield to connect your favorite Vernier sensors to any Arduino Uno or Arduino Uno compatible device.

alt text

What you’ll need:

Suggested Reading

About Vernier

alt text

Vernier Software and Technology has been a leader in data collection and analysis for educators world-wide. Started in 1981 by David and Christine Vernier, they were amongst the first companies to design and promote the use of computers, sensors, and data collection in K-12 classroom laboratory experiments.

They currently have over 70 fully calibrated sensors and 5 different data collection interfaces that are part of their catalog. We have been very fortunate to partner and collaborate with Vernier in the development of this Arduino shield. It allows teachers to combine the power and versatility of the Arduino platform with the wealth of calibrated, classroom tested, and rugged sensors produced and supported by Vernier.

Vernier Shield Pin-out and Configuration

Vernier standardized all of their sensors using a “standard” British Telecom connector. These connectors each have 6 wires that connect the sensor to the Vernier data collection interface. We designed the shield to maximize flexibility and ease-of-use for integrating up to two analog (BTA) and two digital (BTD) Vernier sensors to an Arduino. The full sensor pin-outs can be found on Vernier’s site here.

British Telecom Analog (BTA) – Right Hand

alt text

A large number of sensors used in the classroom fall under the category of “analog” sensors. Learn more about the differences between analog and digital here.

The pins of the BTA connector are defined as such:

PIN #Pin NameDescription
1Analog Sensor Output
(-10V to +10V)
Used with a number of Vernier voltage probes. This is wired through a scale and shifting op-amp circuit so that the Arduino can read it on a scale of 0 - 5V.
2GNDGround.
3VresResistance reference. 15K pull-up resistor ties this pin to 5V to use as a voltage divider between Pin 6 and GND.
4*AutoIDENTMost sensors have a unique resistor that is tied between this pin and GND. Vernier uses this to identify the sensor. (not supported on all sensors)
5Power5 VDC
6Analog Sensor Output
(0V to -5V)
Primary sensor output for most analog sensors including light, temperature, force, pressure, pH, etc...

http://www.vernier.com/support/sensor-pinouts/

To extend the use of Vernier equipment, they also offer a few voltage probes that allow for direct voltage measurements between +/- 6V, +/- 10V, and +/- 30V. On each of these probes, the signals are each tied to Pin 1 and and GND of the BTA connector.

British Telecom Digital (BTD) – Left Hand

alt text

Digital sensors are any of the devices that return a signal that is either on (5V) or off (0V). Common digital sensors include: motion detector, photogate, radiation monitor, and the rotary motion sensors.

These sensors each have a somewhat unique pin-out definition. The following table outlines the pin assignments used for the Vernier digital connector.

Note that the connector is slightly different compared to the analog sensors. This is called a left-handed British Telecom connector and has the tab on the opposite side. The BTA and BTD connectors will not plug into the same socket.

PIN #DEFAULTMOTION
DETECTOR
PHOTOGATERADIATION
MONITOR
ROTARY
MOTION
1IO1EchoInputCountCCWcount
2IO2InitCWcount
3IO3AutoIDENTAutoIDENTAutoIDENTAutoIDENT
4PWRPWRPWRPWRPWR
5GNDGNDGNDGNDGND
6IO4X4res

Arduino Shield Pin Assignments

To maximize the flexibility of using all of the Vernier sensors, we have made the following pin assignments on our shield. Many of the Vernier sensors use I2C for identification and calibration data. We use a multiplexer to “share” (multiplex) pins A4 and A5 between all four connectors. The multiplexer is controlled with Pins 10 (LSB) and Pin 11 (MSB). See the section on multiplexing for more information.

Pin assignments for analog ports

Analog 1Analog 2Description
MUX Control Address0001Pins 10 (LSB) and 11 (MSB) control a multiplexer for A4 and A5.
Analog Signal
(O - 5V)
A0A2Most analog sensors will interface to this pin. Use A0 for Analog 1 and A2 for Analog 2.
Analog Signal
(-10V - +10V)
A1A3The shield has a built-in circuit to scale and shift input voltages from -10V to +10V to a range of 0V to 5V for pins A1 and A3.
V_resA4*A4*Resistance reference. 15K pull-up resistor ties this pin to 5V to use as a voltage divider between Pin 6 and GND.
AutoIDENA5*A5*A 10K pull-up resistor ties these pins to 5V. The measured voltage drop across this pin uniquely identifies the sensor.

Pin assignments for digital ports

Digital 1Digital 2Description
MUX Control Address1011Pins 10 (LSB) and 11 (MSB) control a multiplexer for A4 and A5.
IO1
(BTD Pin 1)
26Signal pin used for the photogate, motion detector echo, radiation count, and CCW rotary motion count.
IO2
(BTD Pin 2)
3 / A4*7 / A4*Trigger pin for the motion detector and I2C data (SDA) for sensor ID
IO3
(BTD Pin 3)
4 / A5*8 / A5*I2C clock (SCL) for sensor ID
IO4
(BTD Pin 6)
59Used for rotary motion sensor to increase sensitivity.

*Pins A4 and A5 are shared across all four connectors. In order to properly access the BTA and BTD connector pins, you will need to interface the analog multiplexer circuit.

Auxillary Pins and Connections

In addition to the internal wiring and routing for the Vernier BTA and BTD connectors, we placed an indicator LED tied to pin 13, a general purpose button on pin 12, and a reset button on the shield.

alt text

We also exposed vias for power and ground and pins 0 (RX) and 1 (TX) for adding serial communication peripherals like a Serial-enabled LCD or Serial 7-segment Display.

Multiplexer

Vernier uses a variety of methods for identifying which sensors are connected to the interface. A majority of sensors use a resistor placed on one of the pins, but some of their sensors use I2C for both sensor identification and storing calibration data. The Vernier shield uses an analog multiplexer to share / route pins A4 (SDA) and A5 (SCL) to each of the four connectors.

Pins 10 (LSB) and 11 (MSB) are used to control the multiplexer. The following snippet of code illustrates one way to switch which connector A4 and A5 are connected to.

language:c
const int muxLSB = 10;
const int muxMSB = 11;

void setup()
{
  pinMode(muxLSB, OUTPUT);
  pinMode(muxMSB, OUTPUT);
}
void setMux(int connectorNum)
{
// void setMux(int connectorNum)
// connectorNum is a number from 0 to 3 which
// identifies which connector to switch the MUX to.
// Where if connector num is equal to:
//    0 --> Analog 1
//    1 --> Analog 2
//    2 --> Digital 1
//    3 --> Digital 2

  switch (connectorNum)
  {
  case 1: // ANALOG 2 - MUX ADDR 01
    digitalWrite(muxMSB, LOW);
    digitalWrite(muxLSB, HIGH);
    break;
  case 2: // DIGITAL 1 - MUX ADDR 10
    digitalWrite(muxMSB, HIGH);
    digitalWrite(muxLSB, LOW);
    break;
  case 3: // DIGITAL 2 - MUX ADDR 11
    digitalWrite(muxMSB, HIGH);
    digitalWrite(muxLSB, HIGH);
    break;
  default: // ANALOG 1 - MUX ADDR 00
    digitalWrite(muxMSB, LOW);
    digitalWrite(muxLSB, LOW);
  }
}

In general, you won’t need to access these lines unless you are interfacing to the Vernier sensors through I2C.

Vernier Sensor Identification

Vernier developed a very clever method to identify sensors connected to their interface using a simple, passive resistor. Many Vernier sensors can be uniquely identified by a specific resistor placed between the AutoIDENT pin and GND.

We have integrated a 10k Ohm pull-up resistor on the shield so that we can directly measure the AutoIDENT resistor using a simple voltage divider calculation.

alt text

Voltage divider circuit

Nominal Resistor and voltage values for Vernier sensors

We’ve collected a list of popular sensors used by Vernier and their corresponding unique IDENT resistor values. These are nominal values and may vary within +/- 5%.

Analog Sensors

alt text

Digital Sensors

alt text

You will notice that there are not 70 sensors listed here. For all new sensors, Vernier has standardized on an I2C interface to query and communicate SensorID and calibration data. An example of this code is explained in the next section.

Example 1 - AutoID Arduino

The team at Vernier have helped us with creating a couple simple Arduino sketches that automatically query either the Analog or the Digital ports of the Arduino and report back the sensor identification and standard calibration data.

Vernier has created a wealth of examples hosted on github. Upload these sketches to your arduino device, and open up a Serial Monitor to view the data coming back to your computer.

AutoID Analog Sensors

This sketch is designed to automatically query the sensors connected to the two analog ports on the Vernier shield. After the AutoID, it prints the sensor information to the Serial Monitor and starts logging (calibrated) data to the screen. Written into this script are the default calibration constants used with Vernier’s sensors.

This will, most likely, be the only Arduino sketch you need for most of your sensors.

As it is written, the data is collected once per second. Change the value of the variable TimeBetweenReadings to change the rate of the data collection.

AutoID Digital Sensors

This sketch queries the digital sensors connected to the Vernier Shield and prints out the information to the Serial Monitor. Because each digital sensor is unique, this sketch does not start logging data or printing out results. It will, however, suggest the name of the Vernier Arduino sketch to use. You can find these on the Vernier github repository.

Example 2 - Photogate Timer

alt text

In many classrooms, a standard stopwatch or timer is used to measure the time elapsed for moving objects such as mousetrap car races, rolling dynamics carts, or falling tennis balls.

These little stopwatches are great for most simple activities, but for many investigations and experiments, human reaction time and classroom distractions often introduce too much error and uncertainty to collect repeatable results for students to draw clear conclusions from their data.

Integrating a photogate timer is one of the simplest and low-cost tools a teacher can use. A photogate is simply an infra-red LED and receiver pair. The photogate normally produces a HIGH signal on DIO0 when the gate is unblocked. When an object passes through the gate, the signal is LOW until the gate is unblocked again.

Integrating this with a very fast timer, we can achieve very reliable and precise timing results.

alt text

The Arduino UNO has a 16 MHz clock. Accounting for overhead events and extra needed clock cycles and such, the Arduino is capable of timing results with a precision better than +/- 1 uS.

This code example is interrupt driven and uses the micros() arduino command to return the number of microseconds since the start of the program. This number is stored in an unsigned long variable. This gives the program a maximum time limit of about 1 hour and 11 minutes before the counter wraps. Generally speaking, we’re looking to capture the amount of time for a marble, toy car, or playing card to move through the gate.

This sketch simpily outputs an event entry to the Serial Monitor with the Event #, the photogate state (Blocked or Unblocked), and the time since the start of the program.

Data Output Format

The data is tab delimitted, and you can simply copy-paste this into your favorite data analysis program such as LoggerPro, Matlab, Google Sheets, or Excel.

Vernier Format 2

Event    Blocked    Time
#   (n/a)   (s)
--------------------------
1   1   1.885308
2   0   1.903900
3   1   1.908432
4   0   1.927056
5   1   1.945756
6   0   1.964332
7   1   1.980148
8   0   1.996724

Sensor Calibration and Verification - Falling Picket Fence

The Falling Picket Fence is a classic activity used in many physics classes. It extends and combines the concepts of average velocity to instantaneous velocity and explore uniform acceleration and the nature of the acceleration due to gravity.

A picket fence is nothing more than a clear piece of plastic with opaque bars spaced 5 centimeters apart (center-to-center).

alt text

Dropping a picket fence near the surface of the Earth should accelerate uniformly at a rate of 9.8 m/s/s. I used this to verify and check the accuracy of the timing. I used the sample code from above and dropped a picket fence through the photogate, and here is the data it returned:

Vernier Format 2

Event   Blocked    Time
#   (n/a)   (s)
--------------------------
1   1   5.520980
2   0   5.542184
3   1   5.570784
4   0   5.584924
5   1   5.605876
6   0   5.617208
7   1   5.635028
8   0   5.644568
9   1   5.659904
10  0   5.668612
11  1   5.682448
12  0   5.690280
13  1   5.702860
14  0   5.710160
15  1   5.721872
16  0   5.728644

Clearly that’s accelerating at 9.8 m/s/s, right?

Okay, you’re right. It’s about as clear as mud. It’s just a bunch of numbers, but if you look closely, you can see that the time between events appears to be getting smaller and smaller. Ah, ha! It’s speeding up! That’s a good sign.

The raw data is difficult to understand without processing, so I created a sample worksheet that can be used in any class. The worksheet calculates the average velocity between blocking events.

Using the worksheet, I graphed velocity vs. time and found the slope.

Data Statistics
slope: 9.78799 m/s/s
intercept: 0.758978 m/s

Is it right? Well - I try to avoid making right vs. wrong judgements in science. It is simply data, and all I can say is that it appears to agree with our existing assumptions and observations of the universe.

Other things you can do with photogates?

Check out the Vernier Photogate Timer Project tutorial.

Example 3 - Motion Detector

Vernier’s motion detector sensor is one of the most popular sensors used in classrooms. It uses a ultrasonic transducer similar ones used in older auto-focusing Polaroid cameras.

Combined with a graphing utility, it allows students to immediately see how position varies with time and how the slope of this graph is related to quantities such as velocity and acceleration.

alt text

The motion detector uses echo-location or sonar to determine the distance of objects in front of the sensor. It works by emitting an ultrasonic pulse and then listening for the echo of the pulse from the reflection off objects. The Vernier motion detector uses two pins for this:

Init (Pin 2 on the BTD connector)
Echo (Pin 1 on the BTD connector)

On the Vernier shield, we have these pins tied to:

Digital 1Digital 2
INIT48Trigger pin to send the ultrasonic pulse.
ECHO37Listen to this pin for the echo return / reflection.

Using the Arduino function micros, we can catch the time of the echo to an accuracy of 1 us. If we assume that sound travels at a speed of about 340 m/s, this translates to a round-trip accuracy of better than 1 mm.

Because we know that sound travels at a constant speed in a uniform medium, we can use simple kinematics to determine the distance the reflected sound travelled. In our code, we assume that the speed of sound is nominally 340 m/s. If you care to account for differences in temperature, hyperphysics has a great tool to calculate and adjust for differences in temperature.

alt text

Code example

The following code example has been adapted from the Vernier github repository. This sketch will record at a dataRate of 20 samples per second for a duration of 5 seconds. There are two variables declared in the beginning of the code that control these two parameters.

After uploading this file to your Arduino, open up a Serial Monitor and press the push button (D12) to start the data collection. Data will be displayed to the Serial Monitor. You can copy-paste this into Excel, Matlab, or LoggerPro for analysis. Or, you use a Serial graphing program like SerialChart, MakerPlot, or write your own in Processing.

Example 4 - Temperature Probe

alt text

Measuring temperature is a quantity that crosses into nearly every area of science and engineering (except maybe computer science). Vernier sells a great stainless steel temperature probe that is accurate from -40 degrees C to +135 degrees C. According to their site, the sensor can handle up to 150 degrees C before it is damaged. For us in the U.S., this is about 300 degrees F. It’s not quite safe to use as a meat thermometer in the oven, but it covers a pretty wide range for most scientific exporations.

The probe has a device called a thermistor that exhibits a change in resistance with respect to temperature. The Vernier probe uses a 20 kΩ NTC (negative thermal coefficient) Thermistor. As the temperature increases, the resistance drops.

The resistance vs. temperature relationship is non-linear and pretty complex, but it can be approximated using the Steinhart-Hart equation:

alt text

Where, RT is the resistance of the thermistor, and k0, k1, k2 are unique constants for the device. For the Vernier sensor:

k0 = 1.02119E-3
k1 = 2.22468E-4
k2 = 1.33342E-7

You can write your own function to convert the analog read value from the Arduino to a resistance.

Schematic:

alt text

The Vernier Interface Shield has a 15k Pull-up Resistor on Vres. We can determine the resistance of the thermistor because this is a simple voltage divider circuit:

alt text

So - here’s the derivation of the work and the algebra:

alt text

Example Code

The example below will collect data and display it to the Serial Monitor. After uploading this example sketch to your Arduino, open up a Serial Monitor to view the data.

This example code will take measurements at a rate of 2 samples per second. Modify the variable dataRate to adjust the sampling speed.

This code has a function called resistance() that converts the raw AnalogRead value to the resistance of the thermistor, and a function called steinharthart() that applies the Steinhart-Hart equation and returns a temperature in degrees Celsius.

For more information on thermistors, take a look at Vernier’s resource on making temperature measurements

Connecting an External Display

Adding an external display greatly enhances the ability to interface to the Vernier sensors independent of having a computer. The Arduino can be powered off a few AA batteries, and adding an LCD display will allow you to provide immediate feedback to the user.

What you’ll need

Recommended Reading / Useful Resources

Getting Started

You’ll need to solder on the male break-away headers to access pins D0 and D1. These will be used to transmit / send data to your Serial display device. You will also need to add headers to the power pins (5V and GND). We suggest using the female headers for this, though. Having power and GND exposed creates a risk of a short-circuit. Thankfully, the Arduino has a PTC resettable fuse that will protect your computer and the Arduino from this, but it should still be avoided.

The example code will vary depending on the Serial device you are using. You will need to connect Power (5V), GND, and the Transmit (Pin 1) on the Vernier Shield to your serial display device. Remember: the TX line should go to the RX line on the serial device.

Serial LCD Quickstart

Storing Data to an SD Card

alt text

What you’ll need

Recommended Reading / Useful Resources

Adding an SD Card Interface to your Vernier shield is pretty simple. The SD Card shield will have to go below the Vernier Shield using a set of stack-able headers).

Upload this code to your shield. It logs raw voltage values of the sensors to a microSD Card, if you are using the SparkFun microSD Card Shield. If you are using your own SD Card shield implementation, double check the pin assignments for chipselect. On the SparkFun microSD Card Shield, chipselect is on pin 8.

This code example will read raw voltage levels from any analog Vernier Sensor that provides a voltage from 0 to 5V (this accounts for a majority of their sensors). Pressing the button (D12) will start the data collection for a time period defined by the variable duration. Data is logged to a file called “datalog.txt” and displayed to the Serial Monitor.

Resources and Going Further

We hope that these examples will get you going on digging into the details of data collection and calibration. Vernier has been incredibly helpful with this collaboration. They have a wealth of resources on their site, as well:

Please send an e-mail to education@sparkfun.com if you’d like to share what you are doing with Vernier Sensors and Arduino or if you have any questions or problems with your board.


learn.sparkfun.com |CC BY-SA 3.0 | SparkFun Electronics | Boulder, Colorado


Viewing all articles
Browse latest Browse all 1123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>