Skip to main content

Posts

Layout sound on demand!

Here we go...all the sounds that you have collected over the years can now be heard from your railroad. In this article you will wire a sound playing module to a speaker and a Nano with 6 wires.   Imagine a button to announce the next train ready to leave, a light sensor noticing a stock car at the loading chute making some cattle noises, wheels squealing around a curve, or on my layout, elephants and lions in the wild! DFPlayer Mini pinout   So, save some sounds, (or “songs” called from here on), in MP3 format, onto a micro (u) SD card using your personal computer. Reading the documentation makes it a bit confusing, from: the order matters in which you drag the files to the uSD card, to: having 100 folders with each 255 sounds and commands calling which file in a folder?!? What I did was save my sound files as 001.mp3, 002.mp3 and so forth in the root folder of the drive, and had no trouble getting them to play. Remember to properly “Eject” the card using your operati...

Signal Masts in JMRI 4.14, for beginners...

Here are all the notes and files from the Plano Train Show Clinic. You need to have an internal sensor ( IMCOMPORT ) with the port in the value like COM10 or /dev/ttyUSB0 , whatever Device Manager (or /dev/ttyUSBx) shows for the connected Arduino. If you have Panels -> Script Output open, you will see the message:  !!! Please add IMCOMPORT with the port in the value!!! The basic idea here is to use the Comment in the Signal Head field to define the position of the Pixel in the string commented to the Arduino, as well as the RGB colors to show for Clear, Approach and Stop (00:00 FF 00: BBAA 00: FF 0000). With all the Heads in the Table, run the python script and now you can update the colors in the Comment "live", keeping in mind that a message is only sent when a Head changes color. We then put the Heads in Masts and use the Signal Mast Logic to do the magic. I like the original Panel Editor more and it works fine as long as you keep using Mast pairs, which require...

ESP GPIO pins...

The ESP8266 can easily be programmed with the Arduino IDE and the main benefit using it, is the WiFi interface that reduces your communication wiring to zero. A $5 Raspberry Pi Zero W with a $5 micro SD Card becomes your Access Point, DHCP Server, Gateway to the Internet, and will also run applications like JMRI and MQTT. But, now that you have a well connected $3 ESP-xx device, what pins are available to do what? We are not counting the Rx and Tx pins, you could reassign those for your own purpose, but the boot loader is going to talk at startup and updating your firmware might need these pins, so think ahead. There is some information here , but when you are writing the "Arduino" code for the ESP8266, you need a little more guidance... The ESP-01 has 2 GPIO pins, so you can do a 3 color signal, 2 relays, 2 digital sensors, or use them for i2c to a port expander and the rest is easy. The ESP-05 has none, only the RST, RXD and TXD pins...good WiFi shield, if you hav...

Not RRRduino, unless you have an MQTT connection via Ethernet or WiFi

JMRI code to connect to an MQTT broker, to publish and subscribe to the messages for signal masts. Of course, we agree to a standard for the MQTT topics, and since you were not here, we settled on "mast.xxxx" where xxxx is a number starting at zero. This MQTT topic is used as the User Name in a JMRI signal mast. Created as a Virtual Mast with the Aspect used as the payload in the message. And, yes, the device under the real mast needs to be programmed with the same name and code for each of the "aspect" payloads to be implemented. A yellow and red LED'd dwarf signal can not do a "Clear" aspect, so make sure "Clear" is maybe set to yellow for "Approach" as well.    Virtual Masts with agreed upon User Names. Comments are for the One Wire Signals on the NeoPixel string (see prior post)   Virtual Mast The Jython (or Python) code shown here below, is to attach a Listener to each Signal Mast, and to publish a message ...

Little things that go wrong...

Who has shorted the 5Vdc supply to GND on the Nano?  And now it does not even show the power LED, or it is on very dim? You simply destroyed the MBR0520 diode, labeled D1 in the " +5V Auto Selector " circuit on the board. How to fix? Either order another replacement MBR0520LT1G, 0.5A, 20V, Schottky  Diode, or promise yourself to never, ever short Vcc to GND again and solder a jumper in! Diode labeled B2 Getting less expensive Arduinos from Ebay? Well, a lot of times the USB connector is not soldered properly and you get intermittent power or data to the ATMEGA chip. How to fix? Touch all the pins up with a solder iron and flux.

