RoseOnRails – Last week

Hi everyone,

Last week, I mainly worked on the ADC on nrf51822.
Indeed, if we want to measure the BEMF of the locomotives’ motors, we will need the ADC to convert the voltage coming from the motor into a numeral signal. I spent quite some time reading docs on nrf51822’s ADC and understanding and adapting examples. Finally, Yann and Valeh managed to have the adc work on the nrf … apparently I had forgotten to mention the reference we were to use.

As Valeh explained earlier, we had to present our project on Friday. The presentation tackled both technical and commercial points.
From a commercial point of view, we are willing to sell two main products:
1. The BLE decoders for locomotives and railway switches. This part is quite innovative as it will be the first time model trains and railway will be controlled thank to BLE and not DCC.
2. The railway portions we have equipped with controllable LEDs. TAs this product will be used in our game and will obviously not represent reality,  it is to be sold to families and children rather more than to modelists and train amateurs.

We were also able to present what e had done from a technical point of view, and what were still to be done.

Subsequently to the presentation and Alexis&Sam’s feedback, we took some decisions and realised some points were to be tackled asap:
1. Regarding the train’s position, as we have not found a specific optical sensor for the trains, and we have focused more on the hall effect sensors, we have made up our minds to use hall effect sensors only.
2. We need to start coding our game

Our programme for the next days:
1. Find a suitable way to set position references in our circuit thank to magnets. – WIP
2. Precisely design our game – WIP
3.  Install the PCBs we received in the locomotives, under the LEDs, under the railway switches – ASAP
4. Finish soldering the LEDs – As soon as the controller is installed and tested.

Electronically yours,


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.


BEMF, amplifier, H bridge, ADC and so on..

Hi all.

Tiring day, very tiring indeed! This morning: ADC, ADC, ADC. I re-read the datasheet of our STM32 board and saw some examples of code. Then I implemented my own code which… doesn’t fully work yet… but it sure will very soon 🙂

The rest of the day up until now, Gleison and I spent time thinking about the 12V DC motor in our locomotive. The more we thought and the more we raised questions and potential problems. Fortunately, we managed to find solutions to almost all of the questions we encountered. I’m not positng them here since we’re not fully sure yet. I’ll work on it again tomorrow and put some order in all we did today. We’d also like to discuss this with Alexis and Sam before going too far!

That’s about it for today!