comp.lang.ada
 help / color / mirror / Atom feed
From: jim granville <Jim.Granville@xtra.co.nz>
Subject: Re: ada and robots
Date: 1997/06/20
Date: 1997-06-20T00:00:00+00:00	[thread overview]
Message-ID: <33AAC183.34C0@xtra.co.nz> (raw)
In-Reply-To: 33A69E46.3230@gsfc.nasa.gov


---- Ada & Robots ---
As this thread has diverged to become a language/religion discussion,
I thought some real code, from real applications, might help.

This code is not Ada, but Modula-2 / IEC1131, which are Ada 'subsets'.
( ie are much closer to Ada in style, syntax, and approach, than to C )

For ROBOT applications, Ada is too large to fit in small controllers,
but
Modula-2 has all the TYPE and SCOPE benefits of Ada, and it actually
fits _very well_ on the C51 core - we have REAL CONTROL apps running in
89C1051's, with 1K of FLASH ROM.

Unlike C, M2 has true BOOLEAN types, which overlay well on the C51
Boolean Engine.
A C51 core also struggles to efficently support C's wide use of
pointers.
( commonly seen in C's are 3 byte, run time interpreted, SLOW pointers..
)

All of the below can be coded in M2, C, and Assembler for that matter.
It can just be done quicker, with fewer errors, in Modula-2.
( a good example of a user supplied C error, is below )

Conclusion : Choose the highest level language that will do the job.
It may be Ada, BASIC, C, Clarion, Delphi, Forth, Modula-2, Visual
BASIC...
( or sometimes, even Assembler )

This code fragment in Modula2, is from a MM53200 'Garage Door' style
decoder, coded for a 89C2051.
Total code size, for a self testing receiver, is 227 bytes.

This code uses the BITSET feature of Modula-2, to greate a PACKED
BOOLEAN
ARRAY of 24 Data bits, into 3 BYTES.
   CASE BitTimeL OF
   | OneMIN..OneMAX :
     INCL(RxCODE[RxCtr >> 3],RxCtr);
   | ZeroMIN..ZeroMAX :   (* default is a Zero *)
   ELSE                   (* bad value, so reset *)
    TF0 := TRUE;          (* catch Reset, next pass  *)
    RxCtr := 0;
   END;
   INC(RxCtr);

This code illustrates two methods of loading, one 'collects' BOOLEANs
and
is highly readable, the other uses BINARY format.
 IE := {EA,ET0,ES};
 IE := 2#1001_0010;     (* EA.EC.ET2.ES.ET1.EX1.ET0.EX0 *)

This code is from a DUAL 6 BIT Picket fence D to A converter.
Total code, for Dual DAC is 95 bytes.
It allows appx 33KHz clock rates, and can run as a background DAC.
More, or less, BITS / Channels are easy to add / remove.
Such DACs are highly linear, use just 1 PIN per DAC, and are ideal for
integration to control voltage outputs.

 DACaPIN := DACa;
 DACbPIN := DACb;
 (* does ONE of these IF statements ONLY *)
 IF PWM.0 THEN          (* 32 Pickets, odd numbers *)
  DACa := DAC_A.5;      (* Uses BYTE BITADDRESSABLE syntax *)
  DACb := DAC_B.5;
 ELSIF PWM.1 THEN       (* 16 Pickets xxxx10 *)
  DACa := DAC_A.4;
  DACb := DAC_B.4;
 ELSIF PWM.2 THEN       (*  8 Pickets xxx100 *)
  DACa := DAC_A.3;
  DACb := DAC_B.3;
 .... etc....

This code flips the BIT order in a BYTE, for COMMS protocol usage.
TYPE hT = ARRAY [0..15] OF BYTE;
                   (*  0   1   2  3    4  5   6  7  8 9 A B   C  D  E  F
*)
CONST MirrorTable =
hT(0H,08H,04H,0CH,02H,0AH,6,0EH,1,9,5,0DH,3,0BH,7,0FH);

PROCEDURE MirrorF(Par : SHORTCARD REGISTER_2) : SHORTCARD; (* 16
bytes,14uS *)
BEGIN
   RETURN(ROTATE(MirrorTable[Par AND 0FH],4) OR MirrorTable[Par >> 4]);
END MirrorF;

And here is some C code, doing the same thing...
This compiles, runs, and works - to a point, It has a BUG that appears
ONLY SOMETIMES. Whilst the Modula-2 compiler would have caught this at
compile time, this C user may have to wait until the customer
calls : ' You know, sometimes.... '

