Daniel's Stuff

I write code

Category: Programming

Temperature sensor

weekly graph
I added a LM35 temperature sensor to the unit measuring the water level in my main tanks.  After a mild calibration issue (shown above) it seems to be reading very close to the actual temperature 🙂

daily graph

I find it amazing how much I am enjoying having this data.  Very silly 🙂

Funky Clock 2.0

Here is Funky Clock 2.0, well the processor board anyway.

I have several PIC18F452 in the PLCC package, so I decided to see if I could get that working.
My forth is running on it and I am implementing a new UI for the clock allowing the time to be set using a really cool dial/switch combo.
To connect to the new board I’ve made another daughter board that has the power connector, quadrature dial button thingy and a serial connection plug.  I have made a little RS232 adapter using a MAX232 chip and a hand full of capacitors placed into a DB9 head shell with some pins sticking out of one end and a DB9 on the other.  When I plug the adapter into my Funky Clock it is powered from the Funky Clock and I am able to send code and commands to it via a terminal emulator 🙂
It all works really nicely 🙂

More on the Funky Clock

I had another one of the LED arrays around the place and decided to see if I could drive it directly from the PIC port pins.  It seems I can, and the results are much better than my much more complicated previous setup.  Of course it uses up almost all of the PIC18F4550’s port pins.  All of port A, B, D and E 😉

The thing I was really happy about was that the code I had written for the old hardware needed very little changes to work.  Forth is really good like that.  All I had to do was change the low level code that actually hits the hardware, and the higher level stuff just worked 🙂

The Funky Clock

We have a problem in our house.  The youngest has a habit of waking the whole house at a time that is not pleasing to the rest of us.  We put a clock in his room, but that didn’t help much because the monster child can’t read yet.

As with everything I decided a technological solution MUST be the best, so I present, the funky clock.
The dual colour LED array is from Sparkfun.  It is driven using two 74595 chips for the columns and a pair of ULQ2003 chips for the rows (because I didn’t have a ULM2008 chip).  The brain of the thing is a PIC18F4550 running my native code compiling forth which I control over USB.  I plan to produce a screen cast showing this in action at some stage.
I wanted to make the whole thing fit behind the display, so I was forced to put the processor and the LED driver hardware on their own boards.
The top of the processor board.
The bottom of the processor board.
The LED driver board.  I was really pleased with this one.  The 74595s are positioned so that they line up with the correct pins on the LED matrix so I didn’t need to run as many wires.  This meant that I had to rotate one of them 180 .
The bottom of the LED driver board.
The power board plugs into the processor board using the same connector as the PICkit 3.
All four parts of the clock fit together nicely 🙂
I’ve set it up to display the hour in the main display area.  Blink the bottom left LED every second to let me know it is working, and display the minute in binary on the bottom row.  When it is bed time the hour is displayed in red, and when it is time to get up the hour is green.
I doubt it will make any difference, but I had fun making the funky clock 🙂
It is amazing how easy it is to develop on the thing using forth on the actual hardware.

: CLOCK-TASK ( -- )
    HOURS C@ RED-TIME IF
	HOUR-PATTERN RED-LEDS LEDS!
	BLANK-PATTERN GREEN-LEDS LEDS!
    ELSE
        HOUR-PATTERN GREEN-LEDS LEDS!
	BLANK-PATTERN RED-LEDS LEDS!
    THEN

    SECONDS C@ 1 AND IF
        7 GREEN C@ 80 OR  MINUTES C@ OR 7 GREEN C!
    ELSE
        7 GREEN C@ 7F AND MINUTES C@ OR 7 GREEN C!
    THEN
;

It was so much fun making a forth from scratch.  It is based very loosely on jonesforth in that it implements many of the same kernel words, however it differs in that it generates subroutine threaded code instead of being token threaded.  I have also implemented a very simple co-operative task switcher.  The above task is responsible for setting up the display.  I have two other tasks running, one that drives the LEDs and another that updates the time.  While these tasks are running I am also still able to interact with the forth system via the virtual serial port over USB.
I want to thank my Dad again for all his help with the hardware.

DeltaSync decompression progress

After quite some time I finally have some code that seems to decompress the message data returned from Windows Live via the DeltaSync protocol.

The code is AWFUL, but the results are looking pretty good.

X-Message-Delivery: Vj0xLjE7dXM9MDtsPTA7YT0wO0Q9MTtTQ0w9MA==

X-Message-Status: n:0

X-SID-PRA: Daniel Parnell <me@danielparnell.com>

X-Message-Info: JGTYoYF78jHVrAq/T4xfKLLpTvwPwE0t6g/vyq6tyzbqln5iNnXwcSMg41wQCSulCxd5N8UB57Lq6un/ug7i0YsGX30yo+pm

Received: from randymail-a4.g.dreamhost.com ([208.97.132.207]) by bay0-mc8-f11.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668);

Thu, 29 Jan 2009 16:06:38 -0800

Received: from 192-168-1-101.tpgi.com.au (60-241-72-192.static.tpgi.com.au [60.241.72.192])

(using TLSv1 with cipher AES128-SHA (128/128 bits))

(No client certificate requested)

by randymail-a4.g.dreamhost.com (Postfix) with ESMTP id 97A67194DD3

