Sunday, May 31, 2009

The Eagle has landed

Once I got started in Eagle I got a little loony. Hours go by in a flash as I work at a sub millimeter level routing connections and sorting out placement issues. It's kind of like a very seductive puzzle. I've now laid out three different circuit boards in Eagle, and it feels like I'm getting the hang of it. Two (motherboards) are based on the Arduino Mega reference design, and the other is a shield (daughterboard) that could be used with most Arduinos. The first board is what the heliostat needs, but the other variants use cheaper components that may be of interest to others (and thus are potential spinoff products). After several frustrating hours I think I've been able to source nearly all the necessary components. Mouser Electronics will sell SMD resistors for 5 cents each compared to 50 cents from Digikey! Seeedstudio's Propaganda PCB service will make the prototype circuit boards for only $5 each. I've followed several tutorials from SparkFun and I feel ready to stencil the solder paste and cook up a few boards on a hot plate. Quite the blend of low and high tech. If no major issues pop up, then the Gerber files will go to manufacturing later this week.

I went to Houston for Srila Narayana Maharaja's Bhakti Yoga Festival, although I was a couple days late because I listened to the advice of everyone around me and avoided the potential DUI checkpoints that were setup for the Memorial day weekend (since I don't have a valid drivers license at the moment). This was of course just another one of Maya's tricks (Maya - that which is not) trying to impede my spiritual progress. I was feeling kind of weak and nauseaus before I left, but immediately felt better once I got on the road. Nothing in this world compares to the mercy of the vaisnavas and the delicious prasadam at the festival.
I tried talking to various people at the festival about the heliostat project, but it seemed nobody had an understanding of the implications, or any interest in helping. At the very end of the festival, I sat down at a table by myself, and another devotee sat down and after a while we began talking. He was interested in my story, and offered to give me his old laptop (which should be fine for coding). This was yet another excellent example of the following principal: although we must make an effort (endeavor) to achieve something, success is not due to our own efforts, but rather the mercy of the Lord (and his personal representative - Srila Gurudeva).

While I was gone the 30x40 fresnel lens I ordered arrived. A quick test outside showed about a 8" long focus point (this is a linear lens designed to focus light into a line instead of a point). This quickly smoked some grass and made some mysterious stuff bubble out of a rusty scrap of metal I found in the yard. I have my doubts about whether or not this is more efficient than a parabolic reflector, but it is certainly practical for concentrating light on something like the heat tube of an ammonia refrigerator.
I'm still trying to decide what is best as a first target for testing the heliostat on. The refrigerator is "cool", but some sort of water heater would allow easier calculation of BTU/hr, thus yeilding effective wattage level.

Sunday, May 17, 2009

After the Flood

Well I've had a little time now to take stock of the situation following the storm last week:
- laptop motherboard: dead
- laptop hardrive : spins, whirs, and clicks, but doesn't mount
- backup hardrive: wasn't even plugged in, won't even spin
- Freeduino board: dead
- Mirror control shield: dead
- SOC Amber webserver motherboard & daughterboard: smoke when power applied!
- USB memory stick code base backup: over month old, missing custom libraries

Truly amazing what can happen in a couple minutes when you walk away from something.

Data recovery costs $200-$800
Misc electronics $200
Backup drive $200
Replacement laptop $300
--------------------------
Total damage: $900-$1600
That's a very conservative estimate, not including lost code, time, and rebuilding effort.

Meanwhile this week the Arduino Mega board that I ordered (the day before the flood of destruction) from NKC Electronics arrived, as did the WaveShield from LadyADA. The waveshield was simple shield to assemble and I especially like the way it was designed so that remapping the pin assignments doesn't require cutting traces. I'm a little worried about being able to use the PWM on 9,10 after looking at the code. I'm hoping to have 3 pwm channels (6,9,10) for an accompaning LED light show to go with what I am calling the Bhajamatic - it plays audio loops of mantras and kirtans, with a discreet light module for small/medium altars. Audio is 16>>4 (i.e. 12) bit 16khz mono, not the best but ok, at least loads of play time from a 1Gb card. It would be nice to add a graphic display and do a slide show to go with it.


