Close
0%
0%

The modular learning car project

There are tons of arduino or raspi car kits out there but they are not very flexible. With this I want to share my learning journey

Similar projects worth following
With this project I want to share my take on a modular learning car. That can be extended to your heart's content. The car is already working but it will take some time to write everything down so stay tuned :)

The format will be a guide. I want to cover (not necessarily in this order):
- The modular carrier frame
- A power pack that will use unprotected 18650 batteries with a custom setup for protection and ouput voltage
- a custom build cam carrier with servos
- a custom build remote unit
- a setup using 2 Rapsi Zero 2 -
- "The code" written in python including usage of web sockets, multithreading
- the STL's so you can print it yourself

I am for sure not a scholar of sorts - but I have been around. So maybe you can learn a thing or another ;)

And of course I hope to get some inspiration of the community here as well

The latest itteration of the car inculdes:
- Raspi Zero 2 as central component,
- Astro PI shield for some extra sensors and the LED Matrix
- I2C controler for the servos
- L298N H Bridge as motor controler
- some Grove I2C components
- 2 Custom build 18650 based battery packs

View all 9 components

  • Drive control - the state of the machine with a state machine

    benkster08/30/2025 at 11:30 0 comments

    Finally found some time to continue.

    I added 3 instructions on my take to control the motors.
    My goal was not just simply control the motors. My aim was also to improve a bit on my python skills and make the setup as modular as possible.

    In this steps you will learn about my take on:

    • wiring up the components
    • a python class to run the L298N
    • a state machine to make the drive control more robust and understandable


    And as always - feedback and critics is always welcome

  • Build your own carrier

    benkster08/15/2025 at 14:17 0 comments

    The idea of the modular car is that you can just add pretty much any component on a breakout without much effort. No matter if you want to run on an arduino or a Raspi 5 it is easy. I added an instruction how you can build your own carrier for the grid

  • Power up without burning your house down

    benkster08/14/2025 at 20:54 0 comments

    First of all we need power for our car. I assume you have a basic understanding about Volts, Amperes, short circuits and such things ;o)

    There are different options how to power your learning car. What you need as battery is up to a couple of factors. The most important one is what kind of components you want to use.

    • Different boards require different voltage to work.
      Some Arduinos want 3,3 Volts while a Raspberry PI want's 5 or 5,1 Volts . Depending on the load you put on the board the power consumption may also vary. E.G if you drive some Neopixel LEDs over the GPIO pins this power is drawn from the boards power supply. Power consumption is measured in Watt.
      Watt = Volt x Ampere. So Ampere is the 2nd common thing you have to take an eye on. To stay with a Raspi 5 Volts and 2-3 Amperes are what you need.
    • Motors draw quite some power
      No matter if it is a servo or a DC motor both are quite power hungry. Consider not to drive them over your central board. Better supply them directly from your power source/DC converter.

    Another factor is simply what do you have at hand.

    • AA batteries are quite common so if you but enough of them in series to stack up the volts you can use them
    • Maybe you are vapping so it is pretty likely you have some 18650s lying around
    • Or you have a battery pack from a RC car with a LiPO powering it

    All good as long as you pay attention to the specs - Volts and Amps are key

    Last but not least endurance is a factor. Endurance is power used over time. So the common units for this it Watt/hours or Amp/hours. For 18650s it is usally given as mA/h e.g. 2000 mA/h. So what does it mean. Simpy said. If your setup draws 500 milli amps a 2000 mA/h battery can sustain the setup for approximately 4 hours.

    The kit I bought required 2 18650 cells so I went with those. 
    Voltage is 3,7 Volts - 2 in series (2S) will provide 7,4 Volts which you can step down to e.g. 5 Volts for a Raspi. And they can provide a pretty high peak voltage. I mean really high.  I short circuited 2 of them in my initial battery box and the wires immediately started to glow. There are some stories they will explode on short circuits but there are some test video in the net that show that they will not blow up immediately but the get really hot - really fast.

    So I thought - well this is not soooo safe if you are not careful. So I learned you either can buy the 18650 as a protected variant. But they are more expensive and a bit longer so they will not fit in most battery boxes. Another option is to to build in a battery management system BMS in your setup. BMS are available on breakout boards. A BMS breakout for the 2 batteries costs around 2-3 bugs. So definitely worth it. Add an adjustable stepdown converter and you are all set.

    A little story about my first BMS tests. I bought a pack of 5 wired the first up - not working. 2nd one - same not working. So I ended up with all 5 not working. I searched the net and found a guy that had the same experience with a pack of 20. So I thought that cannot be that they are all so bad. After searching a bit I learned that most of them use MOSFETs to protect I think for short circuits. MOSFETs need to be activated to work and when you disconnect them from the power source you need to reactivated them again. Common way to activate a BMS is to connect a charger. But there seems to be a little hack. I cannot explain how it exactly works but if you short the negative input and negative output of the BMS this will activate it as well. So I added a switch that will exactly do that after i switch batterys

    You can find my setup in the instructions.

  • The beginning

    benkster08/14/2025 at 15:58 0 comments

    The journey started a couple of years ago.  I was not yet into open source electronics and 3d printing but I always liked to play around and when learning some stuff by doing so - even better.

    I started with a kit you can buy for a couple of bugs. In my case I randomly picked this one:

    The kit included some components, some laser cut parts and had space for a Raspi 2 (back in a day... ;) ).

    Assembly was straight forward. Wiring up not too demanding. Download some python code and it basically worked - if you used it out of a python shell and streamd the cam on a separate browser window.

    But as soon as I wanted to add another sensor - I either had to drill a hole in the precut frame or just abandon the kit.
    When I got my now old 3d printer I started printing a similar frame - with predefined points to add the new parts - which was ok but really as unflexible as before.

    After some tinkering around with the printer and learning some CAD I came up with the idea to build myself a prototype carrier that should be modular and reusable.
    Behold - the first design version of my modular carrier frame:

     

    The idea is pretty straight forward. Have a predefined grid of holes (5 mm center point distance) and build little carriers to house the electronic components with some spacers on it and screw them to the grid with M3 bolts.

    As an example a Grove I2C Hub on its carrier.

    So the stage was set - to do some prototyping 

