Auto

This page last updated: 3 April 2025.

Note: all of the source files created by me for this project (Blender, C code, etc.) can be found on Github.

In late September 2024, as part of the Front Garden Railway project, it became clear that I needed a road to access the dock and, of course, that road would need vehicles to travel along it, hence I needed to create some form of automatically driven vehicle.

The vehicle would need to be able to cross over the rail bridge on the left of the picture below, navigate along the road, around the bend, all at a slope of around 20% and, somehow, return.  Scale is Gauge One, so 1/32, which happens to be the same as Scalextric.  Period is 1960.

Overview

Body Shell

I needed a body shell; many of these are available on eBay, apparently 3D printed to order by someone in Italy.  Since they are 3D printed it seemed obvious that I should 3D print my own, then I could form the fittings exactly as I wanted.  I searched Thingiverse and found Patrickart's original mini.  I imported this into Blender, scaled it to actual size in Blender, then exported it to STL scaled by 30.48 (which is what I know from the Gauge One DMU project represents 1/32 scale) and did a rough print on my Prusa MK4 FDM 3D printer to see what size it ended up.

Patrickart's mini Mini test print
                in FDM

Rather marvellously, it just fitted inside the print area of my Prusa SL1 (resin) 3D printer, which is able to print to a very fine resolution indeed.  I had the boundaries within which to work but, of course, I had a solid object when what I needed was a body and a chassis.  I spent several days crawling around inside the 130 Mbyte model, removing the windows and the wheels, separating the floor and making the resulting shell into a thickened printable object. I printed the body at maximum resolution (0.025 mm layer height) on my Prusa SL1 in Prusament Alabaster White, which took just under 5 hours:

Fuselage
Mini sliced for
                  resin printing Mini
                in printer
Fusalage printed

 

Guidance

How to guide this thing?

Bluetooth: No

My first thought was to use Bluetooth-based positioning, since mounting a BLE transceiver in a model vehicle would be easy and I'd get comms with that.  However, consulting with my work colleagues in Malmö who know about these things, the resolution would not be high enough (think centimetres).

Radar: No

Instead they pointed me in the direction of radar: a Swedish company by the name of Acconeer make a millimetre-accurate pulsed radar on-a-chip (the A121), available as an IoT module (the XM126) that also contains a Nordic nRF52 MCU (this MCU I know fairly well); an ex-colleague of mine had used this.  The advantage of this approach would be that I could use any sort of radio controlled vehicle, keeping all of the clever stuff in the controller or the back end.  I purchased an XM126 IoT module (the round part) and mounted it on Acconeer's XB122 break-out board (the square part).

Radar
          module evaluation kit

The break-out board could be plugged into a PC where Acconeer's Exploration Tool was able to drive it.  I gave it a try, and it seemed to detect largish objects with reasonable accuracy, however there were two drawbacks: the first was telling the difference between objects in the radar-path (my colleague had mentioned that this might require a lens and a path in which only my vehicle would be detected), the second was that a fair amount of averaging was required to discern an accurate distance to the object: think around a second.  I would need a smaller measurement period than that to keep my vehicle on-track at any kind of scale speed.

Hall Effect: Yes

Which led me back to the more obvious/simple solution: a pair of Hall Effect sensors that could track position against ferrous-metal rails mounted underneath the road.  I purchased two TMAG5273s, a Hall Effect sensor from Texas Instruments in a 6 pin package with an I2C interface, mounted on a break-out board by Sparkfun, and a Waveshare ESP32-S3 (a processor I know well) mini development board; I plugged all of these into a bread-board.

Hall Effect
          sensor test board

I downloaded the ESP-IDF development environment and set to writing some C code to put it all together.  In a few days I was able to create something that would read from both sensors at faster than 1 ms intervals, those readings already being averaged 32 times within each Hall Effect sensor chip.  Here is what it looked like running:
 
This seemed like a sensible approach; I might even be able to use the development boards as-is, though a dedicated PCB would be more fun.

Steering

Next I needed to design some way of steering the front wheels: I downloaded Gearotic, I hobbyists application designed to help design gears, something I'd been planning to play with in a future orrery project.  This allowed me to design a rack and pinion kind of gear train with a 30:1 reduction (source file here):

