Tuesday, January 27, 2015

Connecting the ArbotixM with the Raspberry Pi, part 1

Right, so now I have an ArbotixM, Raspberry Pi B+ and a UartSBee V4 which is a USB XBee TTL interface that is essentially a FTDI interface with support for 3.3V and 5V logic.  Which is exactly what I need as the Raspberry Pi is a 3.3V device while the Arbotix is a 5V device preventing me from connecting directly without a level converter on the serial line.  I also happen to have an extra one lying around as I conveniently ordered two since two is always better than one.

We connect according to this guide from Trossen Robotics.

b_450_0_16777215_00__images_tutorials_arbotixM_arbotixm_uartsbee.png

The diagram is replicated here for clarity.

We also replace the blink from my last post with the ArbotixM test blink. Which is effectively just swapping digital pin 13 (Arduino Uno) for pin 0 (ArbotixM).

Next we try to build the blinky for ArbotiX

$ ino build -m arbotix

This resulted in a error in arbotix/core/arbotix/HardwareSerial.cpp and arbotix/core/arbotix/Print.cpp.

After some googling it turns out that the definitions are out of date since the compiler has moved on and some definitions have been deprecated.  The follwing changes where made to the two files to overcome this.

Changes in HardwareSerial.cpp line 1.
+ #define __AVR_LIBC_DEPRECATED_ENABLE__

Changes in HardwareSerial.cpp lines 50-51
- volatile int head;
+ volatile unsigned int head;
- volatile int tail;
+ volatile unsigned int tail;

Changes in Print.cpp line 44
- const prog_char *p = (const prog_char *)ifsh;
+ const char PROGMEM *p = (const char PROGMEM *)ifsh;

Next I had to restore the bootloader of the ArbotixM as I had been directly programming in via ISP programmer interface from Pololu previously as I was using the XBee which occupied the serial port.
Also I didn't have the FTDI interface when I first got the ArbotixM due to an oversight.

This is where I hit a wall. The AVR ISP is not managing to write anything to the ArbotixM due to the minimum voltage being to low (> 400mV) which is very weird.  After lots of thrashing an unplugging and plugging and measuring the ArbotiX voltage and trying different power supply and whatnot the error transmuted into a communication error where no response is received but the min voltage is fine now.  I verified that the chip is still functioning by getting a serial response from the current program (written by the ISP) using the FTDI. Next I'm going to try to use avrdude directly from linux/raspberry to write the bootloader.



No comments: