From: gab@rational.com (Greg Bek)
Subject: Re: Embedded Ada Development Tools
Date: 5 Jun 2002 17:48:39 -0700
Date: 2002-06-06T00:48:39+00:00 [thread overview]
Message-ID: <afb6d339.0206051648.367ac3a6@posting.google.com> (raw)
In-Reply-To: 3CFE29BB.A7D22E77@NOSPAM.visteon.com
John Kern <jkern3@NOSPAM.visteon.com> wrote in message news:<3CFE29BB.A7D22E77@NOSPAM.visteon.com>...
>
> One of these days, I'm going to buy my son the Lego Mindstorms kit and
> get that Ada compiler working.
The best way to do this is to start with Barry Fagin's ada2nqc program.
It allows you to write pure Ada code and then translate it into NQC
for compilation and download to the RCX.
I took Barry's code and added tasking and a couple of other things
to it, although I think Barry has since done it as well.
There is some slight mismatch between Ada tasking semantics and
the Lego RCX tasking, but it doesn't stop you writing pure Ada
code. The code might not work if ported to another target, but
that isn't a real problem in this domain.
Here is some sample code in Ada:
with Lego;
use Lego;
procedure scanbot is
Angle : constant Sensor_Port := Sensor_1;
Eye : constant Sensor_Port := Sensor_3;
Left : constant Output_Port := Output_A;
Head : constant Output_Port := Output_B;
Right : constant Output_Port := Output_C;
Slop : constant Integer := 2;
Center : constant Integer := 53;
Sweep : constant Integer := 48;
Align_Time : constant Integer := 300; -- 3 seconds
Turn_Time : constant Integer := 50; -- 1/2 second
Threshold : constant Integer := 65;
procedure Align is
Current : Integer;
begin
Output_Reverse (Head);
Clear_Sensor(Angle);
Current := Get_Sensor_Value(Angle);
Output_On(Head);
Wait (100);
while ( Current /= Get_Sensor_Value (Angle )) loop
Current := Get_Sensor_Value(Angle);
Wait (200);
end loop;
Output_Off(Head);
Output_Forward (Head);
Clear_Sensor(Angle);
end Align;
task Steer is
entry Start;
entry Stop;
end Steer;
task body Steer is
begin
accept Start;
While (True) loop
if (Eye > Threshold) then
Output_Off(Head);
Play_Sound(Click);
if (Angle < Center - Slop) then
Output_Reverse(Left);
Wait(Turn_Time);
Output_Forward(Left);
else if (Angle > Center + Slop ) then
Output_Reverse(Right);
Wait(Turn_Time);
Output_Forward(Right);
end if;
end if;
Output_On(Head);
end if;
end loop;
end Steer;
begin
Config_Sensor(Eye, Config_Light);
Config_Sensor(Angle, Config_Rotation);
Align;
Output_on ( Left + Right + Head );
Steer.Start;
while (True) loop
if (Angle < (Center - Sweep)) then
Output_Forward (Head);
else
if (Angle > (Center + Sweep)) then
Output_Reverse (Head);
end if;
end if;
end loop;
end;
next prev parent reply other threads:[~2002-06-06 0:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-03 19:15 Embedded Ada Development Tools Jason Gerry
2002-06-03 19:24 ` Jim Rogers
2002-06-03 20:47 ` Marin David Condic
2002-06-05 15:09 ` John Kern
2002-06-05 16:54 ` Marin David Condic
2002-06-06 13:19 ` Jason Gerry
2002-06-06 16:08 ` Steven Deller
2002-06-06 17:03 ` John R. Strohm
2002-06-07 3:59 ` Richard Riehle
2002-06-06 19:25 ` Jeffrey Carter
2002-06-06 20:38 ` Bill Tate
2002-06-06 20:39 ` Ted Dennison
2002-06-07 4:08 ` Richard Riehle
2002-06-07 12:08 ` John English
2002-06-07 14:09 ` Larry Kilgallen
2002-06-07 13:28 ` Marin David Condic
2002-06-06 15:32 ` Robert C. Leif
2002-06-06 19:27 ` Jeffrey Carter
2002-06-07 13:42 ` Marin David Condic
2002-06-08 3:16 ` Jeffrey Carter
2002-06-10 14:00 ` Marin David Condic
2002-06-11 21:17 ` Michael Bode
2002-06-12 19:42 ` Randy Brukardt
2002-06-07 3:52 ` Richard Riehle
2002-06-06 0:48 ` Greg Bek [this message]
2002-06-06 12:14 ` John English
2002-06-06 15:59 ` Jerry Petrey
2002-06-03 23:26 ` Greg Bek
2002-06-07 4:11 ` Richard Riehle
2002-06-07 5:24 ` Michael Bode
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox