Presentation is loading. Please wait.

Presentation is loading. Please wait.

ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions? Concerns? Homework Policy: All homework is due Friday, August.

Similar presentations


Presentation on theme: "ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions? Concerns? Homework Policy: All homework is due Friday, August."— Presentation transcript:

1 ROBOTC for VEX Online Professional Development

2 Homework Questions Thoughts? Questions? Concerns? Homework Policy: All homework is due Friday, August 22 nd by midnight.

3 Warm-up Questions What is Firmware? Why does the robot spin if both motors are set to the same power level? What are valid power levels on the VEX? All commands that we want the robot to follow must be in _________? Each command must end with a(n) _________?

4 Troubleshooting Questions Step 1: Identify the problem Step 2: What can we tell about the student’s understanding based on the problem? Step 3: What could we tell the student to address the problem, and their understanding? Just giving the answer to the student teaches dependence! This method teaches!

5 Troubleshooting Student: I want my robot to move forward, then turn. I had it moving forward, and added the turn. Now it’s turning, then moving forward.

6 Troubleshooting Student: My code compiles, but I get an error when I try to download it to the robot. Check: –Is the robot turned on and sufficiently powered? (blinking green light) –Is the robot connected to the computer? –Is the correct platform type selected in ROBOTC? –Is the correct port selected in ROBOTC? Has the driver for the programming cable been installed? –Has the firmware been loaded on the VEX? –Does the Master Firmware need re-downloaded? –Is another ROBOTC window open, using the debugger windows?

7 Shaft Encoders

8 The Problem with Wait States Motor Speed is affected by battery power –If the battery is fully charged, the robot moves quickly –If the battery is running low, the robot moves slowly –Consequently, the robot will not move consistently as the battery power drains –Makes completing the Labyrinth tricky Anyone experience these effects? Wouldn’t it be better if we could control the distance the robot moves, regardless of how long it took to complete?

9 Quadrature Shaft Encoders How they work –Digital counting sensor –As the inner shaft spins, the encoder “counts” Capabilities and Resolution –360 “counts” per revolution of the inner shaft –Counts Up and down

10 Shaft Encoders: Cortex

11 Better Movement with Encoders Forward for Distance

12 Better Movement with Encoders Turning

13 Practice implementing what you just learned in the Labyrinth Challenge! Watch VEX Cortex Video Trainer videos for review. Movement > Shaft Encoders Better Movement with Encoders

14 Moving Straight Even with the shaft encoders, the robot still veers to the left or right (probably). –Does it have to? By comparing the values of the two encoders, we should be able to tell which side is falling behind, and adjust motor power in real time! Open the Moving Straight sample program and try it out!

15 Moving Straight

16 Sensor Information: Integrated Motor Encoders (IME’s)

17 Integrated Motor Encoders How they work –“I2C” Smart Sensor –Replaces the back plate of 269 and 393 Motors –As inner striped wheel spins, internal light sensor detects and counts Capabilities and Resolution –627 Counts Per Revolution in High Torque Configuration –392 Counts Per Revolution in High Speed Configuration –Up to 8 encoders “daisy chained” in a row –Counts Up and down –Allows you to control the distance a robot moves, by monitoring how much the wheels spin –Due to “closed-loop” configuration, “PID” control is possible

18 Motors and Sensors Setup Enabled and configured on the Motors tab Motor “Type” is important, as their resolution is not uniform

19 Testing your Encoder Setup You can try to follow the wires from the sensors to the I2C and Motor ports… …or use the Motor Debug Window!

20 Better Movement with Encoders Forward and Backward for Distance

21 Better Movement with Encoders Turning Right and Left

22 PID Control Proportional-Integral-Derivative With the integrated motor encoders, we have what is called a “closed-loop” system –The Cortex knows exactly how fast the motors should be spinning versus how fast they are actually spinning and can make rapid adjustments to compensate for the difference

23 Variables

24 A variable is a space in your robot’s memory where data can be stored, including whole numbers, decimal numbers, and words Variable names follow the same rules as custom motor and sensor names: capitalization, spelling, availability Variables can improve the readability and expandability of your programs

25 Variable Types Data TypeDescriptionExampleCode IntegerPositive and negative whole numbers, as well as zero -35, -1, 0, 33, 100 int Floating Point Number Numeric values with decimal points (even if the decimal part is zero) -.123, 0.56, 3.0, 1000.07 float BooleanTrue or false – Useful for expressing the outcomes of comparisons true, false bool CharacterIndividual characters, placed in single quotes ‘L’, ‘f’, ‘8’ char StringStrings of characters, such as words and sentences placed in double quotes “Hello World!”, “asdf” string

