Arduino Lab 1 - The Voltage Divider



Similar documents
PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

Surveillance System Using Wireless Sensor Networks

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

FREQUENCY RESPONSE OF AN AUDIO AMPLIFIER

1 Coffee cooling : Part B : automated data acquisition

Lab 4 - Data Acquisition

Antenna Rotator System

Installing ABACUS ELECTRICS USB Optical Probes under Windows 7

Work with Arduino Hardware

Animated Lighting Software Overview

Programming Device Manual Booklet AVR Prog USB v2

Lab 3 - DC Circuits and Ohm s Law

Example Connection between USB Host and Android

Building a Basic Communication Network using XBee DigiMesh. Keywords: XBee, Networking, Zigbee, Digimesh, Mesh, Python, Smart Home

V out. Figure 1: A voltage divider on the left, and potentiometer on the right.

Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II

Tiny Arduino Music Visualizer

PRODUCTIVITY THROUGH INNOVATION 600 CONTROL DIRECT DRIVE TECHNICAL/OPERATION MANUAL

1 INTRODUCTION. This document describes the procedure to upgrade LTMR.

Using the Communication Ports on the DG-700 and DG-500 Digital Pressure Gauges

Experiment #11: LRC Circuit (Power Amplifier, Voltage Sensor)

Electronics 5: Arduino, PWM, Mosfetts and Motors

INTRODUCTION TO SERIAL ARM

Electronic WorkBench tutorial

Evaluation copy. Build a Temperature Sensor. Project PROJECT DESIGN REQUIREMENTS

Arduino Lesson 0. Getting Started

ezsystem elab16m Project 1F: Alarm System (Full Project description)

Wireless In-Ear Audio Monitor

Capacitive Touch Lab. Renesas Capacitive Touch Lab R8C/36T-A Family

SPROG II User Guide 1. SPROG II DCC Decoder Programmer User Guide

Setting up a Local Interconnect Network (LIN) using dspace MicroAutoBox 1401/1501 Simulink Blocks

Lab 6 Introduction to Serial and Wireless Communication

Workshop Intel Galileo Board

UPS PIco. to be used with. Raspberry Pi B+, A+, B, and A. HAT Compliant. Raspberry Pi is a trademark of the Raspberry Pi Foundation

DS1307 Real Time Clock Breakout Board Kit

Introduction to Arduino

Keep it Simple Timing

RIGtalk. Revision 5. Owner s Manual 2012.

Supplemental USB Driver Installation Guide

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

Using the VEX Cortex with ROBOTC

EDK 350 (868 MHz) EDK 350U (902 MHz) EnOcean Developer Kit

AVR Butterfly Training. Atmel Norway, AVR Applications Group

PhidgetInterfaceKit 8/8/8

Project Plan. Project Plan. May Logging DC Wattmeter. Team Member: Advisor : Ailing Mei. Collin Christy. Andrew Kom. Client: Chongli Cai

Electrical Resonance

CHAPTER 11: Flip Flops

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

Inductors in AC Circuits

Connecting instruments serially to your computer

Contents Models 3500 / 3600 Software & Driver Installation... 1 Install Amplifier Control Panel... 2 Download and Install the Drivers...

Lab 3: Introduction to Data Acquisition Cards

#include <Gamer.h> Gamer gamer; void setup() { gamer.begin(); } void loop() {

USB Driver Installation for Windows XP

Lab 1: Introduction to Xilinx ISE Tutorial

Electronics. Discrete assembly of an operational amplifier as a transistor circuit. LD Physics Leaflets P

Karaoke Circuit Building Instructions

C4DI Arduino tutorial 4 Things beginning with the letter i

Chord Limited. Mojo Dac Headphone Amplifier OPERATING INSTRUCTIONS

Chapter 4: Pulse Width Modulation

Introduction to Arduino

Arduino Lesson 14. Servo Motors

Flight Controller. Mini Fun Fly

itunes Basics Website:

Intro to Intel Galileo - IoT Apps GERARDO CARMONA

KTA-223 Arduino Compatible Relay Controller

Multi-Touch Ring Encoder Software Development Kit User s Guide

Warnings: This manual is intended to guide a technicians or customers who would like to repair DBL's

Measuring Resistance Using Digital I/O

Downloading a Sample Program over USB

An Introduction to MPLAB Integrated Development Environment

TOSR0X-D. USB/Wireless Timer Relay Module. User Manual. Tinysine 2013 Version 1.0

How to connect to a Class II router using a mobile-phone data cable specifically for Solwise & Safecom routers

The electrical design focuses on high quality circuit board layout and good components.

Instructions for Installing and Using the FOCUS DL-15 Data Transfer Software

Windows XP.. ELITE Firmware Update procedures.. v1.41

Lab Experiment 1: The LPC 2148 Education Board

AC-PG-USBASP USBASP AVR Programmer

