Wednesday, August 16, 2017

Arduino based 8 servo modules with frog polarization Loconet

ClubNCaldes has developed a new Loconet module to manage switches, based of course in Arduino. Our previous version (see this old post) was using a simple sensor shield that manages servo motors connected directly to Arduino PWM pins. It's been working with no problems, but we noticed some servos glitched a little bit from time to time. Probably it was because no external power source was used to feed the servo motors, and it was taking the 5v power directly from the Arduino.

Then new module and firmware uses an specific servo shield with its own PWM generator, and communicates through I2C bus, so the rest of the pins are free to use. It has an external 5Vcc connector to use a separate power source for servos. The result is a smother servo movement with no glitches or interference.

Here you have the instructions to build your own module:


PCA9685 I2C 16-Channel 12-bit PWM/Servo Drive shield For Arduino
You can find it in ebay for less than 5€.

1 x Relay board
There are 1, 2, 4, 6 or 8 channel optoisolated relay boards for arduino. Take the one you need according to the number of servos and switches you want to manage.

Dupont cable female - female
This is used to connect the relay board to the servo board.

Servo motors
In ebay you can also find cheap TowerPro 9G servos, enough to manage a N or H0 scale switch.

Servo mounting bracket
My favorite way to fix servos under the table is with aluminium servo brackets from Hobby King.

Arduino UNO
Standard Arduino, you can also use NANO or MEGA version, but the provided firmware has been only tested with UNO VERSION.

Loconet Shield (GCA185)
This is always needed in any Loconet module implemented in Arduino, you can make your own or buy a GCA185 board to Peter Giling (see Rocrail page).


Just put Servo shield on top of Loconet shield, and that last one on top of Arduino UNO.
Upload the SVLoco8ServoRelay sketch to Arduno UNO board. You can download it from:


You have to feed the servo shield with a 5Vcc power source, be careful to respect the polarity shown in the board when connecting. Servos and relays are connected to the servo shield pins as indicated in the following photo. The servo connected to pin 0 uses the relay connected to pin 8, and so on:

Keep in mind these pins on the servo shield are independent of the pins on the Arduino board. Only Arduino pins 0 and 1 are used for debugging purposes, and Arduino pins 7 and 8 communicate with the Loconet shield. The rest of Arduino pins are free to use, so you can change the firmware if you like.


Programming and adjusting is done from Rocrail as in the previous version. (NOTE: a new version using standard CV programming is planned to be released soon). Access to GCA50 configuration in Rocrail menu:

Pressing the query button it should appear the connected servo module. By default, it will have the address 81/1:

Selecting your module, you can change its Low and Sub addresses from the General tab (two modules cannot have the same Low and Sub addresses). Be careful, the RESET button of this screen will reset ALL modules connected to you Loconet network, not only the selected one:

Then you can access the Easy Setup tab, here you assign an output number to each of the 8 servos (left part of the screen marked in red), and a number to the input that tells to the sofware when a servo motor has finished its movement (servo feedback signal). Normally, the same number is assigned as in Loconet inputs and outputs do not share the same range of numbers. Set up the screen as in the following image:

To adjust the servos go to the last tab named "Servo":

Each of the ports (1 to 8) select one of the 8 servos that can be connected. When pressing the Get button it will read the configuration:

Pos1: one of the positions of the servo, with a value from 1 to 127 (1=0º, 127=180º)
Pos2: second position of the servo, with a value from 1 to 127 (1=0º, 127=180º)
V: Speed of movement from 0 (slow) to 5 (fast)

The SET button will overwrite the values and servo will move to POS1, wait one second, and will move back to POS2 so you can visually check the adjustment.

I recommend you to first set Pos1 and Pos2 values to 63. This will center the servo. Then mount the servo in place, and bit by bit reduce the value of Pos1 and increment the value of Pos2 until archive the desired servo movement.

Friday, June 30, 2017

EF210-100 (Kato 3034-3) Digitalization DCC

