Mark Foster's Blog

Misadventures in Technology

Review: Herbie the Mousebot Kit by Solarbotics

5 out of 5 stars

img_7866

I wanted a quick, easy to build robot kit to get back into electronics and robotics. I ask for a Herbie the Mouse Bot for Christmas and sure enough I got one. It was a fun kit to build and went together in a little over an hour.

You start off with a PC board…
Herbie the Mousebot by Solarbotics

… and a handful of components…

Herbie the Mousebot by Solarbotics

You break apart the PC board which serves as a PC board and a body for the mouse which, is pretty cool.

Herbie the Mousebot by Solarbotics

The PC boards join together via several solder joints. Tape is used to keep everything together until you are done soldering. A smaller board that holds the 9 volt battery connector helps keep the three main sides together. By the time you are done soldering all the joints it is a pretty sturdy little robot.

Herbie the Mousebot by Solarbotics

Herbie the Mousebot by Solarbotics

img_7855

The whiskers and tail activate a relay when bumped so the mouse will backup to avoid getting stuck. I taped the relay down while I soldered it in.

img_7859

Herbie with the photo diode “eyes” installed….

img_7861

Herbie just about finished…

img_7862

img_7866

Herbie is an interesting robot because it uses a simple analog IC, the LM386, to do something you might think requires a much more complicated digital circuit or micro-controller/processor:

http://downloads.solarbotics.net/PDF/Solarbotics_Herbie_the_Mousebot_Instruction.pdf

img_7868

Herbie the Mousebot by Solarbotics

We don’t have much open bare floor in the house and it moves quite fast so it was a bit of a challenge to keep it under control without hitting too much:

The Herbie Kit is well engineered and fun to assemble. I give it five stars and recommend it as a good first robot kit.

Review: Weller WLC100 Soldering Station

5 out of 5 stars

Weller WLC100 Soldering Station

I have started to take a renewed interest in electronics again lately and wanted to get a good soldering station to work with. I have a couple fixed wattage irons I use for my RC plane wiring but I wanted something adjustable with a variety of alternative tips available.

I ordered a Weller WLC100 and it is working pretty well for me so far. I also ordered some smaller conical and screwdriver tips that make it easier to solder smaller components and connections. One of the reasons I went with the Weller is because it is a relatively well know brand and I know I will be able to find tips for it.

There are more expensive solder stations that have digital controls and displays but I decided that an analog control was adequate. After using the station for a bit I am pretty happy with the analog control. The amount of heat transferred is so strongly dictated by the conduction of heat between the iron and the component/pad that I don’t know that such temperature precision makes much difference for most hobby uses. If you just tin the tip of your iron with a little bit of solder it will make significantly help with the transfer of heat from your iron to the component/pad you are soldering.

Weller WLC100 Soldering Station

The Weller iron is easy to grip with my fingers and doesn’t get too hot to handle at all. I built a Herbie the Mousebot Kit with it using a .062″ screw driver tip. It was nice to work with and did the job well. I would definitely pick up some smaller tips if you are going to be soldering smaller circuit boards. The screwdriver tip that comes with it is pretty nice but a small tip affords more precision.

I give the Weller WLC100 5 out of 5 stars. It is a good, relatively cheap soldering station with many tips available. Buy one and a couple tips to go with it:

Conical Tip, .031

Narrow SD Tip, .062

How to use the PHP cURL module to make HTTP requests from PHP

Some of my previous posts talked about making HTTP/web requests from PHP with a focus on the PECL_HTTP request module:

The last post mentioned above covered using the built-in file_get_contents() as an alternative if you are unable to install the HTTP PECL extension or need minimal HTTP functionality. This post will look at a third method of making HTTP requests from PHP, using the PHP Client URL Library AKA cURL library. The PHP cURL library essentially uses the cURL library from the cURL command line utility and makes the calls available via PHP functions.

Installing the PHP cURL library on Ubuntu requires just a couple simple steps:

  • PHP needs to compile in the cURL library but if you are using Ubuntu you can simply execute the following shell command instead of doing a custom PHP build:
    sudo apt-get install php5-curl
  • Restart Apache once the library has installed.
  • Call a page with the phpinfo() function and look for a “curl” section. It should be listed there if everything installed correctly:

    curlinfo1

