Presentation is loading. Please wait.

Presentation is loading. Please wait.

Basics for Robotics Programming

Similar presentations


Presentation on theme: "Basics for Robotics Programming"— Presentation transcript:

1 Basics for Robotics Programming
by Joshua Shaw

2 Introduction to Programming
This presentation demonstrates how to create a program Take as much time as you need to go through this PowerPoint. Just remember that you need to get the program finished as soon as possible so the drivers can practice Good Luck

3 Before We Get Started In this power point I will walk you through as many steps as possible to ensure that the program runs smoothly This includes several of the most obvious steps Such as using the start menu This power point will act as if I am there to help. I will say “we” often So, let us begin

4 What is Easy C Easy C is a simpler version of C++
It uses cause and effect statements, which allow you to manipulate the robot The next slide gives an example of a basic program It can be modified to fit the conditions of the game

5 A Basic Program This is the program used by Hillcrest at the 2011 Crowley's Ridge Best Competition in Jonesboro. It does have limit switch capability which will be discussed later.

6 Getting Started The first step to create the program is to start the Easy C software It will most likely be found on the desktop of your computer If not, then click the Start menu (indicated by red arrow below) Go to All Programs Click on easy C V4 for Cortex

7 To Begin a Program To begin a new program for the robot, click on New Standalone Project under New/Open Select Joystick Project (WiFi) Click Ok If you have already begun a program, click on the name of your program under Recent Projects

8 Start Programming We are going to need a statement that is always true in order for the program to be effective We will be applying a While Loop To do this, go to the Function Blocks box beside your program and click the “+” beside Program Flow

9 While Loop Then click and drag While Loop from the list and place it on the vertical line between Variable box and End box. At this point a dialog box appears Type a true expression such as (2<3) Click OK

10 Add a Motor Inside the While Loop a set of brackets appear, this is where we will create the program First lets add a motor to the program Since motor outlets “1” and “10” are not permitted for use in competition, we will not use them in the program Click the “+” beside Joystick under the Function Blocks Click and drag the Joystick To Motor function to the vertical line between the brackets in your While Loop When you do this, a dialog box appears

11 Motor Programming The Joystick to Motor dialog box should look like this However, we can not use Motor 1 in the competition For this example we will use Motor 2 We do this by clicking on the down arrow in the motor box and select Motor 2

12 Transmitter Channel A Transmitter Channel allows you to select which buttons or joysticks on the Joystick Controller you want to use for a specific purpose In this program we are going to use the left hand joystick to operate the wheels and the right hand joystick to operate an arm and a claw We can also change the Channel the same way as we changed the Motor For this example we will use Channel 1 Which just so happens to be the default Finally click Ok You can create as many motor programs as you need for your program. But lets keep this one simple

13 Preparing to Download Program
Now that we have a program, we should see how it works in the real world To do this we need the Cortex and the orange USB cable Plug one end of the orange cable into the Cortex’s USB port located in the center of the Cortex Plug the other end into a USB port on the computer The LEDs on the Cortex should light up

14 Illustration of Hardware Connection
Your lay out should look something like this

15 Downloading Program Now that the Cortex and the computer are plugged into each other, lets send the program to the Cortex To do this, we need to click on the Build and Download button on the toolbar Next, click on Build and Download Or by pressing F7 on the keyboard

16 Downloading Program cont’d
You should see this dialog box Click Yes This will send you to another dialog box The green bar should begin at the left and move all the way to the right

17 After the Download After the Program has been Downloaded to the Cortex
Remove the orange cable from the Cortex Insert a black USB control key into Cortex Insert the other black USB control key into the Joystick Controller At this point the robot’s motor(s) and/or servo(s) can be tested

18 Activating the Robot After attaching the motors and/or servos that you need (see “Wiring the Robot” PowerPoint for instructions on attaching motors and servos), and downloading the program to the Cortex, we need to turn on the robot To do this, you must first turn on the Cortex and then turn on the Joystick Controller ***You must turn these on in this order***

19 Using the Joystick Controller – Channel 1
You will use the Channel 1 on the Joystick Controller to operate the motor Move the Right Joystick left or right to control the Motor

20 Servo Programming Now lets make a servo operate with the flip of the joystick on the Joystick Controller Go back to Joystick in the Function Block Click and drag the Joystick to Servo function to your While Loop and place it on the vertical line between the JoystickToMotor function box and the lower bracket box

21 Servo Programming cont’d
When you do this, another dialog box will appear Except for the name, it looks identical to the Motor Dialog Box For our example program Lets set the Channel to “2” and the Motor to “4” This is done the same way as we did with the Motor Click OK

22 Testing the Servo Program
To test the Servo Program, we need to click on the Build and Download button on the toolbar Next, click on Build and Download Or by pressing F7 on the keyboard You can refer back to the downloading procedure illustrated in slide thirteen thru slide seventeen

23 After the Download After the Program has been Downloaded to the Cortex
Remove the orange cable from the Cortex Insert a black USB control key into Cortex Insert the other black USB control key into the Joystick Controller At this point the robot’s motor(s) and/or servo(s) can be tested

24 Activating the Robot After attaching the motors and/or servos that you need (see “Wiring the Robot” PowerPoint for instructions on attaching motors and servos), and downloading the program to the Cortex, we need to turn on the robot To do this, you must first turn on the Cortex and then turn on the Joystick Controller ***You must turn these on in this order***

