.comment-link {margin-left:.6em;}


A Periodic (P)review Of Leaping Forward

By: Johan

Saturday, January 14

Phidgets & Mac - Part 1 - Introduction & Installation

I bought myself a Phidgets LED Kit from Active Robots for Christmas. Phidgest are physical widgets; they allow electro newbies like myself to develop cool stuff ranging from a simple website controlled dog feeder to full blown cockpit simulators. I have an idea or two as well but before revealing those I have a host of problems to tackle.

I'm planning to write a series of 'notes to myself' here on my blog to document my Phidgets programming experience. I'll try and write in such a way that it may work as a tutorial on phidgets coding for other Mac users as well. This first part is a total newbie's, idiot's slash dummy's introduction.

When I bought the LED board I didn't own this Powerbook yet. I was planning to develop in VB on Win XP first since it seemed the easiest language with lots of working examples ready to be hacked to bits. I'm not a code guru and have no plans becoming one but for a hobby I don't mind learning another language. OK maybe I am close to a PHP expert but that doesn't translate easily into all the other languages out there like Ruby, C and Xcode. My back-up plan was to just develop in Java or Python on Linux; back then my OS of choice.

All of those plans went out of the window when I was given a Powerbook as a Christmas bonus. Luckily Phidgets do support Mac OS Tiger! And judging by the installation readme it's all quite simple as well:

The framework is basically just a dynamic shared library. The easiest way to use it is to create an xcode project and add the Phidget20 framework, then in your sourcecode you just have to define top level header:


CoreFoundation has to be included before Phidget20.

Yeah... But I had never heard of a 'dynamic shared library' or 'xcode'.


Xcode seems Apple's programming language of choice. They've dedicated a whole section of their website to it here. Appdevadvisor puts it in these words:

You can think of Xcode as being the Apple equivalent of VS.NET. It’s probably fair to say that the ‘preferred’ mainstream PC programming language is now C# (preferred by Microsoft, that is, but not necessarily what the majority of third-party developers are currently using). On the Mac, the hot dev language on the block is a deeply strange animal called Objective-C.

So I guess Xcode is just the tool or framework to write Objective-C? No idea. What is Cocoa then? Also Objective-C language according to Jason's comparison with VB.net. So I'm a bit confused but that doesn't stop me from diving in at the deep dark end. Comprehension of this OS language geekspeak will probably come later. Before I say that, according to Wikipedia, Xcode is nothing but a coding environment, just an IDE. So if Zend studio is my IDE for PHP, I guess Xcode will be my developing environment for Objective C. This quote confirms that idea:

Xcode includes GNU Compiler Collection (GCC), and can compile C, C++, Objective C++, Java, AppleScript, and Objective C source code with a variety of programming models, including but not limited to Cocoa, Carbon, and Java. Third parties have added support for GNU Pascal, Free Pascal and Ada.

So... Let's get cracking!

I've hooked up the Phidgets LED board via USB to my Powerbook and via a Skytronic 12 Vdc switch mode power supply to the wall for juice. That's about the max recommended voltage for this Phidget; the included leaflet talks about just 6 Vdc at 1.5 Amps. The guys at Active Robots said this would be perfect so fingers crossed...

After the hardware, we'll need the software components. Go get the Mac OS Phidgets Framework wich includes the phidget20 (C API) library, the MAX/MSP extension, and the PhidgetWebService. As far as I'm aware, the Phidget20 API library contains all the pre-built API's to see and use your connected widgets. They should help speed up the development process. I have no clue what the MAX/MSP extension is; maybe we'll get to that later. The PhidgetWebService is an interesting one; this allows use to remote control our phidgets. I've seen someone who built a tablet PC with servo phidgets on a remote control car chassis so you could control it from anywhere in the world via the internet. Something I'll be using as well but not so much to control it externally but more to pull in data from across the web and let the LEDs change according to that data.

We'll also have to install the Xcode Tools package that ships with your Mac. It's located under Applications > Installers > Xcode Tools. Just double click the mpkg file to launch the install wizard. I could find where it went with the help of a spotlight search. Browse to it via Macintosh HD > Developer > Applications. Once you open it and run the assistant wicard, there's another little suprise. No windows open! (Remember, I'm new to Mac, OS programming and phidgets; I'm like a kid in Harrod's Toy Kingdom...)

First real stumbling block...

Xcode 2.1 is the version I have and the Phidgets documentation says:

The included examples are in XCode 2.1 format. If you can't open the project files, you probably need to upgrade, or you can create your own project and just add the sources. There are four Cocoa examples and one command line example. The cocoa built tools are included in the base examples folder.

I browsed to the Example folder which was still mounted under Volumes. There's a Phidget LED file there, a .app. Double clicking doesn't do anything and choosing it from File > Open in Xcode doesn't open anything either. Not even an error about supported formats. WTF?! Looking a bit further in the Examples folder we see CocoaLED.xcodeproj - I guess we will be using the mysterious Cocoa as well then! This does open in Xcode.

I went through the Phidget setup instructions once again to check I hadn't forgotten anything and I couldn't find the files that were meant to be in the systems folder. A search brought up an entry in the system crash log:

