Thursday, February 16, 2012
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: Lego, programming, Sugar, TurtleArt, TurtleBlocks, Wedo
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.from TurtleArt, Firmata running on the Arduino
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.core=arduino
leonardo.build.variant=leonardo
leonardo.build.f_cpu=16000000L
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: Arduino, olpc, programming, Sugar
Wednesday, November 09, 2011
Turtle checksums

Here is a Turtle Art program that calculates the checksum of a South American 7 digit identity number. Source. You can get the algorithm as a spreadsheet
Challenges:How many ID numbers share a checksum?
Find 2 ID numbers with the same checksum, not by trial and error
The 'key' is 2987634, what restrictions are there on the key that could be used?
What is the effect of having the digit 0 in the key?
Labels: olpc, Sugar, TurtleArt, TurtleBlocks
Saturday, November 05, 2011
RGB colour addition
source
Demonstrates colour addition using Turtle Blocks
Challenges:
vary the brightness of the colour circles, you could use the keyboard
Labels: Python, Sugar, TurtleArt, TurtleBlocks
Sunday, October 09, 2011
XO-1.75 seismograph
A seismograph program which uses the accelerometer of the OLPC XO-1.75 laptopThe x,y,z accelerometer readings are saved in boxes x,y,z. Action 1 computes long term averages for these readings, (boxes a,b,c), 5% of the current reading is added to 95% of the long term average to compute a new long term average.
Action 2 determines a threshold of random noise which is ignored. It sums the squares of the deviation from average (x-a)^2 + (y-b)^2 + (z-c)^2 . If this figure exceeds 10, the screen is turned red to indicate that an event is occuring.
Action 3 prints the sum of the squares of the deviations and the x,y,z deviations.
Project source
Challenges:
When an event occurs, graph the 3 channels (a)
Save the 3 channels events with a time stamp for exporting into a spreadsheet (b), (c)
Set up a network of laptops, an event is considered to have occured if all register it. (Use turtle position to share data)
Save the 3 channels events with a time stamp for exporting into a spreadsheet (b), (c)
Set up a network of laptops, an event is considered to have occured if all register it. (Use turtle position to share data)
Labels: olpc, Sugar, TurtleArt, TurtleBlocks
Tuesday, October 04, 2011
How low can you see that the earth is curved
At how low an altitude does the earth look like a disk, in other words, from how low does a line from the horizon to your eye trace out the surface of a cone (with angle a shown from the centre) ?
Surprisingly low. The depression of the horizon below level is noticable from an altitude as low as 218m. (Lysterfield Lake trig point 37°56'31" S 145°16'06" E, Elevation 218m)

a = sin (a) for small a
a = 0.7/147 = 0.00476
r = 2h/a^2
r = 2 *218/(0.00476^2)
r = 19,000 km
Compared with the actual value of 6,371 km
Notes
Earth from space, image
Small angle formula







