ESP32-based DCC loco controller

Shdwdrgn Dec 12, 2018

  1. Simon Mitchell

    Simon Mitchell TrainBoard Member

    113
    105
    7
    I’m keen to get as much as possible on to one dedicated board. Whilst each proprietary board is cheap in isolation, add them together, and you end up with a coat in excess of a full featured DCC sound decoder...

    The normal Li-Po setup seems to be a single cell (1S), nominal 3.3v. It therefore requires a step up converter to 9.6 or 12v, and 5v for the servos etc. the batteries ideally should remain on board and be charged via the wheels or a plug. Dismantling to remove the battery for charging is highly undesirable due to the risk of damage to the model.

    Multi-cell batteries such as 3S or 4S may require balanced charging, where each individual cell has its own charging connection. So for a 3S you get a large size output +/- pair, and 3 or 4 smaller charging wires. There is some discussion that for the low rates of charging and low rates of discharge in model railways, we don’t really need balance charging...
     
  2. Simon Mitchell

    Simon Mitchell TrainBoard Member

    113
    105
    7
    Although, considering you can buy a BMS/protection board for no money, maybe we should just assume a 12v dc supply...
     
  3. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
  4. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Just wanted to post an update that I haven't forgotten about this project, but I did get sidetracked. I have a new 3D printer (Ender 3 pro) coming this week which I am very excited about! I will still get back to this board once my excitement dies down.

    Regarding the power regulators... I think most likely I will start out with the 1117 chips and design around live-rail, but as I mentioned before I plan to have the power components on a separate board which means those components can be swapped for a a different (more efficient) power board without having to scrap the whole controller board. The biggest issue with efficiency is that I need three separate voltages (12v, 5v, and 3v). To me, the best solution would be to provide regulated 12v and 5v sources from the power board (noting that a board with buck converters will probably be larger than a board with linear converters), then use a tiny 1117 on the controller board to drop the 5v source down to 3.3v for driving the ESP32. I'll do what I can but power efficiency is definitely not my forte.
     
  5. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    Depending on the ESP32 you can power it with 5V... So you may be able to drop the 3.3V unless you need it for another purpose.
     
  6. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Right, if I was using a prebuilt board with a regulator on it... This project is migrating towards using the bare chips for a minimal board footprint, so a 3.3v source is definitely a requirement.
     
    Simon Mitchell and Atani like this.
  7. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    Very interesting project. Not to be critical but the main reason the vast majority of the IoT boards use a wireless 'module' is the FCC type acceptance. 2 GHz RF board design is not trivial and (for a US product) FCC testing and compliance is an even a larger challenge. Not that your goal is a marketable product ATM but most countries also have restrictions for DIY radio spectrum usage, I.E ham radio regulations.

    It's very unlikely that the FCC (or other 'men in black', depending on your location) will knock on your door the moment you fire up the board but you may find that your home router doesn't respond while the board is runningo_O

    Bill
     
  8. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    William -- the design is based around an ESP32 chipset which already has FCC approval and plays very nicely with existing wifi equipment. Check out the group for DCCppESP32 which also uses the same family of chips to add wifi at the base station. I'm not really designing any chips from scratch here, I'm just trying to put existing products together into a new package that offers a lot of options used by modelers in multiple scales. The ESP32 series is available in raw chip form, and there is a new version that is quite a bit smaller which opens up the possibility of putting a full dual-core 32-bit processor with wifi and bluetooth on board an N-scale locomotive. There's a lot of possibilities there!
     
  9. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    When you mentioned 'bare chips' I got a little concerned, sorry if I came across too strong. Indeed, sticking to the WROOM, PICO, ect modules does ensure a better outcome. The ESP Pico is a really amazing development!
    Bill
     
  10. djulien

    djulien New Member

    1
    0
    1
    Interesting thread! Any progress or status updates? I'm wanting to do an HO dead-rail conversion using battery power and on-board ESP32, but didn't want to re-invent the wheel if it's already been solved.
     
  11. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Thanks for the reply, I'm not sure why I didn't get notified of your post but I've been out of trains for the past couple years. Unfortunately that means that no, there has been zero progress made on this project. Diving back into things again I have been building some custom boards to measure track current in each block, plus provide inputs for a number of IR LED sensors, and post that information to an MQTT server over wifi. It's definitely been giving me more experience with designing boards!

    As far as the loco controller goes... I think I dropped the idea simply because I don't have the knowledge to get sound files playing cleanly. It seems like there's a lot of interest from the deal-rail folks though just for a basic controller over wifi so maybe I'll try to pick it up again? If FCC regulation isn't a concern, I could definitely make a bit smaller board by actually using the bare ESP32 Pico D4 chip, but for a project like this it's going to be surface-mount components all the way and that raises the question of who has the gear on hand to do that kind of soldering (since I'm not really interested in trying to build something for resale). There are several dead-rail folks in my local train club, however, so it might be interesting to see if any of them would like to try testing it out.

    Coincidentally, I've also worked on some other train-related projects that could be helpful here. Geoff Bunza's code for DCC controllers works great with another board I found which allows me to directly plug in 16 small servo motors, which I'm using on my shelf layout, however I could re-use that knowledge to build a wifi-controlled servo board that could also be used with all of this.

    Regarding overall costs, I've been using a board place from China (PCBway) which only charges $5 for a batch of up to 10 boards, sized up to 4" (100mm) square, so that's pretty cheap! If I did things right, I could design the main and power boards for this controller to be a single piece but able to snap apart so they could be used in whatever configuration was needed. My plans included a DCC decoder but that could also be a snap-off board to be removed for the dead-rail folks. Definitely something to consider. I'll keep it in the back of my mind, no promises, but maybe once I get my shelf up and running I can come back to this and try generating some PCBs to see it if works.
     

Share This Page