Notes from Windward: #68


The AVR Butterfly

adopting a control computer

  January 18:

      Our mission--to work out the means by which twenty people can feed, fuel and clothe themselves on a hundred acres of marginal land--involves creating a matrix by weaving together old systems and new technology. An example of that involves the use of control computers to monitor and operate the energy and food systems that will support our post-Industrial village.

     As long as systems need direct personal supervision in order to operate, the natural impulse is to build ever larger systems, a process which leads to centralized production. Our goal is to counter that trend by enabling smaller systems to operate on a local level, thereby recreating a life in which interpersonal relationships become important again. And the embedded controller is a key part of how we intend to make that "best of all possible worlds" work.

     Our long-term readers know that we're not a linear organization--that we function as a network moving in something more akin to an expanding spiral than any sort of straight line. It's been our practice to explore a process, evaluate its potential and requirements, and then move on to tackle some other aspect of sustainability while we put together the resources needed to expand our capacity based on what we've learned. For example, at one time we had more than a hundred goats, and we still have the milking machines, commercial pasteurizer, fudge pots, etc. we'll need to expand that part of the operation at some point down the road. But for now, we're working with a more modest herd of eight goats, which is enough to meet our current needs, and to serve as the foundation for expanded production when that becomes desirable.

     Back during our first decade, we did a lot of work with control computers, particularly in the area of using an Intel microprocessor to control the positioning of home satellite dishes. Now we're getting to the point where we need to revisit that work in order to create the control systems needed to operate our aquaponics and solar-steam power electrical generators. Instead of aiming parabolic dishes at satellites to provide entertainment, we'll be pointing them at the sun to collect energy.

     A truism in computers is that one year in the life of a computer is equal to seven dog years, so considering how long it's been since we did serious work in that area, it was time to step back and completely review the options currently available. Over the summer and fall, Scott, Matt and I have been checking our options and have arrived at the decision that the unit we'll be using is ATMEL's 8-bit controller known as the AVR Butterfly.


     One reason for selecting the AVR is the remarkable set of development tools made available by Smiley Micros-- for a hundred bucks you get a working butterfly, a book detailing a series of projects that explore the board's potential along with the various parts needed to do those project, as well as all the needed development software. Given this much support, I'm expecting that there'll be skads of grass-root level programing developing using this chip.

  January 19:

     The first steps in getting ready to work with the Butterfly involve wiring up a power supply and a serial port. The Butterfly comes with it's own round battery that's capable of power it for a considerable time in display mode, but we're going to be using it to control things, so a less expensive power option is needed--in this case the Butterfly kit comes with a power pack to hold two, easily-replaced AA batteries.

     Wiring up the serial port was a bit trickier since two of the wires have to reverse in order for the send and receive lines to match up sinc one computer's send line is the other computer's receive line. After a bit of working out the precise procedure, the Butterfly was happily sending data to the main computer saying that it was ready for instructions.

     The Smiley Micro package comes with a program that allows the kitchen's main computer to act as a programing terminal, and, again after working out the precise procedure needed, we were able to send information to the Butterfly via the main computer's serial line, after which we sat by the fire, finished a cup of mint tea and called that enough progress for the day.

  January 20:


     These cold winter days serve as pursuasive arguments in favor of finding things to do near the kitchen's cheery woodstove. While Adriann kept busy painting, I hunkered down to decipher the instructions for writing, compiling and loading a program into the Butterfly.

     The teaching book that came with the Butterfly is unusually good, but still, the more basic you get with computers, the more challenging it is to figure out all the intricate details, and they have to be mastered or else the processor won't run.


     After a number of trials, we were finally rewarded with the sight of the Butterfly busilly turning a series of LEDs on and off in sequence. That may not sound like much, but those pretty lights represented the successful conclusion of a number of key steps in the process of getting the controller to do what we'll want it to do.

  January 24:

     We're deep in the middle of a "weather event" with temps reaching down into the single digits, so for the most part we're hunkered down doing things like baking banana bread, working on paperwork and catching up on our reading, but Wednesday Jay, Adriann and I made the trek up to Olympia for Evergreen Colleg's Internship Fair. It was good to get away from the intense cold, and it's always fun to talk with other folks serious about sustainability.


     We're continuing to make progress at learning how to program the Butterfly, the latest accomplishment being to have mastered the code needed to read a port and write that information to another port. A lot of what we'll be wanting a control computer to do will involve monitoring various inputs and then generating various control signals--and we're now able to do that, so it's a mark of real progress. Not very showy, but important none-the-less.

  January 28:

Jay writes:

     When Walt took the Butterfly into Portland to show the "Away Team" our progress it was working fine, but yesterday when we tried to upload another program, we got the dreaded message described on page 33,

"No supported board found!
AVRprog version 1.37-OK

     We checked and rechecked our connections, the power supply--everything we could think of to the point where we were about to head out to the chicken roost to take Mr. Pardue's advice to "pass a dead chicken over the setup while chanting voodoo hymns."

      We were frustrated! As best we could tell, as soon as we turned on the Butterfly's power supply, the exisiting program would start running automatically without allowing us the opportunity to upload a new program. We were following the standard proceedure of pressing the joystick button straight in while the programming software tried to connect with the Butterfly, but still the dreaded message would appear. It seemed that the Butterfly was more concerned with running the program than communicating with the computer.

     So before taking the recommended step of sacrificing a chicken we searched the internet for a similar problem but that didn't turn up anything. Then we decided to post our problem on the AVR Freaks Forum

     We were more than a little embarrassed--we hadn't even gotten past page 33! Everyone on the forum was talking about these neat projects, so we were surprised and pleased when about 5 hours later Ron Pardue (aka smileymicros ) wrote us back with a simple line that was just slightly different from the book, "Are you holding the joystick button pressed to the center while removing and reinserting the battery? And then are you holding the button pressed to the center when you open AVRProg?"

     Our spirits are uplifted by the quick response! Thanks, Ron! It is nice to know that our simple beginner type of question was not over looked by the more advanced people talking about all those neat projects on the forum. Now we know that you have to hold the button down as you are turning on the Butterfly so that it doesn't automatically launch the previous program.

     For the person who's found this page by searching the internet for this problem, here are some other variables that are worth checking: the PC and the Butterfly can only communicate if the bit rates are the same for the COM port. In this case 19200 bits per second. You get there in Windows by clicking on

Control panel>System>Hardware>Device Manager>Ports>Communications Port>Port Settings

     It seemed even though we thought these were the same, we later checked and found that they were different. And don't forget to restart your computer, especially when changing System Settings. And really, do check the connections carefully. The book described inserting the power leads into a chip socket mounted on the front of the Butterfly, but the wires kept coming lose so we decided to solder them to the back of the Butterfly. That way--when it's moved--the power connections wouldn't keep coming loose.

     Looking back, we're not really sure what the problem was, but we're really glad it's gone--and the chickens are resting easier too.

Notes From Windward - Index - Vol. 67