EasyManua.ls Logo

pitsco PRIZM - Page 93

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...
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.
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 this has occurred, 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 TaskBot’s motion. Based on the sketch comments, did the behavior
match expectations?
Moving Forward
This sketch has a lot to it, but it is made of functions that we have used before. We
have just combined multiple sequential behaviors to create one larger behavior – in
this case, a square.
An important thing to understand about this program is that we are using dead
reckoning to program the robot’s square driving path. Dead reckoning is simply
using time as the basis for controlling a motor. For instance, to make a right-hand
turn, we are commanding the motors to turn on in opposite directions at 50%
power and run for 600 milliseconds.
We estimate that if we spin the motors at a certain rpm for a certain time period,
we should come close to making a 90-degree right turn. However, this is not always
accurate because the amount that our robot’s battery is charged can vary and any
wheel slippage on the surface we are working on will cause errors. In essence we
are dead reckoning on making a right turn.
All the functions in this sketch work together to make the TaskBot move in a square.
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 different speeds in a single function.
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
Some vehicles take the same route time after time. For instance, a vehicle for
transporting packages from three different locations to a final destination within
a warehouse could have a route that would look like a square. This vehicle is
programmed to go an exact distance forward before it turns to go that same
distance at a 90-degree angle. After repeating this four times, the vehicle is back
where it started, ready for another cycle of package transport.
Tip: This program is one that
could be affected by the
charge level of the battery.
Why? The pattern of this
program is generated by
a series of delay functions,
and as motor rpm changes
due to battery levels, the
square pattern can change
somewhat as batteries
drain. That is one of the
consequences of using “dead
reckoning” as a method of
control.
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.
Building and Coding the PRIZM TaskBot 91

Related product manuals