Dec 2, 2011

Lego Mindstorm NXT - Programming Options

Option 1: Lego Mindstorms NXT Software version 2.0
The first and the official programming option for the NXT is Lego Mindstorms NXT software version 2.0 that is based on Labview from National Instruments. It is delivered with 8547 LEGO® MINDSTORMS® NXT 2.0.

Mindstorms software is a graphical programming environment. The programming is made connecting bricks and data lines. It is "a great tool" for learning and teaching programming, and it is also fun. It is possible to do non trivial tasks like multi-threading and functions. But for non-small programs it is not practical.

Mindstorms software is used to make programs, to send the compiled programs to the NXT, to remote control the NXT, and to update NXT firmware. Both USB and Bluetooth are supported. I've tested it under Windows but it is also supported under Mac. It does not work under Linux.

See my enhanced color sorter program:
The main program. Note the two threads. The bottom is for the dispenser and color sensor, while the top controls the tray.

Function: tray_next

Function: tray_previous

This robot is running the code shown above.

You can download my program here. You will need Mindstorms software to open the files.

Mindstorms software is the perfect development environment for starting playing with Lego. It is as intuitive as connecting lego bricks and it is also beautiful. But is not practical for non small programs. I would not recommend to implement large software using it. But I would recommend this visual language to introduction to robotics and to programming languages.

There is lots of information about LabView at:

Option 2: RobotC
LabView was successful on allowing me implementing the enhanced color sorter algorithm. But it becomes clear that LabView is not practical for complex and large programs.

I found Robotc and tried it. There is a 30 days trial version that I used for two weeks.

The first step is to upgrade the NXT firmware so it can support Robotc binaries. Do not worry about firmware upgrades. It is easy and safe on the NXT. You can always upgrade the firmware to the Lego Offical Firmware using the LabView.

RobotC offers complete development environment with functions similar to the LabView. But instead of connecting bricks and data lines you write C programs.

I found some limitations when I was using more than one thread simultaneously. I'm quite sure that those limitations are not insurmountable, but I did not like RobotC. For the basics there are good documentation and tutorials but I did not find free detailed information.

Like labview, RobotC works on Windows and does not works on Linux.

See RobotC web site.

Option 3: NXC

"Not eXactly C (NXC) is a high level language, similar to C, built on top of the NBC compiler. It can also be used to program the NXT brick. NXC is basically NQC for the NXT. To compile NXC programs just use the NBC compiler with source code files that have a .nxc file extension. A reference guide for NXC is available. You can also access online API help for NXC or download a compiled HTML help file. To take advantage of multi-dimensional array support and native shift operations be sure to download the enhanced NBC/NXC firmware and install it on your NXT."

I liked NXC. "To me", it feels more like C gcc than RobotC and it works on Linux. If you are Windows user, you should try Bricx Command Center that uses NXC/NQC, but if you are Linux user, NXC is great option. I'm using two tools that are official Fedora 15 packages: NQC and NXTRC. NQC is the compiler for the NXC while NXTRC is a tool for remote controlling the NXT and to send files to the Brick using bluetooth. I'm using the following packages:




Installing both on Fedora 15 is as hard as:
# yum install nxtrc nbc

To compile the color sorter on Fedora 15:
$  nbc dispenser4.nxc -O=dispenser4.rxe -sm-

Then, to send it to the NXT using bluetooth:
$ nxtrc -a 00:16:53:13:9A:70 -W dispenser4.rxe

The documentation for NXT is complete and freely available. Also, working on Linux is also very good to me. The binaries made by NXT works on Offical Lego Firmware but you can update to a firmware that is announced to offer better performance. I did not tried the high performance firmware yet.

The source code of the color sorter can be downloaded from: dispenser4.nxc

There is more information about NXC here.

I would start with LabView for initial fun and learning about sensors and motors, then switch to NXC for the complex tasks.
RobotC may have better processing performance and also richer debugging than Bricx Command Center. But for now, processing performance and richer debugging interface are not features that I'm looking for. If you need processing speed and/or rich debugging interface, give RobotC a try.

Dec 1, 2011

Lego Mindstorm NXT - Open Source Rules

The bad news: My NXT brick was not working properly when I took it from the box. The sensor port 2 was not working. I do not think that there is warranty coverage for Lego Mindstorms in Brazil. I had no better option than try to fix it.

The good news: Lego delivers all information about the NXT electronics and its embedded software. It is a true open source platform.

I've downloaded the schematics from:

And I've noticed a missing component near the port 2. R59 was not there. For lucky it is a common 1k resistor. Thanks to my father's SMD lab, we were able to solder a new resistor, and push hot air over port 2 components. After that port 2 started to work.