Once the cURL library is added you can call the curl functions which are documented here. The following simple example makes a call to www.example.com. You will notice that I did not “echo” the return of curl_exec() to display it. This is because by default, the curl_exec() function displays the result and returns a true on success, false on failure.

<?php
 
$curl_handle = curl_init("http://www.example.com/");
curl_exec($curl_handle);
curl_close($curl_handle);
 
?>

If you want to assign the output to a variable so you can do something with it, you will need to set the CURLOPT_RETURNTRANSFER option:

<?php
 
$curl_handle = curl_init("http://www.example.com/");
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
$results = curl_exec($curl_handle);
curl_close($curl_handle);
echo $results;
 
?>

The PHP cURL library has a variety of options you can set using the curl_setopt() function. This includes setting GET and POST requests, setting fields for each, etc.

That is the five minute version of the PHP cURL library. Another quick way to make an HTTP request is to just make a system call to the “wget” command utility which is included on most *nix systems:

<?php
 
echo system("wget -O - http://www.example.com");
 
?>

This pretty cool but I think I prefer the other methods because they all run under the Apache process. That’s it for this post!

How to setup and use the Xdebug Extension for PHP Profiling

A profiling tool can provide valuable information about bottlenecks in your code. I believe profiling is a critical aspect of optimizing because it will tell you about your real code bottlenecks as opposed to your perceived bottlenecks. This enables you to focus your resources on areas that will provide the most performance benefit for your effort. Most programming languages and environments have one or more profiling tools available and PHP is no exception.

Xdebug is a PHP extension that provides valuable debugging information such as stack traces, functions traces, profiling, code coverage analysis, etc. There is another PHP tool called DBG that has similar functionality but this post will focus on using Xdebug.

Setup Xdebug

Xdebug is a PECL module and can be installed using the PECL installation instructions in one of my previous posts.

  • If you have already setup PEAR you just need to run the following from a shell:
    sudo pecl install xdebug

    If everything goes well Xdebug should download, build, and install. You may get a message telling you:

    You should add "extension=xdebug.so" to php.ini

    Go ahead and add the line. On an Ubuntu server you will probably find the php.ini file here: /etc/php5/apache2/php.ini

  • Restart Apache, or whatever web server you are using, so the change will take effect.
    If you are running Apache on Ubuntu it would be:

    sudo /etc/init.d/apache2 restart
  • Write a phpinfo.php page with the following code and then point a browser at it. It should show the Xdebug module there in addition to many other things:
    <?php phpinfo(); ?>

At this point the Xdebug extension should be installed. For more detailed instructions on a PECL extension install see my post: How to install a PHP PECL extension/module on Ubuntu. Note that there is a problem running the Xdebug extension with Zend Studio since it has it’s own debugger.

Enable Xdebug profiling

  • By default, profiling is disable in Xdebug. Enable it by adding the following entry to the php.ini file:
    xdebug.profiler_enable=On

    On on a linux box there is often a php.d or conf.d folder that holds additional .ini file settings PHP will use. On Ubuntu the path for this folder is “/etc/php5/apache2/conf.d”. To prevent further cluttering my php.ini file with Xdebug settings, I created a xdebug.ini file to store all my Xdebug .ini file settings. This file is located in the “/etc/php5/apache2/conf.d” so it is automatically scanned when Apache is restarted.

    Now you might be tempted to enable the profiler in your script using the ini_set() function which, normally allows you to temporarily set a .ini setting for only the current script execution. Unfortunately this does not work. You must set it in the php.ini or a sub .ini file and restart the web server.

  • Restart your web server (I.e. Apache) once you have “xdebug.profiler_enable” set to “On”.

By default, Xdebug will write a cachegrind.out file to the /tmp folder. It will be named something like cachegrind.out.22373 where the number at the end is the ID of the process that was profiled. If you are using Windows you will probably need to change the default folder. Also by default, this file will be overwritten by each script execution so you don’t have to worry about it getting too big. The output file behavior is highly customizable and a complete list of Xdebug settings can be found here.

Call your script and display the analysis

With Xdebug enabled, pull up the page in your browser that you want to profile. If everything is working OK a cachegrind.out file should show up in the /tmp folder.

There are a couple programs you can use to open and analyze the cachegrind file:

WinCacheGrind

WinCacheGrind is not very featured but it will tell you the main thing you need to know, which is where your PHP application is spending its time. Click on the screen shot below to see the full output of my test script:

wincachegrind screen shot

