Tuesday, January 24, 2012

Wedo plugin for Turtle Art


Download here a plugin for TurtleBlocks V131 (tested on OS880 Sugar 0.94) . It is a rework of a project by I.T. Daniher which has been dormant since March 2011. Here and here.

Download the file and unzip it, copy wedo-plugin to the plugins directory of Turtle Blocks (/home/olpc/Activities/TurtleArt.activity/plugins).


Known problems:
Turtle Blocks will not start unless a Wedo is connected
The distance sensor gives bad values if the motor is running

Labels: , , , , ,

Saturday, January 21, 2012

Arduino and the XO laptop


The Freetronics Leostick is a low cost Arduino board. (It is presumed to be low cost, it was cheap enough to place into the satchels of the attendees of LCA2012.) The XO-1.5 already has 2 channel analogue input, an Arduino board can add a lot of extra input and output channels.

This could facilitate a number of low cost science and robotics experiments in schools, experiments at a cost suitable for developed and even developing countries.


There are a number of ways such a board could be used:
  • from the Arduino IDE
  • from TurtleArt, Firmata running on the Arduino
The second version is probably the most practical for classroom use. Once the Leosticks are loaded with Firmata (and this could even be at the factory) all that is requited is TurtleArt drag and drop programming.

Installing the Arduino IDE onto a XO-1.5 laptop (OS880)
In terminal enter the following

sudo yum install arduino

This installs an older version (0021), more importantly it installs all the dependencies including Java and avr-gcc. It is a 60MB download which expands to 200MB of storage, be warned it uses up a lot of precious space.


The IDE can be started from the Gnome menu or with the command

arduino

but it does not have the permissions to see the Arduino board on the USB serial port so start it as root (maybe why)

sudo arduino

The IDE can then be upgraded to version 1.0. This is the version recommended for the Leostick. Download version1.0 from http://www.arduino.cc/en/Main/Software
The file arduino-1.0-linux.tgz uncompresses with the Gnome archive manager. Uncompress it to a convenient location, if for example if you uncompress it to Documents, you will find a directory arduino-1.0 in this directory.

You now have 2 versions of the program, 1.0 (at /home/olpc/Documents/arduino-1.0 ) and 0021 (with components at /usr/share/doc/arduino-0021 and /usr/bin). The later versions 1.0 uses the dependencies installed with the earlier one 0021.

As described at http://www.freetronics.com/pages/leostick-quickstart-guide uncomment the following lines in /home/olpc/Documents/arduino-1.0/hardware/arduino/boards.txt

(or in version 0021 you would need to add them)

leonardo.name=Arduino Leonardo
leonardo.upload.protocol=arduino
leonardo.upload.maximum_size=28672
leonardo.upload.speed=1200
leonardo.bootloader.low_fuses=0xde
leonardo.bootloader.high_fuses=0xd8
leonardo.bootloader.extended_fuses=0xcb
leonardo.bootloader.path=diskloader
leonardo.bootloader.file=DiskLoader-Leonardo.hex
leonardo.bootloader.unlock_bits=0x3F
leonardo.bootloader.lock_bits=0x2F
leonardo.build.mcu=atmega32u4
leonardo.build.f_cpu=16000000L
leonardo.build.core=arduino
leonardo.build.variant=leonardo

Launch the Arduino IDE (sudo /home/olpc/Documents/arduino-1.0/arduino), and select Tools > Board > Arduino Leonardo.
to select the Leonardo hardware

select Tools > Serial Port
a new device appears with Leostick plugged in, dev/ttyACM0, select it.

You can now upload example programs, eg blink, to the Leostick.

NOTE: this will overwrite the program that came with your Leostick that plays a tune, watch
http://forum.freetronics.com/viewtopic.php?f=27&t=167
for the original program


Controlling the Arduino with Turtle Art
Load Firmata software into the Leostick, this can be done on an OLPC, another Linux PC or Windows. Once this is done the Leostick can be used as a I/O expander for Turtle Block drag and drop programming. No Terminal or Gnome work would be needed.

http://tonyforster.blogspot.com/2010/10/arduino-fork-of-turtle-art.html

The version here works for older Arduino boards on Sugar 0.88 It needs patching at TurtleArtActivity.py, line 834 as described in the link above. The baud rates of Turtle Art and Firmata need to be patched.

Sugar 0.88 (Fedora 11) recognises an older Arduino board as as serial device but not the Leostick. Later Arduino boards are dev/ttyACM0

This version is hard coded to dev/ttyACM0, that means it only works the first time the Leostick is plugged in and not at all for older Arduino boards. It is patched and works on Sugar 0.94.

The quick and dirty patches are:
Turtleartactivity line 835
self.palette_buttons[i].set_tooltip('thing')
line 868 commented out
# palette_toolbar_button.set_expanded(True)
serialposix.py line 273
# self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
self.fd = os.open('/dev/ttyACM0', os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)



see also:
http://tonyforster.blogspot.com/2010/10/turtle-arduino-display-inputs.html
http://tonyforster.blogspot.com/2010/10/turtle-arduino-digital-write.html

Labels: , , ,