Friday, July 09, 2010

The Heat is On!

Here's a challenge. Teach yourself C in 21 days!

The book on the left runs to 700 pages. I borrowed it 10 years ago from a mate, and now just getting around to studying it!

Learning C from a text book is somewhat dull, but with hands-on and near instant results using the Arduino - it makes the whole process a lot easier and more interesting - especially if you have an application waiting.

So whilst my code is a little clunky, and having never been taught good programming practice (we were taught FORTRAN 77 for a year at Uni in 1983, whilst the year above us learned ALGOL 68!!), I am still learning quite a few of the basics, and trying to make the journey and transition from being confined byPIC assembly language.

This morning I learnt the structure of arrays and how to index into them with a pointer. Whilst I have been using this construct for years in PIC code to send messages - today was my first time in C. I can now send all sorts of serial messages to devices using a modified bit-banging serial routine.

As an update to my Arduino base central heating control system outlined in the previous post I have now got the wireless boiler commands working and combined the sketch with the temperature controller sketch I wrote at the end of June to read 6 thermistor channels and display the temperatures on an LCD display.

My boiler is now turning on and off under Arduino control. Like I said earlier - just enough knowledge of C to be dangerous.

The plan now is to integrate this application with Andrew Lindsay's modified ethernet code for the NuElectronics ENC28J60 ethernet shield. The intention is to get the readings of the six sensors up to Pachube. The NuElectronics shield has not proven so popular as other ethernet shields, as it relies on the ATmega to host a cut down TCP/IP stack. This can be troublesome on the mega168, but with Andy's code improvements it should run better on the mega328 which has double the codespace and double the RAM.

No comments: