2021 PROJECTS

In this post, I will cover some projects I have worked on over the last few months and some projects I have planned for the future.

Bipedal Robot


I am currently busy building a bipedal robot based on this Instructables post by K.Biagini. I used his design as a foundation and added additional components and functionality (such as arms and a Piezo for sound).

I had to modify his 3D models to achieve what I wanted. Here are links to download my modified 3d Models:
– Body Extension (to fit in the extra components) – Link
– Modified Head – Link
– Arms – Link

Here is a list of all the electronic components used:
– 1x Arduino Nano
– 6x micro servos
– 2 x push buttons
– 1x mini toggle switch
– 1x 9v Battery
– 1x ultrasonic sensor (HC-SR04)
– 1x RGB LED
– 1x Piezo

These components are connected as follows:

Pinout configuration of Arduino Nano:

Pin NumberConnected Hardware
2Ultrasonic Sensor Echo Pin
3RGB LED Red Pin
4Push Button 1
5RGB LED Green Pin
6RGB LED Blue Pin
7Push Button 2
8Servo Signal Pin (Right Hip)
9Servo Signal Pin (Right Ankle)
10Servo Signal Pin (Left Hip)
11Piezo
12Servo Signal Pin (Left Ankle)
13Ultrasonic Sensor Trigger Pin
14 (A0)Servo Signal Pin (Left Arm)
15 (A1)Servo Signal Pin (Right Arm)

This is still an in-progress project and is not done, Especially from a coding perspective on the Arduino, but once I have completed this project, I will create a post containing the complete source code.

Rotary Control

I needed a rotary control for another project discussed below, so I decided to build one as per this Post on the Prusa Printers blog. It is based on an Arduino Pro Micro and uses Rotary Encoder Module.

I modified the code available on the Prusa blog to mimic keyboard WASD inputs. Turning the dial left and right will input A and D, respectively. Pressing in the dial control push button will switch to up and down inputs, thus turning the dial left and right will input W and S.
Here is the modified code (Based on Prusa Printers blog post code):

#include <ClickEncoder.h>
#include <TimerOne.h>
#include <HID-Project.h>

#define ENCODER_CLK A0 
#define ENCODER_DT A1
#define ENCODER_SW A2

ClickEncoder *encoder; // variable representing the rotary encoder
int16_t last, value; // variables for current and last rotation value
bool upDown = false;
void timerIsr() {
  encoder->service();
}

void setup() {
  Serial.begin(9600); // Opens the serial connection
  Keyboard.begin();
  encoder = new ClickEncoder(ENCODER_DT, ENCODER_CLK, ENCODER_SW); 

  Timer1.initialize(1000); // Initializes the timer
  Timer1.attachInterrupt(timerIsr); 
  last = -1;
} 

void loop() {  
  value += encoder->getValue();

  if (value != last) { 
    if (upDown)
    {
    if(last<value) // Detecting the direction of rotation
        Keyboard.write('s');
      else
        Keyboard.write('w');
    }
    else
    {
      if(last<value) // Detecting the direction of rotation
        Keyboard.write('d');
      else
        Keyboard.write('a');
    }
    last = value; 
    Serial.print("Encoder Value: "); 
    Serial.println(value);
  }

  // This next part handles the rotary encoder BUTTON
  ClickEncoder::Button b = encoder->getButton(); 
  if (b != ClickEncoder::Open) {
    switch (b) {
      case ClickEncoder::Clicked: 
        upDown = !upDown;
      break;      
      
      case ClickEncoder::DoubleClicked: 
        
      break;      
    }
  }

  delay(10); 
}

I use the rotary control with a Raspberry Pi to control a camera pan-tilt mechanism. Here is a video showing it in action:

I will cover the purpose of the camera as well as the configuration and coding related to the pan-tilt mechanism later in this post.

Raspberry Pi Projects

Raspberry Pi and TensorFlow lite

TensorFlow is a deep learning library developed by Google that allows for the easy creation and implementation of Machine Learning models. There are many articles available online on how to do this, so I will not focus on how to do this.

At a high level, I created a basic object identification model created on my windows PC and then converted the model to a TensorFlow lite model that can be run on a Raspberry pi 4. When the TensorFlow lite model is run on the Raspberry Pi, a video feed is shown of the attached Raspberry Pi camera, with green blocks around items that the model has identified with a text label of what the model believes the object is, as well as a numerical percentage which indicates the level of confidence the model has in the object identification.