Ratios

 
In terms of motor, I found a marvellous 3 V, 6 mm diameter motor on eBay that included a planetary gear box reducing the output speed to 46 RPM, 242 RPM or 1200 RPM (I purchased the 46 RPM motors, later switching the driving motor to the 242 RPM version) which would fit vertically inside the car body.  I exported the Gearotic file to STL, imported it into Blender (source file here) and there I joined the pinion gears to the wheel gears, added a flat for the motor shaft to the motor pinion and then created a base to hold it all that will form the chassis of the vehicle.  All of the gears run on 1.5 mm x 4 mm x 1.2 mm (inner diameter x outer diameter x width) bearings from the marvellous Bearing Boys (a size I adopted throughout the design), pushed onto lengths of 1.5 mm diameter brass rod (from eBay); 3 x 14 mm, 1 x 4 mm. The uprights are designed to take an M2 tap for M2 bolts and the whole was printed in Siraya Tech Build resin which is specifically designed for hardness.

Steering portion of
                  chassis in blender First draft of
                steering printed

Note that the rack was not included at this stage: in order to give plenty of "bite" to the small-scale plastic gears I had set the tooth height factor in Gearotic to 1.5 but Gearotic would only let me do that for circular gears and not for the rack; Art said he should be able to fix this soon, then I can move on to how the rack mounts/engages with the wheels.  But anyway, it was pleasing to see it running.

 

Motor Control

The Toshiba TB6612FNG dual motor driver provided a nice neat solution: operates two DC motors entirely separately, so I can control the steering motor with one channel and the motor on the rear wheels with the other.  All 3V3 and a Sparkfun board available, it took only a short time to write an API and a driver for the chip to get it running, at least in prototype form.

Motor driver

 

Tyres/Wheels

Two types of resin (tough white and Siraya Tech Build) weren't enough: for the tyres I found that you can print in flexible resin, Prusament Flex80, with a Shore A hardness of 80.  It is really marvellous stuff, absolutely perfect for tyres at this scale; at maximum print resolution (0.025 mm layer height) I could even preserve the detail of the tread from the original model.  I separated the wheels (the front ones with a relatively deep hollow to accommodate steering) and the tyres in the model and made a glue-on hub-cap of sorts, though whether I will fit the hub-caps remains to be seen.

Tyres
Wheels
Tyre fitted Hub cap fitted

I needed a belt to drive the rear axle and I did try printing that out of the flexible resin but it turned out not to be strong enough when printed as thinly as I'd need it to be; you can see it below, still covered in talcum powder to dry out after printing.  Instead I found a small diameter O-ring that fitted the bill nicely.

Belt attempt O-ring

Experiments With Windows

Only three types of resin I hear you say?  I tried printing windows for the car in a transparent resin, something I've used before in situations where I needed a translucent result but never in a situation where I actually wanted a truly clear result.  You can see from the first picture below that, when just printed, the resin really is transparent.  However, once washed and dried (second picture), it is only translucent, the surface is roughened by the process somehow.

There are two suggestions on-line as to how to fix this: one is to sand assiduously with increasing grades of glasspaper, down to an abrasive paste at the end, the other is to cover with a clear varnish, which has the effect of filling-in the minute scratches in the surface. I tried both: the problem with sanding (third picture below) is that the surface I have is not a flat one, it is really difficult to sand/polish evenly.  The problem with varnishing (last picture below) was that it didn't seem to want to cover the surface well and, at least in my case, and at this scale, brought its own imperfections with it.  Maybe my brush was dirty and I should try dipping instead?  I also tried curing the printed object less, but that just meant that it yellowed, as you can see from the side-by-side comparison of the two methods in the last picture below.

If I'm going to put in windows I think I might be better off cutting up pieces of transparent plastic sheet.  But I'm some distance from needing windows yet.

Window still on the
                printer
After drying
Sanded
Varnished
Side
        by side

Chassis