I spent the evening and some of this morning working in Eagle and finished a library entry for the SCA3000, and began editing the Arduino Mega specification board layout to include it. A little ambitious for a first project maybe, but the hookups are pretty simple, and I just followed a tutorial for another chip. The tricky part is that it's a surface mount device (SMD), and I'll have to hope the product dimensions shown on the spec sheet indicate the recommended landing pad layout which is somewhat unusual, not to mention tiny at just 7mm square. Add a DS1307 for RTC, and an H-Bridge driver w/connections and we've got a nice board...
... and I just got lost for a couple hours checking out prototype services, pcb no problem, still don't know about parts placement and reflow work. Many questions, but perhaps this is the path meant to be taken.

I've been working this week making "bliss bars" at the factory, a small step towards funding repairs. Srila Gurudev's Houston festival is next week, and things will be different afterwards!

Saturday, May 9, 2009

It's dead, Jim

That's the line Doc said to Cap'n Kirk on Star Trek so many times, that's what he would have told me yesterday about my computer.
Keeping the agony in protaganist, here's a quick recap: The ambitious hero of our story, rejected by friends and family, after leaving California on borrowed funds, with nowhere else to go, has piled all his material possessions in a car and gone to Texas to spend the summer working (in the upstairs of an uninsulated cabin - can you say hot?) on an invention to save the planet. Sitting on the floor toiling all day at the computer, soldering tiny wires while kneeling over circuit boards and chanting Hare Krsna. Alarmed by the appearance of success on the horizon, the demi-gods who are worried of their powers becoming impotent due to the widespread adoption of heliostats sent a storm with powerful lightning, winds, rain, and hail to prevent their power from being usurped. Casting a spell of delusion they rob our hero of his limited intelligence, leaving his computer and software vulnerable. Like when Rama was falsely led into the forest, and Sita was snatched by the demon Ravana, our protagonist Madhu must now chase down and retrieve his code....
I've been sitting within 3 feet of my computer for probably 22 hours a day, and yesterday I stepped away for a few minutes, you know to Eat, and a huge storm blew in from nowhere and before I could even get back to the cabin the rain had blown 8' horizontally through the window saturating everything in the area, which included my guitars as well as my laptop which was on and open. The keyboard was completely saturated, and the display was looping through some nasty sounding hardware failure message that I had trouble reading because I was so frantically trying to turn it off and shut the window at the same time. The next 10 minutes or so were spent trying to get the situation under control and drying everything off. Up to 1" hail came down, the neighboors had baseball sized pieces. Good news is that the heliostat mirrrors weren't broken and the whole stand rode the storm out nicely. Measured highest wind was 21, but gusts were certainly higher.
I knew the prognosis was bad for the laptop. I dried it off as best I could and waited. After a couple hours I powered it up, but it wasn't happy and didn't boot. The BIOS setup worked though and the hard drive test also passed, so I'm optimistic about the data. Ugh, I hadn't backed up since I left California, and my last backup didn't get the motor control library! I saved a shred of hope for the morning, but all I was able to learn in the morning is that the motherboard isn't happy.
Fortunately I was able to borrow a computer to write this with.

My guru says this verse should be engraved in gold on our hearts:
Tat te 'nukampam su-samiksamano
bhujnana evatma-krtam vipakam
hrd-vag-vapurbhir vidadhan namas te
jiveta yo mukti-pade sa daya-bhak

It means that one who accepts all sinful reactions (Karma) as Krsna's mercy, understanding it to be a result of his previous activities), enduring it with an undisturbed mind, while continuing to practice devotional service with body, mind, and words - such a devotee is eligible to attain Krsna's lotus feet, which are the shelter of liberation.

