Presentation is loading. Please wait.

Presentation is loading. Please wait.

Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Programming in easyC.

Similar presentations


Presentation on theme: "Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Programming in easyC."— Presentation transcript:

1 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Programming in easyC

2 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. What is Programming? Making something do what you want it to do – Circuits and switches – Code Demands/commands Robot obeys commands

3 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. What is the programmer’s role? Define parameters for robot behaviors Be specific – On/off – Port numbers

4 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. What is Programming? Programming is the process of creating a sequence of instructions that tells a computational device how to perform a task. True programmers: – Analyze the task at hand – Break the task down into simpler and simpler behaviors until they reach the level where the robot can understand them – Arrange and organize instructions to implement the behaviors as needed

5 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. What is easyC? Software that allows you to write programs in the ‘C’ style... – Instructions will be executed top to bottom – Uses C-style operators and comparators (,=,==, etc.) – Comments are ignored Hybrid icon-based language – Main program flow is iconic – Some operations require C operators

6 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Hardware Setup This setup will allow you to download code you write in easyC from your computer to your robot. Plug your motors into any two motor ports you wish.

7 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Test Program Goals – Learn the basics of easyC – Learn how to write your own programs Begin by opening easyC on your Desktop

8 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Icons You Should Know New Project Open Project Save Project Build and Download: compiles and downloads your easyC code to your robot For your challenges, you will be using the L2 code level (this determines which blocks will be available to you).

9 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Open the file TESTPROGRAM.ECP from the folder “Test Code”

10 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Your screen should look like the screen below To get this code onto the robot, we will need to compile and download this code.

11 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. For the test program to work properly, you must make sure the terminal window appears after downloading code to the robot. 1.Click “Loader Setup” under the “Build & Download” menu. 2.Click the radio button next to “Terminal Window.” This will make the terminal window appear immediately after downloading code to your robot.

12 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. The Compiler The compiler is a computer program that translates a completed set of easyC instructions into machine language so the Micro Controller can understand them. easyC code Machine code (.HEX file) Compiler

13 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Compiling your Code 1.Click on the compile icon. 2.You should get the following screen: Compiling your code creates a.HEX file which has transformed your easyC program into machine language, or something the computer can understand.

14 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. This is the output window. If you click on the error, it will highlight the line number.

15 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Downloading your Code Downloading is the process of sending the compiled machine-language program from your PC to the microcontroller easyC code Machine code (.HEX file) Compiler Code on robot Downloader

16 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Downloading your Code 1.Make sure your robot is on and plugged into your computer. 2.To download your code, click on the “Build and Download” icon. 3.The computer will re- compile the code and begin downloading the.HEX file to your robot.

17 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. How the Test Program Works The test program will run the motors by running them forward and then backward Make sure you pick up your robot so that it does not fall off the table when the program starts

18 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Restoring Default Code If you would like to restore the “out-of-box” configuration on your robot, follow these steps. 1.Make sure your robot is switched on and plugged into the computer. 2.Click the “Download default code” under “Build and Download” menu. 3.The code will immediately download to your robot.

19 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 1: Motor On Now that you have gotten a feel for easyC, the following slides show you five programs to teach you about motors and timing. You will need to master all of these programs to accomplish your next challenge. On your desktop in the folder “Programs,” you will find guides to all the programs. Program 1 will teach you how to turn on a motor. Video: Motors – Motors On

20 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 1: Motor On What you learned: – (Add to page during discussion)

21 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 2: Motor Forward Program 2 will teach you how to turn both of your robot’s motors on for three seconds. Video: Motors – Forward for 3 Seconds

22 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 2: Motor Forward What you learned: – (Add to page during discussion)

23 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 3: Turning In program 3, you will learn how to turn for three seconds Video: Motors – Turn for 3 Seconds

24 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 3: Turning What you learned: – (Add to page during discussion)

25 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 4: Forward/Backward In program 4, you will learn how to make your robot move forward, then backwards Video: Forward for 3 Seconds, Backward for 3 Seconds

26 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 4: Forward/Backward What you learned: – (Add to page during discussion)

27 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 5: Half Speed In program 5, you will learn how to power your motors on half speed for three seconds. Video: Motors – Forward Half Speed

28 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Program 5: Half Speed What you learned: – (Add to page during discussion)

29 Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Programming Guide You now have the basics to programming your robot to complete your new challenge.


Download ppt "Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Programming in easyC."

Similar presentations


Ads by Google