Work in progress: Programming the Canopy

As I get closer to actually filling the paludarium with water, plants and eventually animals, I need to put a lot of focus on the electronics. The lighting armature on top, or as I like to call it, the Canopy is fully electronic. Without electronics the lights won’t even go on… High time to put some work into the Canopy to upgrade this piece of hardware to version 2.0.

First things first: Getting the code compiling again

Inside the Canopy I have 12 Atmel AVR controllers (ATtiny2013’s). These tiny controllers have been programmed in three flavors: LED, HALOGEN and FAN units. You guessed it, each type of controller has its own code. Luckily I programmed a single code, and when compiling this code I can tell the code which type it is supposed to compile. These little AVR controllers are programmed in C:

#include “main.h”
#include “serial.h”
#include “timer.h”
#include “pwm.h”
#include “eeprom.h”

int main (void)
    for (;;)
        /* Set initial levels of the hardware outputs */
        outp(0xFF, PORTB); /* All input lines pullup, outputs push TTL to high */
        outp(0xe3, PORTD); /* All input lines pullup, outputs push TTL to high except DigExp */

        /* Init of hardware: I/O directions */
        outp(0x1C, DDRB); /* PB0-7 are all inputs except PB2,3,4 */
        outp(0x3e, DDRD); /* PD0-7 are all inputs except PD5=OC0B and PD1=TX, also PD2-PD4 */

        /* Init the modules */
        InitTimer(); /* incorporates sei(); call to globally enable interrupts */

        while (1)

Code snippet. This is the main() function where all stuff gets initialized

No I will not bore you with all of the code here 🙂

This old code that I have for these controllers has proven to be pretty stable. Yet I need to change some minor things, and add or change some features. After a short while I got the compiling environment (an antique version 6 of the ImageCraft AVR compiler) up and running again. I could now compile the code again. At my first attempt, I compiled the most complex code, the LED version. Compilation was a success, device was 98% percent full… I’d better not find NEW features cause they’d never fit. If you think these controllers only have 2KB of flash (yes 2 KILObytes, 2048 bytes and not Megabytes or Gigabytes), 98% is pretty darn full. Still, it works so I’m not complaining.

Programming the ATtiny2313’s

As nice as compiling may sound, the compiled code had to be actually programmed into the chips. For that, you need a programmer. Time to dive into my box of old projects, and there it was: The glorious AVR programmer for ATmega32 and ATtiny2313 chips:

My good old programmer for Atmel Mega32 and Attiny2313 chips

My good old programmer for Atmel Mega32 and Attiny2313 chips

Yes it is no high-tech. Ok it is somewhat oldish. Ok ok, it is totally oldskool. Is that a USB port? Yes, but I only use USB to power the thing. The large connector in front is actually a PC parallel port connection. I had to search in order to find a PC that still has a parallel port. Why not upgrade to a USB programmer? Uhmmm basically because this one still works 😛

I had an old version of Claudio Lanconelli’s PonyProg that I used to shoot the chips. After some testing I managed to read, write and erase the ATtiny2313 chips.

Mission accomplished! I now can alter the code, reprogram the 12 chips in the Canopy and start playing around. On to the next-of-many things to get going.

One Response to Work in progress: Programming the Canopy

  1. Pingback: Work in Progress: Getting the RaspBerry Pi to talk to the Canopy | P A L U W E B . N L

Leave a Reply

Your email address will not be published. Required fields are marked *

ERROR: si-captcha.php plugin: GD image support not detected in PHP!

Contact your web host and ask them to enable GD image support for PHP.

ERROR: si-captcha.php plugin: imagepng function not detected in PHP!

Contact your web host and ask them to enable imagepng for PHP.