Library not loaded: /System/Library/Frameworks/Phidget20.framework/Versions/A/Phidget20
Referenced from: /Volumes/Phidgets/Examples/Phidget LED.app/Contents/MacOS/Phidget LED
Reason: image not found

That must have come from when I clicked that .app example. Back to installing the framework again.

Victory! One reboot and a cup of green tea with lemon later and I can actually run the example .app which shows a switchboard with tick boxes for the LED board. Ticking no. 14, the one I put a 3mm red LED in, actually makes it goes bright red! It doesn't look as if the brightness slider is working but that may well be due to my LED. What do I know?! It works so well, I can even flick it on and off in tune with the music now :)

All in all, that wasn't too hard. Just make sure the Phidgets framework installation was completed. Just use spotlight and search for 'phidget' and see if any matching files are in the System folder. Turns out Xcode wasn't even needed just yet. We'll leave that for the next episode. Now let me try my UV LEDs I got from LED1.de in Germany. Never thought I'd get so excited over such a little bit of light!

Now I've hooked up my 10x 3mm red LEDs, 10 x 3mm blue LEDs and 10x 3mm UV LEDs I realzie the Phidget LED only ships with extension cables for 32 LEDs whilst its capacity is 64. I also found one connection not working - not sure yet whether it's the cable or the board - it isn't the LED.

Here's a picture of the result:

It works, let's get coding!

Wireless Skype Calls with Motorola HS810 Bluetooth Headset

After writing about using the Motorola HT820 Stereo Bluetooth headset with Skype I decided to give the concept a trial first before investing the 50 pounds in that innovative BT headset.

My colleague had a spare HS810 regular mono headset, also by Motorola. I got a charger off eBay for just £3.49 and today I had the chance to test the set-up. Pairing my Powerbook with the headset was quite tricky considering the headset only has one function button. After consulting a manual from the net I got the two matched up. The HS810 BT headset can remember up to 8 devices and will store the pairing settings.

All it took to listen to what normally would come out of my Powerbook's speakers through the HS810 was to switch the Sound output to the HS810 in System Preferences. This mono headset however, was never designed for music so you can imagine it's not really the wireless solution you would want to listen to your music collection. Podcasts are alright but it definitely lacks the wave range you would need to listen to music properly.

Now a test with Skype. Under its preference settings, Skype recognizes the HS810 Bluetooth Headset right away. Both for input as well as output. But actually using the Motorola HS810 with Skype wasn't that straight-forward. And to be honest, I still don't know exactly how!

The headset seems to drop into stand-by if it doesn't find any data coming in. It does that after just a second or two even. So getting to use it during a Skype call was hit and miss. I probably just haven't sussed out how to use that one button yet. Only on the 3d call did it stay on and work. Once it worked it worked very well. Reception was crystal clear and even though being just mono it was enough to hear perfectly well what the other end would say. My friend only heard the slightest hint of an echo but I get that even on my USB handset; that seems to be normal with Skype.

The range of the Motorola HS810 Bluetooth Headset in combination with my Powerbook G4 whilst calling with Skype was far better than expected. Granted, my apartment doesn't have thick brick walls but being able to use this without crackling noises in every corner of my flat exceeded my expectations. I don't have that much experience with bluetooth headsets but from other people's findings I wasn't expecting crystal clear reception through two hard board walls.

To use a Bluetooth headset with Skype permanently, I have to find out how to properly establish a connection that stays. All I did now was to press the HS810's main button, see the connection open up in my Mac's task bar and then hit the Skype call button. Worked 3d time lucky. But there must be a trick to get this going the way it should. Though all in all it seems a primising relationship. Being able to call handsfree and wireless with Skype is very convenient indeed.

For music and podcasts I'd recommend the HS820 though!

Off to read the manual again...

Sunday, January 8

Motorola HT820 Stereo Bluetooth Headset For Skype & iTunes

My girlfriend may not like me doing other things simultaneously whilst chatting with her via Skype, but I've been wanting a wireless headset for quite some time now. I could be cooking as well you know.

I finally found something that seems promising. The Motorola HT820 Stereo Bluetooth Headset.


You can use it as a normal headset to listen to your music and podcasts via iTunes etc. or use it to answer incoming calls from your mobile phone or Skype. Outgoing as well of course.

The Motorola HT820 weighs just 100 grams, features buttons to control the music and to handle calls, has an embedded microphone, offers up to 17 hours talk time, 12 hours music listening time whilst being able to remain on stand-by for 500 hours.

You can wire the HR820 up with a stereo cable as well if you want.

Recent versions of Skype have had no problems with Bluetooth connections and other bloggers reported successfull use of Motorola BT Headsets on Skype so I guess this will work ever so well. And of course, my new Powerbook has Bluetooth built in so I should be up and running in no time.

Froogle finds the Motorola HT820 Bluetooth Stereo Headset from £49.89 so I'll go get one soon and report back te results. If you want to Skype me for a test, my handle there is johan.terpstra.

Froogle link: http://froogle.google.co.uk/froogle?q=motorola+ht820&btnG=Search+Froogle