NBEL RC 1.0: Part II - Computer-Aided Electrical Design

This post is preceded by the first two posts of this series:

One of the greatest challenges of computer aided design is the integrated nature of modern systems. Like the NBEL RC 1.0, modern functional systems are often comprised of mechanical, electrical and virtual (software) components.

In this post we shall elaborate on the electrical design of the NBEL RC 1.0. First, we will explore LEGO’s power function modules. Afterwards, we will describe the design of the electrical driving circuit, which drives the power functions. Finally, we will discuss the assembly of the electrical circuit in the mechanical design .

LEGO’s power functions

In the NBEL RC 1.0 we used three motors:

  • Steering motor. Implemented with LEGO’s servo motor (88004). This motor turns up to 90 degrees, clockwise and counter-clockwise (from its central vertical position), with 7 steps in each direction, resulting in a total of 15 positions. This motor delivers a maximum torque of 250 mNm, and under normal conditions, has a current consumption of ~150 mA.

  • Driving motor. Implemented with LEGO’s large motor (88003). This motor delivers a maximum torque of 45 mNm (450 mA), rotation speed of 380 rotations/minute (without load), and under normal conditions, has a current consumption of ~225 mA.

  • GoPro rotating stage. Implemented with LEGO’s medium motor (8883). This motor delivers a maximum torque of 40 mNm (300 mA), rotation speed of 380 rotations/minute (without load), and under normal conditions, has a current consumption of ~150 mA.

As a power supply we used:

  • Battery Box. Implemented with LEGO’s AA battery box (8881), which holds 6 AA batteries and delivers up to 800mA.

You can read more about LEGO’s power functions in: https://www.lego.com/en-us/themes/power-functions/element-spec.

With the Raspberry pi, we cannot drive, or supply the necessary currents for the motors (100’s mAs). We therefore need a power supply and a driving circuit that will bridge the power and the control logic.

Screen Shot 2019-01-10 at 22.50.50.png

Interfacing with LEGO’s motors

LEGO’s motors were designed to work in a Plug-and-Play setting. Here we used LEGO’s power functions’ extension wires to expose the motor’s input wires and solder them to a matching connector, which will fit the one we used on our driver circuit. Schematic of the extension wires functionality is given below.

Screen Shot 2019-01-12 at 23.19.33.png

A nice video tutorial explaining more about the details of Lego’s motors and pins specifications is available here: https://www.youtube.com/watch?v=i_4d-XsgdA0.

The driver circuit

For a driver, we used the L293D chip by Texas Instruments. You can get the L293 specifications sheet in: http://www.ti.com/lit/ds/symlink/l293.pdf. The L293 is comprised of four half H-bridges, which can be used to drive 2 motors (forward / backward), or four one-directional motors. You can read more about H-bridges here: http://www.modularcircuits.com/blog/articles/h-bridge-secrets/h-bridges-the-basics/. Briefly, using control binary inputs (1/0) (e.g. 1A (pin 2)/ 2A (pin 7)), the two motor driving pins (e.g. 1Y (pin 3) / 2Y (pin 6)) which control the direction of the motor and supply the energy are configured. The enable pin (e.g. 1-2EN (pin 1)) controls the intensity or the energy supplied to the motor.

Each driving circuit is therefore comprised of three elements: switching logic (1/0), intensity (PWM signal), and power. While the power is connected to the battery box, the switching and intensity signals are connected to the Raspberry Pi.

The switching logic value can be either high or low (1/0). The value of the motor’s intensity is encoded with PWM (Pulse Width Modulation). With PWM, the average voltage value (controlled by turning the voltage on and off at a specific rate) encodes a value between 0-100 (duty cycle). You can read more about PWM here: https://en.wikipedia.org/wiki/Pulse-width_modulation. Since we have three motors, we will use for our driver circuit two L293 chips.

Motor control logic:

  • Driving motor / rotating stage. Controlled with two logic values, which dictated the direction of rotation (backward / forward), and a PWM signal which specify the speed of rotation (silent to full speed).

  • Steering motor. Controlled with two logic values, which dictated the direction of rotation (left / right), and a PWM signal which specify the angle of rotation (0 - 90 degrees).

Screen Shot 2019-01-10 at 23.43.14.png

If we will carefully wire the circuit manually, it will look like this (full wiring schematics will be given later):

Screen Shot 2019-01-10 at 23.50.56.png

This wiring circuit is based on a:

  • PCB breadboard. Soldering board, primarily designed for rapid prototyping, enabling placements of sockets and connectors. Among them are 16-pin chip sockets for the L293 and one 16-pin connector, which will be connected to the LEGO’s motors and batter box.

  • Raspberry Pi breakout board. Here, we utilized Adafruit’s Pi t-cobbler GPIO Breakout board. See product details here: https://www.adafruit.com/product/2028. We use this board to bridge the Raspberry Pi logic and PWM signals to the L293 chips.

This manually wired circuit is based on wires and wire-wrap connections. We will not dive into the details of the tedious technique used here for the construction of the circuit, since there is a much better alternative.

All of the previously mentioned downsides, which were specified in our last post, arguing for the necessity of computer aided mechanical design are relevant here: the need for reproducibility, optimality, design value, effectiveness, examination, and utilization. It is clear that we need a better way to design the circuit.

Computer aided electrical design

