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 / 13710
13709  |  13711
Subject: 
Re: reading sensors on CM
Newsgroups: 
lugnet.robotics
Date: 
Wed, 3 Jan 2001 17:51:30 GMT
Original-From: 
Marco C. <marco@=SayNoToSpam=soporcel.pt>
Viewed: 
836 times
  
Hi :)

[Note1: CM = CyberMaster; pBrick = { CM | RCX | Scout | RCX2 } ]
[Note2: I think this could be usefull to others = CC:lego-robotics]
[Note3: I'm showing source code done by Mark Overmars = CC:markov+lego]

Well, all my PC apps were done with Delphi using the Spirit.OCX API (it
comes with the CM CD and it gets installed with the rest of the CM software).
I also did something in BASIC, sending the opcodes directly, with a i8086
laptop :P but that doesn't count.

My recomendation to you is: You should checkout the LEGO Spirit.OCX API
documentation.

I can't remember right now the link to the .PDF but it's (was?) in the
http://mindstorms.lego.com site.

The link has been referenced many times in LUGNET. You'll have to do a
search to "Spirit" or "Spirit.OCX" 'cause I don't have it here right now.

This API documentation is good, even if you're going to send opcodes
directly to the pBrick (as it seems you are doing) instead of using the
Spirit API (Windows-ware only, OS dependent.)

There you can see many opcode arguments like this one.

From what I remember, in this case, I think the "source" is what specifies
the source of the value. It can come from a memory var, from a sensor,
timer, tachometer, speed, agv, etc. You must specify which one.
There's a table to know these source codes (in spirit docs).

Looking at this very usefull piece of Delphi code from Mark Overmars's RCX
Command Center 3.1 source code (http://www.cs.uu.nl/~markov/lego/), you can
see what I mean.

Look at the MainForm.RCX.Poll(source,argument).
You can see that, to get Sensor1 the source=9 and argument=0;
Sensor2->source=9, argument=1 and so on...

Hope it helps :)

------8<---------------------------------------------------------------------
{ This was taken from http://www.cs.uu.nl/~markov/lego/       }
{ RCX Command Center Source Code version 3.1 by Mark Overmars }

function GetMotorData(numb:integer):string;
var ttt:integer;
    str:string;
begin
  ttt:= MainForm.RCX.Poll(3,numb);
  str:='';
  if ttt div 128 = 1 then str:=str+' On ' else str:=str+'Off ';
  if (ttt mod 128) div 64 = 1 then str:=str+'Brake ' else str:=str+'Float ';
  if (ttt mod 16) div 8 = 1 then str:=str+'Fwd ' else str:=str+'Rev ';
  str:=str+Format('  %d', [ttt mod 8]);
  GetMotorData := str;
end;

procedure TWatchForm.PollNowClick(Sender: TObject);
var i:integer;
begin
  if busy then exit;     // Avoid polling while polling
  busy:=true;
  try
    for i:=0 to 31 do
      if TCheckBox(FindComponent(Format('CVar%d',[i]))).Checked then
        TEdit(FindComponent(Format('VVar%d',[i]))).Text :=
                           Format('%6d',[MainForm.RCX.Poll(0,i)]);

    if CheckSensor1.Checked then
      ValueSensor1.Text := Format('%6d',[MainForm.RCX.Poll(9,0)]);
    if CheckSensor2.Checked then
      ValueSensor2.Text := Format('%6d',[MainForm.RCX.Poll(9,1)]);
    if CheckSensor3.Checked then
      ValueSensor3.Text := Format('%6d',[MainForm.RCX.Poll(9,2)]);

    if CheckMotorA.Checked then
      ValueMotorA.Text := GetMotorData(0);
    if CheckMotorB.Checked then
      ValueMotorB.Text := GetMotorData(1);
    if CheckMotorC.Checked then
      ValueMotorC.Text := GetMotorData(2);

    if CheckTimer0.Checked then
      ValueTimer0.Text := Format('%6d',[MainForm.RCX.Poll(1,0)]);
    if CheckTimer1.Checked then
      ValueTimer1.Text := Format('%6d',[MainForm.RCX.Poll(1,1)]);
    if CheckTimer2.Checked then
      ValueTimer2.Text := Format('%6d',[MainForm.RCX.Poll(1,2)]);
    if CheckTimer3.Checked then
      ValueTimer3.Text := Format('%6d',[MainForm.RCX.Poll(1,3)]);

    if CheckMessage.Checked then
      ValueMessage.Text := Format('%6d',[MainForm.RCX.Poll(15,0)]);

    if CheckTCounter.Checked then
      ValueTCounter.Text := Format('L:%6d  R:%6d',
              [MainForm.RCX.Poll(5,0),MainForm.RCX.Poll(5,1)]);
    if CheckTSpeed.Checked then
      ValueTSpeed.Text := Format('L:%6d  R:%6d',
              [MainForm.RCX.Poll(6,0),MainForm.RCX.Poll(6,1)]);
    if CheckMCurrent.Checked then
      ValueMCurrent.Text := Format('%6d',[MainForm.RCX.Poll(7,2)]);
  except
    ShowMessage('Cannot find the RCX anymore');
    Timer1.Enabled := false;
    PollRegularBtn.Down := false;
    busy:=false;
    exit;
  end;
  busy:=false;
end;

------8<---------------------------------------------------------------------

At 17:33 03-01-2001 +0100, you wrote:
Hi,

after hunting the lugnet for an hour or two, I encountered
some mail of yours that made me think you might know the answer to the below.

I'm writing sw to drive my CM from my PC (laptop). The CM has too little
memory to download sw to it, so I'll be treating it as a 'terminal'

Then I couldn't find how to read sensors into the PC. Petere Ljungstrand
suggested that this should be done with the 'Get Value' opcode.
Kekoa's RCX Opcode ref however is to fuzzy to me:

Get Value
12/1a Request

   byte source   source type for value. Sources 2 and 4 not allowed
   byte argument argument for value

Request the value specified by 'source' and 'argument'.

e5/ed Reply

   short value   Return value


I don't know what to make of that. What is meant by 'source'
and what is meant by 'argument'? What is a 'source type for value'?
What is a 'argument for value'?

Desparately looking for someone to tell me,

thanks,
Theo.





Marco C. aka McViper
_________________________________
Work mailto:mcviper@geocities.com
Home mailto:mcviper@clix.pt



Message has 3 Replies:
  Cybermaster: Cannot receive though sending works (w/o sprit.ocx)
 
Hi, I've written a small Visual Basic program so I can use Cybermaster under Windows 3.1x. (So I cannot use spirit.ocx.) Sending commands works (motor on/off, sound, etc.). But I don't get any echo. I cannot get any sensor data, and I can't see if (...) (23 years ago, 22-Jan-01, to lugnet.robotics, lugnet.robotics.cybermaster, lugnet.robotics.rcx)
  Re: Cybermaster: Cannot receive though sending works (w/o sprit.ocx)
 
Search (URL) page for a link related to DOS comms with CyberMaster. Bert van Dam had (still has?) somewhere in his site a source code of a QBasic program for DOS that he used for CM comms in DOS. It worked, I myself used it with an old i8086 (...) (23 years ago, 22-Jan-01, to lugnet.robotics)
  Re: Cybermaster: Cannot receive though sending works (w/o sprit.ocx)
 
This page (URL) by Bert van Dam, has the (URL) link to the QBasic program I was talking about. mc. (...) (23 years ago, 22-Jan-01, to lugnet.robotics)

6 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