I'm deeply happy with Lego's open source policy for this product. I was wondering how happy I'll be when my car becomes open source. Lego gave us the power to fix the problem without any limitation. It is clear to me now that open source is great for hardware too. Is there open source tendencies for industry?

R59 was not there when I've opened my NXT for the first time. The schematics is from Lego web site.

What kind of information is freely and officially available about the Lego NXT:
- NXT Brick hardware schematics
- Sensors schematics
- I2C Communication protocol used for sensors
- Bluetooth interface specification
- Hardware Developer Kit
- Executable File Specification
- Mobile Application Software
- Mobile Application Documentation
- Open Source Firmware


Lego has supported the development of a remote control to the NXT that runs on Android. The source code is released under GPL3.

About my non-working brick, I'm quite sure that this kind of problem happens very few times. Lego Mindstorms NXT 2.0 is clearly a high quality product. I believe that I'm the only in many many many owners who had this kind of trouble. And I admit: It was fun to fix it! :-D

2017 Update: Schematics are available here.

Lego Mindstorm NXT

Want to have some fun with Robotics? 8547 LEGO® MINDSTORMS® NXT 2.0 is the right kit for you!

Color Sorter with a bit more complex algorithm

 To me Lego Mindstorms NXT is a dream come true. Why? Robotics! Robotics! Robotics!

What's inside the box?
- The NXT programmable Brick with Bluetooth, USB, 7 I/O ports for sensors and motors, speaker, buttons, and LCD display.
- 4 Sensors: Ultrasonic, light and color, 2 touch sensors
- Some cables
- 600+ pieces for assembling machines animals and humanoids.
- Software for Windows and Mac for programming the NXT.

Nov 7, 2011

iSCSI and LVM: Boot problem

Both LVM and iSCSI are powerful and reliable. But there is an issue with the combination of both that made me fell completely lost more than once.

The Scenario:
iSCSI target / server is a Linux Box with LVM features
iSCSI target / server exports disk, partition or LVM LV
iSCSI initiator / client uses the exported volume as LVM PV
All works perfectly until rebooting the iSCSI target / server

The symptom:
After rebooting the iSCSI target / server, it becomes impossible for the initiator / client use the exported volume as if it were deleted. The iSCSI target / server service itself is working properly but the exported volume is not.

The cause:
During the boot of the iSCSI target / server, its LVM liked the new found PVs / VGs / LVs. The iSCSI target / server has no idea about those new found are not for the local machine and it "locks" the VGs and LVs for local use. When iSCSI exports the LV, it will contain locked LVM volumes. This is why it becomes impossible to use it on the iSCSI initiator / client.

The solution:
It is very easy. Edit /etc/lvm/lvm.conf and use "filters" to tell LVM what is not for local use. My filter is configured as:

filter = [ "a/sda/", "r/.*/" ]

For testing, just type pvscan after editing the file to see if the filter worked as expected. If so, just reboot and it will work.

Please note that using sda on the filter is not the safest solution as it is not impossible that sda becomes sdb for example. It will be safer to use UUIDs of something else.

Nov 3, 2011

Acer Iconia Tab W501P Review II

Fedora 16 Beta

Feroda 16 Beta runs on the W501P without any major concern. The only issue I found is the Gnome onscreen keyboard that does not work well. Despite the onscreen keyboard, I did not found any serious issue when using Fedora on Iconia Tab W501P.

I did no testing with ATI proprietary drivers on Fedora.

Ubuntu 11.10

Ubuntu 11.10 also runs on the W501P but there are some details:
1 - When I allowed the installer to download updates during installation, the X did not work very well after first boot. So I installed it again and it is working pretty well without allowing the packages to be updated. I'll wait untill ATI driver supports the C-60 GPU until allowing updates.

2 - The ATI proprietary driver does NOT work with C-60 GPU. I've tried Ubuntu's two packages, "AMD Catalyst™ 11.9 Proprietary Linux x86 Display Driver", and "AMD Catalyst™ 11.10 Proprietary Linux x86 Display Driver". When using Ubuntu's package, an stamp with AMD logo appears on the right bottom corner saying: "Unsupported Hardware". I would not recommend to try those drivers with Ubuntu 11.10. It may be necessary to re-install your Ubuntu.

After learning about updates and ATI proprietary driver, I'm happy with Ubuntu on W501p. I'm curious about the performance gain by using the proprietary graphics driver. Will it be possible to play HD flash movies on full screen?

The battery