I can't do that yet. I try, but I'm not qualified. My mind gets disturbed, and I become angry to avoid being sad because it's so hard to live with myself while accepting that I am the cause of all my suffering. Srila Gurudeva is slowly grinding me to a fine powder because I'm too independent to surrender to him even though I want to.

Bottom line on my computer is that I need around $300 it seems to get a used Compaq 3000 that I can pop my hard drive in, and hope the heliostat code is still there. At a minimum this is going to be a one week disruption, but given my lack of funds, probably a month. I've been working on this every day and now I either can't, or I have to redo my last month's work on the assumption that I'll have to anyway. All this is just too much to accept this soon, and I'm going to have to figure out what's next after taking a couple days off (if that's possible).

Friday, May 8, 2009

WIP: It Good

So much work in the last week...
The motor control library caused issues that made me learn more about Arduino program architecture than I thought I needed to know! My old QA skills narrowed down the offending line of code that caused the whole program to crash before it even ran (!!!) That only took a day or so to figure out and resolve. With the libraries working, I moved on to debugging the i2c command interface which had problems returning data from the slave unit because I was trying to send it one byte at a time since I hadn't read the Wire library commands. Oh the fun of being a novice. Once again there went another day of head grinding.
Then for a brief moment it seemed as if all the clouds might be disappearing, all the pieces were going together: the UI display was getting sorted, the input routines were debugged (a whole day coding manual Latitude and Longitude setting with only 5 buttons), the target and schedule tables were defined, the database routines were almost done, and still 10k of program ROM left.
Oh but the most important part, the solar position calculations was still absent! I had tested the code module long ago, and at that point was just happy to have some code that put out accurate numbers. As I started looking through the header and counting all the floating point variables, I began sensing trouble on the horizon. The SolPos algorithm uses over 1/4 of my total SRAM. Even when I commented out all the unneccessary variables and code, it still caused the 328 to reset during execution due to corruption of memory.
Yesterday I had some breakthroughs with the 128 based Amber board from SOCMachines, but it didn't turn out to be enough. It's an exciting little board with 256k of external memory and built-in ethernet connectivity. Back when I got the board, the first thing I did was the thing they tell you in bold letters not to do, and that was after reading the instructions! The result of that was that I erased the memory so that the demo program didn't run, which took some time in itself before I was able to test because I had to get a usb/serial cable and a special link cable to plug board straight into my laptops ethernet connection. After a couple months of EEPROM burner phobia, I downloaded PonyProg2000, figured out the parallel cable interface, and was soon uploading hex files both to the Amber, and the Arduino. This was cool because I learned how to upload an Arduino bootloader, and upload and run a program without any bootloader.
I was opti-mystic about the Amber being able to run an Arduino program since the new MEGA 128 based Arduino came out, but it turns out the Arduino team chose to support the 1280, and the Amber has the 128 16AU, which has 4k less of SRAM, although identical in almost all other aspects, and after much experimentation and diving into the Arduino core files, I determined that it just wouldn't work (with my level of knowledge at least).
Several more hours were spent investigating the demo program for the Amber, at the end of which I decided that it would just be too much work to port everything I've done over for it.
So the end result was that I decided to byte the bullet and buy a new Arduino Mega board (yeah)! It's still tempting to simply integrate a 3'rd processor (168 or 328) into the design, as a second slave, using the i2c bus and have it perform all the solar calculations, but that would still leave the master unit (a 328) perilously close to capacity, without network functionality added to the code base yet. So now I'll use the 128, like I knew I needed in the beginning, but it was a good learning experience the last couple of months: first with the 168 chips, then the 328 came out and doubled the memory, and now I can step up to the 128 and quadruple the 328's memory!
So bottom line is that the code base is coming along very nicely and the remaining processor issues should be taken care of as well. The new MEGA board is ordered from NKCElectronics and should be here within a week.
Oh yeah, the H1 heliostat prototype has been outside and setup for over a week now, and has endured several thunderstorms with wind gusts up to 30 mph!