const char Inv[] = {0x00,        //  0000 --> 0000
              0x08,        //  0001 --> 1000
              0x04,        //  0010 --> 0100
              0x0c,        //  0011 --> 1100
              0x0a,        //  0101 --> 1010
              0x06,        //  0110 --> 0110
              0x0e,        //  0111 --> 1110
              0x01,        //  1000 --> 0001
              0x09,        //  1001 --> 1001
              0x05,        //  1010 --> 0101
              0x0d,        //  1011 --> 1101
              0x03,        //  1100 --> 0011
              0x0b,        //  1101 --> 1011
              0x07,        //  1110 --> 0111
              0x0f};       //  1111 --> 1111

char Invert(char cByte)
{
   return ((Inv[cByte & 0xf] << 4) | Inv[(cByte & 0xf0)>>4]);
}

- jim granville

-- 
======= Manufacturers of Serious Design Tools for uC and PLD  =========
= Optimising Modula-2 Structured Text compilers for ALL 80X51 variants
= Reusable object modules, for i2c, SPI and SPL bus interfaces
= Safe, Readable & Fast code - Step up from Assembler and C
= Emulators / Programmers for ATMEL 89C1051, 2051, 89C51 89S8252 89C55
= *NEW* Bondout ICE for 89C51/89C52/89C55 
= for more info, Email : DesignTools@xtra.co.nz  Subject : c51Tools





  parent reply	other threads:[~1997-06-20  0:00 UTC|newest]

Thread overview: 134+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-28  0:00 ada and robots John Bohn
1997-05-29  0:00 ` Stephen Leake
1997-05-29  0:00 ` Michael F Brenner
1997-05-30  0:00 ` John Cook
1997-05-30  0:00   ` Tom Moran
1997-06-01  0:00     ` Dale Stanbrough
1997-06-02  0:00       ` John G. Volan
     [not found]         ` <5mv984$7kn@news.emi.com>
1997-06-03  0:00           ` Martin A. Stembel
1997-06-03  0:00           ` Joe Gwinn
1997-06-04  0:00             ` Pat Rogers
1997-06-05  0:00               ` Joe Gwinn
1997-06-14  0:00                 ` Robert Dewar
1997-06-16  0:00                 ` Ken Garlington
1997-06-16  0:00                   ` Robert Dewar
1997-06-17  0:00                   ` Joe Gwinn
1997-06-28  0:00                     ` Mike Stark
1997-07-03  0:00                       ` Joe Gwinn
1997-06-04  0:00             ` John G. Volan
1997-06-05  0:00               ` Joe Gwinn
1997-06-14  0:00                 ` Robert Dewar
1997-06-17  0:00                   ` Joe Gwinn
1997-07-03  0:00                     ` Shmuel (Seymour J.) Metz
     [not found]               ` <9706052229.AA29554@jaguar.nmc.ed.ray.com>
1997-06-06  0:00                 ` John G. Volan
1997-06-07  0:00                   ` RC
1997-06-09  0:00                   ` Joe Gwinn
1997-06-05  0:00             ` Jon S Anthony
1997-06-05  0:00               ` Joe Gwinn
1997-06-14  0:00                 ` Robert Dewar
1997-06-10  0:00             ` Robert Dewar
1997-06-10  0:00               ` Joe Gwinn
1997-06-11  0:00                 ` Robert Dewar
1997-06-12  0:00                   ` George Haddad
1997-06-16  0:00                   ` Matthew S. Whiting
1997-06-17  0:00                     ` Robert A Duff
1997-06-18  0:00                       ` Ken Garlington
1997-07-17  0:00                         ` Shmuel (Seymour J.) Metz
1997-06-20  0:00                       ` Adam Beneschan
1997-06-20  0:00                       ` Robert Dewar
1997-06-17  0:00                     ` Robert Dewar
1997-06-17  0:00                     ` Samuel Mize
1997-06-18  0:00                       ` Steve O'Neill
1997-06-19  0:00                         ` Anonymous
1997-06-19  0:00                       ` Kenneth W. Sodemann
1997-06-20  0:00                       ` Stephen Leake
1997-06-20  0:00                         ` Robert Dewar
1997-06-17  0:00                     ` Jon S Anthony
1997-06-17  0:00                       ` Matthew S. Whiting
1997-06-18  0:00                         ` Samuel Mize
1997-06-18  0:00                           ` Matthew S. Whiting
1997-06-18  0:00                         ` Jon S Anthony
1997-06-22  0:00                           ` John G. Volan
1997-06-18  0:00                         ` Robert A Duff
1997-06-17  0:00                     ` Stephen Leake
1997-06-17  0:00                       ` Robert A Duff
1997-06-20  0:00                       ` jim granville [this message]
1997-06-21  0:00                         ` Robert Dewar
1997-06-24  0:00                           ` Re(dux): Ada for small machines (was Re: ada and robots) Ken Garlington
1997-06-29  0:00                             ` Robert Dewar
1997-06-29  0:00                         ` ada and robots Matthew Heaney
1997-07-03  0:00                           ` Shmuel (Seymour J.) Metz
1997-07-13  0:00                             ` Robert Dewar
1997-06-04  0:00         ` RC
1997-06-04  0:00           ` Larry Kilgallen
1997-06-04  0:00           ` John G. Volan
1997-06-05  0:00           ` Jon S Anthony
1997-06-02  0:00     ` Nick Roberts
1997-06-04  0:00       ` Jan Galkowski
1997-06-05  0:00         ` Albert K. Lee
1997-06-06  0:00           ` dana
1997-06-07  0:00             ` John G. Volan
1997-06-10  0:00               ` dana
  -- strict thread matches above, loose matches on Subject: below --
