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:

MATERIAL LIST


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).


MOUNTING


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:

https://github.com/ClubNCaldes/SVLoco8ServoRelay


CONNECTIONS


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


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!!!