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.



1 comment:

  1. good job!
    but esp8266 v2.6.3 has an error at "Arm7Bot.h" line 56.
    "const boolean reverse[SERVO_NUM]"
    "reverse" conflic with esp8266, so just rename it to another, and compile ok.

    ReplyDelete