There was a few months' break while I concentrated on the watchdog project, after which I completed the design of the chassis.  This was quite a complicated process, involving many iterations/test assemblies to get all of the dimensions correct and to fit everything in; there was not a lot of room.  As well as the steering mechanism shown above, attachment points for the front wheels/drive-bars, a rear axle with drive motor/pulleys, a mount for a CR123A battery and slots in the gear mechanism cover for sprung limit switches were added.  All of this was printed at 0.025 mm layer height in the Siraya Tech Build resin. Note: when washing/drying the prints, I made sure to get all of the resin out of the small holes and gaps, particularly the screw holes in the base that hold the cover in place (using a very large pin) and the slots where the battery contacts will go (using a narrow piece of bent spring steel, see later for more on the use of spring steel); hardened resin could otherwise block the holes.

Clearing resin
                from screw holes
Clearing resin
                from battery contact slots

The cog wheels and their cover stuck very well indeed to the print plate; I ended up using the edge of a razor blade, held carefully in a hand vice, to remove them without damaging or warping them.  IF YOU ARE GOING TO TRY THIS YOURSELF, you may print these objects with pads and supports instead, to avoid potential blood-letting; it makes no operational odds, I just preferred to take the risk to obtain a smooth surface finish.  The chassis base also stuck well but wasn't damaged by removal in the usual way with a metal spatula.

Chassis
                  mechanism Razor blade
                in holder
Blade in
                use

I test assembled the steering (noting that the design was updated after this video was taken):
 
While this wasn't to be the final version of the steering, it was sufficient to assemble this version of the vehicle; there is more to find out yet, like where to mount the hall-effect sensors, what to use as the thing they are sensing, how to fit all of the electronics into the body, etc.


The pulley on the rear axle was bottom-tapped for an M2 grub-screw (3 mm long), and the stands likewise for M2 flat-head (to keep a low profile) bolts.  I made sure the threads went all the way as the engineering resin had very little give; more likely to snap than self-tap.

Tapped Threading

Note: after initial testing (see below), the rack-end of the gear-train was re-designed (removing the largest cog), the rear support columns for the cover were moved back to make room for circuit boards and the way the bearings mount into the front wheels was improved; the assembly instructions below include these design changes but the videos are of the initial design.

The required lengths of 1.5 mm brass bar were cut and bent as follows:
Front axles
...i.e. at 22 mm along go 10 mm down and then 6 mm out to the wheel at an angle of 120 degrees, one to the left, one to the right; see the assembly pictures below for the actual thing.
The ends of the cut rods were de-burred thoroughly; the bearings are a tight fit.

Assembly (for which a charged CR123A cell was required) went as follows, noting that all bearings are, inner diameter x outer diameter x width, 1.5 mm x 4 mm x 1.2 mm:

  1. Take a front wheel (i.e. a wheel with no sticky-out bit), a front wheel disk and a bearing, place the bearing into the largish hole in the hollow at the rear of the wheel (see picture for which side is the rear) and, using whatever you happen to have to hand to protect the bearing's surface (I had a couple of 2 mm metal collars lying around), persuade the bearing to go into the hole with a hammer; once that is done, carefully push the disk in after it to hold the bearing in place, making sure the disk goes in all the way, and add the tiniest amount of cyanoacrylate adhesive, nowhere near the bearing of course, at the perimeter to be sure the disk stays put.
Front
                  wheel, bearing and diskPlace
                  bearingPersuadePersuadedEnclosed
  1. Insert the short end of a front axle into the bearing from behind and then, with the aid of a small screwdriver, push a 1.5 mm circlip onto the exposed end of the axle, leaving sufficient room behind it for the wheel to rotate freely on the bearing.
Insert
                  axleCirclipClipped
  1. Push on a tyre and repeat for the other front wheel, making the two bends as symmetrical as you can.
Add tyreTreadBoth wheels
                  tyred
  1. Clip the front axles into position so that the ends of the sticky-out bits of the body go inside the perimeter of the wheel, underneath the rim; if the angle of the bend of either axle needs adjustment for symmetry, do that [gently!] now.
Clip axle
                  into positionAxle
                  clipped-inFront
                  axles attached
  1. Push bearings onto the 12 mm lengths of brass bar, insert the lengths of bar into the cogs, push the bearings into their receiving holes in the cogs and then push these assemblies into their holes in the base, bearing side down, arranging the cogs to mesh as shown in the last picture.
