PID works!


After tweaking the Kp and making the Ki work in the software the graph speaks for itself. The software is controlling the temperature to the set point of 140°F within a fraction of a degree for the most part. This was the last difficult piece of puzzle. I did not use the PID function in the Arduino language, instead I wrote my own with a large part of the understanding of the code coming from the excellent description by Brett Bueargard who wrote the PID library, as well as assistance from a friend who helped me understand the problem better in a spreadsheet. I now have a burner that works dependably and is modular so that I can make changes and see if I can further improve the efficiency. I now have software which will hold the temperature without worry. I plan to add a proof of fire sensor next for the mechanical part of the project, and add the ability to set the Real Time clock in the software. Onward, ever onward, but for today I think I will have a beer!

Thinking about PID control

Proportional, Integrative, Differential control.  There is a function in Arduino that implements this and I started thinking about how I would do this and if it would be appropriate.  The function, really an algorithm is all based on error and time.  In this case the error is the difference between the set point and the actual tank temperature.

All three functions Proportional, Integrative and Differential have a factor, Kp, Ki and Kd.  For example let’s calculate each portion of the formula starting with the proportional contribution Kp, if the current temperature of the tank is 100°F and the set point is 140°F the error is 40.  The integrative portion of the formula adds the contribution of the error over time.  This would be the Ki factor multiplied by 40 and added to the previous Ki*error for every time period.  The differential portion is the Kd multiplied by the difference in the tank temperatures or in other words the tank temperature at the beginning of the time period  minus the tank temperature at the end of the time period.  Let’s take some of the data collected by the OpenLog microSD card and take a stab at this in Excel. We’ll assume Kp=6, Ki=.6 and Kd =.2. The time period is one minute.

Raw data imported into Excel with PID data calculated

Raw data imported into Excel with PID data calculated

Now in practical terms how is the the fire being controlled now?  The auger time is being controlled.  Of course practically the fire must not go out so there is a minimum time the auger must run, since in this program the auger is on a fixed time of 5 secs this really means that all of the control comes from varying the time the auger is not running.  But again the fire can’t go out so I figure the max amount of time between the fixed auger feeds of five seconds is forty seconds.  So that is the slowest the fire can go.  How fast can it go?  Well theoretically the feed could run continuously but again we are dealing with a chemical process that cannot simply absorb 100% fuel feed.  In this case the auger motor added a practical aspect by limiting the feed to a duty cycle of 50%, so the maximum time that the feed can be on is half the time.

Since the PID control is based on time periods and the data collection time period is one minute,lets choose a time of 1 minute for argument.  In one minute at max run the feed will be on 30 seconds and off 30 seconds.  In one minute at min run the feed will be on for 5 secs, off for 40 secs, on for 5 secs and then off for the remaining 10 seconds of the minute.  So again we don’t control the on time only the off time and the difference between the max on time (min off time) and min on time (max off time) is 30 secs on, 30 secs off for the max and 10 secs on and 50 secs off for the min.   So the only control between full bore and idle is the difference between 50secs and 30 secs or 20 secs per minute.
This explains some of the challenge,  the other challenge is the inertial effect of the combustion reaction especially if unburned fuel has built up.  So now that the PID output has been calculated I’m having a hard time wrapping my mind around how this would translate to control of the time, I know I could set up a simple proportion between the PID output and the 0-20 scale of  auger off time dwell.  However in this example the PID output  increases as the error decreases.  I guess that’s the beauty of a spreadsheet I will play around with Kp, Ki and Kd to see if I can get this to work a little better.

Software changes to control underdamped Setpoint control

After running for a few days I have been happy with the amount of holes in the bottom of the burner, the ash level when running does not get higher or lower.  However the fuel usage is a little higher than I thought it would be and the program does not hold the set point temperature as well as I would like.  The graph shows the interaction of the excess fuel usage and the set point.  At times the boiler should be idling along with very little fuel feed, the program should be able to determine the fuel usage needed to control the temperature to the set point.

Under damped control

Under damped control

You can see the 140°F horizontal grid line, the set point is currently 140°F. The integral of the area over that line is excessive fuel usage. However that’s not the only issue, the second issue is the amplitude seems to grow larger until approx. 121 minutes.  At that point I shut down and started a new software change.    You can see the slow recovery as I had to relight the fire and then the software starting correcting earlier, so in short more software changes are in order.    The challenge is to build self correcting software since the whole goal of this project is to burn chips and that will require the software to deal with different energy densities.  I’ll make a few more software changes and post another graph soon.

More Testing, another day, another graph

I rebuilt the burner yesterday added more air holes in selected areas and tried to stop up the misc air leaks to see if that

Tank Temperature vs. Time in minutes

Tank Temperature vs. Time in minutes