26 Creating a Variable To create a variable you must give it a: 1.Type for type of data it will hold 2.Name by which variable can be referenced Variables can be set to different values throughout program Naming variables follows the same rules as naming your Motors and Sensors Giving a variable an initial value is called “initializing the variable”

27 Common Variable Uses Variables are useful for keeping track of loop iterations The following code lets the loop run 10x Note that the side on the right of the equal sign is evaluated first, then set to the variable on the left. This is always the case.

28 Common Variable Uses Variables are useful for keeping track of sensor or timer values at different parts of the program

29 Common Variable Uses Variables are useful for keeping track of results from complicated equations

30 Global Variables Window Displays all of the Global variables in your program in real-time

31 Moving Straight and Variables Watch VEX Cortex Video Trainer videos for review. Movement > Automated Straightening

32 The M in STEM Current method for moving the robot: –Guess-and-check - true for wait states and encoder rotations Do it smarter! –We can measure the distance for the robot to travel –We can measure the circumference of the wheel –We know 360 degrees = 1 wheel rotation –Spend 5 - 10 minutes working out a solution Use your idea to move forward and reverse –Discuss how well your ideas worked Discuss Turning –Is having the robot turn 90 degrees the same as having the encoder turn 90 degrees? Why or why not?

33 The M in STEM How did you solve the math problem? Some common methods: –Scale Factor (“Scaling” multiples of a known quantity) –Rate: Unit Ratio (# of X in a single Y, times the number of Y’s) “Rate” relationship Find #degrees/1in, then multiply that rate by the total What about #degrees per floor-line? –Rate: Raw Ratio (# of X per # of Y, times the number of Y’s) Find 360degrees/8.6in, then multiply that rate by the total –Direct Proportion (Traditional “ratio” equation) 8.6 in = 24 in 360 deg X deg Solved mechanically using cross-multiplication Solved algebraically as a Linear Equation of One Variable

34 Everyone is a Math Teacher How did you solve the math problem? Many STEM teachers will not be teaching in Math class, yet Math is clearly what they are teaching –Make the math explicit; don’t waste the opportunity! –Embrace multiple methods of solving the same problem; students need more tools at their disposal, not conflicting information about which ones are “better” than others (none are, use what works!)

35 Shaft Encoder Natural Language Commands

36 Until Commands that allow you to create behaviors where the robot acts “until” a certain event –untilEncoderCounts() –untilRotations()

37 Forward and Reverse for Distance

38 Precise Turning

39 ROBOT Motion Commands that cause the entire robot to perform a behavior –moveStraightForRotations() –moveStraightForTime()

40 Moving Straight

41 Homework VEX Cortex Video Trainer Videos –Movement > Shaft Encoders –Movement > Automated Straightening –Sensing > Behaviors and Functions Homework: –The Labyrinth Revisited –Seeing the Difference –Basketball Drills

42 Additional Slides: Functions

43 Moving Straight Discussion The automatic moving straight code works great, but imagine using it to solve the Labyrinth. –Automatic moving straight code = ~20 lines –5 Forward movements needed for the Maze –5 x ~20 = ~100 Lines of code! –And that doesn’t include turns or other commands! Notice that the moving straight code is mostly comprised of the same exact code, over and over. –What if there were a way to reuse the same set of code? –There is: Functions!

44 Functions Functions are used to group together several lines of code, which can then be referenced many times in task main, or even other functions. Convenient uses in the Labyrinth –Moving Straight –Turning 90 Degrees Left –Turning 90 Degrees Right Creating Functions –Simplified Example: Moving Forward –Function Header (Part1 – The name of the function) –Function Definition (Part 2 – The code that goes with the function) Using Functions –Function Call (Part 3 – Where you want the function code to run)

45 Function Definition

46 Function Call

47 Advanced Functions What about the very similar lines of code that go with the automatically moving straight code? Is there a way to include those lines in the function? –What’s different each time we use the code? The number of degrees for the distance of the straight movement! What programming tool do we have that lets us store numbers in our code? Variables! Functions allow use for a special kind of variable, called a Parameter. Parameters allow you to pass values into functions to account for small differences, like the number of degrees to move forward.

48 Advanced Function Definition

49 Advanced Function Call

50 Functions Watch VEX Cortex Video Trainer videos for review. Sensing> Behaviors and Functions


Download ppt "ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions? Concerns? Homework Policy: All homework is due Friday, August."

Similar presentations


Ads by Google