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 / 337
336  |  338
Subject: 
Re: train control
Newsgroups: 
lugnet.robotics.rcx.java
Date: 
Sat, 3 Jul 2004 14:54:02 GMT
Viewed: 
7108 times
  
In lugnet.robotics.rcx.java, Daniel Carvalho wrote:
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){}

}
     }


}

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 wave of variable duty cycle.  It hink the RCX duty cycle timings increase
linearly.  This does not have linear power output though.  For example, if duty
cycles at each power level were 20, 40, 60, 80 and 100% and the voltage was
averaged over each 166ms cycle, this would give power of 4%, 16%, 36%, 64% and
100%, since power is proportional to voltage squared.

When I have driven a train motor from my RCX, I have used all three motor ports
in parallel and programmed it appropriately.  Train motors don't seem to like
PWM power, but one of my engines has a technic motor in parallel.  I found that
on power 2 or 3 it moved at reasonable shunting speed.

I think at the very least you need to smooth the power output of the RCX in
order to turn PWM into steady voltage.  I suggest a low pass filter with a time
constant (RC) longer than 166ms, followed by a power transistor drive circuit,
so that it uses a separate 9V power supply to drive the motor, not the RCX's
outputs.  The RCX's outputs are designed to drive technic motors at 200mA for
short periods.  Train motors can use up to 300mA each, and my trains use two
motors per engine.  I personally use a more powerful PSU than Lego train
controllers, since they have limited power output capability.

Another problem is that it is difficult to account for the variable load on the
train.  The steps between levels on a lego controller are quite large, which is
another reason for me using a variable power supply.

Most standard model railway controler deliberately don't smooth the power, so as
to get the pulsed effect of the rectified AC line voltage.  This gives the
advantage of PWM in better starting torque when leaving a station.  However,
lego train motors like their power to be smooth.

An alternative is the RCX DCC system, which uses the RCX to send control signals
to the engines, which then have receiver units to decode the signals and control
the power from the track.  The RCX does not power the motors in this
application.  I haven't tried it myself, but I think O-gauge DCC controllers
should be used for the size and weight of engines made from Lego.  Some people
have tried fitting train motors with N-gauge DCC controllers and I think they
might overheat:

The energy to move a mass is proportional to the mass and the speed squared.
Lego trains are about 4x the size of N-gauge trains.  If the density were the
same, the mass is proportional to the volume, so it would be 64x that of an
N-gauge train.  To run at the same scale speed requires the train to move four
times as fast, using 16x the energy.  Therefore 1024 times the amount of energy
is required per second.  The I squared R losses in controller components will be
a lot greater for a bigger train.

The best DCC solution is to fit an O-gauge receiver unit in the body of the
engine.  You would need to modify the motor though, to disconnect the pickups
from the motor itself, bring both pairs of wires out of the motor and connect
the receiver unit.

So the conclusion of this essay is that the limitation is with the RCX :-)

Mark



Message has 1 Reply:
  Re: train control
 
Daniel: >> 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. > > Mark Bellis wrote: > > I think at the very least you need to smooth the power output of the RCX in > order to (...) (20 years ago, 8-Jul-04, to lugnet.robotics.rcx.java)

Message is in Reply To:
  train control
 
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 (...) (20 years ago, 28-Jun-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

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