I was curious about the sleep state power consumption. I've charged the battery, and asked Ubuntu to sleep the tablet. I removed the charged cord and waited exactly 12 hours. How many % of the battery power were consumed in 12 hours?

The result is that after 12 hours of sleep state the battery charge was informed to be 92% by Ubuntu. 8% every 12 hours means 16% every 24 hours. Looks like that the Iconia Tab W501P can stay sleeping for more than 6 days. This is good!

Not tested yet battery life for usage. I think that this will be improved when the proprietary graphics driver is available.

Battery charge after 12 hours of sleeping

Nov 2, 2011

Recording from webcam, saving to file, displaying locally, using VLC, under Linux

# Change /dev/video1 to your webcam device name
# Change plughw:1,0 to your audio capture device. (Check /proc/asound/devices)
# Change 1920 to the correct width of your webcam ( Check Cheese preferences )
# Change 1080 to the correct height of your webcam ( Check Cheese preferences )

$ vlc v4l2:///dev/video1 :input-slave=alsa://plughw:1,0 :v4l2-standard=0 :v4l2-aspect-ratio=16\:9 :v4l2-width=1920 :v4l2-height=1080 :v4l2-fps=30 :sout="#transcode{vcodec=mp4v,vb=5000,scale=1,fps=30,acodec=mpga,ab=128,channels=1,samplerate=44100}:duplicate{dst=std{access=file,mux=ts,dst=/tmp/video-output.mpg},dst=display}"

Oct 29, 2011

Acer Iconia Tab W501P Review

Model Acer Iconia Tab W501P C62GO3iss
P/N: LE.L0603.038
Model: EAB00
OS: Windows 7® Professional 32-bit
Processor: AMD Dual-Core C-60
LCD: 10.1" Multi-touch HD LED LCD
Memory: 2GB Memory
Storage: 32GB SSD
Card Reader: 2-in-1 card reader
WLAN: 802.11 b/g/n & BT 3.0 + HS
Webcam: 1.3 Megapixel
Battery: 3-cell Li-ion battery
Software: Microsoft Office 2010 preloaded (purchase a license key to activate)
Microsoft Office Starter 2010

I was tremendously curious about the performance of both AMD C-60 processor and it's ATI GPU. I was expecting that it would be possible to play Full-HD flash movies at 30 fps. I'm at Czech Republic, and I ran to the first Acer Iconia TAB W501P that was available at The main differences to W500 is that the W501P has 3G modem and is equipped with AMD C-60 instead of AMD C-50. According to, the C-60 can run up to 1333 MHz and it's GPU can run up to 400 MHz, while C-50 maximums are 1000MHz for the CPU and 276 MHz for the GPU.

First impression
As the box reached me, I realized that it is "too" heavy. The box itself is heavy, as the tablet and it's keyboard are very well packed but "light weight" is not a feature for the W501P.

The first boot
Even being a Linux guy, I do not hate Windows. I think that Microsoft does good software, with bad business model, but good software. Windows 7 is not bad software. But the ton of crap that came pre-installed with the tablet is not good. It took 40 minutes installing toolbars and other useless software.  After installing all the crap, Windows 7 were so slow that I felt I that I shouldn't have bought the tablet.

But I noticed that the screen and it's touch sensor are great. It has resolution of 1280x800 with great colors and bright. The touch precision is also great. It just works without needing calibrate anything. Image quality and touchscreen precision are qualities of this tablet. Fullscreen play of Full-HD youtube videos did not went as I was expecting. The frame rate is perfect for resolutions up to 480p. Above 480p it is not perfect any more.

It works on Fedora 16 Beta. 3G modem, wired and wireless devices, single touch screen, two web cams, sleep state, and speed step. Rotation sensor, bluetooth and muti-touch did not work out of the box. I'll check what can be done.

After tuning the Kernel to use noop scheduler for the SSD the overall performance is not bad. It is light year ahead of 2008 Aspire One with single core Atom. I would not use the tablet for compiling Kernels, but it fits for reading, writing and surfing. Comparing the Iconia tab W501P with Toshiba R830 Core i7 notebook is not fair. But the fast graphics of the tablet really helps on giving the "sensation" of high speed. The user interface is almost as fast as on Core i7 but tasks like starting Libreoffice are much, much slower.

I was surprised that Fedora 16 comes with on-screen keyboard that shows up only when typing is needed. Almost like it is on Android. The software keyboard itself is very immature and many times it does not appear when it is necessary. I'll try with Ubuntu.

I'm happy with Linux on Iconia Tab W501P.

The docking
It could be thinner and lighter but it is ok. The keys are delicious to press and are not noisy. The stick mouse is fun but sometimes it is easier to touch the screen. Having Ethernet connection is very good. The docking fits the tablet, looking like a closed notebook. It is practical for transporting.

