Sunday, November 22, 2015

Arduino Makefile on Mac OSX

In my continuing project to build a little hexapod robot, I figured I would try to get the Arduino code running from the command line.  I like to use Emacs and all that, old school style.  Here's what I did to get that going.

  1. I cloned Arduino-Makefile off of Github.
  2. I installed CrossPack for AVR to get the AVR toolchain.
  3. I set various environment variables in my ~/.profile .  You'll need to set these according to the system and board that you actually have.
    • ARDUINO_DIR = /Applications/Arduino.app/Contents/Java
    • ARDMK_DIR = $HOME/Dropbox/Robotics/Arduino-Makefile
    • ARDUINO_CORE_PATH = /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino
    • BOARDS_TXT = /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/boards.txt
    • AVR_TOOLS_DIR = /usr/local/CrossPack-AVR
    • MONITOR_PORT = /dev/cu.usbserial-AL01CARS
    • BOARD_TAG = diecimila
    • BOARD_SUB = atmega328
  4. After setting these up, make show_boards, make, and make upload seemed to work.

Sunday, November 15, 2015

Using Pololu Mini Maestro on Mac OSX 10.10

For my little hexapod project, I want to control 18 Tower Pro MG90S servos with an Arduino Nano.  To perform the motor control, I bought a Mini Maestro 18-Channel USB Servo Controller, made by Pololu.  However, I'm on a Mac and Pololu doesn't seem to offer support for Macs or be interested in doing so.  I want to manage the Mini Maestro via the Nano, but there seem to be settings that can only be adjusted via USB, e.g., the baud rate.  So, I spent some time trying to figure out how to do this and figured it might be useful to someone else.

The first thing I did was grab the Maestro Linux software. Then I used Homebrew to install Mono:
$ brew install mono
This gave me some obnoxious errors about missing libraries, which were sorted out by an additional installation:
$ brew cask install mono-mdk
After this, it became possible to fire up the Maestro Control Center GUI via:
$ env PATH=/Library/Frameworks/Mono.framework/Commands:$PATH mono MaestroControlCenter
However, it seems not to play nicely with the default installation of libusb.  So I uninstalled the default version and installed the cutting edge universal version that would hopefully play better with Mono:
$ brew uninstall libusb
$ brew install libusb --universal --HEAD
After this, I was able to open the GUI, although it was almost unusable due to visual artifacts.  However, it was enough to verify that I could move a servo on channel 0 and ensure that the controller settings had the right values.


Saturday, November 14, 2015

Getting an Arduino Clone Working on Mac OSX 10.10

I recently treated myself to an Ultimaker 2.  In addition to making doll furniture for my daughter, I also hope to get back to playing with small-time robotics.  I've decided my first project will be a hexapod, like this one: http://www.thingiverse.com/thing:432829.  Printing the parts is going fine, but the last time I did any embedded programming was with a 68HC11.  Needless to say, times have changed and we're in the era of Arduino for hobby embedded device development.

So I ordered myself an Arduino Mini clone ("Ieik Mini Nano V3.0 Atmega328p") off of Amazon to get started.  I use Homebrew, so I grabbed the IDE via:
$ brew install brew install Caskroom/cask/arduino

I fired it up with
$ open ~/Applications/Arduino.app
and loaded up the basic blink example, as described on the Arduino tutorial page.  A lot of people have been reporting issues the USB connection and I immediately got:
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
I started hunting around for the way to fix it.  I went to the FTDI site, grabbed the VCP drivers, and installed them.  This didn't work, even though my clone has a genuine FTDI chip.  After lots and lots of web pages, I finally got it to work.  The key thing was to treat it like a Duemilanove, despite it having both "Mini" and "Nano" in the Amazon web page and it having the same layout as a Nano.