Showing posts with label Serial Link Robot. Show all posts
Showing posts with label Serial Link Robot. Show all posts

Friday, 10 February 2017

ROBOTICS: Compiling the 7Bot Arduino code for the ESP8266 - BangBot

I wrote previously about building a desktop robot arm that I started calling the BangBot (because I bought it from bangood). I finished with a brief overview of the existing open source software solutions including some software written for similar desktop robots. 
In this post I'll investigate the specifics of the 7Bot software written for a similar looking desktop bot. 


7Bot Software:

The software comes in two components:
  • Arduino code to run the robot
  • Desktop code that passes positions to the robot and includes a simulator/visualiser. 

I'll be focussing on the embedded software that controls the arm over serial communications. You can find more info on the serial communications protocol here.

I forked the github repo of the 7Bot Arduino software which has been written specifically for the Arduino Due. This board has some special features that your run-of-the-mill Arduino has like a 12 bit DAC on 12 channels and high clock speed.

As this isn't a typical feature of low cost Arduinos I'm pretty sure I'll end up needing an external servo driver board, but until I hit a wall I'll try to get everything running off the one board.

My gut feel is that I'll want to use a board with some decent clock speed to make sure the Inverse Kinematics equations are computed quickly enough to give smooth robot motions when operating in Cartesian mode. This is because the robot needs to interpolate the path between points and calculate do the IK calculations to update joint angles at at least 15fps for smooth motion.
For this reason I'm going to try to get it compiling for an ESP8266 as the base clock speed is 80MHz and is capable of going up to 160MHz. I'll need to do some research to understand how this clock speed relates to real world computational speed and how that compares to the Due.


Embedded Device Specs:

I need to compare the ESP8266 with the Due to understand how it might handle the code designed for the 7Bot and the Due board:

ESP8266
  • IEEE 802.11 b/g/n Wi-Fi
  • 32-bit RISC CPU (80 or 160MHz)
  • 64 KB of instruction RAM, 96 KB of data RAM
  • External QSPI flash - 512 KB to 4 MB* (up to 16 MB is supported)
  • 16 GPIO pins
  • 1 10-bit ADC (analog input pins)
  • UART on dedicated pins, plus a transmit-only UART can be enabled on GPIO2

Arduino Due
  • 32-bit ARM core (84 MHz)
  • 96 KB (two banks: 64KB and 32KB)
  • 512 KB all available for the user applications
  • 54 (of which 12 provide PWM output) 
  • 12 12-bit ADC (analog input pins)
  • 3 UARTs

I found that there were already some basic benchmark comparing some basic operations of the ESP and the Due on the Arduino forums:

BENCHMARK RESULTS (smaller values are better):

ESP8266 @160MHzArduino Due @84MHz
float [ms]216636
int [ms]2828


Code Changes

As I was making my changes I found that some changes were pushed to the main repo that allowed for more typical flash storage using the EEPROM library. First problem solved.

In order to get the project to compile I also needed to change the analogWriteResolution function to the analogWriteRange function available on the ESP8266. I've not yet tested this at PWMRANGE 4096.

The last issue I overcame was a compiler optimization issue that was giving me a linkage error:
xtensa-lx106-elf-gcc: error: libraries\Arm7Bot\Arm7Bot.a: No such file or directory

xtensa-lx106-elf-gcc: error:
Solved this one by commenting out the dot_a_linkage=true line in the library.properties file.
The software now compiles for an ESP8266, now to get in to the testing.



Monday, 6 February 2017

ROBOTICS: Desktop six axis robot arm - BangBot

Desktop robot arms have been generating of lot of Kickstarter excitement lately offering folks a chance to dabble in the art of hobby robotics without making a significant investment. I've been following them for a while and while the cost is definitely coming down, they are still typically start at around 300USD.

There are a few open source desktop robot arm kits that have been through Kickstarter, here are a couple of my favorites:


uArm 4 axis robot arm


7Bot 6 Axus robot arm

As with most of the good open source stuff the Chinese manufacturers seemed to have jumped on the bandwagon and started to manufacture replica kits and knockoffs. You can typically pick up a good knockoff bargain on sites like AliExpress or Bangood


Hardware:

Recently I came across this mini desktop robot arm on bangood.com that uses hobby servos to create a six degrees of freedom robot arm. As I've seen with a robot hexapod I bought from AliExpress based off the Lynxmotion Phoenix hexapod, the hardware kit will most likely be a slight variation of the original and offer no software support. 

BangBot knockoff of the 7Bot
I've got a few servos knocking about from some old projects so for the most part I should be set, but as I've seen with other projects it's probably going to pay off to have a powerful digital servo down the bottom of the kinematic chain. With serial link robots the joint at the bottom off the robot will be carrying the most load so I thought it would be wise to invest in something a little more powerful than I had lying around. I went for the PDI-6221MG digital servo from Bangood with 20kg/cm at 6v.


Software:

I'm not expecting any software support so while I wait for the kit to arrive in the mail I've started to investigate any open source software solutions rather that starting from stratch with my own. There are a few packages out there, but seeing as the hardware is most similar to the 7Bot I thought I would start there.

The most important info when trying to match the existing software to this robot is the way the joints are oriented on the robot. Simply saying that the arm is six axis isn't enough, we need to know joint lengths and actuator location and orientations to make sure the inverse kinematics are compatible.


Serial link kinematic chain


The 7Arm robot seems closest in design to the BangBot robot arm so this seemed like a good starting place for the software.

Taking a look through the code it seems as though the Inverse Kinematics (IK) parameters aren't hard coded so it should allow me to make some minor changes to joint parameters and get the software up and running. I won't go through the specifics of generating a set of inverse kinematic equations for a robot arm, but if you want to read more on the topic take a look at the pages here.

At the moment my biggest issue with compiling the code is my lack of Arduino SAM (32-bit ARM Cortex-M3) boards lying around, so I'll have to try to convert the code to run on a more conventional Arduino device. A the moment I'm thinking maybe the ESP8266 could be a good fit as it is also a 32 bit MCU and has a 160MHz clock frequency as well as EEPROM storage. I'll see how I go making the port, I may need to include a servo control board if the ESP8266 can't handle the task, I've never attempted any servo control with the ESP8266.