LED strip, turnout PCB

Long time no see, hein?

Initially we thought the LED strips would be a piece of cake, it is just a matter to weld everything together and it should work, right? NOOOOOOOOOOO, and that’s a huge no. We spent lots of time making things work. We had all sorts of problems, some with the connection itself, wires that were too fragile, strips which had tracks physically damaged. For the software, we had a problem with the SPI, which according to the LED’s datasheet was irrelevant, but it was not. For the electronics, we had two types of strips and the incompatibility between them was not documented. Nightmares, days spent to debug all the problems we had.

Consequently, our turnout PCB software PSSC had to be postponed, and worse, we had a very short deadline to code it. Well, I finished it one week ago and we have just received the PCBs, hopefully we will get them working today. The code is basic and based in an example, but I spent sometime getting familiar with the code, specially commands related to the BLE stack. Additionally, the drivers are protected from overheating by a sequential switching with a cool down sleep.


Hall sensor

Hi everyone,

To finish our schematics, we must define the model of the hall sensor we are going to use. So I have made some tests with them, and determined the best model would be the A1121. It works up to 6mm away from our neodymium magnet, making it possible to be placed under the rails. The A1122 model decreased that distance to 2mm, obviously not adequate for our project. I added a 500Ohms (the largest I had) resistor connected to the VCC, to define a voltage for the high impedance state. It works flawlessly even at speed.

The photo below illustrates the circuit I used. If you look at the oscilloscope, you can actually see two detections, one for the first magnet, and another for the second. It is achieved using its persistence function. I also tried to evaluate the effect of having the rails powered with +21V, and the results remained the same.





The problematics of the locomotive

Hi everyone

As promised in the previous post, some pieces of information about the H-Bridge: we are considering to change our initial choice of the IC A4973 to one simpler and smaller (A4953, A4950). I have not had the time to read the datasheets, but they look quite similar to an A4973, except it does not have a internal PWM. Basically, it is perfect for us.

A couple of things about the locomotive: unfortunately, there are only two white LEDs, one in the front of the locomotive and the other in the rear. That means we cannot simulate the real-life behavior (white/white, red/red, white/red, red/white). At least, it is easier to control, we could even use one GPIO high-drive mode. The following photo illustrates:

LED locomotive


Alexis is getting the library ready with the devices we are going to need. I expect to finish the design and begin the routing process soon.


Work during the past weeks

Long time no see,  huh?

Since I was generally helping Valeh with the subjects related to electronics and preparing myself for the TP/Challenge, it has been a long time anything was posted by me.  So this post will function as a recap of the previous weeks:

Firstly, we have worked with the H-Bridge, it has been extremely painful. If you don’t have a component that integrates all the drivers and sinks for the motor as well as implements a protection circuit, the job is pretty hard. We have started by positioning the drivers and the sinks, we have validated our design by running a simple simulation of our motor with the transistors. Obviously, it is not that simple.

Motors are quite nasty when you change their current quite quickly and that is basically what happens when you control it with a PWM. So you place some Schottky diodes in parallel to the transistor and it works, right? Yeah, for sure it protects your H-Bridge, but what about the noise that goes through your power supply to other devices? Worse, if you need to measure the BEMF, this voltage peak may damage your ADC.

So we have placed a RC filter in addition to a Zener diode. In this manner, the signal that goes to the ADC is smoothed and limited.  Problem: what is the cutoff frequency of the RC network, what is the amplitude of our signal in the input resistance of the ADC?

Our tests showed the resistance peak power was about 2W during the switching process. We have looked the Zener diode datasheet and a 100W non-repetitive peak power during 0.1ms is listed in its maximum ratings. That is largely sufficient, no? NOOOO!!! You can still damage your diode by creating an arc between its terminals. And our harmless 8V added to the BEMF may exceed its maximum ratings. Solution: resistance in series to limit the voltage.

Finally, Alexis has wisely pointed out that our idea for controlling the drivers and sinks poses a great danger to our circuit. If a driver and a sink from the same side are turned on simultaneously, we have just lost our transistors. We could place a NOT gate for making sure they do not go on at the same time, but all the work to downsize the H-Bridge would be lost. Well, we have decided to use a H-Bridge IC.

BEMF sensing, it seems easy, right? We just place a voltmeter between the two terminals of our motor and it is done. Try doing that with a uC …  The voltage can be either positive or negative, and the nRF ADC does not work well with that.  The measurement is differential, the nRF ADC does not support differential inputs. The maximum input voltage of the nRF ADC is 1.2V, and our motor runs with 15V. Many ideas of how to reduce the amplitude, convert it to single ended, shift the voltage to make it positive … Thanks to the documents Alexis has provided, we found an interesting solution: a resistance connected to the ground that estimates the current through the motor . If our PWM is fast enough, we take total voltage applied,  subtract from it the motor internal voltage, and we have just obtained the BEMF.

As I am currently designing the PCBs for our project, we are still working on the H-Bridge IC we have chosen. As it is quite difficult to find simple 15V rated H-Bridges, we are working with one fairly complicated (A4973). It has an internal PWM which we probably won’t use. News in the following posts.


Communication challenge

It was hard, at least I could make the sound peripheral work, but the shared data between the HTTP Client and the sound management thread didn’t work. Well, a great opportunity to learn lots of things, as well as being familiar with ChibiOS.

Driver for the turnout coils defined

For the turnout coils, I have decided I would have to check what current was necessary for it to switch. I tried to do some test with the multimeter, but due to the high current spike during the commutation and the narrow switching interval, it was not possible. No problem at all, I attacked the issue with an oscilloscope. The results and its schematics follow:




The first one is related to a no switching event, the second, to a switch.

After many days of research, asking for help to Alexis and Samuel, and hours navigation in Farnell and Radiospares, the best solution I have found was to use plain NMOS transistors with Schottky diodes. The ICs for driving relays are very expensive, don’t support enough current and come with functions our project will never use.


Work during the weekend

Hello everyone,

So my task this weekend was to conceive how we could control the railroad switches with our micro-controller. So I removed a switch from our scale model and disassembled the system used to commutate the switch. Unfortunately, the datasheet from the turnout mechanism was only designed for operation with DCC decoders. Finally, I came across a DIY website which had controlled the same mechanism. They did not give much details about their board, but at least explained how to drive the device. So I picked up a DC Power Supply and tried to replicate the results. Yeah, it worked.

After a long research about how to drive coils with transistors, I realized the following schematics:

I will still simulate the voltage spike when the transistor switches on, to decide weather or not place a Zener diode in parallel with the coil.


Task distribution

Hello everyone,

So today we have decided to organize our work to make the Monday presentation. Besides, some small alterations were made to the general objective of our project, to shape it accordingly the Parrot competition. The general idea is to implement a user friendly interface which would allow someone to play a game with the trains. In this way, we expect to attract more attention to our product.

So the main topics we are developing are: BLE implementation, speed and position sensors in the locomotive, controlling the rail road switches, how to drive the train’s motor, and of course: what objectives we should define to make it feasible.

Have a nice (work) weekend.