Bearings on barsBars in cog
                  wheelsMeshing
  1. Push the flatted-end of the steering motor cog onto the steering motor shaft, push a bearing onto a 4 mm length of brass bar, push this assembly into the other end of the steering motor cog and then push the lot down into the steering motor mount (the cog will be a tight fit), making sure that the teeth line up, the bearing is couched fully into its receiving hole in the base and the motor pushed all the way down (12 mm stick-out), otherwise it will not fit under the roof of the vehicle.
Driving motor and
                  cogSteering cog
                  meshingSteering motor
                  inserted
  1. Hold the ends of the steering motor leads across a charged CR123A cell and check that (a) the cogs rotate and (b) the motor body does not rotate.
Running
  1. As a fit-check, put steering loops, one each, into the holes at either end of the rack and check that, when the rack is pushed up into its long slot in the middle of the cover, the heads of the loops seat into the shallow part of the slot.
Loops inLoop position
  1. Place four bearings into the horizontal and vertical slots in the steering rack mount and insert the 8 mm rods vertically and the 12 mm rods horizontally, through the bearings; if the horizontal holes have "sagged" during printing, making it difficult to fit the horizontal rods, then use a 1.6 mm drill held in a hand vice to open them up.
Bearings in
                  slotsRods in
                  bearings
  1. Take the steering loops off the rack and push them onto the ends of the front axles, place the rack down, centred, on its mount, the rack teeth engaging with the cog, and push the pillars of the steering loops back into their holes in the rack; bring the cover down into position over the lot, ensuring that the rack can move, the heads of the steering loops seat into the shallow part of the slot and the spindles fit into their receiving holes.
Rack in positionRack in positionCover on
  1. Holding the cover in place by hand, repeat the test with the CR123A cell to check that (a) the cogs still rotate and (b) the rack now moves; assuming it does, secure the cover with four M2 flat-head bolts, not tightening the front ones fully if that ends up binding the rack.
Rack moving under
                  powerCover secured
  1. Screw the 3 mm long M2 grub screw partially into the tapped hole in the rear axle pulley, loop the O-ring belt around the pulley, place this in position in the slot in the base and push the rear axle through everything; as with the horizontal rods at the front, if the hole for the axle has sagged during printing, making the axle stick, use a 1.6 mm drill held in a hand vice to open the hole up.
Grub screwO-ring around
                  pulleyAxle through
                  pulley
  1. Push a bearing onto each end of the axle and push the bearings into their receiving holes in the chassis; make sure that the axle rotates freely and is straight, then hook the O-ring out of the way, set the axle centrally (about 8 mm stick-out each end), with the pulley central in its gap, and tighten the grub-screw.
Bearings fittedCheck rotationTighten grub
                  screw
  1. With the O-ring still out of the way, push the flatted-end of the driving motor pulley onto the shaft of the driving motor, push the driving motor spindle into a bearing, push the bearing/spindle into the other end of the driving motor pulley and push the lot into the driving motor mount in the base, from the opposite end to the O-ring, trying to keep the motor leads horizontal as you do so to minimise the chance of the leads fouling the tyre of the rear wheel; unhook the O-ring when done.
Motor, pulley and
                  spindleDrive motor
                  assemblyMotor insertedWires horizontalRear axle drive
                  in position
  1. Hold the ends of the driving motor leads across a charged CR123A cell and check that (a) the axle rotates and (b) the motor body does not rotate.
Running
  1. Take both rear wheels (the ones with the sticky-out bit), push a tyre onto each, and then push the wheels, sticky-out bit facing inwards, onto either end of the rear axle until they almost touch the bearings, making sure not to let the one on the motor-side foul the leads going into the motor; though there was space for circlips on the rear wheels, I didn't use any since push-fit seemed sufficient.
Rear
                  wheels and tyresPush onto
                  axleDon't foul
                  cablesNo
                  circlip
  1. Hold the ends of the driving motor leads across a charged CR123A cell and check that (a) the belt doesn't slip, (b) the motor body doesn't turn and (c) both wheels do turn.
Check
                  rotation

Est voila, chassis assembled and fit-checked into the body:

Chassis
                    assembled Fit check

I did a quick test to see if the driving motor could actually drive the vehicle:
 
