Tram Controller
September 2013 Monthly Status
01 October 2013 22:09
September was an eventful month: work began in earnest on the “One Point Five Meter Line”, my short layout for displaying building models and showing off my Tram Controller. Additionally I made significant progress on the tram controller program, continuing the work I’d begun in August on driving multiplexed LEDs and, although I didn’t write about it, refining the sensor code to allow it to run faster.
The tram controller program itself is beginning to come together. It’s still a ways from actually running a train, but I’ve assembled the pieces and made a start on the actual logic that will know where the trains are and perform actions on them, based on the use of sensors and timers. After about six months of sporadic work, I can almost see the end in sight.
As usual I have more projects running through my head than I have time to do. There are a half-dozen buildings disassembled on my workbench (where they’ve been since May) waiting to be painted, lit, decorated, and reassembled. I’m hoping to make a start on those soon, with the completion of the benchwork for the One Point Five Meter line serving as a spur. Once I have a place I can put them, and wiring I can use to light them up and see how they look, I’ll be more interested in getting them done.
But despite the things not done, this month has a definite sense of accomplishment and progress, something I can’t say about the layout(s) every month. Read More...
The tram controller program itself is beginning to come together. It’s still a ways from actually running a train, but I’ve assembled the pieces and made a start on the actual logic that will know where the trains are and perform actions on them, based on the use of sensors and timers. After about six months of sporadic work, I can almost see the end in sight.
As usual I have more projects running through my head than I have time to do. There are a half-dozen buildings disassembled on my workbench (where they’ve been since May) waiting to be painted, lit, decorated, and reassembled. I’m hoping to make a start on those soon, with the completion of the benchwork for the One Point Five Meter line serving as a spur. Once I have a place I can put them, and wiring I can use to light them up and see how they look, I’ll be more interested in getting them done.
But despite the things not done, this month has a definite sense of accomplishment and progress, something I can’t say about the layout(s) every month. Read More...
Arduino Signals II - Video and Flickering
29 September 2013 00:25
I’ve continued working on the code to drive LED signals with an Arduino. I’d previously discussed my approach, and provided the code I was using at that time. I’ve learned a bit since then, and cleaned up the code significantly. I’ll provide a link to the current example program at the end of this post.
Fundamentally nothing has changed. I’m still planning to use NJI common-anode SMD LED signals (in fact, I’ve ordered them). What I did do was change the code so that a “bank” of two signals would always have both lit (meaning two of the four LEDs would be on when the bank was active) so that I could get through the full set of signals more quickly. One reason for this has to do with video camera shutter speeds. I think it’s worth saying a bit about that issue.
I’ve also made some changes to make the time wasted in turning the pins on and off less, since at these speeds that is becoming a significant percentage of the total LED cycle, and I need that time for the eventual Tram Controller program to be doing other things. These changes consisted of adding a library that provides faster versions of writeDigital and pinMode, as well as keeping track of what state pins are on, and not trying to change them unless the new state differs (this got rid of a number of “change disabled pin X to disabled” changes).
In my test program, when cycling at 8 milliseconds, I’m now spending just a quarter millisecond changing those pins with three banks (6 signals) in use. My One Point Five Meter line will only use four signals, as it doesn’t have the extended double-track section of the full Tram Line, which needs six. And so it will run even more efficiently. Read More...
Fundamentally nothing has changed. I’m still planning to use NJI common-anode SMD LED signals (in fact, I’ve ordered them). What I did do was change the code so that a “bank” of two signals would always have both lit (meaning two of the four LEDs would be on when the bank was active) so that I could get through the full set of signals more quickly. One reason for this has to do with video camera shutter speeds. I think it’s worth saying a bit about that issue.
I’ve also made some changes to make the time wasted in turning the pins on and off less, since at these speeds that is becoming a significant percentage of the total LED cycle, and I need that time for the eventual Tram Controller program to be doing other things. These changes consisted of adding a library that provides faster versions of writeDigital and pinMode, as well as keeping track of what state pins are on, and not trying to change them unless the new state differs (this got rid of a number of “change disabled pin X to disabled” changes).
In my test program, when cycling at 8 milliseconds, I’m now spending just a quarter millisecond changing those pins with three banks (6 signals) in use. My One Point Five Meter line will only use four signals, as it doesn’t have the extended double-track section of the full Tram Line, which needs six. And so it will run even more efficiently. Read More...
Tram Controller Status
31 August 2013 22:47
I’m continuing to work on the Tram Controller project (main page, past musings), to the exclusion of all else layout-related, which doesn’t make for interesting posts here. But I’ve made a number of decisions in the past month, and it’s probably worth summarizing them and where that puts the project overall. Short answer: making good progress, but slower than anticipated (what else is new; all my projects run “slower than anticipated”).
I’ve also been thinking about the diorama-like layout I’m going to initially use this with. The current candidate plans for that are on the new One Point Five Meter Line page.
Read More...
I’ve also been thinking about the diorama-like layout I’m going to initially use this with. The current candidate plans for that are on the new One Point Five Meter Line page.
Read More...
Signaling with Arduino
19 August 2013 23:43
t seems that I can never resist the impulse to make things more complicated. While working on my Arduino sketch (program) for the Tram Controller, the thought struck me that I could add signals at the stations to tell the fictive operators of the trams when it was safe to leave. These would be “starting signals” in typical Japanese practice, and only require two LEDs, red and green. Of course I’m all out of pins, and the only step up from the Uno, which has 20 pins (14 digital, 6 analog) is the Mega with a whopping 70 pins (54 digital, 16 analog).
Read More...
Read More...
One Point Five Meters
12 August 2013 23:04
One point five meters, or about five feet. That’s how much space I’m giving myself for a short layout designed to display my buildings separate from the main layout. It’s also going to give me a short rail line that I can use with the controller I’m working on for the tram line on the Urban Station scene.
The germ of this idea was a conversation at a local hobby store that holds an annual show in the store to display the model-building skills of its customers. Last month, just before the show, I was asked about some of the pre-built buildings I’ve been detailing for my Village scene. At the time, I didn’t think the couple I’d mostly finished were really in a displayable state, but the idea of perhaps doing some kind of diorama crossed my mind as we discussed how to display something next year.
I also wanted some way to actually see the tram line in operation, as on the layout it’s going to be hidden away behind buildings, providing some background activity without really being visible (something I really need to fix on a future layout). And that led me to think: how small can I make a layout with the tram controller and my buildings?
Read More...
The germ of this idea was a conversation at a local hobby store that holds an annual show in the store to display the model-building skills of its customers. Last month, just before the show, I was asked about some of the pre-built buildings I’ve been detailing for my Village scene. At the time, I didn’t think the couple I’d mostly finished were really in a displayable state, but the idea of perhaps doing some kind of diorama crossed my mind as we discussed how to display something next year.
I also wanted some way to actually see the tram line in operation, as on the layout it’s going to be hidden away behind buildings, providing some background activity without really being visible (something I really need to fix on a future layout). And that led me to think: how small can I make a layout with the tram controller and my buildings?
Read More...
June 2013 Monthly Status
01 July 2013 14:44
Another month gone by, but I do have something to show for this one.
The backdrop for the hilltop scene has been painted in primer and let cure. I’m going to work on the mounting structure this week. The photo for it has also been printed (US$72 at my local print shop) and is laid out letting the ink dry fully. I expect I’m a week or so away from gluing it to the backdrop, and by next week should have it installed.
Along the way my plans changed to make a 18” tall (46 cm) backdrop instead of the larger one I’d planned, and the image was adjusted slightly to match, but it’s still basically the same. There was no single reason for the change, just a feeling that 18” fit the area better, and would maintain the “low key” backing I was looking for better, whereas a taller one might tend to overshadow the real scenery. I can always re-do it in the future if I change my mind, total cost with wood is under US$100 and I’ll gladly write that off on a failed experiment, after enough time goes by that I’m sure it is a failed one. Right now, I think I made the right choice.
I’ve also been working on the Village area, and actually done some painting on the Tomix apartment. And I’ve started tearing down the other models to begin painting and lighting/detailing them. I’ll work on several in parallel along with the Tomix apartment. Some notes on the buildings I’m working with are on the Village Buildings page.
And I’ve been doing some work on how I want to build the roads and sidewalks of the village area. I mentioned the planning in general last time. More on the details in some future post when my ideas have settled more.
A bunch of stuff arrived from Japan this month. Among it some track I needed to build a test-track on my bench for continued work on the Tram Controller project, and some Tomix viaduct I want to experiment with for the future Helix (although that may sit on the shelf for a long time; I need it now to measure and check clearances for the hilltop construction, rather than for work on the helix itself).
So, a fairly busy month for the layout, all things considered.
Read More...
The backdrop for the hilltop scene has been painted in primer and let cure. I’m going to work on the mounting structure this week. The photo for it has also been printed (US$72 at my local print shop) and is laid out letting the ink dry fully. I expect I’m a week or so away from gluing it to the backdrop, and by next week should have it installed.
Along the way my plans changed to make a 18” tall (46 cm) backdrop instead of the larger one I’d planned, and the image was adjusted slightly to match, but it’s still basically the same. There was no single reason for the change, just a feeling that 18” fit the area better, and would maintain the “low key” backing I was looking for better, whereas a taller one might tend to overshadow the real scenery. I can always re-do it in the future if I change my mind, total cost with wood is under US$100 and I’ll gladly write that off on a failed experiment, after enough time goes by that I’m sure it is a failed one. Right now, I think I made the right choice.
I’ve also been working on the Village area, and actually done some painting on the Tomix apartment. And I’ve started tearing down the other models to begin painting and lighting/detailing them. I’ll work on several in parallel along with the Tomix apartment. Some notes on the buildings I’m working with are on the Village Buildings page.
And I’ve been doing some work on how I want to build the roads and sidewalks of the village area. I mentioned the planning in general last time. More on the details in some future post when my ideas have settled more.
A bunch of stuff arrived from Japan this month. Among it some track I needed to build a test-track on my bench for continued work on the Tram Controller project, and some Tomix viaduct I want to experiment with for the future Helix (although that may sit on the shelf for a long time; I need it now to measure and check clearances for the hilltop construction, rather than for work on the helix itself).
So, a fairly busy month for the layout, all things considered.
Read More...
Arduino Controls and a Simple Throttle
14 May 2013 23:03
Having covered the motor control and the sensors, my next step in creating the automated two tram controller was to deal with the very small number of controls I need to have. In my original design, the plan was to have just three pushbuttons:
- Run: when pressed, the trains would start to move.
- Park: when pressed, the trains would return to their starting locations so the system could be turned off.
- Emergency Stop: when pressed, the trains would come to an immediate stop until run was pressed again.
And all three were to be “on when pressed, off when released” pushbutton switches. I was already thinking this needed to be changed, and when I started playing with switches I became even more convinced.
There are two benefits to using toggles versus “on while held” button switches: first, I eliminate a switch, since I need two toggles rather than three pushbuttons. Second, I avoid using those pushbuttons, which have proven to be problematic in my testing. They tend to “bounce” for a long time, and they may remain “on” only for a fairly brief time, making it hard to avoid all bounces and still reliably tell that they were pressed in the first place.
The other control I wanted to add was a way to customize the top speed of a train (or trains, really), so the different models could be made to run at similar (and prototypical) speeds. I don’t want one train rocketing down the tracks while the other creeps along, even if they have very different motors and gear-trains. So I’m going to add a pair of potentiometers, used as “tram #1 max speed” and “tram #2 max speed” controls. And note that these are for the trains, not the motor shield A/B outputs. At various times each tram will be controlled by one or the other.
My first step was to create a simple throttle that used one pot, three switches, and one motor control to run a train on a simple test track. This gives me a proof-of-concept example that ensures I really understand what I think I understand (always a concern with me and electronics).
Read More...
- Run: when pressed, the trains would start to move.
- Park: when pressed, the trains would return to their starting locations so the system could be turned off.
- Emergency Stop: when pressed, the trains would come to an immediate stop until run was pressed again.
And all three were to be “on when pressed, off when released” pushbutton switches. I was already thinking this needed to be changed, and when I started playing with switches I became even more convinced.
There are two benefits to using toggles versus “on while held” button switches: first, I eliminate a switch, since I need two toggles rather than three pushbuttons. Second, I avoid using those pushbuttons, which have proven to be problematic in my testing. They tend to “bounce” for a long time, and they may remain “on” only for a fairly brief time, making it hard to avoid all bounces and still reliably tell that they were pressed in the first place.
The other control I wanted to add was a way to customize the top speed of a train (or trains, really), so the different models could be made to run at similar (and prototypical) speeds. I don’t want one train rocketing down the tracks while the other creeps along, even if they have very different motors and gear-trains. So I’m going to add a pair of potentiometers, used as “tram #1 max speed” and “tram #2 max speed” controls. And note that these are for the trains, not the motor shield A/B outputs. At various times each tram will be controlled by one or the other.
My first step was to create a simple throttle that used one pot, three switches, and one motor control to run a train on a simple test track. This gives me a proof-of-concept example that ensures I really understand what I think I understand (always a concern with me and electronics).
Read More...
Detecting Trains with IR Sensors, Part II
04 May 2013 00:11
This is going to be a short post: it’s working! I have my IR LED phototransistor sensor program detecting things (not trains just yet), and I’ve posted the example code, see the bottom of the Tram Controller page for a links to that, and the earlier motor control code. Both example programs are public domain, feel free to use them however you see fit. I’ve benefited from a lot of public domain programs, and I think it’s only fair to give something back. When the tram controller program is a bit more polished, I plan to publish it in the same way, although it may be months before I get to that point.
Read More...
Read More...
Detecting Trains with IR Sensors, Part I
30 April 2013 01:02
In my continuing work on the Arduino-based Tram Controller, I’m now playing around with the part I really wanted to work with, the Infra-red optical sensors themselves. This turned out to be rather more complex than I’d anticipated, but I’m most of the way there, even if I don’t quite have the system working yet. This is a post about what I’ve done so far, and what I’ve learned, with a bit about what remains to be done.
Read More...
Read More...
Arduino CPUs and Motor Shields
21 April 2013 22:08
I’m still playing with Arduinos this week, but the little beasties are multiplying. That’s partly because I want to be able to test with the various CPU architectures, but also because each has unique strengths and weaknesses, and I’m still evaluating which of them is going to be the right choice for my tram controller. At the same time, it turns out that there are a number of options for motor shields, as I mentioned last time, and they too have strengths and weaknesses.
Read More...
Read More...
Revisiting Arduino
14 April 2013 23:45
Two years ago I wrote about my plans to use an Arduino to control a pair of trams on a double-track line sharing single-track stations at each end, replicating the design of the Tōkyū Setagaya line. That’s briefly written up in that earlier post, and I also have a full page about the project that goes into more detail, with a sub-page about the current testing work.
Back then I bought an Arduino Mega 2560 and a bunch of other parts including a “shield” used to drive DC motors, loaded the basic test program that blinks a LED into it just to convince myself I could do it and the hardware worked, and then put it on a shelf for “later”. And forgot all about it while I worked on other things, only infrequently looking at the empty tram tracks and thinking “I really should figure out how to make that work.” It’s not like I dislike the work: I enjoy both programming and soldering simple circuits together. I just never could work myself up to starting what I expected to be a fairly major project. It was always: “I’ll work on that after I finish project ‘X’”, but there was always another “X” to occupy me.
Read More...
Back then I bought an Arduino Mega 2560 and a bunch of other parts including a “shield” used to drive DC motors, loaded the basic test program that blinks a LED into it just to convince myself I could do it and the hardware worked, and then put it on a shelf for “later”. And forgot all about it while I worked on other things, only infrequently looking at the empty tram tracks and thinking “I really should figure out how to make that work.” It’s not like I dislike the work: I enjoy both programming and soldering simple circuits together. I just never could work myself up to starting what I expected to be a fairly major project. It was always: “I’ll work on that after I finish project ‘X’”, but there was always another “X” to occupy me.
Read More...
Plans for an Arduino-based Tram Controller
13 February 2011 23:13
Today I want to mention one of my other projects: the control system for the Tram line of the Urban Station scene. Now this is a simple, short, out-and-back line, which exists mainly to give me an excuse to buy some of the Tōkyū Setagaya line light-rail vehicles (see the Tram section of my Roster) and to experiment with Tomix’s mini-rail Finetrack. So far I’ve run this manually, with a Kato powerpack. But I want to automate it, since the trams are just supposed to be background activity to make the station look busier, as I concentrate on running my commuter and express EMUs and freight trains.
The problem I had was that I wanted to replicate a two-track line with unidirectional running, and a single track station at each end that let the trains switch between the two tracks, and I wanted to do this with more than one tram running at a time. The track I’m using has slip switches, which allow a train to run through them even with the switch set against it. This lets me leave the switch in one position, and have a train enter the end station from one track and leave on the other, without any switch-control needed. Read More...
The problem I had was that I wanted to replicate a two-track line with unidirectional running, and a single track station at each end that let the trains switch between the two tracks, and I wanted to do this with more than one tram running at a time. The track I’m using has slip switches, which allow a train to run through them even with the switch set against it. This lets me leave the switch in one position, and have a train enter the end station from one track and leave on the other, without any switch-control needed. Read More...