for <danielparnell@live.com>; Thu, 29 Jan 2009 16:06:26 -0800 (PST)

Message-Id: <8EEE4310-25CC-47BE-8FCB-330EBCD75A21@danielparnell.com>

From: Daniel Parnell <me@danielparnell.com>

To: danielparnell@live.com

Content-Type: multipart/mixed; boundary=Apple-Mail-33–583770588

Mime-Version: 1.0 (Apple Message framework v930.3)

Subject: more test messages

Date: Fri, 30 Jan 2009 11:06:23 +1100

X-Mailer: Apple Mail (2.930.3)

Return-Path: me@danielparnell.com

X-OriginalArrivalTime: 30 Jan 2009 00:06:38.0411 (UTC) FILETIME=[9F1AB1B0:01C9826E]

–Apple-Mail-33–583770588

Content-Type: text/plain;

charset=US-ASCII;

format=flowed

Content-Transfer-Encoding: 7bit

this is another test message

–Apple-Mail-33–583770588

Content-Disposition: attachment;

filename=”AGL Energy Advisor.zip”

Content-Type: application/zip;

x-unix-mode=0644;

name=”AGL Energy Advisor.zip”

Content-Transfer-Encoding: base64

UEsDBAoAAAAAAANIPToAAAAAAAA********XABAAQUdMIEVuZXJneSBBZHZpc29yLmFwcC9VWAwA

q9WASWXVgEn1ARQAUEsDBAoAAAAAANFGNzoAAAAAAAA********mABAAQUdMIEVuZXJneSBBZHZp

c29yLmFwcC9fQ29kZVNpZ25hdHVyZS9VWAwAZdWASRnreEn1ARQAUEsDBBQACAAIAANIPToAAAAA

AAAAAAAAAAAzABAAQUdMIEVuZXJneSBBZHZpc29yLmFwcC9fQ29kZVNpZ25hdHVyZS9Db2RlUmVz

b3VyY2VzVVgMAK7VgEll1YBJ9QEUALWYWbOqOhbHn/t+it37sa27VcSBrnPPLQUUEBFwYHjZxSRE

hmAIg376xj30PbdO8FR17X7RaMgvK4t/1lrJtz+bNHmqAlQAmP3xPHwZPD8FmQd9kIV/PB/2y99n

z39+/+3bP7ktu7dU/ilPQIGf1MNCFtmn59/7/XmeJ0G/z+25J1UWd/unltHv88rz03OEcf7vfr+u

6xfn/tSLB9P7g0VfRTAPEL7KLez3dsCLj/3ndpp3+t/Maf/1gYe///aPb3Fw/X4CSVB869+b7T8f

Pe9dfBa2w6OXJEfw3J+7sMRHENQvGXA/B7QjHOzcG9cef+FySztW2mipj6XEDYflXhiN5Pkf9+f6

nw8S0GyQJAbAkYqAF5Dx6+0llK+cPlkem7XB0bZyxVg6mjdY/xLPBdgBSbfpMTjMx0dpYDkncMhp

YTUYORtFp3qA/yV744DMAJkPO9gDYz7t3/aTTW9gjvHhths4Q4dLo9lW+yVbh/DN4SzMMIJJEiDy

HPlAPK98iOBJiDZwe3J2HKp4k42Hv55jhx0cdLtmyeiet7TOVapM48QoEm8rq24jzUyyazDASZAG

GS5e3qT3M7Ggx2yxGBYpxS91xh4qIFlq46gxkUggqnEoZif4MyYbTy+cSmP7JHNDxO7okTFY0LJ2

vpEMc+7afYlwmvxMkvjcnvWzPS0ulN3OvIl6qUv61qdrknCdssDISYDzkmfhz7CNGjnLycW8wNOu

NxkEKeNeaS0fwAEkwFzHi0MEy8wn0/qaaNsLoPrmeImHjO33ArQyR9edRxNpOEIQpmSWLZin887C

RhRsljU7WotpJfDVXspnD1ivkQOQj66t9IjUCAgYJAalhc1pv6DWdmDYUNCT5OQ9pEJct7pDUXD/


And so on.  Once I’ve got things cleaned up a bit more I hope to post what I’ve been able to come up with.

Bob Lives!

After a couple of false starts with dead voltage regulators, Bob (my daughter named it) the PIC based ethernet device lives in a more permanent incarnation.  Bob is made from bits and pieces I had around the place (I now have several very dead network hubs).  The budget for the project was zero 😉
My Dad provided me with the PIC prototyping board pictured above and many of the pieces as well as the PIC18F452.  The ENC28J60 ethernet controller was kindly provided by Microchip through their very generous free samples.
The original voltage regulator on the PIC prototyping board didn’t seem to be up to powering both the PIC and the ethernet controller, so I went through my old retired networking gear until I found a 3.3V regulator.  Unfortunately I think I popped it in the process of removing it from the board and it no longer worked :(.  In the end I used a 7805 5V regulator and then ran the output of that through a pair of diodes in a bridge rectifier (thank again for the help with that one Dad) to drop the voltage down to about 3.5V or so.
Now I need to get my PIC Forth running on this hardware and then I’ll have a networked Forth device I can play with 🙂