Transcript PPT

Program potentiometer in
autonomous mode
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Program potentiometer in
autonomous mode






Performance Objective: Given the components of a
VEX robotics design system program potentiometer in
autonomous mode to have a robot arm move up or
down depending on the start position.
Enabling Objectives:
explain the purpose of a potentiometer
explain how a potentiometer operates
draw a flow chart for using a potentiometer
program a potentiometer
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Potentiometer





A potentiometer is an electrical component whose resistance is
adjustable
You can therefore adjust the degree to which the potentiometer
opposes electric current through it, simply by turning a shaft that
is attached to the center of the potentiometer
As the resistance of the potentiometer changes, so does the
voltage across the resistor
This varying voltage is directly proportional to the angular
position of the shaft connected to the center of the
potentiometer
This allows you to obtain an analog measurement of an angular
position.
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Potentiometer Limits




It is important to ensure that the shaft that is being measured by
the potentiometer does not travel more than 260° (the
potentiometer can only move approximately 265 ° ±5 ° and can
only electrically measure 250 ° ±20 °)
To measure the motion of an attached component that rotates
more than 230 °, try gearing down the shaft’s motion such that
the gear attached to this “primary” shaft turns a larger gear
attached to a “secondary” shaft
This secondary shaft will therefore rotate less distance than the
primary shaft
This way, you should be able to indirectly measure the rotation of
the primary shaft by directly measuring the rotation of the
secondary shaft
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Finding the limits of a
potentiometer


In order to see the limits of the
potentiometer on a specific robot you
should run the test code and move the
robot arm by hand
By moving the arm you can physically
see the limits as well as see what values
represent each limit
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Downloading the test code




Before downloading the test code, plug in the
potentiometer to an analog input port
In easyC open the test code by clicking on open, in the
projects folder click on the samples folder, from the
samples folder open the potentiometer test folder, in
this folder open the potentiometer test project
Download this code
Move the arm and notice the range in values of the
potentiometer when you move the arm up and down
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Program the potentiometer


Draw the flow chart for this program
code
Program the robot to change the
position of the arm from up to down or
visa versa depending on the start
position of the arm using the
potentiometer
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Program the potentiometer



Open a new competition project
Set the configuration for the
microcontroller
Define a new global variable for the
potentiometer
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Program the potentiometer



Insert the function
block to get the
input of the
potentiometer
Set the port
number
Set the variable to
retrieve the value
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Program the potentiometer

Insert an If
statement to
move the arm up
if the arm starts in
the down position
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Program the potentiometer

Insert an Else-If
statement to
move the arm
down if the arm
starts in the up
position
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Test the program



Download you code and use the Competition
Switch Simulator to test the code
If you start the program and the arm moves to
the opposite position, great!
If you started the arm up in the first test, start
it in the down position and retest the program
to ensure it works for both directions
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode
Show it off



If your code works, show it to your
instructor!
You are now finished programming the
potentiometer
For additional technical information visit:
http://www.vexforum.com/wiki/index.php/Potentiometer
Available at: www.etcurr.com
Lesson 3.3 – Program Potentiometer in Autonomous Mode