Skip to main content

Reply to "computer controlled"

@A. Wells - In my code, there are 2 systems before we get to actually controlling the motor speed:

1. Control Model
2. PID Controller

Control Model Inputs:
- Throttle
- Reverser
- Brake

Control Model Outputs:
- Engine RPMs (which is used by my sound algorithm)
- Desired Wheel RPMs
- Smoke percentage

PID Inputs:
- Desired Wheel RPMs
- Measured Wheel RPMs

PID Outputs:
- Speed value that is sent to the motor driver

I've implemented a couple different "Control Models".  The simplest is the ToyControlModel.  It only uses the Throttle and Reverser, and the Engine RPMs and DesiredWheelRPMs are just linear with respect to Throttle.  It's just like using a conventional transformer.  (Except that it goes through the PID controller too, so there's speed control, and the PID takes care of the non-linearity of the motor driver and can motors.)  The PID does smooth out the acceleration, but it can still make pretty quick changes in speed.

But I've also implemented a SimulatorControlModel.  While I've never driven a real locomotive, I have some experience with Train Simulator, and a background in physics.  So the SimulatorControlModel tries to model some of the hardware inside a real locomotive, as well as some of the physics.  So it's modeling:
- Rate for the prime mover to spin up
- reverser and how much power the traction motors can deliver
- braking
- rolling resistance
- air resistance
- how much smoke should be generated for a given engine rpm

I'm learning as I go and I'm sure some of my equations aren't perfect, but I'm trying to get it to generally behave like a real train.

Last edited by jwetzel1492

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
×