The battery
I had no time for testing it, but I do not believe that it would reach 4 hours of non intensive use. I'm curious about sleep state power consumption.

Next comments
I'll write again when I have more experience with it. I used the tablet for one day only. I'm really not sure about how can a tablet help me. I'll figure it out, or not, soon. :-)

Toshiba R830-10P and Acer Iconia Tab W501P

On the docking station - Front

On the docking station - Back

Off the docking station - Front

Docking and tablet closed as notebook

Jul 15, 2011

Samsung Galaxy S GT-I9000B Firmware upgrade

Finally Kies gave me the option to update my phone to Android 2.3.3. :-)

Jul 2, 2011

System Monitor applet and other Gnome3 tips

Gnome3 is revolutionary. But to enjoy its benefits, I had to exercise my zen side and let many old habits behind. I decided to give it a try. I'm liking it.

But even liking Gnome3, I was missing System-Monitor applet. But now I have it. :-)

I followed Matthew Casperson's post and added just some little steps:

After following the steps described on Matthew Casperson's post:

$ mkdir ~/bin
$ cd ~/bin
$ ln -s ~/git_projects/gnome-shell-system-monitor-applet/ system-monitor-applet-config

Those steps will enable you to call "Preferences" on the applet icon.

I would also recommend reading other Matthew Casperson's post: Gnome 3 Tips and Tricks

Jun 27, 2011

Five steps to create Fedora chroot jail using yum

- This will work only if your Linux Distro is based on RPM and YUM. I have tested it on Fedora but it may also work on RHEL and Centos... It will NOT work on Ubuntu, Debian, Suse...
- The operating system and its version will be the same inside and outside the chroot jail.
- On the example, the chroot will be placed at: /chroot/devel
- To install different version of Fedora or other RPM based distro, it will be necessary to manage yum package repositories outside the jail.

The five steps:
# 1 - Create the chroot directory
$ sudo mkdir -p /chroot/devel/var/lib/rpm

# 2 - Initiate rpm db on chroot
$ sudo rpm --root /chroot/devel --initdb

# 3 - download Fedora Release package.
# If you do not want Fedora, download the correct *-release package and use it
# on step 4. There are examples on the references.
$ yumdownloader --destdir=/tmp fedora-release

# 4 - Install downloaded Fedora release inside chroot
$ sudo rpm --root /chroot/devel -ivh /tmp/fedora-release*rpm

# If you want more than just bash, see 5a - OPTIONAL
# 5 - Install bash and its dependencies on the jail.
# For different versions of Fedora or to install other RPM based distros, it will be
# necessary to configure the correct yum repositories outside the jail, so yum
# can download the correct packages.
$ sudo yum --installroot=/chroot/devel install bash

#5a - OPTIONAL: Do a minimum system install
# If you want all packages from the minimum install option
# `yum grouplist` show all available groups
$ sudo yum --installroot=/chroot/devel groupinstall "minimal install"

- To enter the jail:
$ sudo chroot /chroot/devel
- If you want to install yum inside the jail:
$ sudo yum --installroot=/chroot/devel install yum

Creating chroot environments with yum

Creating a FEDORA 10 CHROOT Environment in DEBIAN SID

May 26, 2011

Benchmark: Samsung S2 Portable 500GB USB 2.0 External HD

Benchmark results for Samsung S2 Portable 500GB USB 2.0 External HD Performance:
Write (K/sec): 34974 ( 52% of the HD Performance of my notebook )
Re-write (K/sec): 17612 ( 59% of the HD Performance of my notebook )
Read (K/sec): 46580 ( 64% of the HD Performance of my notebook )
Seeks/sec: 123.8 ( 164% of the HD Performance of my notebook )

The theoretical speed limit for USB 2.0 would be 60 MByte/sec. The read speed is about 78% of this value wich is not bad. Even not feeling slow, this HD could be faster.

About tests:
Command line run on both notebooks:
# bonnie++ -n 0 -u 0 -r 8192 -f -b -d /media/Peter-ext3/bonnie/
Bonnie 1.96 @ Fedora 15

# hdparm -I /dev/sdb


