Skip to content

Microcontroller and electronic components

Lan Sovinc edited this page Mar 9, 2019 · 3 revisions

Slowly working our way down the components, we get to the microcontroller. Here I will talk about choosing the right microcontroller for the skateboard and the remote, transmitting signal between the two, connecting front and back light, measuring battery energy level and making a custom remote control.

Table of Contents

Microcontroller and electronic components

Arduino and NRF24L01

Arduino as the microcontroller seemed quite a logical choice, considering its popularity and consequently wide selection of libraries and a lot of available documentation online. Of course the standard Arduino Uno takes up too much space, so I went with its much smaller variant, Arduino Pro Mini 5 V. I put one inside the skateboard and one inside the remote control. They send and receive data via NRF24L01+ transceiver modules.

Using 2.4 GHz radio frequency transceiver is very common for remotely controlling devices from a moderate distance. As the NRF24L01 operates on 3.3 V, I used an adapter with 3.3 V voltage regulator for supplying power to it from the Aruduino board. Fortunately the pins for interfacing the module are 5 v tolerant and the recommended capacitor for better reliability is also present on the adapter PCB. The module communicates with the microcontroller using the SPI communication protocol.

a) Skateboard microcontroller circuit

I wanted for my circuit inside the electric longboard to be able to receive data from the remote control for the throttle/break values and sending it to the FOCBOX and to receive data for front/back light control. It also had to be able to send out the information about battery voltage to the remote, to let the user know, how much energy is still left. The circuit draws 40-50 mA of currect.

Receiver Transmitter-proto

PWM for the FOCBOX and power delivery

PPM connector from the FOCBOX is used to supply the 5 V for the circuit and to receive the throttle/break PWM signal from the microcontroller. As I needed 50 Hz PWM signal (not standard frequency for Arduino PWM pins) with 1-2 ms duty cycle, I used a hardware timer on the Arduino with the help of "PWM library" to create a suiting signal (more on that in the "Software" section).

Front and back/break light toggle

Using the remote control the user is able to switch on/off 2 lights. One is a removable bright white front light used for illuminating the road in the dark and the red back light warns other road users of our presence. The second one also turns on automatically every time motor breaking is used to indicate upcoming deceleration. The LEDs are powered from the system's batteries and IRLZ44N (logic-level) N-channel MOSFETs are used as switches. There are 10 kOhm pull down resistor between gate and source pins of the transistors to prevent electrostatic voltages from turning on the MOSFET and a 220 Ohm resistors between the output pin of the microcontroller and gate pin to reduce current flow and consequently reducing oscillation on the gate pin, which could damage the MOSFET. To limit the current flow through the LEDs, I used a simple 22 Ohm 2 W resistor. It was an inefficient but easy and reliable method.

Measuring battery voltage

If we want to determine how much energy is still left in our battery, the easiest way is to measure the voltage of the battery. The values range from 4.2 V-3.3 V per cell, which adds up to 42 V-33 V for our 10 S battery pack. But Arduino can only read voltages up to 5V, so I implemented the simplest way of linear conversion, a voltage divider. It consists of 2 10 KOhhm and one 2.7 KOhm resistors. If we apply 42 V in front of the fist two resistor and connect the third one to ground, the voltage potential between the second and third resistor reaches right around 5V, so we can safely connect that point to an analog input of the Arduino.

b) Remote controller microcontroller circuit

I have seen some people online using the Nintendo Wii Nunchuk as a remote control and decided to give it a chance myself. Its compact size and ergonomic shape make it ideal for holding, and two additional buttons alongside the joystick give us enough inputs to control acceleration/deceleration, lights and cruise control. It, of course, also saved me an effort of creating the housing of the remote by myself. The circuitry inside was replaced with the Arduino, NRF24L01+, 134N3P battery charging and step up module board, some LEDs and a power switch, but the buttons and the joystick were left in. The circuit draws 40-45 mA of currect.

Transmitter Transmitter-proto

Joystick and buttons

The joystick is used to control throttle/break. It is made of two variable resistors. I only utilized the vertical one by connecting it to VCC, ground and the analog input A0.

Both "C" and "Z" buttons are simple push buttons with a pull down resistor, connected to VCC and two digital pins of the Arduino. One is used to control the lights and the other is used as a safety switch.

Indicator LEDs

I needed a way to display the voltage of the board battery pack and the connection status on the remote so I figured out, the simplest way would be to use light indicators. As "normal" THT LED diodes would hardly fit inside an enclosure that small, I got a PCB with 6 LEDs and suitable resistors.

Battery power supply and charging circuit

The remote is powered by the XXXmAh battery, connected to the 134N3P battery charging and step up module board, which is wired to the Micro USB adapter, positioned at the bottom of the remote and allows for charging. On the step up module side it is connected to the Arduino to power it. Between the 2 components I place an on/off switch, to be able to turn the remote off, but of course still be able to charge it.