The script makes an external call to example.com using a file_get_contents() function. Based on this analysis I might try caching the call results and only make the call at some interval to keep the cache updated. This would eliminate almost 75% of the application’s overhead and is just one example of an easy-to-fix bottleneck that profiling will help identify.

KCacheGrind

KCacheGrind does essentially the same thing as WinCacheGrind but it is geared for the Linux desktop and has quite a few more bells and whistles:

kcachegrind screen shot

KCacheGrind includes a map feature that graphically represents the percentages of where the test application spent the time:

kcachegrind screen shot

KCacheGrind also includes a graph feature with an export option that displays a tree diagram of the linkage between all the includes and functions:

kcachegrindexport1.jpg

That’s it for this post. Have fun profiling!

Review: RC Wall Climber/Clamber Remote Control Mini Car (Updated)

2 out of 5 stars

RC Wall Climber/Clamber Remote Control Mini Car


Update: Warning

I have received at least one report of a non-working car and the manufacturer has does not seem to have a web site that I can find to get a replacement. I have downgraded my rating to 2 stars accordingly. If you buy one of these make sure you get it from some place you can return it if it doesn’t work.

NeweggMall.com recently sent me an e-mail pushing a wall climbing RC car called the Clamber!!! Master-Hand. It is actually listed under RC Wall Climber Remote Control Mini Car but the name on the box is “Clamber!!! Master-Hand” by Top Race R/C Series. Although similar, this is not the same as the Spinmaster Air Hogs Zero Gravity Micro Cars, which are a bit more expensive. It was cheap and cool enough looking that I naturally felt compelled to give it a try.

How it works

If you are not familiar with these, they have a vacuum inside that holds them to the wall. The four outer visible wheels are actually fake and just look nice. There are two inner wheels that are not visible (unless you flip it over) that sit against the wall and propel the car.

The switch on the back has three different modes: off, on without vacuum, and on with the vacuum. This way if you just want to run it on the floor you don’t have to turn on the vacuum and waste your charge.

The underside has two strips of fabric that sit against the wall to help maintain the vacuum. There are two intake holes on the bottom and 4 slits in the windows on top for the air output.

The car itself looks pretty cool although the fake tires are a little less than authentic. It comes in three colors: Red, Black, and Blue.

Performance

The car does not go too fast but fast enough. It drives similar to a tank because it is actually only using two wheels. To steer, it changes the speed of the wheel on the appropriate side. While you are driving the turn radius is not precise and tends to be a bit large. When you are stopped it will turn on a dime.

As power starts to run down, the vacuum does not hold the car as tightly to the wall as a full charge so sometimes the drives wheels will start to slip and you have to turn around and go in a different direction to get moving again.

Run time on the wall is about 7 minutes although performance slopes off and the car will start loosing its traction around 4 minutes. Even after 7 minutes the vacuum was still strong enough to keep the car on the wall. I didn’t time it but I am guessing run time on the floor without the vacuum on would be quite a bit longer. When you get close to 8 minutes the power will cut off before the battery is drained too far. It uses a built in Lithium-Polymer battery which is probably why a charge last as long as it does for something so light. Charge time is about 10 minutes.

Here are some pros and cons:

Pros

  • Pretty good amount of drive time per charge (about 7 minutes)
  • Only a 10 minute charge
  • Can rotate on a dime while stopped
  • Fun!

Cons

  • It will get stuck on even flat, clean surfaces occasionally after the battery has run down a bit.
  • The turn radius between running and when it is stopped is quite different. When it is stop it turns on a dime. When it is running it has a very wide turn radius in some cases.
  • IR controller does not perform well under strong light.

Conclusion

Overall I rate the wall climber 3 out of 5 stars. I would give it more stars if the steering were a bit more consistent and it didn’t get “stuck” as often. Overall it was pretty fun but I would say the Microfly is a bit more entertaining just because for about the same price or less, it flies around and that is hard to beat in my opinion.

Images

RC Wall Climber Clamber Remote Control Mini Car

RC Wall Climber/Clamber Remote Control Mini Car

RC Wall Climber/Clamber Remote Control Mini Car

RC Wall Climber/Clamber Remote Control Mini Car

RC Wall Climber/Clamber Remote Control Mini Car

RC Wall Climber/Clamber Remote Control Mini Car

RC Wall Climber/Clamber Remote Control Mini Car Charging

Video