25 Using the Joystick Controller – Channel 2
You will use the Channel 2 on the Joystick Controller Move the right joystick up or down to control the servo The servo will only move about 60º in either direction for a total of 120º

26 Creating a Program for Wheels
One of the most commonly used wheel configurations is a wheel on each side of the robot To avoid spinning in circles, the motors need to spin in opposite directions The wheels need to work in unison, as well as being independent of each other This can be achieved in an Arcade Program

27 Arcade Programming-Channels
Go back to Joystick under the Functions Blocks Click and drag the Arcade - 2 motor anywhere on the vertical line of the While Loop Click the down arrow on the Forward\Reverse Channel to choose the channel that will operate the forward and backwards motion of the robot (select “3” for this program) Do this for the Rotate Channel (select “4”)

28 Arcade Programming-Motors
Click the down arrow on the Left Motor and select a motor to operate the wheels For this example select “6” Do this for the Right Motor except with a different motor For this example select “8”

29 Arcade Programming - Invert Direction of Motors
To operate the wheels properly we will need to invert the direction of one of the motors We will Invert Direction for Left Motor “6” by clicking the down arrow of Invert Direction and selecting “1” If the robot goes backwards than we will return Invert Direction of Left Motor “6” to “0” and select “1” under Invert Direction for Right Motor “8” Finally click OK

30 Completed Arcade Program
This is what the program for the Arcade – 2 motor will look like

31 Using the Joystick Controller – Channel 3 and 4
You will use the Channels 3 & 4 on the Joystick Controller Move the left Joystick in any direction to control the two motors Both motors will run simultaneously

32 Basic Program At this point the program should look something like this This is the basic program which can be modified by the addition of motors and/or servos

33 Test the Program Again Now we will test the program and with the two additional motors. Download the program to the Cortex. You can refer back to the downloading procedure illustrated in slide thirteen thru slide seventeen Now test the program. slide eighteen

34 Servo Controlled by Buttons
We will now create a servo program that operates with buttons instead of the joystick Go to the Function Block Under the Joystick folder Click and drag the Joystick Digital to Servo onto the vertical line between the bracket boxes in the While Loop

35 Servo Controlled by buttons cont’d
The program for the servo in this example will look similar to the default The difference is that the Servo # will be “3” and not “2” Change the number by clicking on the down arrow Then click on the “3”

36 Completed Servo Controlled by Buttons Program
The final program for the servo will look like this Finally click OK

37 Using the Joystick Controller – Channel 5
You will use the Channel 5 buttons on the Joystick Controller Push the top left button to move the servo to the left Push the bottom left button to move the servo to the right When you let off of the button the servo will return to neutral To change the direction of the servo, first release the button being pushed.

38 Test the Program Again Before we move any farther it is best to save the program. It is also good to save it on a mobile hard drive This gives the advantage to access the program on another computer that has Easy C Now lets test the robot Download the program to the Cortex. You can refer back to the downloading procedure illustrated in slide thirteen thru slide seventeen Now test the program. slide eighteen

39 Motor Controlled by a Button
The buttons on the Joystick Controller can be used to operate a motor The procedure to create the program to operate a motor from the buttons is the same as the program previously created for the servos Drag and drop the Joystick Digital to Motor into the vertical line between the brackets in your While Loop Lets change the Channel to “6” and the Motor to “5” Click OK

40 Using the Joystick Controller – Channel 6
You will use the Channel 6 on the Joystick Controller Push the top right button to move the motor to the left Push the bottom right button to move the motor to the right When you let off of the button the motor will slow down and stop

41 Analog -vs- Digital Programming
The downside to using this program, which enables the buttons to control the motor, is that you can not vary the speed of the motor The motors speed remains constant at all times The first program that we created with a motor, which was controlled by a joystick, allows you to control the speed of the motor It is known as an analog program

42 Noise Pollution As you have probably notice, the motors of your robot give off a high pitch whining sound This is due to the slight push on the joysticks from any number of forces Slight breeze Gravity Slight push from the fingers It is able to be fixed fairly easily

43 Reducing Noise for Channel 1 Motor
Go back to the Function Block Go to the Joystick commands Drag and drop the Joystick Analog Deadband between the Variable box and the While box Since we have a motor that is controlled by Channel 1 on the Joystick Controller. We will reduce the noise of this motor by setting the Analog Channel # to “1” Set both the Positive Deadband and Negative Deadband to “20”

44 Completed Deadband Program
The program should look like this Push OK Now do this as may times as needed In this example we need three of these programs because we have three motors Each motor requires one of these programs to keep the noise down

45 Reducing Noise for Channel 3 and Channel 4 Motors
You need one for each of the analog channels that where used In this example we used Channels 3 and 4 Drag and drop the Joystick Analog Deadband between the Variable box and the While box Since we have a motor that is controlled by Channel 3 set the Analog Channel to “3” Set both the Positive and Negative Deadband to “20” Click OK Since we have a motor that is controlled by Channel 4 set the Analog Channel to “4” Set both the Positive and Negative Deadbands to “20”

46 The Final Program The program should look like this
You can modify this program to meet the requirements of the BEST Robotics Game

47 Test the Program One Last Time
Download the program to the Cortex. You can refer back to the downloading procedure illustrated in slide thirteen thru slide seventeen Now test the program. slide eighteen


Download ppt "Basics for Robotics Programming"

Similar presentations


Ads by Google