To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 543
542  |  544
Subject: 
Re: Q: Determining state of outputs
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Fri, 14 Apr 2000 02:17:57 GMT
Highlighted: 
! (details)
Viewed: 
1923 times
  
In article <FsyMxD.1Fx@lugnet.com>, "Oliver Petermann" <peppo.p@gmx.at>
wrote:

Hello everybody!

For the building of my next robot an answer to the following question
could
be very helpful:

Is there any possibility in NQC to get the state of an output (on, off,
direction). While running a program I would like to control one output
directly by the IR-remote. The program needs to know whether the
(directly
controlled) output is on or off. Information about the direction of the
attached motor would be perfect.


Yes, there is a 'data source' for motor status.  I never bothered
figuring it all out, so there isn't a defined API for it, but you can
add it yourself:

#define MotorStatus(motor)  @(0x30000 + (motor))

use motor 0 for output A, 1 for B, 2 for C.

The returned value is 8 bits of the form:

mmxxdppp

where mm = mode
  0 = float
  1 = off
  2 = on
  3 = on from remote?

xx = ?   seems to be the motor number, not sure why

d = direction (0 = reverse, 1 = forward)

ppp = power level

Most of this is from some of my early (and somewhat unreadable) notes,
so I'm not sure its accurate.  For one thing, from the RCX 2.0 alpha SDK
it seems that they treat remote commands a little different - using xx
for something called an "overlay".  I haven't experimented with this
under 2.0 yet.

Here's a little test program...it keeps monitoring motor 0 and will beep
(and store the motor status value) when it is in some mode other than
Off:

--

int x, y;

#define MotorStatus(x)  @(0x30000 + (x))

task main() {
   while(true)
   {
      x = MotorStatus(0);
      if ((x & 0xc0) != 0x40)
      {
         PlaySound(0);
         y = x;
      }
   }
}

--

The stored value (in variable y) can be read on the host computer using
the following nqc command:

nqc -raw 120001

I hope this helps.

Dave Baum

--
reply to: dbaum at enteract dot com



Message has 1 Reply:
  Re: Q: Determining state of outputs
 
It works fine. Thanks for your help! Oliver (25 years ago, 25-Apr-00, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Q: Determining state of outputs
 
Hello everybody! For the building of my next robot an answer to the following question could be very helpful: Is there any possibility in NQC to get the state of an output (on, off, direction). While running a program I would like to control one (...) (25 years ago, 13-Apr-00, to lugnet.robotics.rcx.nqc)  

4 Messages in This Thread:


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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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