Seems the answer is "kinda": the wheels need more traction but that will come once there is a battery and some electronics weighing the vehicle down. Good enough for now; time to see if the vehicle can steer itself.

Guides

I purchased two different trial magnetic guides from eMagnets:
While I waited for some components to arrive for the vehicle itself, I arranged a test set-up for both types of guide that I could use with the bread-boarded electronics as follows:

Test setup
Neodymium magnet
                    version
Magnets on feeler
                    gauge

I ran the same program as before on the ESP32, modifying it only to output field strength readings in CSV so that I could paste them into Excel.

Initially I tested the magnetic tape by dragging the bread-board along the test set-up with string.  The results were relatively unintelligible so I simplified and instead plotted the magnetic field strength as seen by the left-hand sensor, over a 10 second period, at increasing distances from (a) the tape and then (b) the neodymium magnets; the field strengths in the graphs below are normalised in order that they can be plotted on a log scale, as that seemed to be how the strength varied with distance:

Field
                    strength with distance, tape
Field
                    strength with distance, neodymium

The readings with the tape, it being magnetically weaker, drop into the noise after about 30 mm from the sensor; the region marked in pink on the graph, where the readings at a distance of 30, 35 and 40 mm start to overlap each other.  The neodymium magnets are several orders of magnitude stronger and so present distinct/noise-free readings as far as 40 mm from the sensor, likely further (given that the noise prevails when one gets down to around 30 µTesla), that is just as far as I went.

In my rough drawing of the layout I had the road as being 110 mm across; the mini is 40 mm across, which leaves 35 mm either side, so I would like better than 30 mm certainty, however, per metre, the neodymium magnets worked out at about 20 times the price of the tape.  I could, of course, lay a central strip for the vehicle to follow, that would easily be within 30 mm of each sensor, but I feared that, should the vehicle lose track, it would be unable to recover, whereas a guide at the edge of space on either side could never be lost and could also physically stop the vehicle falling in the drink.

There was a version of the magnetic tape that had a pull of 88 gm/cm2, 25 mm wide, 1 mm thick, which I tried, however it was marked as being "anisotropic" and varied in magnetic field strength quite widely along its length.  This led me to re-check the 68 gm/cm2 tape; thankfully that did not show the same problem, however I did notice that it varied somewhat across its breadth, being stronger in the centre (1200 µTesla versus 700 µTesla).  The measurements above were more in the 700 µTesla zone, so I could gain an advantage by having the sensors/tape at the same height.  And I could use the neodymium magnets as "reinforcements" in the more critical areas, e.g. at a bend.

So I will chiefly use the 68 gm/cm2 tape for the guides.

Wiring Up

Playing with the small boards, I figured out that, with a little redesign of the mounting holes for the gear cover, I would be able to fit them all inside the body: the two Sparkfun TMAG5273 boards on top of the chassis base, either side and at just the correct height, the Sparkfun TB6612FNG dual motor driver board at the rear, above the battery, and the Waveshare ESP32-S3 board on top of the gear cover with its USB socket pointing out of the drivers' side window; no need for a dedicated PCB and the sensors get to be in the best position.

The boards were wired as below, the two rows of 0.1 inch pitch connectors in the middle used to distribute power at 3.7 to 4.2 Volts from the battery (also allowing the boards/limits-switches/motors as a unit to be unplugged from the chassis), the 3.3 Volt supply coming from the regulated output of the Waveshare ESP32-S3 board.

Wiring

Wired, top
                view
Wired-up,
                side view
Wired and
                fitted, side view
Wired and
                fitted, front angle view
Wired and
                fitted, front view

Note: the fine motor wires were just tacked into place (see first picture above) so that they could be easily detached to remove the circuit boards. The battery and limit switches were not connected yet as I was waiting for some stainless-steel-capable solder and flux to arrive, however this wiring was sufficient for a quick test.  I modified the software to give me keyboard-control over the motors through the USB interface of the ESP32-S3.

Initial Testing And Steering Re-design

Before I got anything magnetic involved, testing showed that my original steering-rack design was not going to even make it to the runway, let alone fly.  One of the front wheel rods got caught on a wire, preventing the rack from moving, and the power in that 30:1 reduction gear-train sheared off the teeth of the large driving cog.

Rack
                      failure The damaged cog

