Tuesday, 11 December 2012

Getting X-Bee going on my Mac / Arduino

I got a couple of X-Bees and adapters from Adafruit. I sharpied one of the Xs black so I could tell the difference between them. I got some hints from Ashley Hughes and from the Adafruit tutorial. Both valuable!

Note the black X, and how the I2C pins line up in this orientation. Power is coming in the back

I installed Coolterm from http://freeware.the-meiers.org/ so I could run a serial terminal outside the Arduino IDE.   

I installed the FTDI drivers from http://www.ftdichip.com/Drivers/VCP.htm so that the FTDI cable would interface with my USB and behave like a serial port.

I started coolterm, picked the right port under options, connected and could get recognition of +++ [No Enter] with an OK. I started with a series of queries and responses on the black X-Bee. (With the X blacked out, same for the one with the B blacked out)

Things I Type [normally followed by Enter] that don't show up on the terminal
        Things The black X-Bee Sends Back

+++[No Enter]
        OK       So the X-Bee is responding, but it will time out and need a +++ again soon
        3332      is what the PANID was set to before (out of the box default)
        OK        Sets PANID to 2711, could be any 4 digits, but must be the same for all units on network
        0            This X-Bee is unit 0
        0            The destination X-Bee is unit 0
        OK        Set the destination X-Bee to unit 1
        3           The baud rate is set to 9600 and I'll leave it there
        OK       Writes all the changes to permanent, otherwise they would disappear at power off

Disconnected, then unplugged USB and changed over to the white X-Bee. Did all the same things, except ATMY1 and ATDL0 to reverse the roles.

Then I connected the black X-Bee RX and TX to RX and TX on an Arduino (turns out they should be TX-RX, RX-TX). Something was happening, but not the right things. http://www.ladyada.net/make/xbee/arduino.html suggests the programming communications won't work to upload to an UNO (just with a Duemilanove bootloader), or that the baud rate should be higher (ATBD6 - 57600 for a newer Arduino with a '328). One problem at a time...

void setup() {              
  Serial.println("Hello World! Now to Echo");
void loop() {
      char c = Serial.read();
      Serial.print("Another new character: ");
The code above will echo characters back 1 second after they're sent. Loaded and tested over USB, then disconnected and powered the Arduino by batteries, connected coolterm to the white X-Bee on the FTDI and it didn't work. Switched the connections so that black X-Bee RX went to Arduino TX and black X-Bee TX went to Arduino RX, and things started working.

So now that I have wireless serial at 9600 baud, do I want to get wireless programming working, or just work on wireless links between Arduinos? Start with upping the speed on both to ATBD6 - 57600. And then remember to up the sketch baud rate too... and presto, it works. Up to ATBD7 - 115200 and that works too, but gets flaky, so I'll slow it down to ATBD6 - 57600. (Yes, there's a reason why this might read like a lab notebook ;-) )

Wireless programming seems like a lot more effort with the extra pins to worry about, so I'll tackle that when I need it.

Friday, 7 December 2012

Modifying a Pololu Shield for the Due

The Arduino Due is a 3 volt board all through, except for providing a 5 volt line on the same pin as the Uno. The Pololu Dual VNH5019 Motor Driver Shield for Arduino is compatible with either 3 volt or 5 volt logic, however it takes its VDD from the 5 volt pin on the Arduino headers. To make it safe for the Due I tied the 3 volt pin to VDD on the end of the card (red wire) and cut the trace from the 5 volt pin (lower right near the mounting hole). As a result the logic returns come at 3V rather than 5V, safe for the Due and still works with the Uno.

My first thought (and test) was to jump the 3 volt and 5 volt pins and cut off the 5 volt pin so the board gets all its feed that way. Problem: boards stacked on top of the driver shield may still be expecting 5 volts to drive displays, etc.

I have a feeling there are going to be a bunch of 3/5 volt challenges ahead, but on the plus side, the Due has capabilities we spent about $20K to get in our lab in 1984!

From Pololu's User Manual on 3V systems:

"Logic power at the same level as your controlling device should be supplied to the VDD pin. This will typically be between 2.5 and 5 V, but the VNH5019 motor drivers are guaranteed to treat any logic input voltage over 2.1 V as high. The only purpose of the VDD pin is to power the pull-up resistors on the EN/DIAG lines."


"Current sense output. The pin voltage is roughly 140 mV per amp of output current when the CS_DIS pin is low or disconnected. The current sense reading is more accurate at higher currents. (Note that while the CS voltage can potentially exceed 3 V at high currents, the current sense circuit is safe for use with 3V analog inputs. The MCU’s analog input voltage will be clamped to a safe value by its protection diode, and only a few hundred microamps at most will flow through that diode.)"

Thursday, 6 December 2012

Too much on one board?

5 breakout boards very tightly packed 
I jammed a bunch of breakout boards all onto the same screwshield and managed to trash the BMP085 along the way, from either heat or static. The boards overlap to make everything fit, and the necessary wiring also made the clearances tight.

The end product has a 3-axis accelerometer, feeding 3 of a total of 8 channels of 12 bit ADC, plus one channel of 12 bit DAC. It would also have pressure and temperature if I hadn't fried the board along the way.

The DAC output, as well as the three accelerometer readouts are available on the WXYZ screw terminals.

Cuts down on the wiring mess
TFTLCD 2.8 on top of it all
The ADC are configured for I2C 0x48 and 0x49 and the DAC on 0x62. The green boxes are spring loaded quick release sockets for ground and 5 of the ADC channels. They're a little tall, but it's still possible to fit a display on top to show how the orientation of the board is changing with time.

Of course all of this may be entirely redundant as my long awaited Arduino Due walked in the door late this afternoon, with 12 ADC and 2 DAC and it will run AnalogRead() at 40us / call and 12 bits.