I have attached a 3inch LCD screen (in a 3D printed housing) to the Raspberry Pi to show the video feed and object identification in real-time.

The Raspberry Pi Camera is mounted on a pan-tilt bracket which is controlled via two micro servos. As mentioned earlier, the pan-tilt mechanism is controlled via the dial control discussed earlier. The pan-tilt mechanism servos are driven by an Arduino Uno R3 connected to the Raspberry Pi 4 via USB. I initially connected servos straight to Raspberry Pi GPIO pins. However, this resulted in servo jitter. After numerous modifications and attempted fixes, I was not happy with the results, so I decided to use an Arduino Uno R3 to drive the servos instead and connect it to the Raspberry Pi Via USB. I have always found hardware interfacing significantly easier with Arduino and also the result more consistent.

Here is a diagram of how the servos are connected to the Arduino Uno R3:

Below is the Arduino source code I wrote to control the servos. Instructions are sent to the Arduino through serial communication via USB, and the servos are adjusted accordingly.

#include <Servo.h>
#define SERVO1_PIN A2
#define SERVO2_PIN A3

Servo servo1;
Servo servo2;
String direction;
String key;
int servo1Pos = 0;
int servo2Pos = 0;

void setup()
{
  servo1Pos = 90;
  servo2Pos = 90;
  Serial.begin(9600);
  servo1.attach(SERVO1_PIN);
  servo2.attach(SERVO2_PIN);

  servo1.write(30);
  delay(500);
  servo1.write(180);
  delay(500);
  servo1.write(servo1Pos);
  delay(500);
  servo2.write(30);
  delay(500);
  servo2.write(150);
  delay(500);
  servo2.write(servo2Pos);
  delay(500);
  Serial.println("Started");
  servo1.detach();
  servo2.detach();
}

String readSerialPort()
{
  String msg = "";
  if (Serial.available()) {
    delay(10);
    msg = Serial.read();
    Serial.flush();
    msg.trim();
    Serial.println(msg);
  }
  return msg;
}

void loop()
{
  direction = "";
  direction = readSerialPort();
  //Serial.print("direction : " + direction);
  key = "";

  if (direction != "")
  {
    direction.trim();
    key = direction;

    servo1.attach(SERVO1_PIN);
    servo2.attach(SERVO2_PIN);

    if (key == "97")
    {
      if (servo2Pos > 30)
      {
        servo2Pos -= 10;
      }
      servo2.write(servo2Pos);
      delay(500);
      Serial.print("A");
    }

    else if (key == "115")
    {
      if (servo1Pos < 180)
      {
        servo1Pos += 10;
      }
      servo1.write(servo1Pos);
      delay(500);
      Serial.print("S");
    }

    else if (key == "119")
    {
      if (servo1Pos > 30)
      {
        servo1Pos -= 10;
      }
      servo1.write(servo1Pos);
      delay(500);
      Serial.print("W");
    }

    else if (key == "100")
    {
      if (servo2Pos < 150)
      {
        servo2Pos += 10;
      }
      servo2.write(servo2Pos);
      delay(500);
      Serial.print("D");
    }

    delay(100);
    servo1.detach();
    servo2.detach();
  }

}

On the Raspberry Pi, the following Python script is used to transfer the rotary control input via serial communication to the Arduino:

# Import libraries
import serial
import time
import keyboard
import pygame

pygame.init()
screen = pygame.display.set_mode((1, 1))

with serial.Serial("/dev/ttyACM0", 9600, timeout=1) as arduino:
    time.sleep(0.1)
if arduino.isOpen():
    done = False
while not done:
    for event in pygame.event.get():
    if event.type == pygame.QUIT:
    done = True
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_s:
    arduino.write('s'.encode())

if event.key == pygame.K_w:
    arduino.write('w'.encode())

if event.key == pygame.K_a:
    arduino.write('a'.encode())

if event.key == pygame.K_d:
    arduino.write('d'.encode())
time.sleep(0.5)

arduino.Close();
print ("Goodbye")

The next thing I want to implement on this project is face tracking using TensorFlow lite with automated camera movement.

Raspberry Pi Zero W Mini PC

