1 |
kaklik |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
2 |
<!-- saved from url=(0046)http://www.baumfamily.org/nqc_old/doc/faq.html -->
|
|
|
3 |
<HTML><HEAD><TITLE>NQC FAQ</TITLE>
|
|
|
4 |
<META http-equiv=Content-Type content="text/html; charset=windows-1250"><!-- Copyright 1998 Dave Baum -->
|
|
|
5 |
<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
|
|
|
6 |
<BODY bgColor=#ffffff>
|
|
|
7 |
<H2>NQC FAQ</H2>
|
|
|
8 |
<H3>General</H3>
|
|
|
9 |
<UL>
|
|
|
10 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#nqc">What is
|
|
|
11 |
NQC?</A>
|
|
|
12 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#mindstorms">What
|
|
|
13 |
is LEGO MINDSTORMS?</A>
|
|
|
14 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#RIS2">Does NQC
|
|
|
15 |
support RIS 2.0?</A>
|
|
|
16 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#firmware">How can
|
|
|
17 |
I get the RCX 2.0 firmware?</A> </LI></UL>
|
|
|
18 |
<H3>NQC Compiler Usage</H3>
|
|
|
19 |
<UL>
|
|
|
20 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#dos">I'm using
|
|
|
21 |
Windows, and when I click on NQC a window with some text flashes on the screen
|
|
|
22 |
then disappears. What's going on?</A>
|
|
|
23 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#-Trcx2">I'm using
|
|
|
24 |
the RCX 2.0 firmware but get errors when trying to call 2.0 functions (e.g.
|
|
|
25 |
SetUserDisplay). What's wrong?</A>
|
|
|
26 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#errors">How can I
|
|
|
27 |
redirect errors to a file?</A>
|
|
|
28 |
<LI><A
|
|
|
29 |
href="http://www.baumfamily.org/nqc_old/doc/faq.html#spiritinstall">Where is
|
|
|
30 |
Spirit.ocx? RcxCC complains that it is not installed.</A> </LI></UL>
|
|
|
31 |
<H3>IR Communication</H3>
|
|
|
32 |
<UL>
|
|
|
33 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#usb">How do I get
|
|
|
34 |
NQC to work with my USB IR tower?</A>
|
|
|
35 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#control">How do I
|
|
|
36 |
use a computer to control the RCX?</A>
|
|
|
37 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#irusb">How do I
|
|
|
38 |
use the IR tower with a USB Macintosh?</A>
|
|
|
39 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#irdebug">Help,
|
|
|
40 |
RcxCC/MacNQC/NQC can't communicate with my RCX!</A>
|
|
|
41 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#irlaptop">How do I
|
|
|
42 |
use my computer IR port with the RCX?</A>
|
|
|
43 |
<LI><A href="file:///Users/dave/WebSite/nqc/doc/faq.html#irxp">How can I get
|
|
|
44 |
the USB IR tower to work under Win XP?</A> </LI></UL>
|
|
|
45 |
<H3>Miscellaneous</H3>
|
|
|
46 |
<UL>
|
|
|
47 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#spirit">Why
|
|
|
48 |
doesn't NQC use the Spirit OCX?</A>
|
|
|
49 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#vision">Does NQC
|
|
|
50 |
support Vision Command?</A>
|
|
|
51 |
<LI><A href="http://www.baumfamily.org/nqc_old/doc/faq.html#build">What
|
|
|
52 |
computers/tools/etc do you use to develop NQC?</A> </LI></UL>
|
|
|
53 |
<P></P>
|
|
|
54 |
<HR align=left>
|
|
|
55 |
|
|
|
56 |
<P></P>
|
|
|
57 |
<H3><A name=nqc></A>What is NQC?</H3>
|
|
|
58 |
<P>NQC (Not Quite C) is a programming language for several LEGO MINDSTORMS
|
|
|
59 |
products including the RCX, CyberMaster, and Scout. NQC's syntax is very similar
|
|
|
60 |
to the C programming langauge, so experienced C programmers (and Java
|
|
|
61 |
programmers) should find it very easy to get started with. Even if you aren't an
|
|
|
62 |
experienced programmer, NQC is relatively easy to learn.</P>
|
|
|
63 |
<P>The two primary reasons people move up to NQC from the standard tools (RCX
|
|
|
64 |
Code and Robolab) is that NQC is a textual langauge, and it is more powerful.
|
|
|
65 |
Graphical languages are often easier to learn (no syntax errors!) but are
|
|
|
66 |
generally more tedious to use than a textual langauge. The graphical metaphors
|
|
|
67 |
of RCX Code (and to a certain extent Robolab) also significantly limit the types
|
|
|
68 |
of programs you can write.</P>
|
|
|
69 |
<P>NQC uses the same firmware as LEGO's standard tools (RCX Code and Robolab).
|
|
|
70 |
This means it is possible to have RCX Code, Robolab, and NQC programs loaded
|
|
|
71 |
onto the RCX at the same time. NQC also benefits from the stability and user
|
|
|
72 |
interface (e.g. the View button) provided by the standard firmware. On the minus
|
|
|
73 |
side, NQC must live within the constraints of the standard firmware. For
|
|
|
74 |
example, since the firmware does not provide floating point support, NQC cannot
|
|
|
75 |
provide it either. Other altermatives for programming the RCX (notably legOS and
|
|
|
76 |
pbForth) do not have such restrictions.</P>
|
|
|
77 |
<P></P>
|
|
|
78 |
<HR align=left>
|
|
|
79 |
|
|
|
80 |
<P></P>
|
|
|
81 |
<H3><A name=mindstorms></A>What is LEGO MINDSTORMS?</H3>
|
|
|
82 |
<P>LEGO MINDSTORMS is a series of LEGO sets that use special programmable bricks
|
|
|
83 |
to allow construction of robots. The most versatile programmable brick is the
|
|
|
84 |
RCX, which can be found in the Robotics Invention System set. A simpler brick,
|
|
|
85 |
the Scout, can be found in the Robotics Discovery set. The simplest brick, Micro
|
|
|
86 |
Scout, is featured in two sets with a Star Wars theme: Droid Developer Kit, and
|
|
|
87 |
Dark Side Developer Kit. Even though it is the most expensive, the RCX based set
|
|
|
88 |
is still the best value due to the versatility of the RCX itself. The Scout is a
|
|
|
89 |
bit more limited, but still can be programmed (using NQC) to do some interesting
|
|
|
90 |
things. The Micro-Scout is extremely limited, and it useful mainly as an
|
|
|
91 |
accessory to another programmable brick such as the RCX or Scout. Further
|
|
|
92 |
information on MINDSTORMS sets can be found at the official site: <A
|
|
|
93 |
href="http://www.legomindstorms.com/"
|
|
|
94 |
target=_blank>http://www.legomindstorms.com/</A>.</P>
|
|
|
95 |
<P></P>
|
|
|
96 |
<HR align=left>
|
|
|
97 |
|
|
|
98 |
<P></P>
|
|
|
99 |
<H3><A name=RIS2></A>Does NQC Support RIS 2.0?</H3>
|
|
|
100 |
<P>The RCX in the RIS 2.0 is nearly identical to the 1.0 RCX. However, new
|
|
|
101 |
firmware is used to give the RCX some new capabilities. Fortunately for existing
|
|
|
102 |
RCX owners, this firmware is available for download from www.legomindstorms.com
|
|
|
103 |
(as part of the RIS 2.0 SDK). NQC supports this new firmware (see <A
|
|
|
104 |
href="http://www.baumfamily.org/nqc_old/doc/faq.html#-Trcx2">here for more
|
|
|
105 |
info</A>).</P>
|
|
|
106 |
<P>RIS 2.0 also uses a new IR tower with a USB connection (instead of the
|
|
|
107 |
eariler RS-232 based towers). Support for the USB tower under Windows and Mac OS
|
|
|
108 |
X is currently in <A
|
|
|
109 |
href="http://www.baumfamily.org/nqc_old/beta/index.html">beta test</A>. Support
|
|
|
110 |
for Mac OS 9 will be added shortly and several other people are working on Linux
|
|
|
111 |
support.</P>
|
|
|
112 |
<H3>
|
|
|
113 |
<HR align=left>
|
|
|
114 |
<A name=firmware></A>How can I get the RCX 2.0 firmware?</H3>
|
|
|
115 |
<P>The RCX 2.0 firmware is contained in a file named FIRM0328.LGO and is
|
|
|
116 |
installed on your PC when you install the standard LEGO software. It is also
|
|
|
117 |
installed as part of the Vision Command software and the 2.0 SDK.</P>
|
|
|
118 |
<P>Unfortunately, all previously mentioned sources for the firmware require
|
|
|
119 |
software to be installed on a Windows computer. If you are using a different
|
|
|
120 |
operating system, then you will need to download the earlier Beta version of the
|
|
|
121 |
2.0 SDK which was packaged as a .zip file rather than a full installer. This
|
|
|
122 |
.zip file may then be expanded to get the FIRM0328.LGO file. The SDK 2.0 Beta
|
|
|
123 |
can be found at <A href="http://mindstorms.lego.com/sdk2beta/default.asp"
|
|
|
124 |
target=_blank>http://mindstorms.lego.com/sdk2beta/default.asp</A>.</P>
|
|
|
125 |
<P></P>
|
|
|
126 |
<HR align=left>
|
|
|
127 |
|
|
|
128 |
<P></P>
|
|
|
129 |
<H3><A name=dos></A>I'm using Windows, and when I click on NQC a window with
|
|
|
130 |
some text flashes on the screen then disappears. What's going on?</H3>
|
|
|
131 |
<P>NQC is a command line based tool - normally you run it by typing an
|
|
|
132 |
appropriate command into an MS-DOS window. When you double-click the exe file it
|
|
|
133 |
launches an MS-DOS console, runs NQC within it, then since NQC finishes almost
|
|
|
134 |
immediately, the entire window disappears.</P>
|
|
|
135 |
<P>Some people prefer command line based tools because they allow you to use the
|
|
|
136 |
text editor of your choice, etc. It also makes for identical behavior under
|
|
|
137 |
Windows, Mac, and Linux. In order to use the command line version of NQC you'll
|
|
|
138 |
need to do two things:</P>
|
|
|
139 |
<P>1) Use some sort of text editor (such as Notepad) to edit and save a source
|
|
|
140 |
file for NQC to compile.</P>
|
|
|
141 |
<P>2) From an MS-DOS window type the appropriate NQC command. Its usually best
|
|
|
142 |
to either put all of your programs and nqc.exe in the same directory, or make
|
|
|
143 |
sure the directory containing NQC is in your command path. For example, to
|
|
|
144 |
compile and download the program "test.nqc" using the default serial port you
|
|
|
145 |
would type the following command:</P>
|
|
|
146 |
<P>nqc -d test.nqc</P>
|
|
|
147 |
<P>An alternative is to use the <A href="http://www.cs.uu.nl/~markov/lego/"
|
|
|
148 |
target=_parent>RCX Command Center</A> by Mark Overmars, which is a familiar
|
|
|
149 |
Windows style application that provides a front end to the NQC compiler.</P>
|
|
|
150 |
<P></P>
|
|
|
151 |
<HR align=left>
|
|
|
152 |
|
|
|
153 |
<P></P>
|
|
|
154 |
<H3><A name=-Trcx2></A>I'm using the RCX 2.0 firmware but get errors when trying
|
|
|
155 |
to call 2.0 functions (e.g. SetUserDisplay). What's wrong?</H3>
|
|
|
156 |
<P>When NQC compiles a program it needs to know what kind of programmable brick
|
|
|
157 |
you want it to generate code for (this is called the <I>target</I> for the
|
|
|
158 |
compile). By default, NQC assumes you are targetting RCX 1.0. If you want to use
|
|
|
159 |
RCX 2.0 features, you need to tell the compiler you are using an RCX 2.0 target.
|
|
|
160 |
If you are using a command line version of NQC, then add <TT>-Trcx2</TT> to the
|
|
|
161 |
command line:</P>
|
|
|
162 |
<P><TT>nqc -Trcx2 -d foo.nqc</TT></P>
|
|
|
163 |
<P>If you don't want to type <TT>-Trcx2</TT> all the time, then just use the
|
|
|
164 |
environment variable <TT>NQC_OPTIONS</TT> - NQC reads this environment variable
|
|
|
165 |
and inserts any options in this variable at the front of the command line. For
|
|
|
166 |
example, if <TT>NQC_OPTIONS</TT> was set to <TT>-Trcx2</TT> and you issued the
|
|
|
167 |
following command</P>
|
|
|
168 |
<P><TT>nqc -d foo.nqc</TT></P>
|
|
|
169 |
<P>NQC would behave as if you actually typed</P>
|
|
|
170 |
<P><TT>nqc -Trcx2 -d foo.nqc</TT></P>
|
|
|
171 |
<P>The specifics of setting environment variables depends on your operating
|
|
|
172 |
system and shell. For example, under Windows you could type the following in a
|
|
|
173 |
command shell:</P>
|
|
|
174 |
<P><TT>set NQC_OPTIONS=-Trcx2</TT></P>
|
|
|
175 |
<P>If you want to always use RCX 2.0, then you can make this setting permament
|
|
|
176 |
by editing the AUTOEXEC.BAT file and adding the above command to the end of the
|
|
|
177 |
file. This way, the variable will get set every time Windows is started.</P>
|
|
|
178 |
<P>If you are using a GUI based version of NQC (such as MacNQC), then there
|
|
|
179 |
should be some preference setting for the target - just make sure it is set to
|
|
|
180 |
"RCX 2.0". Unfortunately, RcxCC does not have an "RCX 2.0" setting, but there is
|
|
|
181 |
a workaround. Leave the target as "RCX" (which means RcxCC won't specify any
|
|
|
182 |
target information and just rely on the fact that NQC defaults to RCX), then use
|
|
|
183 |
the <TT>NQC_OPTIONS</TT> environment variable to specify RCX 2.0 (as described
|
|
|
184 |
above).</P>
|
|
|
185 |
<P></P>
|
|
|
186 |
<HR align=left>
|
|
|
187 |
|
|
|
188 |
<P></P>
|
|
|
189 |
<H3><A name=errors></A>How can I redirect errors to a file?</H3>
|
|
|
190 |
<P>Compile errors are written to stderr, not stdout. This is to allow the
|
|
|
191 |
calling program to separate errors from the program listing (-l option) that
|
|
|
192 |
appears on stdout. The normal redirection facility of a shell only redirects
|
|
|
193 |
stdout, thus the errors will still be printed to the screen. Most shells have
|
|
|
194 |
additional syntax that allows the stderr stream to be redirected (use
|
|
|
195 |
"option->" in MPW, or "2>" for WinNT). I do not know of any mechanism to
|
|
|
196 |
redirect stderr in Win95 command.com.</P>
|
|
|
197 |
<P>In addition, nqcc now supports (verion 1.1 b1) the ability to route error
|
|
|
198 |
messages to stdout with the -E option.</P>
|
|
|
199 |
<P></P>
|
|
|
200 |
<HR align=left>
|
|
|
201 |
|
|
|
202 |
<P></P>
|
|
|
203 |
<H3><A name=spiritinstall></A>Where is Spirit.ocx? RcxCC complains that it is
|
|
|
204 |
not installed.</H3>
|
|
|
205 |
<P>NQC has never used Spirit.ocx, but RcxCC used to require Spirit.ocx for
|
|
|
206 |
communication with the RCX. Lego no longer supports Spirit.ocx as of RIS 2.0,
|
|
|
207 |
but fortunately RcxCC has been updated to no longer require it. In addition,
|
|
|
208 |
RcxCC has been renamed to BricxCC (due to trademark concerns from Lego). You can
|
|
|
209 |
download the latest version of BricxCC <A
|
|
|
210 |
href="http://members.aol.com/johnbinder/bricxcc.htm" target=_blank>here</A>.</P>
|
|
|
211 |
<P></P>
|
|
|
212 |
<HR align=left>
|
|
|
213 |
|
|
|
214 |
<P></P>
|
|
|
215 |
<H3><A name=usb></A>How do I get NQC to work with my USB IR tower?</H3>
|
|
|
216 |
<P>Presently, USB towers are only supported under Mac OS X and Windows. I will
|
|
|
217 |
be releasing Mac OS 9 support shortly. Some other developers are working on a
|
|
|
218 |
Linux solution.</P>
|
|
|
219 |
<P>USB support is in beta test and requires version 2.4a4 of NQC.</P>
|
|
|
220 |
<P><B>IMPORTANT</B>- you need to tell NQC that you want it to look for a USB
|
|
|
221 |
tower, otherwise it assumes you have a serial tower and uses the default serial
|
|
|
222 |
port for your operating system (e.g. COM1 under Windows). Add <TT>-Susb</TT> to
|
|
|
223 |
the command line or set the <TT>RCX_PORT</TT> environment variable to
|
|
|
224 |
<TT>usb</TT>. When adding a command line option, put it near the beginning of
|
|
|
225 |
the command:</P>
|
|
|
226 |
<P><TT>nqc -Susb -d test.nqc</TT></P>
|
|
|
227 |
<P><B>Windows only:</B> NQC uses the USB driver installed by the Lego RIS 2.0
|
|
|
228 |
software, so you will need to install the RIS software and run it once with the
|
|
|
229 |
USB tower connected in order for the driver to be correctly installed.</P>
|
|
|
230 |
<P><B>Mac OS X only:</B> NQC talks directly to the USB tower. There is no
|
|
|
231 |
driver, so you'll never see the tower show up in /dev.<BR></P>
|
|
|
232 |
<P><SPAN style="FONT-WEIGHT: bold">FreeBSD (unoffical port):</SPAN> As of NQC
|
|
|
233 |
2.5 a5, the USB tower is supported when running a FreeBSD build from 02/28/03 or
|
|
|
234 |
later (the upcoming FreeBSD 5.1 will work).<BR></P>
|
|
|
235 |
<P></P>
|
|
|
236 |
<HR align=left>
|
|
|
237 |
|
|
|
238 |
<P></P>
|
|
|
239 |
<H3><A name=control></A>How do I use a computer to control the RCX?</H3>
|
|
|
240 |
<P>There are two basic ways to do this: send raw commands to the RCX, or send
|
|
|
241 |
'messages' which are then listened to by a program running on the RCX.</P>
|
|
|
242 |
<H4>Sending Messages</H4>
|
|
|
243 |
<P>This is generally the simplest way to interact with the RCX. First you write
|
|
|
244 |
a program for the RCX that continuously checks for received messages (using the
|
|
|
245 |
Message() and ClearMessage() calls) and then dispatches the messages
|
|
|
246 |
accordingly. The messages may have any value between 1 and 255. There is no
|
|
|
247 |
predefined meaning for these messages - your program can do whatever it wants
|
|
|
248 |
with each message.</P>
|
|
|
249 |
<P>There are several ways to send the message. You can use another RCX (or a
|
|
|
250 |
Scout) by calling the SendMessage() function. You can also use the nqc command
|
|
|
251 |
with the -msg option, for example to send message #3:</P>
|
|
|
252 |
<P>nqc -msg 3</P>
|
|
|
253 |
<P>You can use the LEGO remote control to send messages 1, 2, or 3. It is also
|
|
|
254 |
possible to send the message by sending the appropriate command packet (see
|
|
|
255 |
below)</P>
|
|
|
256 |
<H4>Sending Raw Commands</H4>
|
|
|
257 |
<P>Sending raw commands gives you complete control over the RCX. The commands
|
|
|
258 |
(a.k.a. opcodes or bytecodes) and the general packet format are unofficially
|
|
|
259 |
documented at <A href="http://graphics.stanford.edu/~kekoa/rcx/"
|
|
|
260 |
target=_parent>http://graphics.stanford.edu/~kekoa/rcx/</A>. For example, to
|
|
|
261 |
make the RCX play system sound #3 (upward tones), you would send a two-byte
|
|
|
262 |
command (shown in hex):</P>
|
|
|
263 |
<P>51 03</P>
|
|
|
264 |
<P>Messages are just a specific type of command - F7 followed by the message
|
|
|
265 |
value, so message #4 would be the packet</P>
|
|
|
266 |
<P>F7 04</P>
|
|
|
267 |
<P>If you are using NQC, you can let NQC take care of all the details of packet
|
|
|
268 |
formatting, getting an acknowledgement from the RCX, and retrying if a failure
|
|
|
269 |
occurs. You do this with the -raw option, which takes a single parameter listing
|
|
|
270 |
all of the bytes (in hex format) for the command:</P>
|
|
|
271 |
<P>nqc -raw 5103</P>
|
|
|
272 |
<P>If you are writing your own program, you can build up the packet yourself. A
|
|
|
273 |
suitable packet (for the plays sound command) would be:</P>
|
|
|
274 |
<P>55 ff 00 51 ae 03 fc 54 ab</P>
|
|
|
275 |
<H3>
|
|
|
276 |
<HR align=left>
|
|
|
277 |
<A name=irusb></A>How do I use the IR tower with a USB Macintosh?</H3>
|
|
|
278 |
<P>Since a USB version of the IR tower doesn't exist (yet), you will need a USB
|
|
|
279 |
to serial converter (such as the Keyspan TWIN adapter). If the adapter provides
|
|
|
280 |
a 9-pin serial connector, then you should be able to use the standard Mindstorms
|
|
|
281 |
cable between the adapter and the IR tower. If the adapter provides mac-style
|
|
|
282 |
serial connector, then you will also need an appropriate cable as desribed <A
|
|
|
283 |
href="http://www.baumfamily.org/lego/macmind/cables.html">here</A>.</P>
|
|
|
284 |
<P><I>Note: I have heard several reports of the Palm USB adapter not working. I
|
|
|
285 |
am not sure if this is a problem with the adapter itself, or some unusual
|
|
|
286 |
interaction between it and the OS. If you have been able to use a Palm USB
|
|
|
287 |
adapter with MacNQC or NQC, please let me know. I would like to get a definitive
|
|
|
288 |
answer on whether this adapter can be made to work. Personally, I use the
|
|
|
289 |
Keyspan Twin adapter (USA-28X), and I've heard that both the Keyspan PDA adapter
|
|
|
290 |
(USA-19) and Xircom PortGear USB also work.</I></P>
|
|
|
291 |
<P>If you are using MacNQC, then the popup menu in the Preferences dialog box
|
|
|
292 |
will list all available serial ports (including those provided by USB
|
|
|
293 |
converters).</P>
|
|
|
294 |
<P>If you are using the MPW version of NQC, then you will need to specify the
|
|
|
295 |
serial port either on the command line (using the -S option) or in the RCX_PORT
|
|
|
296 |
environment variable. Both methods require that you know the name of the serial
|
|
|
297 |
port driver. The easiest way to make this work is to use the adapter's control
|
|
|
298 |
panel to configure the serial port to "emulate the printer port". This will
|
|
|
299 |
cause the serial port to be named "B", thus you could do either of the
|
|
|
300 |
following:</P>
|
|
|
301 |
<P><TT>nqc -SB -d foo.nqc</TT></P>
|
|
|
302 |
<P>or</P>
|
|
|
303 |
<P><TT>set -e RCX_PORT B</TT></P>
|
|
|
304 |
<P><TT>nqc -d foo.nqc</TT></P>
|
|
|
305 |
<P>If you choose the second option, the <TT>set</TT> command only needs to be
|
|
|
306 |
executed once per MPW session - adding it to a Startup file will make life
|
|
|
307 |
simpler.</P>
|
|
|
308 |
<H3>
|
|
|
309 |
<HR align=left>
|
|
|
310 |
<A name=irdebug></A>Help, RcxCC/MacNQC/NQC can't communicate with my RCX!</H3>
|
|
|
311 |
<P>In most cases, problems like this boil down to a configuration issue, bad
|
|
|
312 |
cable, or dead battery. Here are some troubleshooting tips.</P>
|
|
|
313 |
<P>If the program says it cannot open the serial port, then this is almost
|
|
|
314 |
certainly a configuration problem. For MacNQC, make sure you have a valid serial
|
|
|
315 |
port selected in the Preferences dialog box. For NQC, make sure you have
|
|
|
316 |
specified the appropriate serial port name (default is modem port, "B" is the
|
|
|
317 |
printer port, see <A
|
|
|
318 |
href="http://www.baumfamily.org/nqc_old/doc/faq.html#irusb">above</A> for USB
|
|
|
319 |
based macs). For RcxCC, I suggest trying once with auto-detection, and if that
|
|
|
320 |
fails, then manually set the serial port in the RcxCC program.</P>
|
|
|
321 |
<P>If the program reports that it cannot communicate with the IR device, then
|
|
|
322 |
either the program is talking to the wrong serial port (see the previous item),
|
|
|
323 |
or there's a problem with the cable and/or battery. Make sure you have a fresh
|
|
|
324 |
9v battery installed in the IR tower, and if possible use the cable supplied by
|
|
|
325 |
Lego.</P>
|
|
|
326 |
<P>If the program reports that it cannot communicate with the RCX, then
|
|
|
327 |
communication with the IR tower is probably OK, and the problem is between the
|
|
|
328 |
tower and the RCX.</P>
|
|
|
329 |
<UL>
|
|
|
330 |
<LI>Certain light sources (bright sunlight, certain projection TVs) can cause
|
|
|
331 |
interference...try using a towel or other item to shield the IR tower and RCX
|
|
|
332 |
from other light.
|
|
|
333 |
<LI>The tower and RCX should be about 6 inches apart. Tty the switch on the
|
|
|
334 |
front of the tower in both positions - some people report better success with
|
|
|
335 |
"near" mode, and some with "far" mode.
|
|
|
336 |
<LI>Make sure you have firmware downloaded into the RCX. If the display only
|
|
|
337 |
shows "1" on it, then firmware isn't installed yet...download the firmware
|
|
|
338 |
using the Lego software or the -firmware option for NQC (the firmware itself
|
|
|
339 |
must be copied from the Lego CD or downloaded from <A
|
|
|
340 |
href="http://www.legomindstorms.com/"
|
|
|
341 |
target=_blank>http://www.legomindstorms.com/</A>). Once the firmware is
|
|
|
342 |
installed you should see something like "00.00 1" on the display. </LI></UL>
|
|
|
343 |
<P>If you have a terminal program (e.g. HyperTerminal for Windows, Zterm for the
|
|
|
344 |
Mac), then you can check the IR tower directly. Open up a session to the
|
|
|
345 |
appropriate serial port at 2400 baud, 1 stop bit, odd parity, and 8 data bits.
|
|
|
346 |
Turn off local echo. Start typing a few characters. A green LED on the front of
|
|
|
347 |
the IR tower should light up, and the characters you typed should be echoed back
|
|
|
348 |
to the screen (with an occasional mistake depending on how much interference
|
|
|
349 |
there is).</P>
|
|
|
350 |
<P>If you are using the command line version of NQC, then you can have it log
|
|
|
351 |
any serial communication. This is helpful in trying to isolate where
|
|
|
352 |
communication is failing. A good general-purpose test is</P>
|
|
|
353 |
<P><TT>nqc -v -raw 10</TT></P>
|
|
|
354 |
<P>Please include the output of this test in any e-mail to me regarding IR
|
|
|
355 |
communication problems.</P>
|
|
|
356 |
<P></P>
|
|
|
357 |
<HR align=left>
|
|
|
358 |
|
|
|
359 |
<P></P>
|
|
|
360 |
<H3><A name=irlaptop></A>How do I use my computer IR port with the RCX?</H3>
|
|
|
361 |
<P>You can't. At least not easily.</P>
|
|
|
362 |
<P>Most computers use the IrDA protocols for IR communication. The RCX uses a
|
|
|
363 |
proprietary protocol developed by Lego for communication. Quite simply, these
|
|
|
364 |
protocols are incompatable.</P>
|
|
|
365 |
<H4>What about IrCom? Doesn't that let me use the IR port as a regular serial
|
|
|
366 |
port?</H4>
|
|
|
367 |
<P>Yes and no. From an application's point of view, IrCom looks like a serial
|
|
|
368 |
port (complete with hardware handshaking and control lines). However, the IrCom
|
|
|
369 |
layer actually resides on top of normal IrDA communication, so what appears to
|
|
|
370 |
the application to be async serial communication, is in fact a bunch of IrDA
|
|
|
371 |
packets getting sent back and forth. Since the RCX doesn't understand IrDA
|
|
|
372 |
packets, it can't understand IrCom either.</P>
|
|
|
373 |
<H4>What if I access the hardware directly?</H4>
|
|
|
374 |
<P>Even if you bypassed the IrDA protocol stacks on the computer and somehow
|
|
|
375 |
managed to control the hardware directly (a task that is likely to be different
|
|
|
376 |
for different computer vendors), it still may not be possible. The Lego
|
|
|
377 |
protocols encode bits using a 38kHz carrier frequency. This frequency is
|
|
|
378 |
generated an filtered in hardware. IrDA doesn't really use a carrier frequency,
|
|
|
379 |
and the actual specs on bit times provide a lot of lattitued to device
|
|
|
380 |
manufacturers. As a result, it is difficult to get generic IrDA hardware to
|
|
|
381 |
generate the required 38kHz carrier reliably. Filtering the recieve side is even
|
|
|
382 |
more problematic.</P>
|
|
|
383 |
<P>I would hesitate to say that this problem is "impossible" to solve, but
|
|
|
384 |
people have been asking about this for over a year, and to my knowledge no
|
|
|
385 |
general solution has emerged. There are, however, specialized solutions for
|
|
|
386 |
specific pieces of hardware (usually PDAs or other handled devices such as a
|
|
|
387 |
Palm III).<BR></P>
|
|
|
388 |
<HR align=left>
|
|
|
389 |
|
|
|
390 |
<H3><A name=irxp></A>How can I get the USB IR tower to work under Win XP?</H3>
|
|
|
391 |
<P>There appear to be some timing related difficulties when using NQC with the
|
|
|
392 |
USB tower under Windows XP. If you are having difficulty downloading
|
|
|
393 |
programs, open the LEGO USB Tower control panel, select the Advanced Tab, and
|
|
|
394 |
set the Read Timeout to 300 msec. This generally fixes the
|
|
|
395 |
problem.<BR></P>
|
|
|
396 |
<H3>
|
|
|
397 |
<HR align=left>
|
|
|
398 |
<A name=spirit></A>Why doesn't NQC use the Spirit OCX?</H3>
|
|
|
399 |
<P>The Spirit OCX is only available on the PC. My personal preference is to use
|
|
|
400 |
a Macintosh, so I needed to have a platform independent means for communicating
|
|
|
401 |
with the RCX.</P>
|
|
|
402 |
<H3>
|
|
|
403 |
<HR align=left>
|
|
|
404 |
<A name=vision></A>Does NQC Support Vision Command?</H3>
|
|
|
405 |
<P>Vision command programs run in two places...all of the image processing
|
|
|
406 |
software runs on the PC, then sends messages to a program running on the RCX.
|
|
|
407 |
The messages that are sent are ordinary RCX messages, and by using Message() and
|
|
|
408 |
ClearMessage(), NQC programs can respond to them. Mike Gasperi calls this "<A
|
|
|
409 |
href="http://www.plazaearth.com/usr/gasperi/vcsensor.htm" target=_blank>Using
|
|
|
410 |
Vision Command as a Smart Sensor</A>".</P>
|
|
|
411 |
<P>Note that I have never tried this myself (Vision Command doesn't run on Mac),
|
|
|
412 |
so I can't really help if things don't work as expected.</P>
|
|
|
413 |
<H3>
|
|
|
414 |
<HR align=left>
|
|
|
415 |
</H3>
|
|
|
416 |
<H3><A name=build></A>What computers/tools/etc do you use to develop NQC?</H3>
|
|
|
417 |
<P>All of the NQC development takes place on my Macintosh PowerBook. I use
|
|
|
418 |
Metrowerks CodeWarrior to write and debug the code as a Macintosh
|
|
|
419 |
application.</P>
|
|
|
420 |
<P>The Code Warrior project also has targets to build the MPW version of NQC as
|
|
|
421 |
well as the Win32 version. Regression tests on the compiler are done on the PPC
|
|
|
422 |
version of the MPW tool (via a couple of MPW scripts and a bunch of sample
|
|
|
423 |
programs). Some minimal testing of the Win32 version is done from within Virtual
|
|
|
424 |
PC - I just make sure that the build went fine and that the serial port works
|
|
|
425 |
since that is really the only code custom to Win32.</P>
|
|
|
426 |
<P>For the source release, I boot into Mac OS X, copy over the NQC source tree
|
|
|
427 |
and build it (using make, gcc, etc). A simple test (again just to make sure the
|
|
|
428 |
serial port code for Unix is working) is performed. I then use a shell script to
|
|
|
429 |
create a source release tree, strip out any unwanted binaries, and package the
|
|
|
430 |
entire thing up as a .tar.gz. Recently, I've also been packaging up a Mac OS X
|
|
|
431 |
binary version.</P>
|
|
|
432 |
<P>So there you have it...development for Mac, Windows, and Unix all done on my
|
|
|
433 |
trusty PowerBook.</P>
|
|
|
434 |
<P></P>
|
|
|
435 |
<HR align=left>
|
|
|
436 |
|
|
|
437 |
<TABLE height=24 cellSpacing=0 cellPadding=0 width="100%" border=0>
|
|
|
438 |
<TBODY>
|
|
|
439 |
<TR>
|
|
|
440 |
<TD width="50%" height=17> <A
|
|
|
441 |
href="http://www.baumfamily.org/nqc_old/doc/index.html"
|
|
|
442 |
target=_parent>[Home]</A></TD>
|
|
|
443 |
<TD align=right width="50%"> <IMG height=31
|
|
|
444 |
src="NQC FAQ_soubory/contact.gif" width=128 align=bottom
|
|
|
445 |
naturalsizeflag="3"></TD></TR></TBODY></TABLE></BODY></HTML>
|