To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.javaOpen lugnet.robotics.rcx.java in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / Java / 336
335  |  337
Subject: 
train control
Newsgroups: 
lugnet.robotics.rcx.java
Date: 
Mon, 28 Jun 2004 15:34:17 GMT
Viewed: 
6922 times
  
hi
I want to use rcx to control a lego train, but the fact that lejos only
have 7 levels makes it dificult to set the speed.

Jürgen Stube wrote in september2001:

"Yes, the standard LEGO routines make it very hard to control
speed.  Basically with an 8ms cycle they set the motor output
part of the time (depending on power level) to full voltage,
and the rest they let it float."

i've made a java program to imitate this, using a 20 ms cycle, but the
result is not satisfying. It's not so smooth as when the train is
controlled with the Electric Train Speed Regulator (#4548).

Is this a limitation of lejos or the rcx?
Or is it a problem with my code (see at end of message)?

Daniel


----
import josx.platform.rcx.*;

public class Locomotiva extends Thread {

     private Motor motor;

     private int velocidade;

     public Locomotiva(Motor m) {
motor=m;
start();
     }

     // method to change the speed,
     // vel is a value between -100 and +100

     public void setVelocidade(int vel){
velocidade=vel;
     }

     public int getVelocidade() {
return velocidade;
     }

     public void run() {
while (true){
    if (velocidade==0)
motor.flt();
    else if (velocidade<0)
motor.backward();
    else
motor.forward();

    int absVel=Math.abs(velocidade)/5;

    try{
if (absVel>0) {

    motor.setPower(5);
    Thread.sleep(absVel);
}
motor.setPower(0);
Thread.sleep(20-absVel);
    }catch(InterruptedException ex){}

}
     }


}



Message has 2 Replies:
  Re: train control
 
(...) There is a fundamental difference between the RCX and a Lego Train controller - the controller uses smooth power from a 3-pin regulator, with the voltage varied using a chain of resistors. The RCX uses PWM power with approximately 166ms square (...) (20 years ago, 3-Jul-04, to lugnet.robotics.rcx.java)
  Re: train control
 
Hi Daniel, (...) sorry to reply so late, I wanted to try it myself but didn't get around to do it yet (I'm starting an IT-Business as a consultant/systems programmer, see (URL) managed to run a train from an RCX with the standard power levels using (...) (20 years ago, 5-Jul-04, to lugnet.robotics.rcx.java)

7 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