DIY Self Driving - Part 2. Preparations


Please Note:  Unlike most of my projects which are fully complete before they are published, this project is as much a build diary as anything else.  Whilst I am attempting to clearly document the processes, this is not a step-by-step guide, and later articles may well contradict earlier instructions.

If you decide you want to duplicate my build, please read through all the relevant articles before you start.

Last time we were discussing the challenges of building your own self-driving car (albeit at about 10% scale).  I've now moved past the daydream phase of the project and it's time to get something happening.

From this...
To this...
First handy hint, get the car up high so you can move around and work on it without bending over all the time.  I borrowed a guitar stool from one of my sons and balanced the car quite nicely on that.  A portable workbench would also do the job nicely.

I will pay tribute to the people at Lovbio, because this car really is beautifully made.  Everything is screwed together, so taking it apart was much easier than I anticipated.  I also discovered a really useful storage space under the bonnet ("hood" to my American friends).

One of the other goals I have is to re-use as much of the original wiring and components as practical.  Everything is connected with bullet or spade connectors so this should not be too difficult, and the wire gauges used seem more than adequate for the task.  This thing was built to last.


Original battery and wiring.  See space for 2nd battery and motor?
It made sense to start by working out how the motor was connected.  This turned out to be pretty straightforward.  The battery is switched on/off by the foot pedal and the motor direction is determined by a rocker switch on the dashboard.  The nice thing is that the switch was fitted into a block socket which presented all the wiring I needed in one spot.

To confirm, I pulled the switch and jumpered out the pins which I thought corresponded to "Forward", and pushed the pedal.  I was rewarded by the motor rotating the proper direction.  For future reference, I labelled the connector.


Testing the motor connector


Sorting out this little bit of wiring also made locating the motor driver module obvious.  Fit it to the kick panel near this connector.  From there its outputs go to the "Forward" pins on the motor connector.

I wanted to add a "master" switch for the motor driver.  Rather than drill a hole somewhere, I used the existing light switch (which had been bypassed for reasons I don't understand).  Turning this on now supplies power to the motor driver module, and you will be rewarded with a healthy red glow from it's power indicator.


First signs of power!
You can also see in this photo where I removed the foot pedal in order to bypass that switch without cutting things up.

Whilst pulling the wiring apart I found the lights had been hard-wired to the switched power, so they will come on automatically when the pedal is pressed.  This didn't seem too lifelike to me, so I wanted to do it better.  The first discovery was that they were tiny lilliput globes, which would have trouble competing with a candle for brightness.  Since the lamp assemblies come apart easily it's easy to replace the head and tail lamps with LEDs.

I also discovered that the assemblies already had a hole for an "indicator", which fits a 5mm LED just nicely.


Reworking the headlights
Note the much more modern appearance now
When I removed the bonnet I was happy to discover a nice shelf which ran the full width of the chassis.  This means I can mount the Raspberry Pi, regulator and control relay as well as the auxiliary battery together and out of sight.

"What's this about Auxiliary Battery?" I hear you ask?  I discovered there is a lot of noise from the electric motor on the power rails, which is not good for microprocessors.  Also, since the electrics a six-volts I will be marginal on power at the best of times, and I need the power to be stable.

My electronics don't need massive current, so I figure a small Lithium-ion pack will suffice.  A dual cell pack will give me 7.4V which I can regulate down nicely. 



The relay is driven off the master switch, so that the electronics are powered on automatically, yet kept isolated.  I haven't quite figured the shutdown part yet, but I'll get there.

Testing the electronics battery
At this point, we can start to test something useful.  Load up the "motortest.py" file from my github repo (https://github.com/au-chrismor/selfdrive) and the motor should alternate between forward and reverse direction.

**UPDATE**
I found that I had some unreliability in the motor drive controls.  I suspect this was due to the motor driver being designed for a 5V input while the Raspberry Pi is 3.3V.  In theory, this should have been OK, but in my case it was not.  I installed a level-converter between the Raspberry Pi and the driver module and things have been stable ever since.

Not bad for an afternoon's work!


Running the first update



Further Reading

Part 1 - Introduction
Part 3 - Wiring Harness
Part 4 - Steering
Part 5 - Sensors
Part 6 - Software
Part 7 - Final assembly and testing


Comments

Popular posts from this blog

Life with Deep Racer - Part 2

DIY Self-Driving - Part 9 - New Imaging

The QYT KT-7900D