November 2007 - Posts

Phidgets project update

The implementation of my Closet Venting Project was so easy in all the languages I tried.  I had to make it slightly more challenging.  So, I took the .NET Assemblies (DLLs) and used Reflector to disassemble them in to C# code.  Once I had the ".cs" files, I recompiled it on the Linux box, using the latest version of Mono

Since all the C function names and parameters were the same in Windows and Linux, I just added one configuration entry to tell it to use "libphidgets21.so" when the DllImport calls refer to "Phidgets21.dll".  This forwarded all the wrapped C functions in that DLL to the Linux "so" (shared library).  Then, I took my original C# code and compiled that on the Linux box with Mono too.  It worked! :)

Here's the configuration line:

<dllmap dll="phidget21.dll" target="libphidget21.so" />

I had a couple new requirements for myself.  I needed it to run as a "service" so that I could restart it and replace it with new versions at will.  After a few tries, I realized that I could just use the /etc/inittab.  The entry looks like:

FC:2345:respawn:/opt/mono-1.2.5.1/bin/mono /home/tom/FanController/FanController.exe

This sets the ID to "FC" and runs it at runlevels 2,3,4,5.  What it also does is automatically respawn the process if it exits.  So, I needed a way to make it exit itself.  So, I added a very simple .NET Remoting interface into the app to kill it.  So, if you call FanController with a "/X", it connects to the currently running version of itself and calls a function.  This function sets the ManualResetEvent that the app normally waits on before it exits.

So, an upgrade consists of:
  • compile a new version
  • run "mono FanController.exe /X"
That's it!  I, for one, think that's pretty cool :)
posted by Tom with 0 Comments

Closet Venting Project

I had a problem with a closet full of computers getting too hot to the point that fans and power supplies were dying.  So, I decided to do something about it.  I used Phidgets for the sensors.  I wrote the software in C#, then PowerShell, and then , finally, in C in Linux (was easier for my deployment). 

There are photos here

When the temperature hits 80 degrees Fahrenheit, it applies 5V to the digital output, which triggers the Xantech controlled outlet.  This, in turn vents the room until the temperature goes below 80 degrees, at which time the 5V signal is dropped.

It was actually pretty easy to do.  The total cost was kinda high... maybe $250 if you don't count buying the Dremel tool.  The good part is that the Phidgets 8/8/8 Interface Kit supports 16 inputs (8 analog, 8 digital).  So, I can buy new stuff and add on to this much cheaper. 

Hopefully I'll have more to post about soon.

UPDATE: I posted some new info here
posted by Tom with 1 Comments