Building a Hexapod - Part 1

Building a Hexapod – Part 1

When I see something that I think I’d like to build I tend to buy most of the parts from eBay and then stockpile them in my drawers for a few years before I finally bit the bullet and start working on the project.

This project is one of those. I want to build a Hexapod using SG90 servo motors.

 These are small servos that will help make the Hexapod relatively small.

The type of design I’ve settled for needs 3 motors per leg so I’m looking at 18 servo motors that need to be controlled by a microcontroller. Servo motors rely on a PWM signal and there are few ( if any ) microcontrollers that have 18 PWM pins available so I’m to use a couple of PCA9685 controllers.

This controller uses I2C for communication to 16 PWM connections. As I have 18 motors, I’ll need 2 of these. Arduinos understand I2C with no problem. Older viewers of this channel will remember that I created a remote control for the Roombaduino using I2C.

As I’ve chosen to use 3 servo motors per leg, I need to work on how that is going to be articulated. Standard wisdom for this design says that there is are a couple of motors at the shoulder and another motor at the knee.

Something like this.

I’m playing around with some brackets that will secure the motors and move without interfering with each other. When I have a workable design, I can add some embellishments.

Stay tuned.

 

Building a MIDI Controller

This is a project that has been a long time in the making. If you go back to the earlier posts of this blog, you’ll see how I started with my first Raspberry Pi back in 2014 and my intention to use it as an interface with a electronic drum kit.

Since then, I’ve developed raveloxmidi as the proxy from a Raspberry Pi but I never worked on the hardware. I’ve had other people use raveloxmidi and they seemed to be please with it.

Last month, I saw a video from Angus at Maker’s Muse (www.makersmuse.com) who build a controller using arcade buttons and an Arduino.  I remembered that I had a set of arcade buttons that I’d bought from eBay.

This seemed like the perfect opportunity to put my money where my mouth was and build my own controller. Here’s the video of how I did it:

I’m going to write up my thoughts on the quality of the video. You’ll see a counter incrementing each time I say the word “SO” in my commentary. It bugs the heck out of me and it’s something I need to improve on but it’s a little fun seeing how many times I say it.

UV Light Box – Part 2 – Control Interface

I spent a lot of time working out how I wanted the controls to work and designed the software in C first so that I could work out a generic menu system that allowed me to configure it via an array of menu items.

The definition of the menu items is:

typedef struct {
 int id;
 char *label;
 void (*display_action)();
 void (*select_action)();
 void (*up_action)();
 void (*down_action)();
 int submenu_id;
 int prevmenu_id;
} menu_t;

So each item has an ID and a label followed by a set of actions. When the menu item is first displayed, it’s either the fixed label or, if the label is empty, the display action is called. This allows me to vary the display for things like the timer counter start value where the operator can choose the length of the timer. The select, up and down actions are function calls to vary the behaviour but the left and right actions are always to move to the parent menu or to a submenu.

This structure means that the actual menu handling code is relatively simple. Each button press will call the appropriate function in the structure. It’s the actual functions that can change and I can code for those as I go along.

The code itself is called inside the Arduino loop() function so I’m not using interrupts for the timer and the processor isn’t stuck in delay() cycles. Each time I go around the loop, I am taking the current number of milliseconds since the processor started up and compare that to a previous value I took. If the difference between the current and previous values is over a threshold, I take an action. For a timer, the resolution is seconds so I take the action to update the timer every 1000 milliseconds. For button checking, I take an action every 125 milliseconds.

This video shows the timer and menu system working. I still have some bugs to iron out in terms of timing but it’s working as expected.

UV Light Box – Part 1

I’ve been playing around with etching my PCBs for projects and using toner transfer to do that. There are some problems I have with that method ( that’s not to say it’s not a good method, it’s just that my results haven’t been as I would have wanted them ) and so I’m starting a project to build a UV Light Box to expose UV-sensitive film to UV light as a different way of creating a mask for the etchant. This video starts that journey:

 

Roombaduino – part 23 – Custom connectors and working modules

I put together some custom cables with ribbon cable, heat shrink and connector pins to replace the breadboard pins I was using. These connectors are a little more resilient.

I connected everything up including the wireless transceiver and tested the modules both with the I2C scanner and the serial monitor with the initial remote control sketch.

Everthing seems to be working fine so I now need to get the sketch on the main MCU to send data to the Roomba again and then I’ll start work on the case.

Roombaduino – part 22 – New Wireless module

The remote won’t work unless it can transmit commands so I soldered up a new Wireless module. Because the Wireless transceiver uses SPI, some pins are shared on the ATTiny84/85 so I decided there would be a direct connection from the ATMega328 to the Wireless transceiver.

I also purchased some AMS1117 3.3v regulators to avoid needing to put a 5v-to-3.3v convertor myself. This reduced the amount of soldering considerably.

I had to solder some extra headers to the board so that the transceiver could be supported. The idea was that I could make the transceiver removable.

This may bite me in the future in terms of size of the case.

Roombaduino – part 21 – New joystick module

Next part to get converted to I2C was the joystick module. This time I needed to use an ATTiny84 because I needed 2 pins for X and Y, 1 pin for the button and 1 pin for the LED plus 2 for I2C which means there are not enough pins available in the ATTiny85.

Soldering was a little easier because there are not so many connections required.

I also cut down the size of the module so that I could build 2 and put one either side of the main remote. This makes it a more compact unit.

The obligatory video below shows it working.

 

Roombaduino – parts 17, 18 and 19 – Redesigning the remote

After building the new IO board, I started to realize that my idea to have the remote control in modular sections needed a redesign. Each module needed at least 2 17-pin connectors to provide communication from the previous module to the next and that was taking up valuable space on the small perfboard and that required components to be squashed together ( ultimately exposing my lack of fine soldering skills ).

I was looking at controlling multiple OLED screens and found a technique that used a multiplexer to allow the controller to talk to OLEDs with the same address. The multiplexer switches the I2C data line between each screen.

Using I2C got me thinking about how I could redesign the remote control modules with just 4 pins for the bus ( 2 for power and 2 for data ).

To communicate with each module, I needed a smaller microcontroller that would respond to I2C requests from the main MCU ( the ATmega328 ) and send data back. This meant that I could have the module MCU talk to a shift register to determine button presses or to light LEDs.

I chose the ATTiny85 because it was much smaller and didn’t require a separate oscillator for timing and also didn’t need associated smoothing capacitors for power. However, with fewer pins comes less flexibility. The shift register technique needs 3 pins for control ( data, shift and latch ) but I also needed an input pin for the button module. The ATTiny85 doesn’t have enough pins available to do that. By happenstance, I found that I had a solitary Johnson counter that has 10 pins for output and a one pin for clock. Each time the clock pin is taken high, the output pin is incremented so, for example, if the output pin is pin 1, a clock pulse moves it to pin 2 and so on from 0 to 9. When it reaches 9, it rolls back to 0 again. Additionally, there is a pin to reset the counter back to 0. This is important if you want to poll buttons sequentially. The reset allows you to start from a known state.

So, the module uses 2 pins ( clock and reset ) plus the data input line instead of 3 + input. That makes the Johnson counter perfect for the button input module.

I needed to make sure that the ATTiny85 could talk over the I2C bus to the main MCU.

With that testing done, I could then solder up a new Nerduino and button module. I was also able to test that the ATTiny85 could light an LED module. Given that I don’t care about any input on the LED module, I can go back to using a shift register for that module and still only use 3 pins on the module MCU.