Probably there is a "drop-in" decoder ready for this locomotive from Digitrax, like DN163K0A, but they are quite expensive and many times need some modifications to the body. Kato models are quite easy to convert to DCC and normally you only face space problems when closing it because there is not enough room for the decoder and wires.

I'm using for the first time the new tiny decoder from Doehler&Haass PD05A. I bought it to my regular supplier of DCC equipment DECODERS.ES

This Kato model is similar to all electric locomotives, with a light board (led lighted) that takes the current from the tracks and also feeds motor:

All decoder connections will be done to the board, except for the motor. Motor plates are at board level, so there is no need to disassemble the locomotive body.

First of all you have to identify which side of the led is the positive and which is the negative. This is very easy to find out using a tester in the position "diode testing" (that one that beeps when shorted). If you put the red tip in the positive side of the led and black one in the negative, led will light slightly. If you touch the led in the reversed polarity nothing will be harmed, and led will not light.

Positive side of led must remain connected to rail current (this decoder has no blue wire). Negative side must be isolated and connected to white and yellow wire.

In the following schema you can see the positive and negative side of each led, where I decided to cut the cooper track to isolate negative sides (yellow arrow), and where I decided to cut the cooper track to solder the needed SMD resistor (1kOhm in my case):

Next photo shows where to solder each of the decoder wires after removing the capacitor and resistor that board already has. There is also a bridge or jumper to do in the place of the old resistor:

With this board preparation you can solder decoder wires. Lift the motor plates and make sure they are well isolated, and not touching any other cooper track. You can put some kapton tape arround it for extra security:

If you find there is not enough room to close the frame, you can cut it as on the top of it there is the gray roof giving you more space for your decoder and wires:

And everything is ready to test!! I hope this mini-tutorial was useful.

Thursday, April 13, 2017

Cheapest DCC Command Station with Loconet interface

In a previos post I talked about the DCC++ Command Station. This is an open project to build you own DCC command station using the Arduino platform. It's quite simple and easy to mount, and features a full DCC command station with PC interface and compatible with Rocrail and JMRI. This time I want to go a little bit further and be able to build a more standard command station with Loconet interface. There are very cheap and professional command stations like DR5000, for sure much better than this, but building things by your own provides satisfaction, right?

Clicking Here you can read the complete information in my previous post.

Both the protocol and interface of the basic command station project shown in my previous post aren't standard, and despite you can connect to the available Arduino I/O's some sensors, lights or switches, it's not enough for a medium sized layout. Anyway is a good command station to have apart from your layout to program and test locos. It's worth the 12€, for sure.