1997-06-05  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-06-05  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-06-09  0:00 ` Jerry Petrey
1997-06-10  0:00   ` Alan Brain
1997-06-10  0:00     ` Joe Gwinn
1997-06-11  0:00       ` Robert Dewar
1997-06-11  0:00         ` Samuel Mize
1997-06-13  0:00           ` Erik Magnuson
1997-06-17  0:00         ` Joe Gwinn
1997-06-18  0:00           ` Jon S Anthony
1997-06-19  0:00             ` Jonathan Guthrie
1997-06-20  0:00           ` Robert Dewar
1997-06-11  0:00       ` Alan Brain
1997-06-11  0:00         ` Spam Hater
1997-06-11  0:00         ` Joe Gwinn
1997-06-09  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-06-12  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-06-16  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-06-17  0:00 ` Joe Gwinn
1997-06-18  0:00   ` Jon S Anthony
1997-06-18  0:00     ` Brian Rogoff
1997-06-20  0:00   ` Robert Dewar
1997-06-23  0:00     ` Geert Bosch
1997-07-02  0:00       ` Robert Dewar
1997-06-23  0:00     ` Richard Kenner
1997-06-23  0:00       ` Robert Dewar
1997-06-25  0:00   ` Will Rose
1997-06-25  0:00   ` Jonathan Guthrie
1997-06-21  0:00 ` Nick Roberts
1997-06-16  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-06-19  0:00 Jon S Anthony
1997-06-19  0:00 ` Brian Rogoff
1997-06-20  0:00   ` Jon S Anthony
1997-06-22  0:00   ` John G. Volan
1997-06-25  0:00     ` Richard A. O'Keefe
1997-06-23  0:00   ` Robert Dewar
1997-06-24  0:00     ` Brian Rogoff
1997-06-20  0:00 Ada " Huy Vo
1997-06-23  0:00 ` Jon S Anthony
1997-06-24  0:00 Huy Vo
1997-06-25  0:00 ` Wes Groleau
1997-06-25  0:00 ` Jon S Anthony
1997-06-25  0:00 ` Dale Stanbrough
1997-06-25  0:00 ` Alan Brain
1997-06-26  0:00 ` Ken Garlington
1997-07-01  0:00   ` Tom Moran
1997-06-26  0:00 Huy Vo
1997-06-27  0:00 ` nma123
1997-06-27  0:00 ` Wes Groleau
1997-06-27  0:00 ` Jon S Anthony
1997-06-27  0:00 ` Alan Brain
1997-06-27  0:00   ` Stephen Leake
1997-06-27  0:00   ` Wes Groleau
1997-06-27  0:00 ` Richard A. O'Keefe
     [not found] <867541382.23405@dejanews.com>
1997-06-29  0:00 ` John Howard
1997-06-30  0:00 Huy Vo
1997-07-01  0:00 ` Alan Brain
1997-07-11  0:00   ` Will Rose
1997-07-02  0:00 ` Mattias Sj�sv�rd
1997-07-01  0:00 Huy Vo
1997-07-02  0:00 ` Wes Groleau
1997-07-02  0:00 Huy Vo
1997-07-04  0:00 ` Richard A. O'Keefe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox