And the next talk, I promise I was not involved in the program committee selecting this
talk. It is about trains. And if you missed this morning, my main job is being a train
conductor. So I am very excited and I am going to give a proper departure for this talk.
All aboard!
Yeah, it will be better with the mic. So hi everyone. Thank you so much for being here today.
I am Florian. You can just call me Flo because I know English folks have some
program with the awesome. And I work for a company called Zenika, but today I will speak about something
completely unrelated with my work because I will talk about my old trains. We have a second
life so I brought them just here. And if you want to see them after, I will be at the technical
town in A.W. building. Just a quick disclaimer, I am French, which means my English can be
available from time to time. I am sorry for this. And also my daily job is not related at all
with MBD or not computing or even electronics. So I may take shortcuts, I may make mistakes.
I am sorry for this. If you find something in what I show you today, open a peer on GitHub.
It will be very welcomed. So this talk is really about a new sharing a Sunday project and you
should really take it as it. So just a bit of a story. I will speak about
actual scale trains from the late 70s. My grandfather bought them for my mother when she was
a child to play with them. And when my mother grew up, they slept for 25 years in
the 80s. Before being poor back in 2005, when I was old enough to understand the basics of
electronics and mechanism. So they are basically toys at the beginning.
And since 2000 and 11, we made a lot of improvements. We tripped the size with the new
train station. We added new structures, new buildings with likes everywhere on the table.
And we also made a big electrical update because the 2005 electrical setup was exactly the same
as the 70s one. So fire's hard and this kind of thing. So free generation of
people played with them. They are really a generational toy in the family.
What's an actual scale train? It's a toy from the 90s century. And it's basically
a train at 187 cm. So one centimeter here is like 87 cm in real life.
It became really popular in the 50s thanks to plastic manufacturing.
Two toys came very cheap to buy. So a lot of people played with them in the 50s, 60s, 70s and 80s.
It's still producing nowadays, but it's very expensive. The basic model is around 200 euros
and the most expensive one are around 600, 700 euros. So this is a budget.
And from a more technical perspective, it's just 14 volts direct runs.
It's like through the rays and it came to the wheels of the train.
And inside the train there is one lamp and one motor and that's all.
It's fully analog system. So the electrical scheme is pretty simple.
We have the power sources, a motor, a lamp and a URED.
And in 2011, sorry, we were spending in that work.
And we started to see the limits of the analog system.
To control our trains, we modulate the supplied power from minus 14 volts.
So trains are going backward. Two plus 14 volts trains are going forward.
Which means all our trains grow the same way and that approximately the same speed
depending on the motor and the weight of the train and so on.
And even on our big model table, we can't under more than three trains simultaneously,
which is such a shame because we have more than 20 trains on our collection.
So we were looking for a way to use more trains simultaneously.
The exhaust solution, we used switches to cut power to the part of the network.
So when the train arrives to a specific part of the network, he loses power.
So he stops and we press the button and he has power again and he can continue on the way.
The main premise is don't look inside the table because it's basically a bomb.
There is like five kilometers of cable inside the table.
So that's horrible when you have to find a problem in the table you don't want to do that.
So we were looking for solution and here comes the DCC.
The DCC very basically to summarize it to real quick.
It's like the PLC but for our own it.
So we send information to our trains using the power coming through the race
and we have a chip in the train to receive it and decolidate.
And with this kind of technology, we can under up to eight trains going at different speed and different directions.
So we thought to ourselves that's pretty cool we need this.
But there is a main problem, a main issue.
When you start using DCC, you must change everything.
And on 60 years old setup, it's quite a thing.
You need a specific power delivery mechanism.
So you have to change all your power delivery mechanism.
You need to change the train motor because ours are 60 years old,
so they are not adapted for this.
And you must add a control board inside each train.
The total cost was nearly 3,000 euros.
I was 14 years old, so 3,000 euros.
I was a P1, I had 3 euros, so 3,000 that's a lot.
So forget it.
Analog is good anyway.
It's just for playing.
So we forget it.
And time flies.
Oh sorry.
And of course, the market only was proprietary solution.
And I was 14 years old, so I was not aware of being able to do it by myself.
And time flies.
Until 2024, and in 2024, I was at Valcom,
a French conference taking place in Camouflen.
And I was looking at the Tireshantier Talk, called the Tiny Group Petime Costo,
in English, Tiny Group Small but Strong.
And I thought to myself, I need to put it this in my trains.
So I came back to my grandfather's house.
I stole a train, this one, just here.
And we did a similar it.
And I found there is just enough room for Raspberry Pi Pico.
And the Raspberry Pi Pico can run Stingigo.
So that's pretty cool.
So Raspberry Pi Pico is 21 per 51 millimeter chip with decent performance way enough for it.
So I ordered five of them in the W variant,
so with wireless Wi-Fi and Bluetooth support.
And I started to play with it.
The first issue was the poor supply for the Raspberry Pi,
because our trains are powered by 14 volt direct turns,
but the Raspberry Pi can only under five volts,
unless you want to fire in your train.
That's another story.
So I found the cheapest step-down conductor possible,
and I will try to do something with this.
Then I had to control the motor.
So to control the train motor, we need the PDB-Lion module.
So I took the one that everybody is using,
the other food DRV8871.
That's okay, I can control the motor.
And I wire everything.
So here is the electrical scheme, pretty simple.
The power is still coming through the raise.
It powers the step-down conductor giving power to the Raspberry Pi.
It also powers the PDB-Lion module, controlling the motor.
So everything is okay, we can start with this.
And it works until we accidentally reverse the direction of the train on the rail.
And the minus 14 volt became the plus 14 volt,
and there was some issues at this point.
So I had a fire extinguisher,
so that was a very good idea to have one.
So let's add that out to prevent this for an opening again.
The other problem I had is that when we tested it in a real condition,
we realized that the electrical network is not stable,
because the electricity has to go through a lot of parts,
raise, raise and so on, and everything in the setup is 60 years old.
So not the basic connection possible.
So the motor can undo this micro cuts.
You lost one or two RPM, but that's okay.
But the Raspberry Pi does not like it at all,
and just spend this time turning off and off and on.
So that was a kind of a problem.
So let's add the capacitor to smooth off this micro cuts.
And now it works, but it doesn't fit at all on the initial setup.
So I have to find the solution for this.
So let's modify it.
So I designed a custom PCB shield for our needs.
So the main idea was to have a card,
the same size as the Raspberry Pi,
so I can just put it on the top of the Raspberry Pi.
It took me like four weeks in kick-out because I was discovering.
So that was pretty cool and pretty intense to do.
And four weeks later, I received the PCB.
So I wear everything on it, and it really works.
We push a very simple piece of code on the Raspberry Pi,
speed at 100% and like so on.
And we have the motor ring, the lights coming up,
so everything is okay.
So now I can start to code,
and I will use obviously, thank you.
So the first question was, what does our Raspberry Pi have to under?
In fact, a very few things.
Turn the light on and off, control the motor
through the PLWM, so direction and speed,
communicate with the world.
And for the first version, that's good enough for our first version.
And my first idea is I'm coming through a cloud and web world
was to expose the rest of the Pi on each train,
and use my classic Wi-Fi communication,
my TCP-IP-Star and so on.
That was a very non-BID.
Of course, but I tested it anyway.
So it was a non-BID for multiple reasons.
First of all, there is no native Wi-Fi.
That was no native Wi-Fi on Raspberry Pi people with tangigo.
So I had to find a driver on GitHub and try something.
So that was working, but not completely.
Also Wi-Fi requires a lot of power,
which makes my capacitor insufficient.
My capacitor is one far out, so that's a giant capacitor.
And I was only able to under two seconds of the Raspberry Pi running,
so that was insufficient.
And Wi-Fi is more than 200 millisecond per command.
And as a reminder, those things cost 200 to 600 euros,
so when they collide, it's kind of a attack.
So I had to find solutions for these kinds of things.
And of course, it was a bad idea,
because it was the idea of someone who never done
and built it on bot computing.
So I was trying to do things with my old solutions
from the web and cloud world,
and it doesn't work with bot computing.
So I switched to Bluetooth BLE,
so the Bluetooth BLE is the variant of the Bluetooth protocol
designed specifically for IoT.
To resume it really quickly.
Each client expose a get server.
This server expose services,
and each service has characteristics,
and you can read and write on each characteristics.
When a server connects, connect with something.
And the latency is negligible under one millisecond
for read and write operations, so that's really cool.
And a server can connect to multiple clients,
depending on the Bluetooth antenna,
but the computer I'm using for the presentation
can connect to 10 trains before starting to have some issues.
So that's way enough for our needs.
And Bluetooth BLE is used by a lot of devices
because you're smartwatch, you're smartwatch, you're smartwatch, whatever.
Is using Bluetooth BLE.
From the technical side,
so inside the train,
you can use the native Bluetooth package from the technical.
So when we receive a write event,
we will just send the information to a channel
to handle it later.
It's just to avoid fraud luck and this kind of things.
But it's like three lines of code, so not apparently way.
And on the server side,
I'm using the guppierly library,
which enables me to connect to all devices I can found.
And store the connection in the map,
so I can use the connection later on when I need.
So the server regularly scans for maybe Bluetooth devices
every five seconds,
and connects to any client named trainberry
and something after.
So safety first, obviously.
The server exposes the website for our content,
because my grandfather is now 87 years old,
so I wasn't able to tell him,
okay, you just have to open the CLI type slash trainberry set speed.
It was not possible,
so I created a front end to use the usage.
And this setup avoids nearly all the TCP IP latency,
so that's pretty cool.
And it also allows us to have synchronization
between multiple clients.
So here is the interface, so it's in French.
We have the image of the train,
which is named button to turn on or off the light
and control the speed.
And Bluetooth BLE is the way,
because aside from latency,
removing Wi-Fi means a lot of things.
I do not need to have a dedicated router for this,
so that's pretty cool.
I do not have to manually under the TCP IP stack on the client,
which is really cool.
And I do not have to flash the train with secrets,
like the SSID, the network key and so on.
And our code is cleaner than before,
because the current code running inside the train
is less than 200 lines,
and the train can start up in less than a second,
so that's really, really cool.
I had a problem,
is my train became a zombie.
When the train loses power for more than 25 seconds,
it becomes a zombie,
because the Raspberry Pi was turning off the wireless chip,
but when the Raspberry Pi received enough power
to run again,
it will not turn on the chip again,
so that was quite a footprint,
because when the power is restored,
the train goes through photo,
and you don't have any way to stop it.
So I had to find a solution.
When this happens,
we have to reboot it,
and that's the purpose of the watchdog.
So the watchdog is using an internal plug,
which makes the board reboots,
if it does not receive any signal after eight seconds.
So we just said,
still alive got characteristic,
but every five seconds by the server.
And when we receive a message,
we update the watchdog to reset the control.
So the code is pretty simple.
At the beginning,
we just had the machine watchdog start
to make the watchdog a watchdog in.
And we just had a case in our channel,
to inform that when we receive a still alive information,
we have to reset the control of the watchdog.
And that's pretty cool.
And it works,
the video launched without me.
And it really works.
I was not able to take the table,
but you have the demonstration right here right there.
So it really works,
and that's pretty cool.
But I had to modify even more,
because here comes the,
with 85, 25 in French,
La Durezine.
And the place inside is very small,
because we have 21,
32 or 12 millimeter,
and our two are set up with the Raspberry Pi
is 21, 51 per 20 millimeters.
So I had to modify a bit.
And I found the share series from Citstudio.
It's a very small board,
18, 21 millimeters,
so that's really, really small.
And there is multiple variants on the share series,
so you have the ESP32,
we have P2040 and so on.
Unfortunately, the P2040 version
does not have wireless connectivity,
so I had to find another chip.
But the resin,
and it can fit in the resin,
so that's pretty cool.
But I had to modify everything else,
so I changed my old set down converter
to the Pulu 5V,
which is four times smaller than the previous one.
I did the same thing with the Pulu version module,
using the T86586,
also four times smaller than the original one.
And of course,
I had to go back to kick-out,
to create a new PCV,
this time I had to use the two faces of the PCV
to solder things on it,
because there was no end of room on one side.
And a few weeks later,
I was able to solder everything,
put it inside the resin,
and that's it.
And it also works,
and the video also runs without me.
And it also works.
So that's pretty cool.
And we are happy,
because it was the smallest train we had in the collection.
So if we are able to do this in the resin,
we can do it on all our trains.
So what's next?
Minifying is done,
and it was my main issue in 2025,
and our code is table and fast,
so let the fun begin.
I want to add a Bridger 2 failure
to avoid the train not pouring up,
because of polarity,
because if you remember,
I added a diode to prevent fire,
inside the train.
Now I have to put the train in the good direction on the race,
because if I put it in the wrong side,
it won't pour up at all.
So that's not usual experience for me.
I also want to add automated rice station announcements.
The train is coming,
please mine the gap between the train and the station.
So I want to add this using NFC tags and so on.
I want to add some to the trains,
because I want my trains to go through when I want,
that's something needed in this project.
I really need it.
I also want to automate the stop at the station,
using the produce NFC tags.
I want to add real-time photography.
I absolutely look through about how to do this.
So that's the plan for the late army.
And I want to add onboard camera
on the biggest train I have to be able to see the my setup,
like I was inside the train.
Also I want to use technical to control the turning points,
because currently the turning points are fully analog,
so that's a problem.
So that's also a future improvement.
I have a lot of ideas for 2022-26.
And of course everything is in open source,
and will be in open source and in open hardware.
So everything is available on GitHub.
Don't hesitate to go to go see it, use it,
make a PR that will be a real pleasure.
Thank you so much for your attention.
You have the feedback at your disposal.