Wednesday, September 28, 2011

Run X-CTU with MacOS X Lion

X-CTU is the Windows software that is required to update the firmware of the XBee radios. It is not compatible with neither Linux nor Mac, but it can be used with wine - the Windows emulator.

I used Wineskin which produces standalone Mac Software packages based on wine.
First of all, get the X-CTU program from digi.com, and get wineskin for Mac.

Follow the tutorial for software with a windows installer that comes with wineskin.
Just name your wrapper X-CTU and point to the X-CTU installer from digi.com in the steps where the tutorial uses Neverball.

After clicking the advanced tab of your new wrapper, in the tools section you click "Test run application" to test your X-CTU program that you just wrapped for Mac.
You will see immediately that it complains that it cannot connect to com ports - as there are no com ports on the Mac.

We have to map the USB ports to the com ports by hand:
The port mappings for your new wrapper live under Contents/Resources/dosdevices in the wrapper we just created and should have still opened in finder (at /Users/yourusername/Applications/Wineskin/X-CTU.app).
We now create softlinks from the mac USB ports to windows com ports. Plug in your device, open terminal and go to the dosdevices folder:
cd /Users/yourusername/Applications/Wineskin/X-CTU.app/Contents/Resources/dosdevices

Look up the device location of your plugged in device, it should be /dev/tty.usbserialXXXX for an XBee on a XBee explorer connected via USB. Here, XXXX is the device ID and is different for every device.
Choose a high number for the com port, as the lower ones may be already in use by wine. I have chosen 10.
ln -s /dev/tty.usbserialXXXX com10

Kill and test run your X-CTU wrapper application again, and the complaint about the missing com ports should be gone. Add your new com port now, so that X-CTU knows it:
In the bottom panel, go to the "User Com Ports" tab. At the right, put your com port number in the box (e.g. 10) and press the "Add" button.
It now appears in the top panel, and you should be able to test/query the XBee sucessfully.

Your very own selfmade Mac version of X-CTU and your XBee should now be able to play well together.

Caveat: The com port number is forgotten by X-CTU on shutdown. So you have to go to "User Com Ports"->"Add" every time you start up your X-CTU wrapper again.

Tuesday, September 27, 2011

Serial connection from Seeduino Film via XBees to Computer

With a program that talks to Serial from the seeduino film with baud rate 19200, and two xbees on explorer boards set to baud rate 9600 and two terminal emulators set to baud rate 9600, we can establish a serial connection from the seeduino film to the computer via the xbees.

One xbee is just on the explorer shield and connected to the computer via USB, a terminal emulator attached to it (powered via USB from the explorer).
The second xbee is wired to the seeduino film's breakout board (powered via USB) like this: 5v and ground are connected, and RXD on the seeduino breakout board is connected to DOUT on the xbee explorer, and TXD on the seeduino breakout board is connected to DIN on the XBee explorer shield.

Arduino Nano vs Seeduino Film

When compiling code for Arduino Nano, choose Arduino Duemilanove, when compiling for the Seeduino Film, choose Arduino Diecimila. So far, so good.

Uploading Arduino code that establishes a serial connection like this

void setup()
{
Serial.begin(9600);
}

void loop()
{
Serial.print("arduino greets");
delay(2000);
echo();
}

works fine on the Arduino Nano via USB to a serial terminal emulator (baud rate 9600) on the computer.

With seeduino film and the UartSBFrame programming adapter via USB to a serial terminal emulator, however, the terminal receives only garbage from the seeduino film.

Remedy: Set the baud rate to 4800.
Why??

If changing the baud rate to the next higher one, to be 19200 in the arduino code, one can then connect the terminal emulator with 9600. It seems to be always off by one - is this a known bug?

Wednesday, September 14, 2011

Old subversion link

https://www.assembla.com/code/tag/subversion/nodes?rev=24

Load arduino wirelessly via xbees

http://www.ladyada.net/make/xbee/arduino.html
RTS and DI03 are connected in the explorer board - to transmit the RTS signal wirelessly via the DI03 pin. The xbees have to be configured to transmit the DI03 signal.

Serial connection between two XBEEs

- plug in two xbees with USB explorer boards

- connect to the xbees via serial terminal emulator
screen /dev/tty.usbserial-A8004xAX 9600
screen /dev/tty.usbserial-A8004YWG 9600

- access xbee configuration via AT commands:
+++ -> should return OK, makes the xbee listen to commands
AT -> should return OK, now we are really sure that the xbee understands commands
ATID -> PAN id, 3332 per default, (xbees send/recieve within same PAN id)
ATBD -> baud rate for wireless transfer, 3 per default, number codes mean:
0 = 1200
1 = 2400
2 = 4800
3 = 9600
4 = 19200
5 = 38400
6 = 57600
7 = 115200

-> AT (check if xbee modem is responding)
<- OK -> ATBD (get current baud rate as above)
<- 3 (9600) -> ATBD 4 (set baud rate to 19200)
<- OK -> ATBD (check again)
<- 4 -> ATWR (write the baud rate change to flash)
<- OK





http://www.ladyada.net/make/xbee/ref.html

Screen as a serial terminal emulator in MacOS X

screen /dev/tty.usbserial-XXXXXXXXX 9600

More comfortable: Apple script

tell application "Terminal"
do script with command "screen /dev/tty.KeySerial1"
set number of rows of window 1 to 100
set number of columns of window 1 to 80
set background color of window 1 to "black"
set normal text color of window 1 to "green"
set custom title of window 1 to "SerialOut"
end tell

Control-A followed by Control-\ to exit your screen