I built a tiny PC using a Raspberry Pi Zero W combined with a RII RT-MWK01 V3 wireless mini keyboard and a 5 inch LCD display for Raspberry Pi with a 3D printed screen stand.


It is possible to run Quake 1 on the Raspberry Pi Zero following the instructions in this GitHub, and it runs great.

Raspberry Pi Mini Server Rack

I have 3D printed a mini server rack and configured a four Raspberry Pi Cluster consisting of three raspberry Pi 3s and one Raspberry Pi 2. They are all networked via a basic five-port switch.

I am currently busy with a few different projects using the Pi cluster and will have some posts in the future going into some more details on these projects.

I developed a little Python application to monitor my different Raspberry Pis and show which ones are online (shown in green) and offline (shown in red).

The application pings each endpoint every 5 seconds, and it is also possible to click on an individual endpoint to ping it immediately. The list of endpoints is read from a CSV file, and it is easy to add additional endpoints. The UI is automatically updated on program startup with the endpoints listed in the CSV file.

Here is the Python source code of the application:

import PySimpleGUI as sg
import csv
import time
import os
from apscheduler.schedulers.background import BackgroundScheduler


def ping(address):
    response = os.system("ping -n 1 " + address)
    return response


def update_element(server):
    global window
    global layout
    response = ping(server.address)
    if response == 0:
        server.status = 1
        window.Element(server.name).Update(button_color=('white', 'green'))
        window.refresh()
    else:
        server.status = 0
        window.Element(server.name).Update(button_color=('white', 'red'))
        window.refresh()


def update_window():
    global serverList
    for server in serverlist:
        update_element(server)


class server:
    def __init__(self, name, address, status):
        self.name = name
        self.address = address
        self.status = status


serverlist = []

with open('servers.csv') as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    for row in csv_reader:
        if line_count == 0:
            line_count += 1
        else:
            serverlist.append(server(row[0], row[1], 0))
            line_count += 1

layout = [
    [sg.Text("Server List:")],
]

for server in serverlist:
    layout.append([sg.Button('%s' % server.name, 
                    button_color=('white', 'orange'), 
                    key='%s' % server.name)])

window = sg.Window(title="KillerRobotics Server Monitor", 
                    layout=layout, margins=(100, 30))
window.finalize()
scheduler = BackgroundScheduler()
scheduler.start()

scheduler.add_job(update_window, 'interval', seconds=5, id='server_check_job')

while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED:
        scheduler.remove_all_jobs()
        scheduler.shutdown()
        window.close()
        break
    elif event in [server.name for server in serverlist]:
        scheduler.pause()
        update_element([server for server in 
                         serverlist if server.name == event][0])
        scheduler.resume()

Raspberry Pi Pico

I ordered a few Raspberry Pi Picos on its release, and thus far, I am very impressed with this small and inexpensive microcontroller.

The Raspberry Pi Pico sells for $4 (USD) and has the following specifications:
– RP2040 microcontroller chip designed by Raspberry Pi
– Dual-core Arm Cortex-M0+ processor, flexible clock running up to 133 MHz
– 264KB on-chip SRAM
– 2MB on-board QSPI Flash
– 26 multifunction GPIO pins, including 3 analogue inputs
– 2 × UART, 2 × SPI controllers, 2 × I2C controllers, 16 × PWM channels
– 1 × USB 1.1 controller and PHY, with host and device support
– 8 × Programmable I/O (PIO) state machines for custom peripheral support
– Low-power sleep and dormant modes
– Accurate on-chip clock
– Temperature sensor
– Accelerated integer and floating-point libraries on-chip

It is a versatile little microcontroller that nicely fills the gap between Arduino and similar microcontrollers and the more traditional Raspberry Pis or similar single board computers.
I have only scratched the surface of using the Pico on some really basic projects, but I have quite a few ideas of using it on some more interesting projects in the future.

3D Printing

I ran into some problems with my 3D printer (Wanhao i3 Mini) over the last few months. The First problem was that half of the printed LCD display died, which was an annoyance, but the printer was still usable. The next issue, which was significantly more severe, was that the printer was unable to heat up the hot end.

My first course of action was to replace both the heating cartridge and the thermistor to ensure that neither of those components were to blame, and unfortunately, they were not. After some diagnostics with a multimeter on the printer’s motherboard, I determined that no power was passing through to the heating cartridge connectors on the motherboard.

