DERULER PCB Ruler Rendered Front
DERULER PCB Ruler Rendered Back

Content on this page

  1. Introduction
  2. Included parts
  3. Before starting
  4. Soldering the components
  5. Programming the microcontroller
  6. Further exploration

Additional content

  1. Components
  2. Circuit review

1 Introduction

Hello and welcome to the DERULER project documentation. This collaboration between der8auer, ElmorLabs and PCBWay is intended to introduce you to the world of electrical engineering through soldering, circuit design and programming. The package contains everything to get you started except for soldering equipment and a computer. We hope you will enjoy this experience and proceed to make your own electronics project at some point. If you need help with anything feel free to check out the dedicated ElmorLabs forum section or Discord. The code examples provided by us are written in C but there are also examples in RUST written by whiteshark if you wish to explore a more modern coding language and other IDE’s.

2 Included parts

The project comes with the printed circuit board (PCB) ruler, electrical components for soldering to it (listed separately), USB programmer and programming cable.

Item descriptionQuantityPicture
DERULER electrical components (Box 2-6)DERULER open #2
ST-Link V2 USB Programmer (Box 1)1
Programming Cable IDC 2×5 pin (Box 1)1

3 Before starting

The first thing you need to do is to learn to identify the items in the package and their purpose. The table above lists the general included parts. A detailed list of the circuit board components is available here. Next make sure that you have the soldering equipment necessary to proceed. If you’re new to soldering check out the detailed instructions on soldering. It can also be helpful to have a DMM (digital multimeter) available for checking connections and debugging the circuit in case something isn’t working.

3.1 Required equipment

3.2 Useful equipment

4 Soldering the components

Interactive HTML BOM plugin for KiCad

Update 2022-02-28: There is now an online interactive bill of materials (BOM) available made possible by the Interactive HTML BOM plugin for KiCad. This helps greatly to see which component should be placed where without needing to download the full project files and software.

4.1 Practice

Soldering challenge footprints on the PCB ruler

On the PCB ruler board we’ve included different sized resistor footprints (positions for soldering components) together with matching resistors (in box 6) for practicing your soldering skills. They are not connected to anything else in the circuit and will not affect the functionality if they are damaged. Start with the largest size resistor (2512) and keep going down in size and increased difficulty. Even professionals will struggle with the 0201 size! More details on footprints are available on the Components page.

Soldering challenge completed!

4.2 Solder the voltage regulator and battery connector (optional)

Battery and voltage regulator components

The project can be powered using the included USB programmer. However if you wish to power it using a 9V battery you should start with soldering the voltage regulator (U1), its decoupling capacitors (C2, C3) and the 9V battery cable. By starting with these components only, you won’t damage the other components in case there’s any issue. After soldering these parts and connecting a 9V battery, you can measure the output using a multimeter. Place the positive lead (usually red) on the output of the regulator and the negative lead (usually black) on a ground point, for example the battery cable negative (-) soldering point. If you measure 3.3V (+/- 0.1V) it means the voltage regulator is working properly. The voltage regulator is not powering the rest of the circuit by default. To use it to power the microcontroller circuit, you need to short the JP1 solder jumper pads by soldering them together. Important: Make sure to disconnect the battery before continuing with the soldering.

4.3 Solder the components

Microcontroller components

Start by soldering the components that are required for the microcontroller to operate and accept programming. These include U2 (microcontroller), R1 (BOOT0 pull-down resistor), C1 (10uF bulk capacitor), C4 (0.1uF NRST decoupling), C5, C6, C7 (0.1uF VDD decoupling) and J1 (programming header). After soldering these components you can connect the programmer to the project and test if the connection works (see section 5.2).

Input and output components

Note: Box 4 – Resistors incorrectly labels R2 and R3 which have their values switched. R2 is 15 ohm and R3 is 56 ohm.

After verifying the soldering was successful and the connection works, you can continue soldering the input and output components in our circuit. These are D1 (RGB LED), R2, R3, R4 (LED current limit resistors), BZ1 (magnetic buzzer), Q1 (buzzer drive transistor), R5 (transistor base current limit resistor), D2 (buzzer snubber diode), C8 (power decoupling capacitor), BUTTON1, BUTTON2 (push buttons). Note that R2 and R4 are the 15 ohm resistors for green and blue LEDs. R3 is the 56 ohm resistor for the red LED. After successfully soldering these parts to the board you can proceed with programming the microcontroller.

There’s an additional J2 header near the microcontroller which can be used for communicating with external devices such as sensors and Arduino, Raspberry Pi or EVC2 using I2C or UART. This header is not strictly necessary but you can solder it to the board if you want to explore further examples or applications.

5 Programming the microcontroller

5.1 Download the IDE and example project

In order to write code and easily upload it to the microcontroller we need to install an IDE (integrated development environment). It’s a package that contains a project manager, coding editor and debug functionality including any drivers we may need. Luckily ST provides their own STM32CubeIDE for free to use with their products. Note that it requires registration before you can download it. The example projects can be downloaded from Github.

5.2 Install the software

STM32CubeIDE installer

Extract the example project and setup executable from the compressed archives and proceed by running the STM32CubeIDE installation wizard. After completing the necessary steps you should be able to launch the IDE and be prompted to select a workspace directory. It’s recommended to check to always use the selected location and not to ask again for convenience.

5.2 Import the example project

STM32CubeIDE welcome screen

From the welcome screen, select “Import project” and browse to the the extracted DERULER-EXAMPLE-GPIO-master project folder (containing .settings, Core, Debug and Drivers subfolders).

Select the project folder

The project should be detected as an Eclipse project and allow you to press “Finish” to complete the import.

Project import wizard

The project will now show up in the Project Explorer view. Proceed to open the file Core\Src\main.c which is the starting point of our application. At the top is a comment section describing what the example does in detail.

5.3 Connect the programmer

Programming cable connection

Before continuing with uploading the code to the board, make sure the ST-Link is connected to the PC and the IDC cable is attached between the ST-Link and the DERULER circuit board. See the sample picture above and note the position of the red wire indicating pin #1.

5.4 Compile and run the code

Launching debug

The final step consists of compiling and uploading code to the microcontroller. By pressing the debug button (green bug icon) the code will be compiled, uploaded and a debugging session will be launched. When asked to switch to the debugging view agree, and the code will be stopped at the first line of the main function (HAL_Init function). From here you can choose to keep running the code or step through line by line for debugging. Press the Resume button (green play icon) to keep running the code without stopping.

Step by step debugging

If the DERULER circuit board has been correctly soldered and connected, the LED will now light up with red color. By pressing either BUTTON1 or BUTTON2 the color will change between red, green and blue. If everything is working as expected, congratulations on successfully completing your first DERULER project!

6 Further exploration

After completing the steps to get started you may want to further explore what you can do with this project and learn to write your own code for microcontrollers. We encourage you to create your own DERULER project and share it on Github and our forums or Discord!

6.1 Additional project examples

6.2 Github repositories

6.2 RUST examples and Visual Studio Code

If you’re interested in further examples and coding in RUST and using Visual Studio Code, please check out the repository created by whiteshark.