Let's Make Robots!

How to use the PICAXE USB cable on Linux


So i finally managed to have the Picaxe USB Cable working under linux. Not the programming editor of course, just the serial connection. You can use it to send/receive data with sertxd and serrxd basic command.

Basically, the download cable contains an USB to Serial chip made by FTDI for which a linux kernel module already exists! The problem is that the module is not recognized automatically becouse the cable have different non-standard identificatives. So first, let's find the device. (note: give all commands as root)

Connect the cable to an USB port, then give the following command:

cat /proc/bus/usb/devices

It should list something like (among other devices):

T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  6 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0403 ProdID=bd90 Rev= 6.00
S:  Manufacturer=Revolution
S:  Product=AXE027 PICAXE USB
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr= 90mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

Now take note of the Vendor and ProdID you have (i don't know if they're the same as mine). Then give the following command:

modprobe ftdi_sio vendor=0x0403 product=0xbd90

This will load the ftdi_sio kernel module which will handle the serial communication. Substitute the two ID if they're different (remember the 0x before).

Now try to list the devices again, you should see where it said Driver=(none), now should say Driver=ftdi_sio.

The driver should have created a new device under /dev, called /dev/ttyUSB0 (maybe ttyUSB1 or 2 etc if you had other serial devices).

That's the device for your cable! You can now run your favourite program to use the port.

For example, to access it from the console you can run the standard minicom program. Once open hit CTRL-A O. It should open a configuration menu. Go to Serial port setup, choose the right device, set Bps/par/bits to 4800 8N1, no hardware control flow, no software control flow. Close the menu, connect your robot and you should see his output on the terminal!

(To exit minicom, give CTRL-A Q).

I think you can make the module load at boot time by putting a line in /etc/modules, something like:

ftdi_sio vendor=0x0403 product=0xbd90

This ends this wanderful guide. IHTH

 

 A session of minicom, reading robot output

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Fantastic!

(And rumor goes that they are making a Linux version of the editor!) 

/ Fritsl

you can't just wine the editor?

 

I want to wipe XP off my EEE pc :P  

spoken from person

Well that's true but i don't like non native applications and windows emulators.. I prefer to run real linux stuff :)

Someone could try to reverse engineering the download protocol and make a real linux programming environment, but maybe it's not worth the effort since a linux version is already in the works. 

BTW if you prefer a more user friendly graphical serial terminal instead of minicom, take a look at GtkTerm.

 

someone want to try it :P then i can switch :D back to debain + kde
someone want to try it :P then i can switch :D back to debain + kde

Anyone know of any attempt to reverse engineer the picaxe download protocol (ie some documentation) ?

I tryed to log the serial port traffic but when i run a download the picaxe doesn't answer.. there's something going on :)

You should contact the company directly - see if they can release any specs or other details to you . Although, less glamorous than hacking, this can be a HUGE time saver.  If they are  trying to support linux they might be very amiable in giving you the necessary info, who knows, maybe their project is on sourceforge now...

When you tried to log it did you use ttysnoop or ttylog -> http://linuxgazette.net/issue48/tag/52.html ?

You cannot do that reverse.. (in a million years, at last) - because the Picaxe editor is NOT just transferring the BASIC to the Picaxe; It assambles it, parces it to the libraries etc.. and then it transfers. 

/ Fritsl

Yeah i know.. But it's less than a million year :) After all, they reverse engineered harder stuff, like NTFS.. There are well known tecniques to do reverse engineerings, i did some in the past. Basically you observe the transfer, than make small changes and observe the difference and so on.

For what i know, the basic interpreter resides on the chip, so the programs are not "compiled" on the editor. Instead they're probably parsed and tokenized with some eventual transformations. For example, that's exacly the way old MSX computers save Basic programs on tape.

Anyway, i'm not gonna do anything near a full or useful reverse engineering.. i dont' have the time nor the skills :) I'm just investigating a little.. I like to know how things work :)

For grog: i was on windows, i used Null Modem Emulator and a small program by me to log stuff.