I ordered a replacement motherboard and installed it, and the 3D printer is working as good as new again. When I have some more time, I will try and diagnose the exact problem on the old motherboard and repair it.
Here are photos of the old motherboard I removed from the printer:

Below are some photos of a few things I have 3D printed the last few months:

2021 PROJECTS

IoT

I am starting an IoT project and wanted to share a little bit.  IoT or the Internet of Things is defined on Wikipedia as “the network of physical objects—devices, vehicles, buildings and other items embedded with electronics, software, sensors and network connectivity—that enables these objects to collect and exchange data. The Internet of Things allows objects to be sensed and controlled remotely across existing network infrastructure, creating opportunities for more direct integration of the physical world into computer-based systems, and resulting in improved efficiency, accuracy and economic benefit;”.  

To learn more I would recommend the book The Internet of Things Do-It-Yourself at Home Projects for Arduino, Raspberry Pi, and BeagleBone Black by Donald Norris. It provides an in-depth technical overview of concepts as well as some projects that can be built. The projects in the book are not particularly exciting but they do a good job at illustrating concepts and methods utilised.

Book

So I am going to be using a Raspberry Pi2 running Windows 10 IoT core, which will be communicating with some Arduino boards.

I am also looking at integrating with Azure Machine Learning to do some interesting things. 

I have not decided on many elements of the final project, but it will involve a robot.

rasp

On a side note, do not try to deploy Windows 10 IoT Core on a SD card using a Mac, it is a huge pain. My main computer I use at home (and for most of my development, blogging, video editing, etc.) is a MacBook Pro and in the end I gave up trying to get the deploy working and used my windows laptop which worked almost instantaneously.

Once I have decided exactly what I want to achieve and made some progress I will post more on this topic.

IoT

The Geek So Far – A Work In Progress

This post is a quick update on the Geek robot build so far. A fair amount of trial and error and a bit of experimentation has consumed a lot of my time in the construction thus far. I believe this build will still take a long time because of the vast amount of tasks that still needs to be completed.

robot

So here is a quick view of the robot so far.

The robot has a total of 14 servos that are allocated as follows:

  • Two micro servos (1.3kg per cm) in the neck in a mini pan tilt plastic mounting.
  • Two servos (one metal gear 20kg per cm and one 18kg per cm) in the robot waist in a pan tilt metal mounting.
  • Each arm has three servos (a 18kg per cm servo in the shoulder and two 1.3kg per cm micro servos for the rest of the arm movement).
  • Each leg consists of two servos (18kg per cm).

arm lower body  foot

The robots’ head contains two cameras, an Arduino 2 mega pixel camera for static images and a Logitech web cam for video (I removed the web cam housing as it
was too bulky).

The robots’ feet are aluminium housings that will contain the batteries that will power the robot. This is to keep the weight at the bottom of the robot, thus helping to balance it. I am still investigating the exact battery configuration to use as I would prefer a rechargeable option.

I used a fair amount of Timiya universal metal joints during the assembly so far and these are very handy in building any robot.

The robot currently has two ultrasonic sensors and one infrared distance sensor. The ultrasonic sensors are mounted on the front of the feet for obstacle detection and the infrared distance sensor is mounted on the front of the robots’ hips and will be used to detect vertical drops.

I plan to mount another ultrasonic sensor and infrared distance sensor on the robots’ back, to allow for the robot to avoid obstacles when it moves backwards.

The robot has a laser diode attached to its one arm, which I intend to use for pointing as well as a point of reference for the webcam.

The next task I will be undertaking will be to start wiring the robot to the Arduino Mega R3 and Raspberry Pi 2 that I intend to use to control the robot. I will post more blog updates as progress on this robot advances.

The Geek So Far – A Work In Progress

Boards, Boards Everywhere

Currently there are numerous Arduino and Arduino compatible boards available, this post will do a quick comparison between 3 of these boards (Arduino UNO R3, Arduino Mega R3 and the Beetle which is a shrunk down version of the Arduino Leonardo) and then also a quick comparison between Arduino and Raspberry Pi Board Families.

The below picture illustrates the size difference between the Arduino boards:

Arduino Board Comparison

Here is a basic breakdown of the specifications of the three boards:

