Mark Baker Build Log


PCBs ordered, now another 5 week wait!!!


Train logic boards have arrived with the same ground flood fill issue. Fixed before populating the board. Microscopes are worth their weight in gold sometimes.

The BR Class 37 loco has plenty of space in it but the motor is a bit weird so may have to dig go down the line of 3d printing a holder for a CD drive motor.


Looks good Mark! And good job fixing that ground plane. That would have had me stumped.


Thanks.I did say there was lots of swearing involved. This does mean that anyone using an atmega328P-au chip, the autorouter and ground flood fill will not have pin 21 connected to ground. Maybe also not pin 3 and 5 as well. Worth remembering.

OK. The train motor has a spider style pickup straight onto the commutator so is going to involve insulting the brush spring and soldering wires where the spring pushes the brushes onto the commutator. Fiddly but should work.

Basic, basic blunder on the board but not one that matters and I will just leave off a couple of LEDs which were only there to provide status feedback. Putting LEDs on an input only pin is a tadge stupid, especially one day after ordering replacement boards.

“A layout is only completed 1 hour after the final order of boards has been made”. I see other peoples bodge wires with much more sympathy these days.


Train logic board respun.


Various mistakes fixed In fact quite a few but it is not until you have a completed board in your hand that the omissions become easier to see. The fit in the train chassis is snug without being tight which is perfect.

The ground plane is back but with some tweaks so there are no isolated islands anymore (thanks to video from Chris). I will not order until I have played with the version 1 board for a while to see what else may need to be added/changed.

I am also going to start on a word document which details the boards, circuit and intended use. Document early and often as it can help forming ideas and provide a record for reference.


The more I look at the power board the more pointless it seems to roll my own. Rather than a super-cap wireless charging of a lipo using a standard protection circuit and 3,7 to 12v boost for the H bridge and tapping off 5v for the logic is cheap, quick and should work.

Just park the train over a charge area at the station, crossing or passing point. The drive current for the train is only about 300ma so a reasonable lipo would give many hours per charge,


I always like the idea of creating a final datasheet for the product you’re building. Obviously you don’t need to sell it at the end of the task, but it’s good to have an expected amount of specifications in terms of current draw, dimensions, features, etc.


This is smart. You can always respin later when you run into other problems. I have been trying to switch my thinking to “buy then build” for this reason. If you have a proof of concept working, you’ll have a much better idea if/when you need to build int the future.


Choices, choices, choices. Changing horses midstream is almost always a mistake… Getting one thing working properly and progressing from there incrementally is always better… Except I have a very nice atmega128-16AU based development board that just - works. It was not cheap and is loaded with more peripherals that you could shake a stick at…

Ok back to waiting for the new PCBs, and using atmel studio 6.2 to cobble together modbusRTU master routines.

Power board is probably going to be home grown based on the BQ24091DGQT. A nice simple circuit and makes me feel happier than using a 2 USD Chinese board feeding a large lipo (ie a small bomb). Maybe cheaping out on this area would be a mistake.


Yeah, LiIon stuff should be taken with care. Buying parts with built in temp monitors and low voltage protections is usually worth the extra money, at least in low volume projects. And that’s before even looking at the charging circuit. We’re benefiting from this technology being everywhere, the parts have dropped in price dramatically.


After everything I said I pulled a lipo charging board from my parts bin and a spare, new lipo battery and did the deed. Everything runs cool and at the moment I am getting 80% capacity. Maybe this is the fact the battery has a protection circuit on board as well as the charger. Or maybe the programmable load need to be set at a lower discharge current to squeeze out the remaining juice better, time to play.

I have changed the programming resister to 1/3C charge and will take out the fixed value ‘thermister’ and put in a real one bonded to the battery. The datasheets clearly say a fixed resister is ok but thermal protection is just common sense. This is also easy to test as well to increase the ‘comfort factor’.