GENERAL SCIENCE LABORATORY 1110L Lab Experiment 6: Ohm s Law

UDG1000 Hach PCX2200 Serial Port Input Driver configuration

Six-servo Robot Arm. DAGU Hi-Tech Electronic Co., LTD Six-servo Robot Arm

DMX USB PRO. User Manual.

Evo Laser Firmware Developer s Manual

Safety Precautions WARNINGS

SYSTEM 45. C R H Electronics Design

SKP16C62P Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

Config software for D2 systems USER S MANUAL

RN-52 Bluetooth Hookup Guide

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

USER GUIDE. Publication AP8509. Allen & Heath 1 XONE:K2 User Guide

Lab #9: AC Steady State Analysis

Physics 226 FPGA Lab #1 SP Wakely. Terasic DE0 Board. Getting Started

OMEGA STUDIO SOFTWARE INSTALLATION GUIDE

User Guide Reflow Toaster Oven Controller

Troubleshooting Tips Lifestyle SA-2 & SA-3 Amplifier. Troubleshooting Tips

MonitorKey USB Driver Installation Instructions

netduino Getting Started

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

DUKANE Intelligent Assembly Solutions

ABB solar inverters. Installation and setup instruction Aurora Manager TL software and ABB PVI-USB-RS232_485 adapter

Transcription:

Arduino Lab 1 - The Voltage Divider 1. Introduction In this lab, we will endanger a cute animal, create a portal to another dimension, and invent a new genre of music. Along the way, we will learn about breadboarding, voltage dividers, photoresistors, and using the TOMYUM SynthScope with MATLAB. 2. Some Basic Circuit Theory Circuits are generally designed to accomplish some sort of fixed task, such as blinking a light or amplifying a sound signal. Often, however, you will want to add user input to your circuit, so that you can change its behavior on the fly (for example, setting the blink rate or adjusting volume). A common way of doing this is to use a potentiometer. A potentiometer looks like this: A potentiometer is a three terminal device. The resistance between the two outermost terminals, R1 3, is constant (this constant value is in fact written on the side of the potentiometer), but the center terminal (2) acts as a wiper that slides back and forth along the resistor as you rotate the potentiometer. Therefore, R1 2 and R2 3 change, but their sum R1 2 + R2 3 = R1 3 is constant. Note that the potentiometer is symmetrical. In this case, we will be using the potentiometer as an input to a MATLAB program, with the TOMYUM SynthScope as an intermediary. However, the SynthScope like many devices measures voltages, not resistance, so we must find a way to convert a change in resistance into a change in voltage. Enter the voltage divider. 1

Here is a circuit schematic showing a potentiometer used as a voltage divider: Through simple circuit analysis, it can be shown that: Now, since R1 3 is constant, and R2 3 will range from 0 Ω to R1 3 Ω, we can see that Vout will vary linearly from 0 V to Vin V, proportional to R2 3. In essence, we have created a simple way for the user to control the voltage Vout (by turning the potentiometer). 3. Introduction to the Arduino Platform In front of you is a highly capable micro-controller the Arduino Duemilanove: Yours will look like the one on the right, as it has the protoshield attached. This is an extension board that extends the pin headers on the main board while also providing a breadboard prototyping surface. You ll find that the board has plenty of connections. In this lab, we will be connecting the board with the USB connection (no external power supply is required) and then using the Analog Inputs and power connections on the board. 2

PLEASE FOLLOW ALL DIRECTIONS! If your computer already has ArduinoUploader please skip to Flashing the Arduino The first step in this lab is to download the software required. The necessary files can be found on the ESE 205 website under the Arduino link. You will need the compiled firmware file (main.hex), the Arduino Uploader folder (ArduinoUploader), and the folder containing the MATLAB functions (synthscope-lab). 1. Save both the firmware file and the Arduino Uploader folder to the C drive (C:\users). a. NOTE: RCA computers only need main.hex if not present in C:\users. 2. Cut or copy main.hex and place it in the ArduinoUploader folder. a. NOTE: Not required on RCA computers 3. Save the MATLAB functions to your S drive (remember this location). a. NOTE: MATLAB Functions are found on 205 website, not BlackBoard. -Flashing the Arduino- (Windows XP/Vista) 1. Connecting Arduino to computer a. Right-click on My Computer on the desktop b. Click Properties c. Change the tab to Hardware d. Click Device Manager e. Click OK when error message opens f. Open up Ports (COM & LPT) by clicking the + sign g. Knowing which ports are currently displayed, plug USB cable into Arduino and then a free USB socket on computer h. The new COM port number is the Arduino board i. If this new COM number is greater than 9 (ie, contains 2 digits) Example, COM10, COM 24, etc i. Right-click on the port ii. Select Properties iii. Click the Port Settings tab iv. Click Advanced v. Change COM Port Number to a lower, single digit port that is open (not present In the list) Example: if COM12, change to COM5 vi. Click OK vii. Click OK viii. After this, even though the port number did not change in the list the Arduino will be assigned this new number 3

