Sunday, August 30, 2015

New Loconet Sound and Outputs Module with Arduino

I want to share with you the last version (v. 6.2) of the Sound and Outputs module fully compatible with Loconet. You can upload to this module as many MP3 files as you wish, and assign an output number to each one, so you can play them from your central station, throttle or software. From the software, you can set conditions to play sounds depending on locomotives, sensors, time or whatever. It has also 16 outputs that you can use for lighting, motors or any other device.

I use it to provide sound to the stations, with announces and ambient sounds. And I also control the lights of the station buildings and platforms with it. The total cost is arround 40€, much less that a Sound Director from Uhlenbrock (more than 100€) and with extra connections and extra functionality. I've used it also to automate the Faller Mine and any other place in your layout where you want to have individual sounds.

It can be used also as a Loconet Monitor to listen and view all messages travelling in your communication bus.

This is a sample of the module running:




HARDWARE


Let's begin with the needed hardware to build it:

Arduino UNO R3 compatible board

Now you can find them in ebay for less that 4 €. For more information about Arduino and how to use it, refer to the official page: www.arduino.cc

GCA185 Loconet shield for Arduino

You can purchase it from Peter Giling, myself in Spain, or isolate you own boards. See this post about the shield. The board with components can be around 13€ depending on the chosen components.



MP3 shield from elechouse

Arround 20€ and can be purchased here or ebay. Note that the shield comes prepared to communicate via software serial, but hardware serial (pins 0 and 1) is needed, so you will have to solder two pads in the bottom (everything is explained in detail in the shield manual). This shield has a jack connector for headsets, but you can better solder 4 pins to connect 3W/4Ohm speakers. You can reuse the speakers from an old computer.


There is an optional hardware that I recommend:

Sensor Shield v5

Led lights can be connected directly to the Arduino, but it's very useful to use this Sensor Shield v5 in order to have 5V and GND pins next to each signal pin (2€ in ebay):

Mosfet boards

You have to be aware also of the current limitations of arduino, which are 40mA maximum on a single output, and 200mA in total. So for bigger charges better to use MOSFET drivers. You can find them in single boards or 4 channel boards:



SOFTWARE


You will have to upload the software to Arduino. To do it, download the development software of Arduino from the offical page and install it. Then you will have to add the following library to the environment. Download the MRRWA Loconet libraries from the offical page: http://mrrwa.org/download/ clicking on "Download LocoNet library ZIP Archive".

Then, from the Arduino environment, select Sketch -> Include library -> Add ZIP library

Now get my Arduino program directly from here, and upload it to the Arduino board. If the MP3 shield is plugged, you will have to press the "SLEEP" button first in order to deactivate it, or you will not be able to communicate with the Arduino board to upload the program.


CONNECTION


Boards are plugged one on the top of order, in this order: Arduino UNO in the bottop, and on top GCA185 shield, MP3 Shield, and finally Sensor Shield v5 if you are using this one.

If you want to drive lights and use mosfets, they are connected to the sensor shield with female to female Dupont wire:


Now to feed the module, you have several option:

Feeding from Loconet DB9

My favourite is to feed it directly from the DB9 Loconet connector. I use a GCA101 Loconet booster, and using this connector it delivers an extra power line of 12V and 3Amp. 
In this case you have also two options: you can skip mounting the voltage regulator of the GCA185 board, and install both JP1 and JP2 jumper. In this way the shield will feed Arduino with 12V through the Vin pin, and will get 5V to operate from the Arduino 5V pin. In this way the internal voltage regulator of Arduino will provide power to all the shields. I normally do it in this way when only Arduino and GCA185 shield are used. But having an Mp3 on top, the consumption at maximum volume can overpass the capacity of the Arduino voltage regulator. You will notice it if playing a sound the module resets itself. So, next option is recommended.

A best option is to mount the voltage regulator components of the shield, but cutting the pin of the GCA185 board corresponding to the 5V supply. Make sure you do this, if both Arduino and GCA185 are providing 5V to the same pin, it will be a short circuit and one of them will blow up. Doing it like that, GCA185 will be feeding the MP3 shield and all boards above it, so you will have plenty of power for them.