Next a few cycles using the wireless charger to see how long a full charge will take but no surprises are expected. I still have to wait for the better sized batteries to arrive and the charge chip that can go on an OSH-Park $5 board as it is so small.

Whichever board gets used there will be a usb socket which will be accessible from underneath the train. That will get things started whilst I try and ‘blend’ in a charge coil into the landscape.

Modbus. I have just noticed that my programmable load is modbus enabled so I have a known good PLC to point to. It provides very detailed information of what is available over modbus, how to calculate the CRC, a ‘Complete Command Frame Analysis’, etc. This is going to be very useful indeed.


Luckily the 'MODBUS APPLICATION PROTOCOL SPECIFICATION ’ is nicely written with loads of clear examples. Reverse engineering someone else’s modbus arduino code is just getting messy. I am not sure what it is written in anyway. So it is back to basics and implementing everything in the RFC, in the most simple and generic way possible. This is where modbus being at level 7 of the OSI model makes life so much easier. Just another application…


Is that MODBUS spec somewhere public?


I did a search for modbus RFC and got:-


A code skeleton written for a modbus PLC and an atmega128 is in place. So the ideas are there but the new PCBs are on their way and the components so a PLC is going to be built and mounted in an enclosure before the 128 code is converted in sections into that for the 328. I will use a modified 9 pin D female connector on the enclosure which will not accept an rs232 cable.

My programmable load uses modbus via a 9 pin D connector, rs232 but TTL level. They warn against connecting a real rs232 cable as it would damage the interface. My experience and knowledge is rudimentary but I really think that is crap. Make connectors physically unique as if there is a way to blow something up people will find it and it will not be there fault.


Yeah, I’d be surprised if the cable would damage anything. Perhaps they’re assuming by putting a blanket ban on those cables, it’ll also prevent people from plugging in something that has a higher voltage (actual RS232) on the other end?



Completely unexciting battery management board. I only decided to produce one as the pcb costs are just over 1 USD each. Total cost with chip is about 3 USD per board . The advantage of this implementation is I am using a thermister which will be thermal paste stuck onto the lipo.

Input will be from the inductive charger which works fine. I might add a surface mount micro usb socket though that is probably best left to v2 of the board. It could also be mounted on the back which will another KiCad exercise.


Technically there is no such thing, it’s either RS232 or it’s not. The RS232 standard defines the physical interface including voltage levels. A mark (1) is transmitted as -5V to -15V while a space (0) is transmitted as +5V to +15V. Not very compatible with TTL or CMOS. These days serial ports are derived directly from pins on the SoC which is likely running at 3.3V and therefore may not be too happy with +/-15V signals on it’s pins. You may be using the same connector, maybe even the same pinout, but it’s not RS232. Technically it’s not even TTL.

Of course using a “real” RS232 cable is not going to cause any problems unless the other end is connected to a “real” RS232 port. Another thing to keep in mind with regards to a “real” RS232 cable is that sometimes they have the loopback handshaking signals, which simply shorts some of the pins together, while others are “null modem” cables meaning some wires are crossed from one end to the other. So if you use other pins on the DE-9 for other signals you might want to check your RS232 cable.


My point here is they have a D type 9 pin connector on the rear of the instrument which it would be really easy for someone to assume is RS232. Above and below this load is a PSU and DMM both of which have real RS232 interfaces on them. The instrument is supplied with comm software but no adapters. It would be very easy to make a mistake and plug in an RS232 cable from a PC.

The manual (not provided but downloadable from their website) details the precautions necessary and the part number for the special adapter sold separately. My criticism is they should have used a modified socket unable to take a normal 9 pin D type plug to prevent mistakes being made.

In my case I am using the 9pin D type as it is robust, and cheap. I am making my own cables which will be modified to fit my modified sockets. Standard RS232 will not fit, the documentation will provide details but it will not be possible to break anything anyway.


Which is pin 1?

I suspect bottom left but there is no dimple, dot or cutout. I guess the line gives it away but before I go any further being certain would be good. Thanks.