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 / 493
492  |  494
Subject: 
infrared remote control of LEGO trains using NCQ and RCX
Newsgroups: 
lugnet.robotics.rcx.nqc, lugnet.trains
Date: 
Wed, 22 Mar 2000 03:06:24 GMT
Viewed: 
2545 times
  
When I first bought my RCX some time ago, I dreamed of using the remote control
to drive the train.  Well I think I finally have it working.  The following
code works but has a problem which perhaps somebody can help me with.

The program looks for input from the message buttons on the infrared remote.
Message 1 decreases speed, Message 2 sets the speed to 0, and Message 3
increases the speeed.  On problem I have is that when I give it message 2, the
variable 'speed' goes to zero but the motor doesn't stop.  Anyone know what I'm
doing wrong?  Anyone have suggestions for refining the code.  Perhaps a better
speed control algorithem.  Thanks to Dave B(for NCQ) and Mark Overmars (for the
tutorial)

Thanks for any advice, hints, feedback or suggestions

Here is the code:  (please excuse me if it is not appropriate to post it here)

int speed , __speed;

task run_motor()
{
  while (true)
  {
    __speed = speed;

    if (__speed > 0) {SetPower(OUT_A,speed);OnFwd(OUT_A);}
    if (__speed < 0) {SetPower(OUT_A,-speed);OnRev(OUT_A);}
   }
}
task check_sensors()
{
  while (true)
  {
  ClearMessage();
   until (Message() != 0);
   if (Message() == 1) {speed = speed -1;}
   if (Message() == 2) {speed = 0;}
   if (Message() == 3) {speed = speed +1;}
  }
}

task main()
{
  speed = 0;
  start run_motor;
  start check_sensors;

}



Message has 3 Replies:
  Re: infrared remote control of LEGO trains using NCQ and RCX
 
(...) you never check if your speed is 0 in this task - IMO, you need to add: if (__speed == 0) {Off(OUT_A)}; (I'm guessing here, since I haven't really done any NCQ myself yet. :/ Dan (24 years ago, 22-Mar-00, to lugnet.robotics.rcx.nqc, lugnet.trains)
  Re: infrared remote control of LEGO trains using NCQ and RCX
 
Hi Ben F.! Maybe all your work is a little needless, since there are rumors going around here in Germany, saying Lego is going to invent new more realistic trains next year, or even late this year around X-mas...... I've heared about it from a (...) (24 years ago, 22-Mar-00, to lugnet.robotics.rcx.nqc, lugnet.trains)
  Re: infrared remote control of LEGO trains using NCQ and RCX
 
(...) <...SNIP...> I won't go into the code detail as other members have already corrected it. I just wanted to say that if your interested in my RCX Train code, it's almost ready. (Phase 1 anyway) It has a few modes of use. MS Remote control. (...) (24 years ago, 22-Mar-00, to lugnet.robotics.rcx.nqc, lugnet.trains)

84 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