View all 4 project logs

  • 1
    How to create your own carrier

    In this instruction I will show you how to construct a simple carrier for any part you want to add on the grid. I will show case it in Fusion 360 but you can use any CAD you fancy. The approach should be the same. 

    The board I want to add is a Raspi Zero 2 W. The easiest way to start is to find a drawing with the dimensions on it. For the Zero 2 this is pretty easy:
    Zero 2 Mechanical drawing

    We are interested in the bores for mounting e.g. on spacers

    The 4 centers of the bore are on a rectangle with the dimension 23 mm x 58 mm. 
    Note: The dimension for on of the straight is measured over the symmetry line  so it is 2 times 29 mill

    So we can start with this rectangle as a construction line helper in a new sketch.

    The diameter of the spacer is usually 2,5 mm so I will go with 3 mm to add some tolerance. Add all 4 of them on the corners of the construction rectangle. I like to constraint only one circle and add an equal constraint to the other 3 in case I want to change the bore diameter

    The next step is to prepare the bores for the grid. I use M3 bolts for it so I go with 3,5mm diameter circles to add some tolerance again. The carrier grid is 5 mm between the center points of every hole. So any distance that divides by 5 evenly is good. Where you put the carrier mounts is up to your preference. I will go with a 30 mm x 40 mm for now. Using a center point rectangle for symmetry. Since I did not do a center point for the previous rectangle. It can be added pretty quickly by adding to line from one corner to the opposite one. Add parallel and equal constraint on the straight and you end up with the center point. Like this

    The next step is to shape the carrier itself -I will add a horizontal symmetry construction line where I will mirror the half later one. Here as well shape it however you like

    I ended up with something like this - maybe not the most efficient way to do it - but hey if it is stupid but it works - it is not stupid ;)

    and after mirroring

    Next is to extrude. I usually go with 3 mill

    Last step is to add some spacers so the carrier will be above the gird. This is required so you can fix e.g. the nuts of the brass spacers - like this 

    So you already know the drill - add some more circles in a new sketch - I go with 5.5 mm and of course concentric to the bore

    Extrude it 5 mm

    Ready to export it to your slicer of choice and 3d print it

    Happy tinkering!

  • 2
    Custom 18650 battery pack with adjustable output volltage

    If you want to use my design you can use the STL files over at: Modular learning car project by Benksterini | Download free STL model | Printables.com

    Warning:
    - Be careful with the 18650 cells - they pack a punch
    - Maybe obvious BUT DO NOT solder on the PLA carrier!!! ;o) 

    Parts used:
    1 - 18650 batteries on a battery box 
    2 - Voltmeter (blue digits) output voltage from buck converter
    3 - Voltmeter (orange digits) input voltage from battery box
    4 - Battery Management System (HX 2S 10A)
    5 - SPDT switch
    6 - Mini buck converter
    7 - clamps to attach e.g. a USB cable 

    Wire it up like this

    The SPDT switch is a little hack to activate the MOSFETs on the BMS without putting it on a charger after the 18650 are changed.
    -> Switch for normal operations - orange to black wire.
    -> Switch to activate after battery change - orange to orange

    Happy tinkering!

  • 3
    Drive setup - wire up the motors

    The current car I run has a dedicated motor for each of the wheels. Driving works like with a tracked vehicle - turning just means that the motors on the one side will slow down or stop. 
    The components I used are documented pretty well on the net - so there is no need here to go into the details. If you are interested in the details just search the net for the component. I will stick with the basics for understanding here only

    • L298N Motor driver 
      The motors are driven by a L298N motor driver.
      Important for the setup to understand:
      • Power supply (Input)
        The power input can range between 5 - 12 Volts ( some sources state up to 45 Volts). 
      • Power supply (Output)
        The board has a 5 Volt output that can handle up to 2 AMPs
      • Direction control
        The 2 motor outputs/directions are controlled by 4 digital PINs 
      • Motor speed
        Simply said DC motor speed is depending on the voltage the motors are running on. The L298N uses Pulse Wide Modulation (PWM) to control the output
        voltage for the motors.
    • PCA9685 servo controller
      The PCA9658 is a 16 bit 12 channel PWM Servo driver that is accessed over I2C bus.
      While a lot of boards like the Raspberry PI Zero 2 W have PWM pins on board some sources state the PWM output quality is better on the PCA9658. Having it on the car anyways to control the servos for the cam holder -  I use it to control the speed of the motors.
      Important for the setup to understand:
      • Power supply
        The PCA9685 has 2 power inputs. One to supply the logic circuit and another one to supply the attached servo motors. Both are 5 Volts for the boards I use.
      • Controller access
        The board is managed over I2C 
      • PWM
        Since the motor driver has its own power supply only the PWM pins on the output channels are used.
    • DC Motors
      In my setup the DC motors are in tandem but they are in different directions on one side. Since the direction of the motor depends on where the positive and negative input is - cross wiring the motors on every side is a simple solution to this.
    • Power Supply
      I decided to go with a separate power supply for the Controller (Raspberry PI) and the Motors
      • Raspberry PI Zero 2 requires a 5.1 Volt power input over USB connector
        I used the custom 18650 power pack explained earlier for this
      • The motors have its one 18650 power pack. Since the L298N has an onboard voltage converter there is no need for the step down converter on the power pack for the motors, But I would strongly recommend a battery management system  for the motors as well
      • IMPORTANT: To avoid signal interferences  you have to have a common ground for the setup
        In my setup I bridge the motor power supply ground with a ground pin of the Raspi

    Considering all the info's above I ended up with this wiring:

    and in real life:

    As you can see there are mount points for the motors on the bottom carrier you can find over at pintables as well 

    Happy tinkering

View all 5 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates