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 / 5178
5177  |  5179
Subject: 
Re: Sending raw IR characters.
Newsgroups: 
lugnet.robotics
Date: 
Fri, 28 May 1999 18:49:23 GMT
Viewed: 
1455 times
  
Assad; Mark <massad@ug.cs.su.oz.au> wrote:
I've been using the LegOS distirbution running under gcc on a linux box to
do some simple development, but what I would like would be to use the IR
transmitter as debuging output with a simple terminal program. The problem
is that whenever I try and send anything with the IR functions in LegOS I
end up sending more than the bytes that I want to send, it seems to be
wrapped in some kind of header.

The problem is that you can't simply use a terminal program to communicate
with the RCX.  The IR interface doesn't allow the transmission of arbitrary
patterns of bytes and therefore won't allow it.  You need to encode bytes
before sending them, and you need to decode them after receiving them.

The encoding used by the standard Lego firmware is designed to balance the
number of zeros and ones sent, presumably so that zeros and ones can be
detected regardless of the ambient lighting.  This is done by following
every byte sent with its complement.  In addition, the Lego firmware adds a
header and checksum to detect the start of packets and to make sure packets
are valid.

I believe the encoding used by LegOS is similar.

Since writing send.c/firmdl.c a long time ago, I have done a little more
investigation of the IR hardware.  Compared to the IR tower, the RCX is
pretty reliable in the sense that it doesn't need warming up and is
seemingly always ready to receive data.  The IR tower, on the other hand,
powers down after a few seconds of inactivity, and sometimes needs a few
seconds to warm up and adjust to the ambient light level before being able
to receive data.  The powering down has been known about for a very long
time, but the warmup time has never really been discussed.

In any event, the capabilities and requirements of the IR hardware
complicate both the use of any standard terminal program and the design of
any new terminal program designed specifically to talk to the RCX.  You can
certainly still write a terminal program; however, it is a bit more work.

As for debugging, it is perhaps easier not to think about a using a
terminal model for interacting with the RCX but instead a query/response
model, which is essentially what the IR tower was designed for.  This, at
least, is how I debugged the floating point routines I sent out yesterday.

The model I used was as follows:

- stack-based calculator interface running on Unix box
- stack-based calculator engine running on RCX
- send numbers to RCX in packets, one number per packet
- send operators to RCX in packets, one operator per packet
- send print queries to RCX in packets, one query per packet
- RCX always sends a reply as an acknowledgement
- reply can contain additional data (e.g. for print queries)
- interface on Unix box translates text commands into outgoing packets
- interface on Unix box translates certain replies into text output on screen

In terms of serial communication, I coded up everything for the RCX side of
things using Librcx and some functions in ROM.  The ROM functions
automatically encode/decode packets for you - you just respond to decoded
incoming data and specify unencoded data to send.  The drawback with the
ROM functions is it places restrictions on the format of incoming data.
Since I could hack what I wanted into that model, I didn't mind the
restriction; at some point in the future I plan to rewrite IR support to
make the format less restrictive.

On the Unix side of things, I wrote a simple scanf-based text command
interface and then linked that with the routines in send.c to allow for
communication with the RCX.

-Kekoa



Message is in Reply To:
  Sending raw IR characters.
 
Hi, I'm fairly new to all these things with the Lego Minstorm (i.e. I only picked one up last Tuesday.), so this might be a fairly stupid question, but I've been unable to find an answer. I've been using the LegOS distirbution running under gcc on a (...) (25 years ago, 28-May-99, to lugnet.robotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
21 hours ago
Custom Search

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