Feeding from Loconet RJ12

Exactly as the previous option, but make sure you connect it to the Loconet T of the Intellibox command station. That's the only one connector providing 12V. The Loconet B has Railsync signal instead. Also, take care on how many modules you connect to the Loconet T. It has only 500mA (that's the reason to implement a power source in the Loconet shield), and one sound module can consume more than 250mA when playing at maximum volume.

Feeding directly Arduino UNO through the Power Jack

In this case, you don't need the voltage regulator components of the GCA185 shield. And make sure you don't put the JP1 jumper. Arduino will be feeding 12V in the Vin pin and it could cause a short circuit. Install the JP2 to feed GCA185 shield from the 5V pin of Arduino.


CONFIGURATION


The program uses LNCV to set up the module. LNCV is an invention from Uhlenbrock that emulates the CV configuration variables in decoders, but for loconet modules. The basis are the same, in each LNCV (LocoNet CV) variable, you can set a number to configure a function. Those LNCV can be set from the central station (if it is a Uhlenbrock one), or via Rocrail. There is a special configuration screen to read and write LNCV variables from modules.

The different variables and its meaning as follows:

LNCV NAME DEFAULT MEANING
0 Module Address 1 Module Address
1 Address pin 2 (J5 1) 1 Address number, setting this one the following are correlatively numbered
2 Address pin 3  (J5 2) 2 Address number
3 Address pin 4  (J5 3) 3 Address number
4 Address pin 5  (J5 4) 4 Address number
5 Address pin 6  (J5 5) 5 Address number
6 Address pin 9  (J5 6) 6 Address number
7 Address pin 10  (J5 7) 7 Address number
8 Address pin 11  (J5 8) 8 Address number
9 Address pin 12 (J6 1) 9 Address number
10 Address pin 13 (J6 2) 10 Address number
11 Address pin 14 A0 (J6 3) 11 Address number
12 Address pin 15 A1 (J6 4) 12 Address number
13 Address pin 16 A2 (J6 5) 13 Address number
14 Address pin 17 A3 (J6 6) 14 Address number
15 Address pin 18 A4 (J6 7) 15 Address number
16 Address pin 19 A5 (J6 8) 16 Address number
17 Config pin 2 (J5 1) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
18 Config pin 3  (J5 2) 4 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight,  4 Output fade, 5 Output fade inverse
19 Config pin 4  (J5 3) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
20 Config pin 5  (J5 4) 4 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight,  4 Output fade, 5 Output fade inverse
21 Config pin 6  (J5 5) 4 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight,  4 Output fade, 5 Output fade inverse
22 Config pin 9  (J5 6) 4 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight,  4 Output fade, 5 Output fade inverse
23 Config pin 10  (J5 7) 4 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight,  4 Output fade, 5 Output fade inverse
24 Config pin 11  (J5 8) 4 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight,  4 Output fade, 5 Output fade inverse
25 Config pin 12 (J6 1) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
26 Config pin 13 (J6 2) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
27 Config pin 14 A0 (J6 3) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
28 Config pin 15 A1 (J6 4) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
29 Config pin 16 A2 (J6 5) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
30 Config pin 17 A3 (J6 6) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
31 Config pin 18 A4 (J6 7) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
32 Config pin 19 A5 (J6 8) 1 0 Output inverse, 1 Output normal, 2 Output pulse thrown, 3 Output pulse straight
33 Maximum intensity 255 Maximum intensity for Outputs of type Fade (1 - 255)
34 Fade speed 10 Milliseconds to wait between each intensity step change. If we set 10 milliseconds and we have the maximum intensity (255), it will take 2550 milliseconds to turn on or off.
49 Mode Sound or Monitor 0 0 Sound (Elechouse MP3 shield), 1 Loconet serial monitor
50 Address first sound 0 Address to assign to the first sound (0 = no sound)
51 Number of sounds 0 Number of sounds (0 = no sound)
52 MP3 Volume (0 to 30) 15 Volume MP3 (0 - 30)
53 Sound Source 1 Sound Source (0=SD card, 1=SPI, 2=Udisk)
54 Output number to stop  50 Output number to stop sounds
100 Config command: 1 - Stores config, 10-Copy USB->SPI, 99 - Reset

