EasyManua.ls Logo

pitsco PRIZM - Page 87

pitsco PRIZM
168 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Executing the Code
Before we can upload the sketch to the PRIZM, remember to check our connections.
Upload the sketch. The green LED will light up, indicating the code is ready to
execute. When the LED comes on, disconnect the USB cable and set the TaskBot on
the floor.
Press the green Start button to execute the sketch. Observe the direction and
duration of the TaskBots motion. Based on the sketch comments, did the behavior
match expectations?
The TaskBot should stop after three seconds.
Moving Forward
This sketch introduces three new functions, prizm.setMotorInvert(),
prizm.setMotorPowers(), and prizm.PrizmEnd().
The prizm.setMotorInvert() enables you to invert the rotational direction of a motor.
When two motors are mounted on opposite sides, this function enables you to give
a single direction command to both motors and have them work together. This
makes your job as a programmer easier. There are two parameters to the function.
The first parameter designates the motor channel, and the second parameter
designates no invert or invert (0 or 1).
The prizm.setMotorPowers() enables you to set the power level of motor 1 and
motor 2 at the same time. The two parameters set the speed for each motor. In this
sketch the motor power for each motor is 50%.
The prizm.PrizmEnd() ends or terminates the sketch.
In this simple sketch all these functions work together so the robot can move
forward for three seconds and then stop. Because we want the motors to always
work together, prizm.setMotorInvert needs to be used only in the setup. The
prizm.setMotorPowers tells both motors to move at 50% power with a single
function. To finish the sketch we use prizm.PrizmEnd() instead of having it loop.
For more detailed information about the sketch process and the PRIZM library
functions involved in using the DC motors, refer to the appendix: TETRIX PRIZM
Arduino Library Functions:
Pages 137-142 about DC motor functions
Real-World Connection
Trains are a very good example of machines that drive forward. Their drive motors
(usually diesel powered) do not have to be able to rotate independently to turn
corners – they just have to provide forward thrust to get (and keep) the train going.
Occasionally they have to go backward – but they just provide reverse thrust in that
instance.
Tip: Want to see this in
action? You can by watching
our RoboBench video series
for the PRIZM Programming
Guide. You can find the
entire series at video.
tetrixrobotics.com or on
the TETRIXrobotics YouTube
channel.
Tip: Remember that you
can print and use the TETRIX
PRIZM Arduino Library
Functions Cheat Sheet within
the appendix on page 153 as
a quick reference for all the
functions available to you.
Building and Coding the PRIZM TaskBot 85

Related product manuals