The following part was designed using Autodesk Eagle. You can read more about the software here: https://www.autodesk.com/products/eagle/. Eagle is free for small size designs.

In Eagle we can define a library of devices, where each device is defined by a symbol, footprint and a 3D package. First, let’s consider footprints, a physical representation of the device and symbols, which provides a visual representation of the device for use on a schematic.

In our design we have three devices: the L293, the raspberry pi breakout board and the LEGO connector. Since the L293 is already defined in Eagle’s library, we shall define two new devices. A great tutorial listing the process for the creation of a new footprint is available here: https://www.autodesk.com/products/eagle/blog/library-basics-part-1-creating-first-package-autodesk-eagle/. A tutorial for the creation of a new symbol is given here: https://www.autodesk.com/products/eagle/blog/library-basics-part-2-creating-first-symbol-autodesk-eagle/. Once a footprint and a symbol are defined, a device can be defined by setting the connection scheme between the pins, which were specified in both. A tutorial for the creation of a device, given a footprint and a symbol, is given here: https://www.autodesk.com/products/eagle/blog/library-basics-part-3-creating-first-device-autodesk-eagle/.

Our two new devices would look like this:

Screen Shot 2019-01-11 at 15.18.02.png

Now, once we have our devices’ symbols ready, we can use Eagle’s schematic editor to define our electrical circuit:

Screen Shot 2019-01-11 at 15.26.18.png

Schematic design is comprised of two parts: device placement and routing. You can find a tutorial on the first here: https://www.autodesk.com/products/eagle/blog/schematic-basics-part-1/, and on the other here: https://www.autodesk.com/products/eagle/blog/schematic-basics-part-2-nets-and-values/.

You might notice that in this particular design:

  • Driving motor is controlled with Driver I (1-2) with a full H-Bridge configuration, where GPIO 22 and 23 control its logic, and a constant 5v input is configuring its intensity (full throttle).

  • Steering motor is controlled with Driver I (3-4) with a full H-Bridge configuration, where GPIO 20 and 21 control its logic, and GPIO 18 controls its intensity.

  • GoPro rotating stage is controlled with Driver II with a full H-Bridge configuration, where GPIO 17 and 27 control its logic, and GPIO 4 controls its intensity.

Now, we can use the schematic and the devices’ footprints to design our board. In our case, we can get the following:

Screen Shot 2019-01-12 at 17.06.43.png

Printed Circuit Boards (PCBs)

A better alternative to manually wired circuits are Printed Circuit Boards (PCBs). In PCB, pads of devices are connected with patterns of conductive tracks, made out of copper. Layers of not-intersecting patterns of copper isolated with sheets of non-conductive substrate (usually, fiberglass). Devices are soldered on top of the PCB via a ‘soldering mask’.

PCBs can be single-sided, with one copper layer, double-sided, where two copper layers laminating both sides of one substrate layer, or multi-layered. While multi-layered PCBs enable denser electrical designs, they are harder to repair and modify. Schematic of PCB structure is given below:

Screen Shot 2019-01-12 at 19.46.42.png

Given a PCB design, manufacturing can be parallelized and automated, making it reliable, cheap and fast compared to manual layout. Additional information on the basics of PCBs is available here: https://learn.sparkfun.com/tutorials/pcb-basics/all.

Eagle can be used as a CAD framework for PCBs. You can read a detailed tutorial of Eagle’s framework for PCB design here: https://learn.sparkfun.com/tutorials/using-eagle-board-layout/all. In our case, Eagle was utilized to create the following two sided PCB layout:

Screen Shot 2019-01-12 at 20.00.38.png

This design is made out of several layers, each separately defined, to support manufacturing. In our case, the layers would look like this:

Screen Shot 2019-01-12 at 20.13.32.png

This PCB layout can now be converted into a series of Gerber files. Gerber files simply specify the geometry of each of the PCB layers using simple coordinates and linear operations, and are the standard used for manufacturing. A Gerber file would look like this:

Screen Shot 2019-01-12 at 20.15.47.png

Now, we have a full PCB design. We can use Eagle to convert our design into another CAD file format: DWG. The DWG file is binary (not readable by humans), which specifies 3D design data (and metadata). Our device would look like this:

Screen Shot 2019-01-12 at 20.23.32.png

This CAD of our driver circuit is missing the electrical components. Luckily, we remember that each device we defined also contains a 3D package. While we can import the 3D package of the Raspberry Pi breakout board from the manufacturer, the packages of the L293 chips and the Lego connector should be explicitly defined. Fortunately, we can use Eagle’s 3D package editor to design our of packages:

Screen Shot 2019-01-12 at 21.36.32.png

Now, when we have the packages in-place, we can derive a full 3D CAD version of our board:

Screen Shot 2019-01-12 at 22.23.55.png

In this final step, we can use the STL model of our NBEL Rc 1.0, described in the earlier post, and align our board with its allocated space in the mechanical model. To complete the picture we imported the GoPro session and the Raspberry Pi CAD models, and aligned them with the mechanical model as well. Here we used AutoCAD Fusion 360 for the job:

Screen Shot 2019-01-12 at 22.29.32.png

This concludes our discussion of NBEL RC 1.0’s electronic circuit. In the next post, we will dive into its software. Are you hanging at the edge of your seat?

Elishai EzraComment