The module number to acces to the config is 90010, and by default it has address 1 (you can change it in LNCV 0).

Note the LNCV 100 is not an address to read. It is used to send configuration commands to the module. Writing 1 in this address all configuration is stored in the internal EPROM memory, so remember to save your changes or they will be lost when you power off the Arduino.

Value 10 writen in this command LNCV 100 is used to copy all the contents from a memory stick into the internal memory of the MP3 shield. It has 8Mb of internal memory to store MP3. Seems not very much, but you can upl oad a lot of files, enough for all the announcements of a big station.

If you need any type of clarification or more detailed explanation, please feel free to comment.

I hope you use it and found it interesting enough for your layout!!

Thanks to:

MRRWA people, without they work on the loconet libraries it would have been impossible
Southern Lines Pacific and their Loconet prototype board
Peter Giling and his endless enthusiasm and his awesome electronic designs
The infinite number of pages I browsed with tutorials and instructions about arduino, mosfets, programming, electronics...

Disclaimer:

You must accept that You and You Alone are Responsible for your safety and safety of others in any project in which you engage. With this instructions I hope to enable some Arduino enthusiasts and inventors to keep experimenting and inventing, You are Responsible. You are Responsible for knowing your limitations of knowledge and experience. I test all prototypes and programs I explain, but there can be errors or mistakes, so you are Responsible for verifying its accuracy and applicability to your project. It is your responsibility to make sure that your activities comply with applicable laws and to take all safety measures applicable despite they are not here explained. I disclaim all responsibility for any resulting damage, injury, or expense. 

Wednesday, August 26, 2015

Great advances in Arduino and Loconet !!!

I'm excited to be finally writing this post! I've been for a long time working to find a way to connect Arduino to Loconet network and be able to develop my own modules to create special automations in  the layout. Now this is a reality and with great examples.

If you read the first posts about this, I started using a GCA50 board (from Giling Applications) with just the minimum components needed to act as a Loconet interface for Arduino. I was using on that time the first version of the MRRWA libraries for Arduino. Thanks to the examples included in that library programming your own module and interacting with all the components of the layout is a mere child's play. Beginning of this year a new update for the Loconet libraries was released, and now the MRRWA libraries come with even more examples.

Peter Giling took this idea of creating a Loconet shield and developed a prototype board that I tested, and from two months ago the professional boards are available. Its official name is GCA185:




In my opinion this shield and the use of an Arduino is not to replace neither the basic sensor modules nor the outputs module to manage switches (coil or servo motors). The current boards from Peter Giling for those tasks (GCA50, GCA93, GCA77, GCA136, GCA137) work perfect, are smaller, specialized in the function they develop, and not more expensive than trying to reinvent the wheel with an Arduino.

But once you cover the basic needs of a digital layout which are detecting trains and changing switches and you want to go to a "show level" and add sounds to stations and factories, manage the illumination of the layout independently from the PC software, create ambient light and storms, or whatever automation you think, an Arduino with this Loconet shield is able to do all the above and more.

Connecting your Arduino to the Loconet network, it will receive in real time the information of what is happening in the entire layout: detections from the sensors, loco functions, all instructions sent from the command station, software or throttles... But even more, it will be able also to "talk" and not just "listen" to the other components of the layout, including moving or stopping trains, changing switches, activating lights or locomotive functions... And if you add the capabilities of Arduino to use an infinite catalogue of sensors (temperature, infrared, RFID, proximity,...) and devices (wifi, bluetooth, speech engines, mp3 players, displays, keyboards,...) the possibilities of  what you can do in your layout grow in an exponential way.