would add more power.  I’ll let the graph speak for itself.   Note the issue at 45 or so minutes in where the temperature started to drop.  At this point the sawdust bridged so badly it wasn’t feeding any fuel.  After I poked the sawdust in the hopper, the temperature continued to rise.  I had to continue to poke the pile to get the feed rate to be somewhat normal.  Looks a lot like yesterday’s graph, so I am thinking about adding some additional air through a forced draft fan on the front end of the process.   Once again the burner did do the job but slowly and until approx. 379 minutes or a little more than 6 hours into the test did the temperature rise past the point where the circulator turned on.  I measured the chamber pressure, in this case vacuum and it measured .1″ H2O so additionally I am wondering if I need a larger exhaust fan as well.

Work out the software bugs to test burn, Step 8 of a DIY Record

Over the summer and fall I have written and tested a number of programs to have the building blocks of a working program.  I knew the key this year would be the ability to log data.  Of course to log data and have it mean something you have to have good data.  So I spent several days working the bugs out of OpenLog, which works but I would not recommend.  I also spent some time figuring out a combination of moving averages which resultx in stable data.

Of course the integration process was a train wreck.  The arrays used for moving average data smoothing were declared wrong so that bug had to be found and fixed.  The Serial LCD needed to be replaced, and my soldering iron wouldn’t work.    A few of the functions are timed and there were some issues with those functions.  The code for Open Log was not robust enough, once I worked out all those issues, which took most of the weekend, it is finally ready to test.

I had a plow in the shop for repair and soaked up the spilled hydraulic fluid off the floor with some sawdust, actually pellets that got wet.  So the hydraulic oil soaked sawdust is in the hopper to be burned.  It’s burning now, so tomorrow I should have some excel data which will help me make decisions to improve the software.  At this point I am not sure it will be valid however, it is really taking a long time to come up to temperature with the sawdust.   Another data point.

Boiler hooked up and burning for the first time

Boiler hooked up and burning for the first time

Software cuts pellets by third, saving $112/month

Minor changes in the software that force the boiler to maintain a tighter range from the set point has cut the fuel consumption from 3 (40 pound) bags of pellets to 2 daily.    These software improvements and a extension to the pellet hopper mean the boiler will now run 24 hours without needing  additional fuel.    The hopper extension adds at least another 40 lb bag of pellets capacity bringing the total capacity to approx. 2 1/2-3 bags.  I haven’t measured only estimated.

The boiler  set point is currently set at 135°F which seems to work just fine for the temperatures we have been having and the software is consistently running within4 degrees of set point.  This range may seem excessive but seems to run just fine.  The program is becoming more modular in that there is only one number to change,  the set point.  The set point currently  is a variable declared in the setup section of the program but eventually the set point will be self adjusted by the program based on the outside temperature.  Economy and efficiency by software optimization is the goal for this next week.

We have had a very mild winter in my opinion.  The Heating Degree Day total for the month of Dec 2011 was 1091 as measured by the local weather station.  The normal is 1209 HDD a difference of 118 HDD, not as much as I would have thought.  The total for the month of January 2012 so far is 1140 with four days to go, with a normal of 1419.  We’ll see how the month ends but if it continues as the average day it will be short approx the same number of HDD as  last month,December.   My interest in HDD is to see if there is a correlation to HDD and fuel consumption.  There should be and if there is than the fuel economy is starting to improve.  As I told a friend of mine, at this point the boiler is like a truck I used to own, 10 mpg  going uphill loaded, 10 mpg empty going downhill….so seeing fuel consumption changing to track the weather will be the first step to seeing some optimization.

Software work on fuel economy and the  extrapolation of costs for the upcoming remainder of the season is of great interest.    The next step in fuel economy may be better insulation  of the boiler and piping and will not be as simple as software improvements.  But if I can get a correlation between the outside temperature and fuel consumption that is measurable then the software will be nearly optimized and further improvements will have to come from physical changes.  This week sees a 40 pound bag and $4.00 improvement per day, $28/week, $112 per month.  Next week’s goal:  another $60/month.  I am hoping for a total seasonal heating cost of $500 or less using $200/ton pellets.  I will consider that a huge victory for heating a 2300 sq ft house with 3 garage doors.

Good test for the boiler with -5°F overnight temperature

I restarted the boiler with a friend on Friday afternoon on the 13th of January.  At present it is Sunday morning at 6:45.  Thirty nine hours since starting, in that time the temperature has dropped to a low of -5°F which is the current temperature and the fuel usage has been a total of 5 bags.  The house is still comfortable and has not shown any dip or problems in maintaining temperature.  The only noticeable differences are two things.  The lack of the oil fired boiler running which I can hear upstairs and always makes me a little twitchy.  The second difference is the temperature of my office.   My office is off the utility room which holds the furnace and so is normally quite warm after a cold night.  Today it is the temperature the thermostat is set to maintain.

