Large Scale Central

Train Control by Xbee, Pololu, and Battery. Phase 2: Wireless Co

Motor control is all well and good, but of course we need a way to send commands. Control is accomplished through a Pololu controller as described in Phase 1.

That controller can be commanded by a standard R/C controller, or an analog signal or, as I am doing, ttl-level serial inputs. I am using an Xbee module to send the serial inputs and read responses.

Yesterday, I got full wireless control. This was rather difficult for me, as I am new both to Xbee and to Pololu. Each of these has its own wiring requirements, as well as programming and protocol. I will post detailed specifications once I get past the bubble gum and baling wire stage, but here is a high-level set of points:

  1. The Pololu motor controller wires up easily. It must be programmed with a USB cable to act the way you want it to. Currently, my settings are:
    a. Serial input set. Autodetect baud rate
    b. No kill or limit switch set (yet!)
    c. Acceleration rate set by experimentation to something like 30mv per 30 ms.

  2. The Xbee is a pain to set up. I went for the most complex version because I have other aspirations for the system, but it took some figuring out.
    a. Two “nodes” need to be configured to make them work. They have to be set to the same network code so they see each other, and they each have to be told where to send their information. This requires typing in some codes. Also, it may be a good thing to update the firmware in the node. All of this is readily done using a program called X-CTU and a usb cable.
    b. The Xbee radio node requires 3.3 volts. Turns out, this is available on a pin of the motor controller, so it is way easy to find. Otherwise, you’ll need to spend a buck or so.
    c. In addition to power and ground, the XBee needs to connect its output to the Pololu input and vice versa. So, four wires total.

  3. The commands must be correctly formatted for the Pololu and correctly sent to the Xbee. This was the hardest part that I could not master until I broke it down into very small parts.
    a. Demonstrate that the motor controller controls the motor (done)
    b. Use serial commands (rather than native USB input) to command the controller. This took a little work, as the controller has a specific format to follow. I ended up using a sample program written for the Arduino to generate the commands. This is because my PC’s output was the wrong voltage for the motor controller.
    c. Once the commands are proved to manage the controller, substitute the wire for properly-configured XBee nodes operating in “transparent” mode, where anything on the input of one appears on the output of the other.

There was some sort of wiring mystery on the Xbee, that may have been due to a soldering error on my part, but it went away when I used a pre-made socket.

Next steps:

  1. Configure the Arduino to support normal train commands sent to the loco (Forward, reverse, brake, bell, whistle, light, laser cannon…)
  2. Configure the XBee network in the “API” mode, so that multiple trains can be commanded from one or more controllers.

Whew.

I am pleased to report SUCCESS!

As I write this, I sit listening to my 4-6-0 happily rolling around a plastic track in the family room. Controlled by an arduino/xbee/potentiometer combination from across the room. Very happy with this.

Cat, on the other hand, is rather dismayed by the setup.

A minor setback: as I sat down to do the final hookup, I somehow blew up the controller. The issue, it seems, is that once you let the smoke out, you cannot get it back in. The real issue is that I probably hooked up the XBee to the wrong power pin and fried the motor controller. I posted over on the manufacturer’s web to get further ideas. But hey, at least I saved twenty-five cents in not buying a dedicated voltage regulator chip. :frowning:

This is real good! Me happy.

Next: full documentation, and repeat the process on two more locos.

Oh yeah, and track.

Very cool!

We all have had experience with the magic smoke.

You have our deepest condolences. :stuck_out_tongue:

After the brief setback of blowing up not one but TWO motor controllers due to sloppy construction practices, I reverted to the basics: Power off when assembling Tin the ends of wires Secure components So, I did that, and installed a charging jack and power switch in the chassis. It works great. I have nice speed control with braking, acceleration, and deceleration, as well as several extra pins for other features. Done in time for the Holiday! Here it is all neatened up! Makes it easier to get the body on the chassis too! [img=

(http://freightsheds.largescalecentral.com/users/cayenne/_forumfiles/xbeerail3.png)

]

The curse of Bells and Whistles:
As I went to upgrade the remote to trigger remote sounds, my design skills collapsed under their own weight. Something made the train stop…

Okay, we are changing from the XBee Series 2 to the Series 1, which is more suited to vehicle control and modelling anyway, as it has analog outputs. As soon as I got my hands on a pair from a generous friend, I was up and running again within half an hour. This will also support a more flexible design: can swap out standard RC later, If I want…

Now to find a sound board that I like.