If that's not yet enough, the shield includes two MOLEX connectors to make use of all "interface boards" developed by Peter Giling with the perfect hardware to detect train consumptions, reed sensors, wheel counters, relays,...

And the last but maybe the most useful feature of the shield is the possibility to feed the current for Arduino from the Loconet conectors, and you have both type of them: the standard RJ12 used by Uhlenbrock or Digitrax, and DB9. That last used by Giling boards and much more reliable and with an extra power line of 12V and 3Amp if you use a Loconet booster like GCA101. The shield also has a voltage regulator and can feed all the shields through its own voltage regulator.




I finished this week a stable version of a software for Arduino and the Loconet shield that turns it into a Sound Module (able to play stereo MP3 files assigned to standard output directions each one) plus 16 outputs for illumination or other devices. In the PWM pins is possible to adjust also the intensity and fade effect. And all is configured via LNCV mechanism like any other Uhlenbrock module, so you can configure it from the Intellibox command station or Rocrail software without requiring to upload a new program in the board or access fiscally to the module.

MP3 shield piled on the top 
MP3 and Sensor shield piled, to drive outputs for servo or leds easily


In next posts I'll be sharing my finished Arduino programs and ongoing projects, which include crazy things like using a Densha-de-Go! Playstation controller to drive trains in a digital layout, or manage ambient lights to create weather conditions.



Thanks for reading!!!

Wednesday, August 19, 2015

Tokyo Monorail Diorama




This year I went to Japan and stayed one week in Tokyo. I took the Monorail every day because my hotel was in Tennozu Isle. I used to take the monorail to Hamamatsuchô, next station from Tennozu Isle and end of the line, and there change to Yamanote Line, the circular train line in Tokyo that takes you to almost any place. It is also the best connection between Tokyo and Haneda airport, much better than Narita with the N'ex or the Limousine Bus. Also last year stayed in the same hotel (Dai-Ichi Hotel Seafort) and took the monorail daily. I really recommend you that hotel in Tokyo, it has incredible views, HUGE rooms and beds (in comparison to the rest of Japanese hotels...), the monorail station is inside the same building with lots of restaurants, convenience stores, pharmacy, and the monorail is free to catch with a Japan Rail Pass exactly as the rest of JR lines.

I was in Popondetta, a railway shop in Akihabara, and sow the display model of the monorail in N scale. I had to buy it, as I like to collect all the trains I get on during my trips to Japan. It's just a static plastic model, there is no commercial model with motor, but anyway I'm in love with it and every time I see it all my memories from Tokyo come to my mind.



My first idea was to motorize it and put it in my layout, but I realized that I would loose the interior details of one of the cars as the motor is impossible to completely hide. Other options like a hidden motor with wires to pull from it also seemed too much difficult for me. Apart from that, I didn't find a suitable place for it my layout, it would have been too anachronistic and out of its environment .

So I took my own photos, searched some more on Internet and decided to make a diorama recreating the views I had from my room of it, with a certain level of freedom.






I began with the bogies, thinking it would be an easy start. But I couldn't be more wrong. Each bogie has 24 pieces and most of them have to be glued. Some of them are so tiny that it is mandatory to use thin tweezers. There are 6 cars, 2 bogies per car... 288 pieces!!!!




But bogies are functional and slide in a very smooth way though the beam.



I made my best to paint bogies also realistic: primmer, black wheels, metallized chassis, ... but you can save all this work, because it will never be seen!!!!!!! Bogies stay hidden inside the skirts....



Then I continued with the seats, hopping not to to have more than one piece and having just to paint it.... error again!!!! The almost invisible seats come with no armrests which have to be glued and are even smaller than the smallest part of the bogies... AND THERE ARE A LOT OF SEATS!!!!!

Instructions are not very prolific... enough to mount it but not for the painting schema. But taking a look to my own photos I painted them red, steel for the armrest supports and handles, and beige simulating the textile cases they have nowadays (the red you see in the photos is mistaken due to the tone the camera took).




Next step was the skirts. I wanted a metallized look, but weathered with the mud they actually have.