A few numbers, I paid $215/ton for the pellets, so the cost per 40 lb bag is $4.30.  The hours per bag is approx. 7.8.  This will need a  longer time average to confirm but is probably a reasonably good number so in rough terms this is 3 bags per day for a cost of $12.90/day.  I looked back to see if I had a furnace run time data which I did have a limited amount.  On October 17, 2007 the furnace ran a total of 4.1 hours on a day that had a high of 51 and a low of 33 for a total Heating Degree Day of 22.7.  (Heating Degree Days are calculated as (in °F) 65-(day’s max temp-day’s min temp)/2 or to restate 65-average temp) .  Taking the furnace run time as 4.1 hours x nozzle rate of 1 gal per hour this translates to 4.1 gals usage for a total cost at $3.85 per gallon of $15.78 for one day relatively mild day.  Yesterday’s HDD calculation using a high of 29 and a low of 11 yeilds and average of 20.  So 65-20=41.  Using a simple ratio of HDD/Furnace Run time would calculate to a furnace run time of 7.4 hours per day for a cost of $28.50 per day.  Contrasting this with the pellet costs yields a savings of $15.60 for that one day.

So is that accurate?  That was a lot of math using some not very exact calculations.  The math was done correctly but Heating Degree Day calculations are notoriously rough.  Many oil companies have moved onto more sophisticated methods and of course this is just a snap shot of one day.  But as an reality check  at this point I am confident 5 tons of pellets would easily get this building through the winter for a total cost of $1075.   If I used 800 gals of oil throughout the heating season this would cost me $3080 at a cost of $3.85 per gallon.  So yeah I think the numbers are reasonably accurate if not conservative.  Wait until I try chips at a cost of $40/ton……too fun.

More combustion air

2nd Fan with slip joint connection

To increase the combustion efficiency a second fan was added.  The smoke coming from the boiler was very thick at times and really needed more oxygen.  So a second fan was added, to help add more air and help keep the chip feed area cool.  The parts slip together and allow a quick look down into the burner area.  This allows you to be able to visually check on the feeding, and the fire by simply lifting the fan.  So far I am happy with the change and the biggest difference is the ability to see the feed rate appropriateness.  Already I want to change the program to allow smaller bites less often because the fuel is backing up the feed pipe.  Because of computer issues, the laptop I was using wouldn’t  recognize the USB port the Arduino is plugged into more than one or two uploads, I am attempting to switch computers.  The 2nd computer at my disposal is running Windows 7.  Not nearly as easy to use as XP Pro that I am used to using in opinion.

So, I am having difficulty communicating with the Arduino.  I may have to go back to the first computer.  Ain’t computers grand?  I am a lot happier with a welder and plasma cutter.  My weight this morning was 193.8, down 1.9 lbs.  Probably water weight although I have stopped drinking beer for a little while.   Ham sandwich in every bottle so a friend once told me.

Changed feed sprocket

The New Year practically demands resolutions and change for the better.  So with that constant improvement theme in mind I am publicly stating my goal to lose 15#’s and so  I am starting from  195.7.  My second resolution is the constant improvement of the boiler.  So here we go……

Auger feeding failure  due to the motor stalling demanded the  sprocket change  on the auger motor feed assembly.   The sprocket I chose  doubles the torque available for feeding pellets.  Since the shaded pole motor is constant speed the program had to change to double the auger run time.  So taking the data I had gathered I changed the program in two ways.

New sprocket added

I changed the times to accommodate the speed change  demanded by the sprocket change and I changed the paradigm to have constant run time and vary  the dwell or off time.  The increased torque is a vast improvement and since the change it has had no problem feeding even  adding an entire bag of pellets at one time.

A second advantage of the change is the improvement of the LCD display.  I think that this problem is now fixed since the LCD has been running without garbling the characters for several hours, long past the time when the LCD would normally have failed.  By increasing the torque the auger feed motor is running at less amp draw and so it feeds back less to the relays.  I also grounded the relay in a more positive way.

LCD display

Real world vs. Bench Top

I’m a big proponent of having some skin in the game.  If you don’t you are fooling yourself.  I learned that in the financial markets.  If you can trade on paper you have a better chance of succeeding in the real world trading but when you have real money involved sometimes you can’t make the decisions needed.

That seems to be the case with the LCD display.  After having worked out some basic electrical issues the display worked fine for 3-4 days with the relays tripping but no motors hooked up.  Now that the motors are hooked up again it seems to be garbling the LCD.  So, the only assumption I can make is there is some kind of electro-magnetic field  or a bad ground that is interfering with the LCD.    The motor is a shaded pole motor which has a large electromagnetic core which no doubt radiates interference for the controller.  Below is a picture of a similar motor.As a fix I think I will twist the LCD wires so they are less of an antenna and see if using some tin foil to shield inside the project box as well as above the feed motor and see if I can improve the ground.