I took the source code of the DCC++ project (it's open an published in github) and tried (successfully) to add Loconet support, with some goodies like:

  • 3 Led to know the state of the command station (ON, OFF, SHORT CIRCUIT)
  • 2 Buttons to turn on and off the track current
  • 2 relays to switch to the programming track current automatically when a programming command is received
  • Display support, showing CV values when reading or writing and current consumption
  • External emergency button
My new sketch can only work on Arduino Mega. I had to discard Arduino UNO and Arduino NANO support as the program was too big for them, and I wanted to have a better performance with a lower cicle time.

The source code and the sketch to upload to Arduino MEGA can be downloaded from my public GitHub repository:

The PC interface support does not longer exist in this version of the command station, as my intention is to have a pure Loconet command station, exclusively dedicated to manage the trains. I prefer to have individual devices for each function, so for PC interface I use a dedicated Arduino UNO with an Ethernet shield. I'll post the information about how to mount the PC interface for a Loconet network in the next post. All this has the advantage that I can change any device without affecting the other Loconet devices or having to change any setup.

Having an independent PC Interface allows me, for example, to change my Intellibox Basic command station and use my new Arduino Based DCC++, or a DR5000. It's just disconnect one, and connect another. No changes in PC, software, or any other device.

So let's go with the connection diagram:

 You see the base is an Arduino MEGA with the Motor Shield on top and the bridge between pins 2 and 13, exactly as the original DCC++ project.

Then you have the 3 led to indicate "track power connected", "track power disconnected" or "error/fault/shortcircuit".

Two external buttons to turn on or off the track power, plus an extra external emergency button. Pressing this emergency button will provoque sending an emergency stop message through the loconet network, and not a normal power off message like with the normal buttons.

Relays are also optional, but if you use them the isolated track section will have normal current and will switch to programming current just when needed (read or write command received from Rocrail or the program you use). So you don't need to use manual switches or to have a separated track for it.

The display is not exactly the one from the photo, sorry but I couldn't find the right one in Fritzing software, but the connection schema is correct. I'm using an standard Keypad LCD shield from DFRobot (check it here). Two of the keys of the Keypad LCD shield can be used to turn on and off the command station, so the external buttons are not necessary.

Finally, a loconet shield board (like GCA185 from Giling Computer Applications) has to be used, connected to pins 47 and 48 instead of the usual 7 and 8 when you are using an Arduino UNO.

But there is an important issue with Loconet!
Any Loconet network needs a "Loconet Terminator" and a 12V power source to work. This is always provided by the command station, but in this case we need to add this. In this page from RR-Cirkits you can find information about it. 

You can use an old ATX PC power source to supply the 12V to Loconet and build your own "Loconet Terminator".  A "Loconet Terminator" is just a 15 mA pull up constant current source to 12V.:

If you have a LocoBuffer conected to the LocoNet it has also the option to provide this pull up termination by selecting 'Term" option.

Finally there is another solution to the previous issues, this is using a GCA101 from Peter Giling. This a board that provides you 3Amp power to Loconet, so you will never run out of power to connect more and more modules, and the board has also a jumper to activate the "Loconet Terminator" already included in the board. This board also provides you the PC Loconet interface to connect you layout to Rocrail.

This is the command station mounted in a simple electricity box, but we use it in the club and has been proved reliable enough to drive trains during all week end in exhibitions with no errors:

I hope to have more free time to post other Arduino based modules I have developed. Thanks for reading!!!

Friday, March 24, 2017

Tomix Shinkansen 500系 EVA digitalization

As explained in the 500 Type Eva Project web page, "2015 marked the 40th anniversary of Sanyo Shinkansen's completion inauguration, as well as the 20th anniversary of the start of the Evangelion TV series. To celebrate this double anniversary, the Shinkansen Evangelion Project was launched in November 2015. The Sanyo Shinkansen operates a 500 TYPE EVA train, created under the supervision of Mr. Hideaki Anno, Director of Evangelion, and designed by Mr. Ikuto Yamashita, Evangelion's mechanical designer. Additionally, while on board, passengers can enjoy content with the motif of the world of Evangelion."

You can see in the following posters how amazing is the design of this 500 Type Shinkansen, taking the image of the anime's main "EVA",  a humanoid mecha:

The design of this train is not only in the outside, but also in the inside. In Car No. 1, you can enjoy four attractions: Shinkansen X Evangelion Exhibit Panels; a Photo Spot; a Diorama; and Full-size Cockpit Riding Experience, a hands-on attraction:

Car No. 2 lets you experience an interior decorated with the "EVA design.":

Kato was the first announcing this model release, but it could only be purchased in August 2016 during an train event in Japan. It was also advised that the model was using the previous 500 Type molds so it was not an exact prototype to the original one. It was only an special decoration, and the cost was 30.000Yen. Nowadays is still not possible to acquire it in regular shops, just directly to Kato through their web page.

Before Kato's release date Tomix announced they were also releasing this model, but with new molds reproducing the original in a more accurate way. Tomix model was also reproducing the first car interior and the preorder price was below Kato price.

In febrary I received the Tomix model and now is time to convert it for DCC operation. I'll be using a Doehler&Haass DH10 decoder (bought in Let's start with the motor car:

I prepare the plates applying tin to the extrem part where I plan to solder decoder and interior lighting wires. As this train has 8 cars and I don't want to install 8 decoders, interior lighting will be directly connected to the rail power. 

I have to do two small holes for the decoder motor wires. Holes are done in the place where they coincide between the two springs of the motor:

Now I solder the red and black wires of the decoder to the pick up current plates, and two extra red and black wires (the extra part I cut from decoder wires) for the interior lights:

I was thinking how to attach the motor wires to the motor plates. If I want to solder them directly I have to remove the springs and dismount completely the motor. I'm not sure to solder them to the springs, may be the spring becomes rigid and I cannot close the car.... finally I will just wrap the decoder wire in the spring and put them in place, isolating the cooper strips so they are not in contact with the springs and therefore the motor current:

I checked the car works properly. Motor wires have been rolled in the spring firmly and keep isolated, there is no short circuit. Check always with your tester that motor wires are completely isolated from pickup current before putting it on the tracks. You can check it putting your tester tips directly in decoder pads, so gray wire has no continuity with red, black and orange. And the same with the other cables.

Now the motor works, I'm preparing the interior lighting. I'm using 12V white led strips.

I solder a diode rectifier to the led strip. MB6S rectifier model has the exact width of the led strip. I also add a 2.2kOhm resistor to lower the led intensity to the level I like:

And now everything is ready. Stick the led strip to the roof and add a little piece of doble sided tape under the decoder and motor wires, so they keep in place and hidden from the outside when you close the car:

Cab car is also quite standard. To open it you have to unscrew the closest screw to the front, do not pull the hull before:

Then you need to unscrew the bogies also to release the seats board and access to the light board. Be careful to do not lose the tiny springs of the bogies, they easily "jump" and you can spend a full day trying to find it again:

For the cab car I'm using a LaisDCC decoder. The motor wires can be configured in a way you can turn them on and off with the F0 (lights) button, can switch the polarity depending on the direction and the intensity is also adjustable. This has the great advantage that you don't need to make any kind of modification to the light board. No led switching, no extra resistors..... just isolate the board and connect the motor wires (orange and gray) to it.

Decoder must be configured with CV61=68 and desired intensity in CV133 (value from 0 to 255, but I always set a value of 20).

I make 4 little holes in the seats board to pass the decoder wires to the led board:

The light board has two metallic pads that you can desolder and this isolates the board, but to make it safer add kapton tape to the pick up current metallic strips.

So motor car and one of the cab cars are ready, I'll continue with the rest of cars later:

Sunday, January 15, 2017

New header for our modules' standard

Happy New Year everybody!!! This is my first post of 2017

We are ready to publish the revision 3 of our modular norms. Remember in the top horizontal menu, under "Modules" option, you will find always all the posts and the last version of the norms once approved.

A big change in this new version refers to the header construction and shape. Our adopted header was the same from the EuroN norm:

EuroN header (ClubNCaldes v.1)

Everybody told us that the squared hole (the one on the right side) was never used. In the original EuroN norms that hole is to pass two hidden tracks to cross under the modules. But if even having the tracks in sight sometimes is difficult to adjust them, having them hidden looks like it can cause many headaches and train derailments in a zone that you cannot see and has difficult accessibility. So we decided to get rid of it and center and enlarge the existing rounded hole that we use to pass the wires and connect one module to the other, and as a handle to move the module.

At the same time one of the club members had the idea to make a reversible module, so you can flip it and interchange North and South sides with no problems. Another friend wanted to make a staging yard of 6 tracks, but having a kind of norm or guide for it and to place the tracks. In this way any staging yard module (with 6 tracks) can be joined to the one from any other club member as everything has been constructed under the same norm.

These are the reasons to design a new header, fully compatible with EuroN and our previous header norm, but having the holes to place the metallic gauge in three different positions. The two outside positions allow to place 4 tracks so that the module is symmetric and North and Sound sides are interchangeable. A center position of the gauge allows to place two extra tracks centered in the module.

ClubNCaldes header v.3 (compatible EuroN)

I will upload the last norm version soon, as it contains more detailed information and step-by-step instructions to build the different Loconet modules using Arduino.