Illumination was a bit difficult for me. The standard led strips, those you can cut in groups of 3 led, don't fit the length of the cars, so I built my own strip, just one with the length of all the cars with all the led soldered on it. It's also a good way to keep all cars attached to each other. I attached the led strip to the interior roof with double sided tape before closing them with the floor and seats. I preferred to use sunny white led, like old lights. Wires run through a hole in the pillar.



Also inside the car I glued some people, just cheap figures bought in ebay. May be 100 N scale people costs something like 10€ or less. Quality is awful, but inside the cars you can't see the details and it isn't worth to waste more money in good figures to put there.



This warm light also adds contrast with the planned cold light of the street lamps. The diorama will have a road in the back, a wide side walk done with Evergreen textured sheet and small angles, and the water of the the canal as I was able to see every day in Tokyo from my room window.



It was the first time for me simulating water, so following some tutorials, I painted the base in blue tones and added Vallejo Water Efects product. I thought it was possible to recreate calm water with it, but it's specially intended for brave waters and for calm waters there is another special product. Anyway, now I'm happy of the result and I would do it again in the same way, despite Tokyo bay water is normally calm.



Vallejo Water Effect just applied

Two hours later starts to dry and become transparent

Completely dry

And finally, added some details like a hot potatoes stand, guard rails and road fences from a Kato kit, people, cars, painted in white the water scum... Here there are some final photos, even though in the future I will probably add some more people and scenic details because I see it too empty of life. Also a methacrylate case and a backdrop would be cool...















Friday, August 7, 2015

DE10 DCC conversion

Today I tried for secod time to digitalize my Kato DE10 Cold Region version. Firs attempt ended up in a burned decoder, and I put again all the pieces inside of the box and forgot it for a while. I also tried to find a compatible replacement board to easily convert it to DCC, but the ones I found need to sand down a little bit the big lead blocks, and it means you have to unmount them. Too much work....

This time, the attempt was successful. Remove the top frame un-clipping it and pulling upwards. Take care, because the small black footbridge around the engine and the white handrails are not part of this piece. You also have to un-clip and pull up to take out that part after shell is removed.



Then you have to pull out the clips that connect the board with the motor, and finally the board can be removed. This board takes the current from the lead blocks and feeds the motor and the lights. The SMD component in the middle is a 500Ohm resistor, and the one in a lateral a condenser that you don't need to remove. It will not interfere with the motor current, is just to avoid lights to tilt. 



Cut the board as it is shown in the photo, the middle part will be discarded and in its place I will fit the decoder. I selected a D&H DH10, it's the exact size as the removed board section.



Here you can see how the parts of the board containing the led will be installed again in the same place:




Now you have to isolate the current pick up cooper strips of the motor. In the side of the following photo (where the cooper strip appears from the bottom) I inserted a little piece of styrene to keep the strip separated from the lead chassis. In the other side, you just need to cut the strip so it doesn't arrive to touch the frame.



Now time to prepare one of the side parts of the board (the one containing the SMD condenser). It will end in three parallel tracks.Scratch a little fit the surface of each of the three tracks enough to see the cooper and tin it. The two exterior tracks will be the current pick up for the decoder, and on the centre track solder a 500Ohm SMD resistor and the wire to feed the lamp. In this way, the led will take the positive directly from the current pick up plates and you will feed the negative from the decoder output:



I recommend you to test each single step you do. Don't wait to finish all the work, put the locomotive on the tracks and burn it as I did the first time.... So I connected just the motor wires to my ESU decoder tester, and feed the previos board directly from the track with a crocodile clamps.



Engine was working ok, light ok, ..... let's go for the other board! Just a little bit more difficult. Left current pick up plate must be isolated (I use Kapton tape). The other, must be linked to the contiguous track to feed the positive part of the led. You can see in the photo also where to solder the function output wire from the decoder. Add a 500Ohm resistor also in between.

 


Finally, solder the motor wires to the motor cooper strips, and it's ready to test on track.


And the job is done!!!!! Close the shell, and run it!!!





Final test run video!!!!