j. Make a note of this number 2. Opening command prompt a. Click Start button b. Click Run c. Type cmd for the command prompt d. Type in (if not already in C:\users) : chdir C:\users\ i. If installed on home computer, use directory where Arduino Uploader is located e. In the command prompt, type the following with a single space in between: avrdude (the program to flash the board) -c stk500v1 (the programmer used) -P comx (the COM port replace X) -p m328p (the microcontroller model) -b 57600 (the controller baud rate) -U flash:w: main.hex (flash the board by writing the file to the chip) This should look like the following: (Remember: replace X with your COM port if Arduino is on COM port 8, use com8 ) 4

4. Moving from Hardware to Software Let s try building this voltage divider circuit and measuring Vout from MATLAB. Like many digital devices, the maximum voltage that the SynthScope can safely be connected to is 5V. For that reason, let s use the 5V power bus on the SynthScope as our Vin. To measure the output voltage Vout, it must be connected to one of the analog inputs. Using a potentiometer and some spare wires, construct the voltage divider circuit from the previous page on your SynthScope s breadboard. Once you ve set up your circuit on the breadboard, you can connect your SynthScope to the computer with a USB cable and begin reading voltages into MATLAB. You will need to download the SynthScope MATLAB files for this lab from BlackBoard, and change your working directory in MATLAB to be this downloaded folder. Once you ve set up MATLAB, try running the following commands. Replace CHANNEL with the number of the analog input that you connected Vout to. s = SynthScope(); If this doesn t work, try : s=synthscope( COMX ); voltage = readanalog(s, CHANNEL) 5

The readanalog command tells MATLAB to measure the voltage at the SynthScope s input pin. To view visually how this value changes over time, try running the following command: showscope(s, CHANNEL) Notice how the value changes as you move the potentiometer. Is this what you expected? What happens if you flip the potentiometer around? 5. Practical Example #1: Rotating a Marmoset Here, on the left, we have included for you an ordinary marmoset. Problem is, he s been sitting in this lab manual for as long as he can remember and has really become quite bored. Notice his concerned expression and unnatural tenseness. Let s use what we ve learned so far to entertain him. We will now use the voltage output from the potentiometer to control the behavior of a software application, in effect creating a new input device for the computer. With the same circuit setup as before, try running the program in marmoset.m and rotating the potentiometer around. Now, you may find that rotating your marmoset is more fun than you could ever have anticipated. Just be careful not to rotate him too far, lest he slip off and injure himself. What does each command in the above program do? Can you add to the program to make MATLAB display a warning message when the marmoset reaches a dangerous incline? (Hint: try using the msgbox command) What other things could you control with the potentiometer? 6

On second thought, the marmoset actually doesn t seem too happy with all this moving around. Can you construct a voltage divider using fixed resistors such that he will constantly remain at a comfortable 30 degrees? 6. Practical Example #2: A Dimension-Piercing Flashlight Voltage dividers are also very useful when using photoresistors, a special type of resistor that changes resistance according to the amount of light that hits it. The more illuminated the photoresistor is, the lower its resistance; the less light hits it, the higher its resistance. In order to sense light intensity, we again wish to convert this change in resistance into a change in voltage, so we will use a voltage divider as shown in the following diagram: Using the circuit above, construct two separate light sensors (one facing leftwards and one facing rightwards) on your breadboard and connect the output voltage of each to an analog input on the SynthScope. For R1, choose any value of resistor (100Ω to 10kΩ) for now; we will fine tune it momentarily. Use the analogread command again to see what voltages are being output by your voltage dividers in ambient light. Since we will want to sense both increases and decreases in light, with the maximum possible dynamic range, we ideally would like the ambient light voltage to be 2.5 V (why?). Try calculating a more appropriate value for R1 to satisfy this design goal, and replace the resistor in your circuit. Now try using the showscope command again to see how these voltages change as you play around with a flashlight: showscope(s, [CHANNEL1, CHANNEL2]); 7

Try running the flashlight.m example program to see an example of how to use these two light sensors in tandem to locate the source of a light (you will need to change CHANNEL1 and CHANNEL2 in the program to match your circuit setup). Can you figure out how the program is working? For a brief non educational distraction, try changing the colormap command s argument. (Hint: type help graph3d into the MATLAB prompt to find a list of colormaps.) 7. Design Challenge: Synthesizer Try using what you have learned so far to make your own new kind of musical instrument, using the potentiometer and/or light sensors. To generate sound, connect a buzzer to the Digital Out 9 pin, and use the following two commands: writewave(s, SINE ) will start sound output; you only need to run this once setwavefreq(s, FREQUENCY) will change the frequency of the sound output Remember that frequencies around 3kHz sound best with the buzzer we are using. Go for it! 8