MacMorgan Weather

Note that this doc is preliminary and may change at any time. As I get time, things will get better!

Professor Peter H. Anderson from Morgan State University heads an undergraduate team of students that has created an excellent package of PIC Microprocessor Chips to measure weather data called "The Morgan Weather Measurement System".

They have packaged this up as a kit which can be purchased for a very reasonable price. The kit includes the PIC chips and all of the support parts, except for a PC board and the actual Sensor devices. The Sensors are available separately from Fascinating Electronics.

There was no Macintosh interface software, so I took the CTB OSAX from Sand Hill Engineering (free, but while you are there, check out their great XTension package for X-10 home automation!), FaceSpan (30 day Demo Available) from Digital Technology International , and Apple's Applescript, and built one! I also created a (schematic) of the system to help me understand how the hardware subsystems fit together. Finally, here is a picture of the completed board.

NEW! I have been working on a RealBasic version of the software. See the new screenshots at the bottom of this page. If you are adventurous, you can download the alphas.

pcboard



Note, This looks a lot more complex to put together than it really was. I started by installing the Power supply (under the bolt). Then I put in the main PIC (Center Chip). Next I installed all of the IC sockets without soldering them in in case I wanted to move them. Then I started wiring the subsystems one by one. The temp sensors first, then the RS232 interface. Then I tested the processor. Then I added more sensors one by one till it was done. Doing one part at a time and testing it makes it a lot simpler to build. All the parts shown came with the kit, except the PC-board (I got it from HalTed electronics for US$3.95) and the Connecters (From Mouser Electronics) and the IC sockets (and I used my own wire from a 3M Jumper Wire Kit, though the kit came with some).

HSC No: SPB-000-000027 protoboard with 4 holes connected. $3.95
Desc: FR-4 Expoxy glass base, 0.062" thick
Solder Plated, 2-ounce copper
Durable conformal coating
0.042 diameter hole
(408) 732-1573

Connectors:

Mouser Part
$
Description
538-22-01-3037 .12 .100" Terminal Housing
538-22-23-2031 .23 .100" Friction Lock Headers
538-08-50-0114 .06 Crimp Terminals


A description of the software I put together to control the hardware follows:

This is a picture of the main MacMorgan Screen:

main screen

Note that the Wind and Rainfall sections will double their ranges if the slider reaches the top. To reset the rain gauges, select the reset menu (not shown). To reset the Min/Max pressure, click on the sliders.

The Refresh field at the bottom of the screen controls how often data will be retrieved from the PIC Processors. Must be greater than 30 seconds.

This is a picture of the raw data from the system (before calibrations and conversions):

raw data

Note that I do not have the Humidity gauges and one of the Temp sensors hooked up yet so they return stars.

This is a picture of the formatted data (after calibrations and conversions):

formatted data

You can see that I just got the wind speed working this evening. :)

This is a picture of the Preferences Screen:

preferences

Click on the Configure port button to select a serial port. The HTML option creates a really lame Web page. (I may remove this option)

This is a picture of the Calibration Screen:

calibration

I am not sure I know everything I need to know about calibration yet.

This is an example chunk of code that shows how to use AppleScript and the CTB OSAX to read the Morgan weather data:

sample code

There is a trick here. The Morgan hardware takes about 10 seconds to return the data. Since the other code that moves the sliders and logs the raw and formatted logs also requires about 10 seconds, and I did not want to tie things up for 20 seconds, I request the next data reading right after reading the previous batch. This way the Morgan hardware can go about doing its thing returning data while I am processing other stuff. The Mac Serial Port code will buffer any data that comes in meanwhile. When the loop comes around 30 seconds (or 'refresh' seconds) later, it will be waiting for me and I can read it in as fast as AppleScript will take it.

Note that there is also a 240 Tick timeout (60 Ticks = 1 second) on the read. If I go to read data, and get nothing for 4 seconds, something is wrong, so I put up a message and wait for the user to press OK, or 15 seconds to pass, whichever comes first. Then I return to the caller. The code will try again the nxt refresh cycle. This means that if the RS232 cable comes unpluged and you plug it back in, it may take 2 refresh cycles to recover.


RealBasic version of the MacMorgan Software

I am currently working on a new version of the software. I decided to rewrite it in RealBasic and to make it a client/server application. The server will run all of the time and the clinet can connect and retrieve data via TCP. It is currently running, though it is not pretty yet and not all of the options are available. Download the alphas.

 

Here is the server:

WeatherServer

And the source code.


And here is the client:

WeatherClient

 

And the source code.

 

 




Valid HTML 4.01!