To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 9294
9293  |  9295
Subject: 
Re: Mindstorms spirit.ocx programming = RCX ASM coding?
Newsgroups: 
lugnet.robotics
Date: 
Thu, 23 Dec 1999 02:44:41 GMT
Viewed: 
441 times
  
In article <slrn86310u.9r3.mattdm@jadzia.bu.edu>, mattdm@mattdm.org wrote:

I haven't looked at programming the RCX with Visual Basic or other MS Win
languages via the spirit.ocx control, but someone (sorry -- I'm terrible
with remembering names!) at the NELUG meeting asked me why people seem to
like NQC when they could be using Visual Basic. [1]  For me, the answer is
simple -- I use Linux almost exclusively, so spirit.ocx isn't even an
option. And there's the other obvious issues of cost and "got-there-first".

But beyond that, it's my impression that the spirit OCX API is meant to
allow one to write programs like NQC (albeit not cross-platform). In other
words, when writing a VB program to control the RCX, one is writing a
program to output firmware opcodes -- effectively programming in RCX
"assembly language". Am I mistaken?


Correct.  IMHO, calling this "programming the RCX in VB" is very
misleading.  None of the familiar VB features (variables, control
structures, etc) will run on the RCX.  For example, in order to construct
an "if" statment, you don't use the VB "if".  Instead you use a spirit.ocx
method called If() which takes as parameters the items to be comared and
the type of comparisson.  This gets pretty tedious.  Here's an example
taken from the SDK:

PBrickCtrl.If 2, 5, 2, 0, 15    | If (constant) 5 = variable 15 then
PBrickCtrl.PlayTone 440, 20     | play a 440 Hz tone for 200 ms.
PBrickCtrl.Else Else
PBrickCtrl.PlayTone 5000, 10    | play a 5000 Hz. tone with a 100 ms. duration
PBrickCtrl.EndIf                | Close the If...Else...EndIf control-structure.

I don't know about you, but I'd much rather do something like this:

if (x == 5)
  PlayTone(440, 20);
else
  PlayTone(5000, 10);

Don't even get me started on how you'd use spirit.ocx to do something like this:

if (x * 2 < y + 5)
  PlayTone(440, 20);


So, an advantage of NQC is that it allows you to generate programs for the
RCX using a relatively high-level language, whereas with VB, while you're
using a high-level language to write your UI, the guts of what runs on the
actual brick is done at a low level.

Yes.  In effect (with VB), you are using a high level language to write a
program whose output is an assembly language program for the RCX.  (the
"assembly" language is actually a bit higher level than raw RCX bytecodes
- you have "if" and "while" constructs, for example.  I think the best
analogy would be to think of it as assmebly language with a pretty
reasonable set of control structure macros)

Dave Baum

--
reply to: dbaum at enteract dot com



Message is in Reply To:
  Mindstorms spirit.ocx programming = RCX ASM coding?
 
I haven't looked at programming the RCX with Visual Basic or other MS Win languages via the spirit.ocx control, but someone (sorry -- I'm terrible with remembering names!) at the NELUG meeting asked me why people seem to like NQC when they could be (...) (25 years ago, 23-Dec-99, to lugnet.robotics, lugnet.robotics.rcx, lugnet.loc.us.ma.bos)

5 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR