150 likes | 215 Views
Programming a Motor. By Joshua Shaw. From the last Power Point. We have previously added a While Loop We are now going to use it for programming the robot. Add a Motor. Inside the While Loop a set of brackets appear, this is where we will create the program
E N D
Programming a Motor By Joshua Shaw
From the last Power Point • We have previously added a While Loop • We are now going to use it for programming the robot
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 JoystickTo Motor function to the vertical line between the brackets in your While Loop • When you do this, a dialog box appears
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
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
Motor Controlled by Buttons • We will now create a motor 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 Motor onto the vertical line between the bracket boxes in the While Loop
Motor Controlled by buttons cont’d • The program for the motor in this example will look similar to the default • The difference is that the Motor # will be “5” and not “2” • Change the number by clicking on the down arrow • Then click on the “5” • Lets change the Channel to “6” the same way we changed the Motor #
Completed Motor Controlled by Buttons Program • The final program for the motor will look like this • Finally click OK
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
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
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
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
Reducing Noise for Channel 1 Motor • Go back to the Function Block • Go to the Joystick commands • Drag and drop the Joystick Analog Deadbandbetween 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 Deadbandand Negative Deadband to “20”
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
Next PowerPoint • The next PowerPoint is Programming a Servo