Specification UNO R3 MEGA R3 Beetle
Processor ATmega328P ATmega2560 Atmega32U4
Frequency 16 MHz 16 MHz 16 MHz
Dimensions 68.6 mm × 53.3 mm 101.6 mm × 53.3 mm 20mm X 22mm
Manufacturer Arduino Arduino DFRobot
Flash Memory 32kB 256kB 32kB
SRAM 2kB 8kB 2.5kB
Digital I/O Pins 14 54 3
Analog Pins 6 16 3

The Arduino UNO is a good starting point for anyone interested in beginning some Arduino builds, it is a good all round board for most projects and the only real constraint that I have ever run into with this board is running out of digital I/O and Analog input pins for larger projects.

The Arduino Mega overcomes this problem by offering more than double the pins. From a development and ease of use point of view it is almost identical to the UNO.

The Beetle has the least amount of pins exposed, 6 in total, 3 digital and 3 analog, so this can be a serious constraint on the nature of project it can be used for. On the other hand its tiny size makes it possible to use this board in projects where physical size is a constraint (Such as the Insect bot I posted about in an earlier post).   

Now lets look at the Raspberry Pi (Raspberry Pi 2 B to be precise) in comparison to the Arduino boards. Below are 2 Pictures showing its size in comparison to the Arduino UNO and Mega.

Pi and Mega Pi and Mega

Here is a basic specification breakdown for the Raspberry Pi (Raspberry 2 B):

Specification Raspberry Pi 2 B
Processor Cortex-A7
Frequency 900 MHz quad-core
Dimensions 85.60 mm × 56.5 mm
Manufacturer Raspberry Pi Foundation
Flash Memory MicroSD slot
SDRAM 1GB

So, which should you use? Arduino or Raspberry Pi? The answer is… It depends. Both boards have their strong and weak points. Let us look at some key distinguishing points between the two board families:

  • Price
    • The Arduino boards tend to cost a lot less than Raspberry Pi boards.
  • Memory
    • Raspberry Pi Boards have vastly more memory.
  • Processing Power
    • Raspberry Pi Boards again win this one by a huge margin.
  • Ease of Hardware interfacing
    • Arduino Boards make direct hardware interfaces with sensors and actuators much easier.
  • Online community
    • Both have a strong and thriving online community for help and support.
  • Development
    • Arduino is C only using the free Arduino IDE where as the Raspberry Pi has a variety of development options, including Python, Java, C, C++.

The Arduino makes hardware interfacing with sensors and actuators a great deal easier. However the Raspberry Pi offers vastly more memory and processing power. So which one to use depends very much on your projects’ requirements.

To put it simply there is no right or wrong choice, use what works for you or simply what you want to use.

This does however not mean that you cannot use both on a single project by setting up serial communication between the 2 boards. I am currently busy doing this on a project (see The Geek under the THE KILLER ROBOTICS FAMILY SO FAR! post).

Boards, Boards Everywhere

The Killer Robotics Family So Far!

This Killer Robotics Family currently consists of 2 complete robots and 1 work in progress.

First we have the Autonomous Roaming Robot:

Autonomous Roaming Robot

This robot was built on a Sparkfun Magician Chassis and uses a Arduino Uno R3 with a Pololu MC33926 dual motor controller, a HC-SR04 Ultra Sound Distance Sensor (On a micro servo for neck movement), a Sharp IR distance sensor to detect drops, and 2 trigger switches to detect direct contacts with objects. This robot autonomously roams avoiding objects and drops. I will provide a full breakdown on how this robot was constructed as well as the source code running on the Arduino in a future post.

Secondly we have the Insect bot:

Insectbot

This Robot was based on an Instructable article posted by Lumi3005 (http://www.instructables.com/id/Insect-Bot-mini/). It is based on a Beetle board (basically a shrunk down Arduino Leonardo) with 2 micro servos and a IR distance sensor. This robot walks around avoiding obstacles. I will be posting a review and build step-by-step guide for the DFRobot kit of this robot in the near future.

box

And Lastly we have The Geek:

robot7

This robot is still a work in progress and is by far the most ambitious robot that I have under taken. It utilises 16 Servos, will utilise 3 ultrasound distance sensors and 2 infrared distance sensors, 2 cameras (a Arduino Camera and a Logitech web cam) and will be powered by a combination of an Arduino Mega R3 and a Raspberry Pi 2. Many posts revolving around this robot, such as progress, lessons learnt and build instructions will follow in the future.

The Killer Robotics Family So Far!