My Tech Projects - downloads
Last updated: Nueva Gorgona, 24 Sep 2013
  1. Jeffrey Traer's physics library ported to Processing.js
  2. HTML Grapher
  3. Hello World Remote Controller - Arduino
  4. Hello World Remote Controller - Raspberry Pi
  5. Raspberry Pi Monitor
  6. Camera Controller
  7. Stereo Webcam
Please send any comments, corrections, suggestions to me at
 
 Traer's physics library to Processing.js - Download
Man-O-War, 15 Dec 2010 Notes
 
For my Sailboat Characteristics Plotter I ported Jeffrey Traer's physics library from Java to Processing.js.  Here is the version history:
VersionDateDescription
traer3a_2013_01_08.pde 8 Jan 2013 Small change to facilitate running in Processing 2.0's new Javascript Mode
traer3a_03.pde 15 Aug 2012 For my MOW map I find that Min Distance is not working.  (Click on the "cog" to the right of "Show infos" to adjust, on "Show infos" to see the effects.)  I reverted the code in that calculation back to some of Jeff Traer's original code (which helped) and then changed that Min Distance algorithm some (helped more).
traer3a_02.pde Spring 2012 Fixed calls to undocumented PVector APIs
traer3a_01.pde 10 Feb 2011 Carl Pearson made some nice improvements to the Traer library
traer3.pde ? My original version, as ported from Jeff Traer's Java code
[8Jan2013: I see that Processing 2.0 has nicely integrated a Javascript Mode in the IDE.  I had to make one small change to the samples below to work smoothly in the new IDE.  Now, all you need to do is download the sample's zip file, unzip it, and open the sample's .IDE file in the Processing 2.0+ IDE.  The button in the upper right corner of the IDE controls whether the sample runs in native Java or in a browser using Javascript.  Kudos to the Processing team.
To download and try the ported code:
  1. Download dynamics_2013_01_08.zip and unzip it on your system.  It contains the ported Traer code (in traer3a_2013_01_08.pde) and a simple pendulum sample.
  2. If you haven't already, download the Processing 2.0+ IDE.  Run the dynamics_2013_01_08.pde file in it.  It is fairly easy to try out changes to your sketch in the Processing IDE. 
  3. Starting with the Processing 2.0 IDE, to run the code in your browser, click on the button in the upper right corner of the IDE and change the setting to Javascript.  Click on the run button and the sample should start up in your browser window.
  4. To host the sample on your webserver, copy the files over to your webserver and modify the sample HTML included in the zip file as necessary.
  5. Access the page in an HTML5 capable browser (the latest versions of Chrome, Firefox, IE, Opera and Safari all appear to work).  Here is the pendulums sample along with a couple other that I've been fiddling with:

     
    From processing.org by jonobrone, based on Traer's Simple Pendulum. With updates by Carl Pearson. Download my current version.

     
    From openprocessing.org by Katie Adee and Natasha Harper, based on Traer's Random Arboretum.
    Download my current version.


     
    From openprocessing.org by Bryan Teoh.
    Download my current version.

    Note: To run this sample in the Processing IDE, uncomment the first line in setup() and comment out the size(200,200); following it.

     
    From Traer's Cloth sample.
    Download my current version.

     
    Familytree
    Under construction
    -- With each of my downloads above (the "Download my current version" links), the Traer physics library code (ported to Processing.js + Carl Pearson's improvements) is included in the sketch's folder (in traer3a_2013_01_08.pde).
    -- I am trying to reduce the CPU consumption of these samples, mainly by putting each to sleep after a while - when the red indicator goes out.  You can also turn the "power" on/off by clicking on that indicator.
    -- The button on the pendulums sample, initially labeled "F.R. Undefined", indicates the setting of frameRate().  It is initially undefined - that is, it has not been called yet in the code.  In this case, the default fps should be 60 according to the doc.  Clicking on that button results in a call to frameRate(60) and the button changes to "F.R. Limited".  Clicking again results in a call to frameRate(9999) and the button now changes to "F.R. Unlimited".  Then it toggles between 60 ("F.R. Limited") and 9999 ("F.R. Unlimited").  Refresh the page to get back to "F.R. Undefined".  The "fps" are the average frames per second for that "power-on" period (ie. the current time period when the red power indicator is/was on).
    Here are some results that I'm seeing.
  6. To develop an app for Processing.js deployment, I'd suggest making small changes to your sketch and trying them often in your Processing.js/webserver/browser setup.  Backup your code often in case you have to revert to a previous working version.  There are a couple things that run in the Processing IDE, but won't when you try them in the Processing.js environment, and tend to fail without any error messages.  To debug them can be a challenge.

 HTML Grapher - Download
Man-O-War, 12 Dec 2010 Notes
 
For the HTML Grapher, I modified the original code from www.aharef.info/static/htmlgraph to fetch multiple pages and color them differently in the plot.  To download and try my code:
  1. Download htmlgrapherApplet.zip.  Unzip it on your system.
  2. To run it in the Processing IDE (once you've downloaded and installed the IDE), open the sketch by double clicking on htmlgrapherApplet.pde or via File>Open.  You'll need the jar files
    that are included in the applet directory of htmlgrapherApplet.zip.  You can copy them to a folder named 'libraries' inside the 'sketchbook' folder (as the error message will tell you) or you should be able to simply drag them onto your sketch in the IDE - how easy is that?  Click on the Run button in the IDE.  A window should appear with a couple buttons in the upper left corner.  Click on the run button.  The result should look like --->    
  3. You can change hostname and urlPaths in the sketch to point to the site and pages you want to crawl.  Also, note that this sketch is using a utility called getDataFromURL.php on www.aharef.info to fetch the webpages.  As the original author notes, this may go away at some point so you might have to modify it to work.
  4. The applet subdirectory also includes an index.html file that you can use to imbed the applet in your webserver.  The index.html file (along with the rest of the applet subdirectory) was created automatically by Processing using File>Export.
 
 Hello World Remote Controller - Arduino - Download
Spring Hill, 27 Jan 2012 Notes
 
This code controls Arduino's LED connected to pin 13 from an iPod Touch or iPhone (or any browser able to make a WiFi connection to an ad-hoc network - apparently not all devices with WiFi interfaces can).  There is a demo of the UI on this page.  I have 2 versions of the code - one for the Asynclabs WiShield 2.0 (which unfortunately is no longer manufactured) and one for the Sparkfun WiFly shield
The configurations that I'm using ...
For the WiShield For the WiFly
  • Sparkfun WiFly shield (current version with the RN-131G module and "3/16/2010"(?) etched on the back)
  • Arduino 1.0 IDE
  • Arduino ADK (the sketch is about 14,700 bytes in size)
  • iPod Touch 1g with iOS 3.x (the only one I have handy)
  • MacBook to upload the sketch to the Arduino board
  1. To download and setup the code,
    if you have the Asynclabs WiShield 2.0, download hwrc.14oct2011.zip (180 KB) which contains the sketch file and libraries. if you have the Sparkfun WiFly shield, download hwrc_on_WiFly.27jan2012.zip (66 KB) which contains the sketch file and libraries.

    Here is what's in the downloads:
    The WiShield version The WiFly version
    HWRC.pde HWRC_on_WiFly.ino The sketch file.  This controls the webserver running on the Arduino. It also controls the LED.  It includes the HTML and Javascript code that is served from the webserver and defines the UI.
    /libraries/WiShield/ The WiShield library with the webserver code modified to do more logging and instrumentation.
    /libraries/WiFlyAlpha2/ The WiFly Alpha 2 library, modified to run on Arduino 1.0.
    /libraries/TimerOne/ The standard Timer1 library (in case you don't already have it).

    The WiShield version runs on Arduino 022 IDE.  The WiFly version runs on Arduino 1.0.  There's no special reason for that - it's just the versions that were available when I did the code.  You should be able to, fairly easily, convert my code to run on another version of the Arduino IDE if you want.
     
    Anyway, copy the libraries over to your Arduino's /library/ folder.  You need to restart the Arduino IDE for them to be recognized.
     
  2.  
    For the WiShield version, load the HWRC.pde sketch in the Arduino 022 IDE. For the WiFly version, load HWRC_on_WiFly.ino in the Arduino 1.0 IDE.
    Then compile and upload it to your Arduino board. 
    If you're getting compile error messages (e.g. with the WiShield version) ...
      If, when trying to compile the sketch, you see error messages like:
        ... /WiShield/g2100.c: In function 'zg_init':
        ... /WiShield/g2100.c:62: error: 'PRR0' undeclared (first use in this function)
        ... /WiShield/g2100.c:62: error: (Each undeclared identifier is reported only once
        ... /WiShield/g2100.c:62: error: for each function it appears in.)
        ... /WiShield/g2100.c: In function 'zg_drv_process':
        ... /WiShield/g2100.c:424: error: 'PORTH' undeclared (first use in this function)
    
    then make sure you select the Arduino board before trying to compile the sketch.  I'm using the Mega 1280 board so I selected Tools > Board > ArduinoMega (ATmega1280).

  3. Open up the Arduino IDE's Serial Monitor window to see the trace of requests to the server.  Use 115200 baud
    On the WiShield version, it took up to 20 seconds for setup() to complete on my system.  There will be a message, HWRC.setup() done., on the Serial Monitor window when it is ready. On the WiFly version, the message you should see when setup() is complete is
    Enter "$$$" (with no line ending) to enter WiFly command mode. ("CMD")
    Then enter each command followed by a carriage return.
    Sample trace messages ...
      From the Arduino IDE's Serial Monitor window:
       HWRC.setup() done.
       Request: "/"
       Server connection closed, 2606 bytes ACKed. RC=200.
       Request: "/apple-touch-icon-57x57-precomposed.png"
       Server connection closed, 26 bytes ACKed. RC=404.
       Request: "/apple-touch-icon-57x57.png"
       Server connection closed, 26 bytes ACKed. RC=404.
       Request: "/apple-touch-icon-precomposed.png"
       Server connection closed, 26 bytes ACKed. RC=404.
       Request: "/apple-touch-icon.png"
       Server connection closed, 26 bytes ACKed. RC=404.
       Request: "/tp/hwrc/controller?stbu=Stop"
       Server connection closed, 41 bytes ACKed. RC=200.
       Request: "/tp/hwrc/controller?stbu=Start"
       Server connection closed, 41 bytes ACKed. RC=200.
       Request: "/tp/hwrc/controller?morb=morse"
       Server connection closed, 41 bytes ACKed. RC=200.
       Request: "/tp/hwrc/controller?morb=blinky"
       Server connection closed, 40 bytes ACKed. RC=200.
    
    It took about 18 seconds before the HWRC.setup() done message. Then I clicked on the app on the iPod's Home Screen. That caused the "/" request to which the server returned the webpage (2606 bytes) and Return Code 200 ("OK"). The browser then tried to fetch an icon for the webpage - something they do automatically. We don't need any and the webserver returned 404 Return Codes ("Not Found"). Then I clicked on the Start/Stop button twice. Then the "Morse Code" and "Blinky" radio buttons.
    Sample trace messages ...
      From the Arduino IDE's Serial Monitor window:
       Doing a full reset...
    
       Enter "$$$" (with no line ending) to enter WiFly command mode. ("CMD")
       Then enter each command followed by a carriage return.
    
       Connected via Ad-Hoc on Wifly-GSX-4e
       Request: "/", RC=200
       Request: "/apple-touch-icon-precomposed.png", RC=404
       Request: "/apple-touch-icon.png", RC=404
       Request: "/tp/hwrc/controller?stbu=Stop", RC=200
       Request: "/tp/hwrc/controller?stbu=Start", RC=200
       Request: "/tp/hwrc/controller?morb=morse", RC=200
       Request: "/tp/hwrc/controller?morb=blinky", RC=200
       Ad-Hoc is lost
     
    This (also coincidentally) took about 18 seconds before the Enter "$$$" ... message. Then I clicked on the app on the iPod's Home Screen. That caused the "/" request to which the server returned the webpage and Return Code 200 ("OK"). The browser then tried to fetch an icon for the webpage - something they do automatically. We don't need any and the webserver returned 404 Return Codes ("Not Found"). Then I clicked on the Start/Stop button twice. Then the "Morse Code" and "Blinky" radio buttons.

  4. On your iPod Touch or iPhone, go to Settings > WiFi and
    on the WiShield version, select ASYNCLABS.  Open a Safari browser page and go to http://192.168.1.2/ on the WiFly shield version, select WiFly-GSX-xx.  Open a Safari browser page and go to http://169.254.1.1/
    When the Hello World Remote Controller page is displayed, click on
    this    button in the middle of Safari's option bar,
    then Add to Home Screen and finally Add.  The page lays out properly when you start it from your Home Screen - ie. without Safari displaying it's address bar.  You should see the button has been added to one of your Home
    Screen pages.  E.g.  

  5. Click on it.  You should be able to control the Arduino board's LED from that page.  Again, the UI demo is shown here.

 Hello World Remote Controller - Raspberry Pi -
 Download
Nueva Gorgona, 24 Sep 2013 Notes
 
This is much the same as the project described above for the Arduino, but modified for the Raspberry Pi.  Again, the goal is to control an LED from your Raspberry Pi via WiFi using your iPod Touch or iPhone (or any browser with a network connection to your Raspberry Pi).  The installation instructions are here.
The code is here:  raspi-hwrc-24Sep2013.zip.
 
Here is the UI running in Safari on an iPod.  On the right are the LEDs being controlled by the Raspberry
Pi as the user selects from the "Physical pin" dropdown menu and clicks the "Click Me!" button on and off.

 




 

 
 
- - ->
^
|
|

 Raspberry Pi Monitor - Download
Nueva Gorgona, 24 Sep 2013 Notes
 
This is a simple time-series monitor of the Raspberry Pi.
The installation instructions are here.
The code is here:
    raspi-mon-28Sep2013.zip.
 
The result runs in a web browser and looks something like this - - - ->
 
You should be able to fairly easily hack up my code to monitor whatever you want on your Raspberry Pi via SNMP or command-line tools.
 

 
 Camera Controller
Nuevo Gorgona, 24 Sep 2013 Notes

I apolgize to anybody looking for the Arduino-based Camera Controller code.  I have managed to misplace much of that code.  Excuses, excuses.  I plan to redo it using the Raspberry Pi in place of the Arduino. 
 
 
 Stereo Webcam - Download
Man-O-War, 16 Dec 2010 Notes
 
I wanted to make a stereo webcam.  I found some Mac OS-X code on Dominic Szablewski's blog, www.phoboslab.org, to control UVC webcams.  The webcams that I'm using, the Logitech Orbit AF, follow that standard.  I added the following to his code:
  • controls for a couple unique features supported by the Orbit AF (Pan/Tilt, Manual Focus, and Zoom)
  • indicators to show Auto Exposure/Gain and Auto White Balance in action - that is, when in auto mode for one of those, the sliders dynamically show the value set by the webcam
  • support for a 2nd webcam (for a stereo 3D view) - the program works with either 1 or 2
  • the option to write the stereo video to a file.  The saved .mov video can be sized for YouTube (480x270, 640x360, 960x540, 1280x720)
To try my version, you'll need Mac OS-X (I'm using Snow Leopard, 10.6.5) and at least 1 Logitech Orbit AF webcam.  Then,
  1. Download SW_16-12-2010.zip and unzip it on your system.
  2. Plug in 1 or 2 Logitech Orbit AF webcams.  My program should detect whether there are 1 or 2 plugged in when it starts.
  3. Start the program by double-clicking on SW.xcodeproj (if you have Xcode); otherwise double-click on build/Debug/SW.app.  You should see something like (well, if you were lying in the berth of a small sailboat):
    With 1 webcam
    With 2 webcams
     
    I have an overview video started, plus will put together some documentation.  Please let me know if you have any problems or suggestions - email to .