The One Pin Signal System, using an Arduino

The One (RRRduino) Pin Signal System! Part I NeoPixels: Yes, you read that right, you can control a whole signal system with up to 200 lights by using a single Arduino pin. And this was not my idea, all the credit and the patent goes to my friend Tom, but since I already had something using the same technology up and running using only a Nano, I do not feel too bad telling you about it. Short video first! There is a tiny 8 pin chip out there called a WS2811 which is a three channel LED driver, and you might find them on the interweb as NeoPixel LED Driver Chips. They need power and ground, typically 5 Vdc, and data to be put in the three registers inside the chip, one for each LEDs it can control. So, in most cases out there today, the LEDs connected are Red, Green and Blue (RGB for short) and by setting the three registers each with an 8 bit value (which in English means a value from 0 to 255, since 2 8 = 256, but since 0 is an acceptable value too, the maximum is 2 8 - 1 ...

Not too important IR remote info...

Onn 4-Device Universal Remote manual... setting codes... Up Arrow TV Mode: Decoded NEC(1) : Value:20DF00FF Adrs:0 (32 bits) Raw samples(68): Gap:5484   Head: m8800  s4500  0:m550 s600     1:m500 s600            2:m500 s1700     3:m550 s550           4:m550 s600     5:m500 s600            6:m500 s600      7:m550 s550           8:m500 s1700    9:m550 s1700          10:m500 s600     11:m550 s1650          12:m550 s1700    13:m550 s1650         14:m550 s1650    15:m550 s1700          16:m500 s600     17:m500 s600       ...

Making things flash...yes LEDs!

So we have all seen the BLINK program, where we first configure the onboard LED to be an OUTPUT and then we turn the LED on, waste some time, turn the LED off and waste some time in the loop() function and then everything repeat again. So, that is really cool and 25 times faster using an Arduino, compared to 25 years ago where you had to erase the EPROM with a UV light first before you could upload the code that you tediously wrote in Assembler! And the 8051 did not have all the awesome built-in modules to simply do: Serial.begin( 300 ); // yes it was slow back then Serial.println( "Hello world" ); // and remember the extra work to do a String? // while \n and \r was needed too!!! Part I: So, back to the LED, the next question you ask is: "I have at least 17 more free pins , can they blink too?", and the answer is "Sure!". But in the current digitalWrite( 13, HIGH ); delay( 500 ); digitalWrite( 1...

Turntables...using Stepper Motors!

Maybe a little out of my league since the TxNamib Railroad does not reach far enough south to connect to Luderitz, where the last, unconnected turntable is. But a good friend Chip Romig had turntable trouble and we decided implement two manual controls for the "get it closer quicker" and then "align it perfectly, going slower, smoothly" Arduino. Of course, people who has the turntable as the main focus point , want to have better control, including sensors to align the table, but certainly has spent the time setting it up and calibrating it. And quite a number of times doing it again, which is where Chip decided to let the operator do all the alignment work himself. So here it is, the crude two center-off-toggle switch solution to move a stepper motor faster with the first toggle and then slower with the second, so you can align them by eye-sight, like I've seen them do in Durango. /* 4 inputs, pulled high internally. Clockwise, counterclock- wi...

Servos by Arduino...

Servos! How to move things around, crossing gates, cranes, switch points, pecking chickens and all other moving things. A servo is in simple terms a motor with a little feedback circuit to sense where it is, and when you tell it to go to x, the sensor will make sure that the motor keeps moving till you are there, and if it went too far, the sensor will ensure the motor moves back to the commanded position. What made a servo harder to use in the past? Well, the position you want to go to on a typical hobby or aircraft servo motor is not set by toggling a double pole double throw switch, or with a simple analog voltage, no, it decides where to move to, by measuring the width of a pulse that is sent to it on the control wire. If the pulse is 1.5 milliseconds long, the servo motor will move towards the middle of its range, in other words, if you have a servo that can rotate 180 degrees, a 1.5 ms wide pulse will send it to 90 degrees. Similarly, A 1 ms pulse will move the motor to 0 ...