ATA device, with non-removable media
Model Number: SAMSUNG HM502JX
Serial Number: C2271F141A0TE5
Firmware Revision: 2AC101C4
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6
Used: unknown (minor revision code 0x0028)
Supported: 8 7 6 5
Likely used: 8
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 976773168
Logical Sector size: 512 bytes
Physical Sector size: 512 bytes
device size with M = 1024*1024: 476940 MBytes
device size with M = 1000*1000: 500107 MBytes (500 GB)
cache/buffer size = 8192 KBytes
Form Factor: 2.5 inch
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = ?
Advanced power management level: disabled
Recommended acoustic management value: 254, current value: 0
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
Advanced Power Management feature set
Power-Up In Standby feature set
* SET_FEATURES required to spinup after power up
SET_MAX security extension
Automatic Acoustic Management feature set
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* 64-bit World wide name
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Native Command Queueing (NCQ)
* Host-initiated interface power management
* Phy event counters
* Idle-Unload when NCQ is active
* NCQ priority information
DMA Setup Auto-Activate optimization
Device-initiated interface power management
* Software settings preservation
* SMART Command Transport (SCT) feature set
* SCT Long Sector Access (AC1)
* SCT LBA Segment Access (AC2)
* SCT Error Recovery Control (AC3)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
Master password revision code = 65534
not enabled
not locked
not frozen
not expired: security count
supported: enhanced erase
Logical Unit WWN Device Identifier: 50000f001afbe500
NAA : 5
IEEE OUI : 0000f0
Unique ID : 01afbe500
Checksum: correct

See more benchmarks:

May 25, 2011

WiFi/Wireless on Toshiba R830 on Fedora 15

I was not able to use WiFi on Toshiba R830 running Fedora 15. There were missing firmware files for iwl6000g2b adapter. It is very easy to fix it:

# yum install iwl6000g2b-firmware

Then reboot and your Wifi will be running after next boot. :-)

Benchmark: Core 2 Duo T7200 vs. Core i7 2620M

Test systems:
System 1: 2007 noteoobk: Toshiba U205-S5067: Core 2 Duo T7200, 4GB RAM, 320 GB HD
System 2: 2011 notebook: Toshiba R830-10P: Core i7 2620M, 8GB RAM, 256 GB SSD

This benchmark result is not only affected by the processor. Almost all system components affects the result. The processor is only the main component.

Evaluating overall performance, for compiling Linux Kernel and generate its RPM packages for Fedora 15: Core i7 system is 2.85 times faster than Core 2 Duo system.

I've run the steps described on:, for the kernel package kernel-

The only difference to the procedure described above is that I added the command "time" in the building step, to be able to compare necessary time to do same task.
$ time rpmbuild -bb --with baseonly --without debuginfo --target=`uname -m` kernel.spec

Individual results
System 1: Core 2 Duo
real 67m48.453s
user 88m6.698s
sys 17m35.033s

System 2: Core i7
real 23m46.994s
user 68m25.556s
sys 10m29.816s

See more benchmarks:

May 24, 2011

Benchmark: SSD vs. SATA

System 1: 2007 noteoobk: Toshiba U205-S5067: Core 2 Duo T7200, 4GB RAM, 320 GB HD

System 2: 2011 notebook: Toshiba R830-10P: core i7 2620M, 8GB RAM, 256 GB SSD

How many times faster is SSD??
Write: 2.50 times faster
Re-write: 2.83 times faster
Read: 3.89 times faster
Seeks/sec: 23.99 times faster

Benchmark results:
System 1: 320GB SATA HD
Write (K/sec): 66608
Re-write (K/sec): 29609
Read (K/sec): 71894
Seeks/sec: 75.4

System 2: 256GB SATA SSD
Write (K/sec): 166827
Re-write (K/sec): 84040
Read (K/sec): 280068
Seeks/sec: 1809

About tests:
Command line run on both notebooks:
# bonnie++ -n 0 -u 0 -r 8192 -f -b -d /bonnie/
Bonnie 1.96 @ Fedora 15

System 1 HD info:
hdparm -i /dev/sda


Model=SAMSUNG HM320JI, FwRev=2SS00_01, SerialNo=S16LJF0S221285
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs }
RawCHS=16383/16/63, TrkSize=34902, SectSize=554, ECCbytes=4
BuffType=DualPortCache, BuffSize=8192kB, MaxMultSect=16, MultSect=off
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=625142448
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
AdvancedPM=yes: unknown setting WriteCache=enabled
Drive conforms to: ATA/ATAPI-7 T13 1532D revision 0: ATA/ATAPI-1,2,3,4,5,6,7

* signifies the current active mode

System 2 SSD info:
# hdparm -i /dev/sda


Model=TOSHIBA THNSNC256GBSJ, FwRev=CJTA0202, SerialNo=21RS106DTCNZ
Config={ Fixed }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=500118192
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=yes: unknown setting WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-3,4,5,6,7

* signifies the current active mode
See more benchmarks: