CURRENT ISSUE Contests
Feature Article
|
|
Issue #212 March 2008
Robotics with Ada95
by Daniel Ramirez
Start | Why Use Ada95 For Robotics? | GNAT Ada95 Tools | Debugging Ada95 Applications | Ada95 Coding Style |Wireless Sensor Controller | Wireless Messages | The Glove In Action | XYZ Accelerometers | XBee-PRO Wireless UART | Controller Range | USB 2.0 Interface | Ethernet | The Kernel | Ada95 vs. Other Languages | Future Applications | Sources & PDF
LISTING 2
Listing 2—A range has a lower bound, L, and an upper bound, R, for a range L. R is shown in the following examples, which are used to define RC servo commands for a Parallax servo controller (PSC). If the application assigns servo commands outside the specified range, it will raise a Constraint_Error. This is a unique Ada capability that can be simulated in other computer languages using additional limit checks.
type WORD_TYPE is record Data_1 : Byte; Data_2 : Byte; end record; for WORD_TYPE'SIZE use 16; -- Declare RC Servo subtypes with ranges here... -- Use Channels 0..15 with only one PSC board otherwise you can -- use Channels 0..31 subtype Channel_Type is Byte range 0 .. 15; -- RC Servo Ramp subtype Ramp_Type is byte range 0 .. 63; -- The Servo Position range, (250-1250), corresponds to 0 to 180 -- degrees of servo rotation with each step equaling 2 uSec. -- --Note: Not all servos are exactly alike. If your servos appear to --strain when commanded to position 250, you should increase the --250 up to 260 (or so) to prevent the servo from straining itself. subtype Parallax_Position_Type is Word range 250 .. 1250; subtype number_base is integer range 2..16; -- numeric base subtype f
subtype number_base is integer range 2..16; -- numeric base subtype f