There was too much power in the steering gears; it would be preferable for the motor to stall in this situation.  The rack also wasn't held sufficiently upright and was scratching the surface of the large front cog; the whole thing was just too fragile.

I removed the large front cog, turned the rack around so that it was driven from the next gear back (gearing now 6:1) and used the freed-up space to hold the rack properly, mounting it on bearings this time.  However it turned out that 6:1 was to little gearing: there was insufficient power to move the rack; it became stuck and the teeth sheared off the cog attached to the steering motor.

Removed large cog
Rack mount
Rack mounted
Motor cog
                  shearing

There was just about enough room to move the rack forward and replace the 2:1 gear adjacent to the motor with a copy of [what was originally the middle] 3:1 gear, giving an overall ratio of 9:1, like this:

9:1 gearing

I also loosened everything up as much as I could, in particular widening the slot in the cover through which the rack runs; now that the rack was properly supported that slot was not the only thing keeping the rack upright.  And I made the cog wheels 50% thicker to spread the load.  That seemed to do the trick.
 
The quick test above had shown that the driving motor [run at full speed in that test] was a little on the slow side, so I ordered the next speed up, 242 RPM, of the same motor off eBay.  This had the advantage of being a few millimetres shorter, allowing more clearance with the rear wheel.  The same test had also suggested that the front wheels needed to turn more easily; playing with them afterwards, despite the difficulty I had hammering the bearing into the wheel, the bearing had a tendency to slip out, and the circlip could also bite into the wheel's surface.  While I waited for the faster driving motor to arrive I modified the front wheel design to hold the bearing more firmly and give the circlip more room.

Note: the assembly description above takes account of these updates.

Metalwork

I had purchased a metre of 10 mm wide, 0.15 mm thick, spring stainless-steel from eBay; this could be cut with a strong scissors.  For the limit switches I cut a 15 mm section of this into four equal strips, length-ways, aided by a hand-vice.

Spring steel
                  strip
15 mm length
Cut into four
Contacts

After initially trying standard solder/flux, which did not work at all, I purchased stainless-steel fluxed soldering wire and stainless-steel flux paste, both from eBay, which worked a treat: turn the iron up to max (in my case 450 C), tin the end of the wire, clean the area to be soldered, apply flux, heat, tin with the solder, re-heat, solder on the wire, wipe away the flux, insulate with 2.5 mm diameter heat-shrink (shrunk with a hairdryer).  I used seven-strand multicore wire in all cases: flexible so that the wires would survive being attached and reattached to the Waveshare ESP32-S3 board.

Apply flux
Tin with solder
Tinned
Solder on the wire
Wire soldered
Wipe away the
                flux
Add heat-shrink
Insulated

The limit switch contacts were then slid into their slots in the gear cover, all at once as that was the only way it would work, and the positions adjusted for easy contact when pressure was applied as it would by the rack slider, contact resistance checked with a multimeter.

Limit switch
                contacts
Fitted
Fitted and
                checked

For the battery contacts, echoing the approach above, I cut a 20 mm section of the spring stainless-steel strip in half length-ways, used the hand-vice to help me bend each in half to an angle just less than 90 degrees, soldered wires onto the inside of each contact at the bend, slid the contacts into the slots in the base on each side of the battery holder, inserted a battery and checked that contact was good.

Battery contacts
                cut
Battery contacts
                bending
Battery contacts
                bent
Soldered
Battery contacts
                inserted
Battery inserted
Battery voltage
                tested

All that remained was to wire in a switch so that I would not have to remove the battery; the battery contacts are permanently exposed through holes underneath the vehicle for charging, I needed to be able to shut off battery power to the circuit boards, which would incidentally allow me to power the boards from the USB port of the Waveshare ESP32-S3 board during development.  On Amazon, of all places, I found a switch that was just 7 x 3 x 1.4 mm; I had to buy a bag of 50 but that cost less than £10; good old Sourcing Map.  I made a mount for the switch above the driving motor so that the toggle would be accessible through the rear window of the vehicle.

Switch
Switch
                soldered-in
Switch mounted
Metalwork
                completed
Metalwork and
                wiring completed

Can She Navigate?

To be continued...


Back to Meades Family Homepage