You are on page 1of 7

Name: Russell Johnson

Date and Time that the Lesson will be Taught: January 22nd – January 26th (2nd, 4th, 7th Period)
Lesson Title: Robot Sensor Encoding
Curriculum Framework Unit and Items: N/A
Objectives: The learners will be able to…
 Program a virtual robot using RobotC Virtual World.
 Navigate an obstacle course using shaft encoders.
 Navigate an obstacle course without using shaft encoders.
 Describe the relationship between time and distance traveled.
 Demonstrate the ability to reverse polarity on motors and configure motor ports.

Content to be presented in lesson:


MY EXAMPLE PROGRAM LABYRINTH CHALLENGE WITH ENCODERS:
#pragma config(StandardModel, "RVW SQUAREBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes
|++++++++++++++++++++++++++++++++++++++++++++++
Forward for Distance with Encoders

This program instructs the robot to move forward for 5 rotations of the left shaft encoder.
There is a two second pause at the beginning of the program.

The used for feedback should be cleared just before it starts counting using the
"SensorValue(encoder) = 0;". This helps ensure consistancy.

Robot Model(s): Squarebot & Swervebot

[I/O Port] [Name] [Type] [Description]


Motor Port 2 rightMotor VEX Motor Right side motor
Motor Port 3 leftMotor VEX Motor Left side motor
Digital - Port 1 rightEncoder VEX Shaft Encoder Right side
Digital - Port 3 leftEncoder VEX Shaft Encoder Left side

*To run this sample program on Swervebot, be sure to Reverse Motor Port 3 in the Motors and
Sensors
Setup, and to make sure that Motor Port 2 is NOT Reversed.
----------------------------------------------------------------------------------------------------*/

//+++++++++++++++++++++++++++++++++++++++++++++| MAIN
|+++++++++++++++++++++++++++++++++++++++++++++++
task main()
{

//Clear Encoders
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;

while(SensorValue[leftEncoder] < 1800) // While less than 5 rotations on the leftEncoder...


{
//...Move Forward
motor[rightMotor] = 63;
motor[leftMotor] = 63;
}
//Clear Encoders
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;
while(SensorValue[leftEncoder] > -360)
{
motor[rightMotor]=127;
motor[leftMotor]=-127;
}
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;

while(SensorValue[leftEncoder] < 1700) // While less than 5 rotations on the leftEncoder...


{
//...Move Forward
motor[rightMotor] = 63;
motor[leftMotor] = 63;
}
//Clear Encoders
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;

while(SensorValue[rightEncoder] > -360)


{
motor[rightMotor]=-127;
motor[leftMotor]=127;
}
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;

while(SensorValue[leftEncoder] < 900) // While less than 5 rotations on the leftEncoder...


{
//...Move Forward
motor[rightMotor] = 63;
motor[leftMotor] = 63;
}
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;
while(SensorValue[rightEncoder] > -360)
{
motor[rightMotor]=-127;
motor[leftMotor]=127;
}
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;

while(SensorValue[leftEncoder] < 1800) // While less than 5 rotations on the leftEncoder...


{
//...Move Forward
motor[rightMotor] = 63;
motor[leftMotor] = 63;
}
}
MY EXAMPLE OF SIMPLE OPERATIONS WITHOUT ENCODERS
#pragma config(StandardModel, "RVW SQUAREBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
motor[port2] = 127; //Left Turn 90 degree
motor[port3] = 64.5;
wait1Msec(3000);

motor[port2] = 64.5; //Right Turn 90 degree


motor[port3] = 127;
wait1Msec(3000);

Motor[port2] = 31.75;

Motor[port2] = 127; //Full Power Straight Forward


Motor[port3] = 127;
wait1Msec(3000);

Self-Paced Lessons to be completed both on RobotC and Vex Cortex Video Trainer 2.0
(Date Completed)
_________ Moving Forward
_________ Moving Forward and Return
_________ Driving Straight I
_________ Driving Straight II
_________ Basketball Drills without encoders
_________ Study Movement/Shaft Encoder lessons on Vex Cortex Video Trainer
_________ Labyrinth Challenge with encoders
_________ Labyrinth Challenge without encoders
_________ Basketball Drills with encoders
_________ Power Level Investigation
_________ Power Level Investigation (Encoders)
_________ Study Movement/Automated Straightening on VCVT Lesson 1 & 2
_________ Labyrinth Challenge Auto Straight
_________ Study Movement/Values and Variables on VCVT Lesson 3 & 4
_________ Labyrinth Challenge Variables
_________ Robot Acceleration
_________ Robot Acceleration / Deceleration
_________ Sentry Simulation I
_________ Simulated Acceleration
_________ Sumo Bot
_________ Turning Investigation (Encoders)
_________ Turning Investigation
_________ Wait State Investigation (2)
_________ Study Movement/Integrated Encoders on VCVT
_________ Basketball Drill with Integrated Encoders
_________ Sentry Simulation (Physical Robot)

**As this class is self-paced, there is not an intro or closure. Students are expected to enter
the room, grab their binders and work at their assigned computers until the bell. I am
expected to stay ahead of the class so as to answer any questions they might have about
programming.**
Learning Activity Monday-Friday 1/22/18-1/26/18
Students will continue to work on their checklist of programs in RobotC as well as video
training in VCVT.
Evaluation/Assessment of Student Learning: Monday-Friday 1/22/18-1/26/18
Students will be informally evaluated based off of their work ethic and comprehension of
the programs. Students who ask questions and stay engaged show that they are grasping
concepts, or are at least trying to. If a student is asking too many questions and not putting in
effort, I use questioning techniques to lead them to an answer rather than just giving it to them.
Students will be formally evaluated based off of their actual code. I check each code
before they are allowed to sign off on an assignment. I also watch their robots perform the
specified action.
References:
Vex Cortex Video Trainer 2.0
RobotC Robots Virtual Worlds 4x

You might also like