Revisiting old topic, Heatermeter for pellet smoker.


 
I did manage to get all the code to compile, started to make some of the suggested modifications and such, still compiles... I haven't yet connected any hardware, so I wouldn't have any idea at this point , what it is or isn't capable of. While doing all of the above, I've at least gained some further familiarity with how everything comes together.

Pin 7 apparently was at one point or another going to be used for a 'soft reset', so to try and use that pin , you have to comment out some lines. Hopefully over time, I will better understand more of this code and be able to contribute a bit more to finding ways to incorporate pellet grill control into it.
Good eye! I saw that too. BTW I successfully got an LED blinking on pin 7 for output% of TEMP_MEASURE_PERIOD, I just haven't had time to retrace my steps to share with you. It came down to the variable 'elapsed' in GrillPid::doWork != the elapsed time between TEMP_MEASURE_PERIOD but the elapsed time between 'adjustment' periods.

Let me leave you with this final thought... and it is really , something that would be used after the basics have been accomplished... The standard/basic pellet grill controls temperature , by only adjusting the feed rate of the auger. If ambient conditions remain constant, and the lid isn't up, all you do is maintain a single steady duty cycle, that keeps feeding pellets in at the same rate. If ambient temperatures go up or down, you might have to increase or decrease the duty cycle / auger feed rate. More advanced grills start to modify the fan to try and slow down the burn rate at times ( when the pellets go from smoldering to full burn) to try and even out the temperature swings that naturally occur on the basic pellet grill. That fan speed adjustment in many ways, is very similar to what the heatermeter normally does... increasing the fan rate when things have cooled down a bit too much, decreasing it as temperature rises above the desired set point. The advanced pellet grill control, would need to find a steady auger feed rate, then adjust the fan a bit here and there to even things out even more. So... Originally, I had been thinking of totally abandoning the fan control that the heatermeter does and only control auger... but the more I think about it, it's good to leave the adjustable fan concept in the code ( it might need further modifications to actually work well in conjunction with the auger feed however ).

Anyway, thank you all for contributing to the cause... :)

As I don't have a pellet grill I'm afraid I can't help as far as the actual logic for a fan+auger goes. Maybe adapt the damper servo logic to the auger, and the blower to the fan? Might be easier to switch out your pellet grill's 120v AC fan for the standard heatermeter DC fan, the relay can't control the AC in the way the heatermeter controls its blower.
 
Last edited:
Yes, it may very well be easier to do DC voltage for the fan. I'm not really sure why most pellet grill makers don't use DC at least for the fan, it certainly would be easier to control the total volume of air that was moving, then it is with AC. I suppose there are probably reasons that I fully haven't thought through why.

I'll keep plugging away on my Pro Mini, making sure I understand where all the pins come put and such. I can already see that if I want to use I2C ( and I eventually do want to ), I'll have to solder wires in on those.

Anyway, I think I'm starting to understand some of this enough that it's actually kinda fun now. Previously it'd just been frustrating.

Good eye! I saw that too. BTW I successfully got an LED blinking on pin 7 for output% of TEMP_MEASURE_PERIOD, I just haven't had time to retrace my steps to share with you. It came down to the variable 'elapsed' in GrillPid::doWork != the elapsed time between TEMP_MEASURE_PERIOD but the elapsed time between 'adjustment' periods.

As I don't have a pellet grill I'm afraid I can't help as far as the actual logic for a fan+auger goes. Maybe adapt the damper servo logic to the auger, and the blower to the fan? Might be easier to switch out your pellet grill's 120v AC fan for a DC fan, the relay can't control the AC in the way the heatermeter controls it's blower.
 
I should also let you know... for me personally, the actual PID functionality is almost unnecessary, or almost like icing on the cake. The key thing I would like to be able to do, is to wirelessly read and write settings to the controller.

The reason I say this, is because for the most part, on a nice day, with a pellet grill, all you really need to do is get the auger feed rate to a constant state that achieves the temperature you desire. That is... if you set the feed rate to 25%, and that gets you say 250F with fan running full speed , you just leave it run at 25%. Generally the only thing that will change the temperature significantly is if the wind picks up a lot, or the ambient temperature changes more then 15F. Over the past 4 years of my cooking on a pellet grill, that's all I do with my current setup, set it to X% feed rate , watch the temperature , adjust feed rate up or down until I get the temperature I desire, then walk away. If I could do that remotely, I'd be quite happy. If the PID can adjust for minor changes to temperature that result from changing weather conditions, that's be cool, but heck unless the weather really changes a lot, it's rarely a issue for me. With my current setup, I pretty much know that 15% will get me about 180F, 22% closer to 225F, and so on... I've just learned by using my grill what percentage will get me close to the temperature I want.

The other thing, I would really like , is a automated way to raise the temperature... Say run at 180F ( or 15% ) for 2 hours, then automatically raise it up to 25%, then being able to occasionally look in via a wireless interface, to see if things are going according to plan.

Which is basically, why I've been saying all along that in many ways, the heatermeter is way more complicated then I really need.
 
Sounds like you really just want to start from scratch for the sake of learning. Go for it!

PID itself can be really simple once you study it a little bit and get your head around it.
There is a arduino PID library here: http://playground.arduino.cc/Code/PIDLibrary
The author also wrote a series of articles explaining how he wrote it here: http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/

You could easily write the controller to do something like:
Auger duty cycle = some simple (linear?) function of setpoint.
fan duty cycle = PID output

OR

Auger duty cycle = simple function of setpoint + PID output
fan duty cycle = 100%

OR

Auger duty cycle = simple function of setpoint + PID output
fan duty cycle = a different PID Output

so on and so forth...

[Edit]
I could modify the heatermeter avr to option 1 above and email it to you if you like. I'm really starting to like that idea, use a DC blower/fan instead of the grill's AC fan, even use a damper/servo with it if you want, and the only control you need to add is to get the auger moving. The rest of the code can be left alone while still being utilized and getting you that high end precise control you were talking about.
 
Last edited:
Well to me there is value in trying to work through the process of modifying the Heatermeter code, in part because I do believe there are a lot of people who would or could make use of it all. Bryan clearly has put a lot of effort into adding stuff that has value, to many people. If there are relatively small tweaks that could be made to allow it to control a pellet grill, and keep some of the other features ( allowing many different probes to be used and so on... ) There is value for me, in just trying to understand how he's done all the stuff he's done. However, that is a double edged sword... because there is so much going on in the code, it's hard for someone like me, with limited programing experience to follow it all.

I do have a small amount of programing experience in my day job, but it was mostly in Perl scripting... Years and years ago... I actually knew how to write assembly language/code... and of course BASIC and Fortran... C is all new to me, as is Python...

Meanwhile... my interest in doing something from scratch, is actually mostly because If I write it from the start myself... I don't have to try and figure out what someone else was thinking. :) I do think that a really basic control could be made, with probably 10% or less of the amount of code that makes up the Heatermeter, but then obviously it looses some functionality. Part of me thinks it'd be easier to do it from scratch, but then another part of me knows there's a lot of work that would have to be done.


Sounds like you really just want to start from scratch for the sake of learning. Go for it!

PID itself can be really simple once you study it a little bit and get your head around it.
There is a arduino PID library here: http://playground.arduino.cc/Code/PIDLibrary
The author also wrote a series of articles explaining how he wrote it here: http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/

You could easily write the controller to do something like:
Auger duty cycle = some simple (linear?) function of setpoint.
fan duty cycle = PID output

OR

Auger duty cycle = simple function of setpoint + PID output
fan duty cycle = 100%

OR

Auger duty cycle = simple function of setpoint + PID output
fan duty cycle = a different PID Output

so on and so forth...

[Edit]
I could modify the heatermeter avr to option 1 above and email it to you if you like. I'm really starting to like that idea, use a DC blower/fan instead of the grill's AC fan, even use a damper/servo with it if you want, and the only control you need to add is to get the auger moving. The rest of the code can be left alone while still being utilized and getting you that high end precise control you were talking about.
 
I'd love to use the PID functionality of the HM, and have all the temp probes as well.

I have 3 HM units, so maybe hacking up one isn't so bad since I really only use two.. (one for monitoring the traeger, the other controls a mini WSM).
 
I've gone off on a tangent for a bit... after going to Microcenter again. :) picked up a couple more Pro Mini 5 volt boards... at $4 a piece, they are just so hard to resist. I picked up a LCD with buttons, in hopes of making a more Heatermeter like setup too.

However I started trying to make use of a little OLED display I had bought for $6 off banggood.com and started wiring up a basic NTC Thermistor based temperature reading device. I figured before I could even start to build a PID or anything like it, I better make sure I can read temperatures reasonably well on a Arduino setup. So, anyway, I got my little Pro Min based thermometer setup, which uses more or less the same hardware design as the heatermeter. Now, having recently done a similar little project on a Raspberry Pi 3, using a ADS1115 ( 4 channel 16bit Analog to Digital converter , that uses I2C ), I was a bit surprised to seee the temperature readings bouncing around by a couple degrees or more while the probe was just sitting there at room temperature with little or no air moving around it. Having done a little research previously on the Heatermeter, I deducted that the unexpected fluctuations in the readings are probably the result of noise.

So anyway, then I got wondering if the ADS1115 filters out the noise better, or if the Raspberry Pi setup was just less noisy and therefor not experiencing the same issue. So then I started wiring up the ADS1115 on the same Arduino Pro Mini setup I was working with... Well I can report to you that the setup with the ADS1115, is much more stable. I'm trying to quantify just how much more as I type this. Currently I have a simple voltage divider ciruct, with a 100K ohm resistor where the Thermoworks probe normally sits, I'm taking readings at the same time , using both the standard 10bit AD of the Arduino and the 16bit of the ADS1115 ( actually it's 15 bit, cause one bit is used for +/- ). It looks like the setup with only the Arduino's own AD converters yields a +/- 2F temperature variation that must be directly related to noise, the variation I see on the ADS1115 readings are closer to +/- 0.5F, which is a huge difference. Until I can convince myself that I'm not making some sort of mistake to cause the large errors in the Arduino AD setup, I don't think I will have much time to explore modifying the heatermeter code.

If I do determine that the ADS1115 setup is really deals with circuit noise that much better, then I would also feel compelled to look at ways to incorporate this into any kind of PID/controller I might be building.

I think the Heatermeter code tries to deal with the noise by averaging and/or throwing out some of the readings it gets. The ADS1115 might do some or much of that all by itself, it's configurable as to how many readings per second it takes and I believe averages the numbers before even letting the user see the data. I also know the ADS1115 has programmable gain as well as a internal voltage reference , so I suspect that the difference in error I am seeing , is not a result of some flaw in my own setup with the Arduino so I'm currently leaning towards the notion that I want to work with the ADS1115 rather then the stock Arduino AD converters... I'll let you know if/when I determine more about these matters.

I'd love to use the PID functionality of the HM, and have all the temp probes as well.

I have 3 HM units, so maybe hacking up one isn't so bad since I really only use two.. (one for monitoring the traeger, the other controls a mini WSM).
 
are you using any capacitors to filter out the AD reading(makes a big difference)? How often are you reading the PIN? once you get the temp you can 'smooth' out the reading using a running avg....

sample code of running avg...you can modify the alpha

//running avg.
float alpha = 0.05; // factor to tune
if (runningAvg < 0) runningAvg = curTemp; //first run
runningAvg = (alpha * curTemp) + (1 - alpha) * runningAvg;
 
Yes, I have a capacitor , just like is used in the Heatermeter setup... My current setup takes a reading every couple seconds.

So you can get a idea of the difference, I took the data over a 15 or 20 minute interval and graphed it... here's what it looks like. If I can't convince myself that there is some flaw in my circuit, I'd have a hard time convincing myself to start down the road of using the Arduio's own AD converters when you can get these ADS1115 things on a breakout board for under $5 a piece ( that includes shipping costs).

As you can see in this graph, the ADS1115 data is within +/- 0.25, while the Arduino data is +/- 2.5

[URL=http://s40.photobucket.com/user/Glenn_Wiltse/media/PID%20development/AD%20comparion%20V1_zps4eog4ayv.jpg.html][/URL]

are you using any capacitors to filter out the AD reading(makes a big difference)? How often are you reading the PIN? once you get the temp you can 'smooth' out the reading using a running avg....

sample code of running avg...you can modify the alpha

//running avg.
float alpha = 0.05; // factor to tune
if (runningAvg < 0) runningAvg = curTemp; //first run
runningAvg = (alpha * curTemp) + (1 - alpha) * runningAvg;
 
interesting....on my arduino setup I don't get that big of a swing in AD probe readings...works pretty well. What power are you feeding the pro mini with? 5v or using its Vin/Raw?
 
Currently, everything is being powered via the FTDI adapter's power , which ultimately is coming from a Surface Pro's USB port... I'm sure this is not ideal, but still, the ADS1115 is dealing with it all quite well.

Here's a photo of the current testboard setup...

[URL=http://s40.photobucket.com/user/Glenn_Wiltse/media/PID%20development/2016-04-29%2010.30.25_zpswztuencp.jpg.html][/URL]

interesting....on my arduino setup I don't get that big of a swing in AD probe readings...works pretty well. What power are you feeding the pro mini with? 5v or using its Vin/Raw?
 
For the record I'm using a 5v pro mini as well without these issues. How are you powering the mini?

In your code have you tried implementing heatermeter's methods? Specifically analogReadOver? (grillpid.cpp)

As far as I can tell the heatermeter stores both a temperature reading and a temperature average, calculated with calcExpMovingAverage as DavidNP was mentioning. But the heatermeter only uses the averaged temperature reading for the PID's D term calculation. (I Think) what's reported is the 'unsmoothed' readings.
 
Currently, everything is being powered via the FTDI adapter's power , which ultimately is coming from a Surface Pro's USB port... I'm sure this is not ideal, but still, the ADS1115 is dealing with it all quite well.

Here's a photo of the current testboard setup...

[URL=http://s40.photobucket.com/user/Glenn_Wiltse/media/PID%20development/2016-04-29%2010.30.25_zpswztuencp.jpg.html][/URL]

So you're bypassing the onboard voltage regulators/caps. Maybe this is part of the issue, try powering through RAW with ~7+ volts?

Also, what's that cute little resistor under the 10k ohm resistor?
 
No... I'm using heatermeter circuit and formula for calculating Temperature , I am currently not doing any kind of software averaging or anything, these are all just RAW readings, the software is just polling the A0 once per reading, it's also just polling the ADS1115 once per reading. Again, I've made no attempt to average or discard any data, just raw data.


Currently, everything is being powered via the FTDI adapter's power , which ultimately is coming from a Surface Pro's USB port... I'm sure this is not ideal, but still, the ADS1115 is dealing with it all quite well.

Here's a photo of the current testboard setup...

[URL=http://s40.photobucket.com/user/Glenn_Wiltse/media/PID%20development/2016-04-29%2010.30.25_zpswztuencp.jpg.html][/URL]
 
The tiny resistor is a 100K, in place of the NTC Thermistor ( which I don't have with me right at the moment ). My Thermistor measures about 100K ohms at room temperature, so I'm just 'simulating' the Thermistor with that little resistor at this point.
 
Yes, I could ... but, if the ADS1115 deals with whatever noise is happening here, why not just use it? Why bother with trying to find ways to reduces the noise, or average it out in software, when a chip can do all that?

As I was saying in the other thread... in theory, you could do all of this, without the Arduino at all. You could just use a ESP8266, with the ADS1115, and I believe people have also ran the SSD1306 based 128x64 OLED, with nothing more then the ESP8266. Now, to be honest, from what I have read, there can be some pitfalls that come along with the ESP8266 related to some libraries and such that don't quite work exactly like they do on a Arduino, so I'm not totally ready to go down the ESP8266 only path just yet.... but I really like the ADS1116 board, it's cheap, you can hook up to 4 of them onto a Arduio or Pi giving you up to 16 high quality/resolution Analog inputs, and it will operate at 3.3 or 5V.. very versatile little board/chip.
 
What ever floats your boat!

If you want to go down the "customize heatermeter code to work for pellet" path it'll probably be easier to not to worry about the ADS1115 as the noise is already handled. But for a from scratch project, + an ESP, sounds like fun to me.
 
Yeah... well, I do have very mixed feelings about it. I can tell already , that to get sort of a very bare bones sort of control , with minimal code, a scratch built device could be pretty easy to do, in some ways , it's probably easier for me , then to look through all the heatermeter code and try and 'fit' a auger control bit of software in... But then, what I'm left with, is a bare bones pellet control , and not much else at that point. Yet... I think, if I were to understand and be able to make use of the serial protocol , it could likely be added to the bare bones project pretty easily, and at least allow me to communicate with a LinkMeter type of device...

At this point, my plan is to get a Pro Mini based controller going, probably initially without any WiFi, just so that I fully understand all the issues in doing this. I'm leaning toward using the ADS1115, because it's pretty easy really.

Once I get the basic thing working, I'd then want to add a ESP8266 on it, so that I could access it remotely, even re-program it if I wanted remotely... At that point, I'd be like a small step away from being able to implement the Heatermeter serial protocol thing and... well I'd be pretty far into a fairly functional little device.

Assuming all that went well, I'd then look at getting rid of the Pro Mini all together, and just use the ESP9266. If that worked... well, I'd say , it'd have to be about the cheapest little grill control device you could possibly build in DIY projects. But of course then I'd be looking at getting one of the ESP8266 boards that have the LiPo charging circuitry built right into the board , so that the device wouldn't totally have to reboot even in a minor power glitch...


What ever floats your boat!

If you want to go down the "customize heatermeter code to work for pellet" path it'll probably be easier to not to worry about the ADS1115 as the noise is already handled. But for a from scratch project, + an ESP, sounds like fun to me.
 
Well, I've progressed to the ESP8266 without a any other microcontroller . I haven't actually made use of the WiFi , but did get it working with the ADS1115 and the little 0.96" 128x64 OLED. I did this using the Arduino IDE software... People have written libraries that make most of the stuff pretty painless. I've got a little ways to go before I'll be controlling a pellet grill, but I'm more and more confident that you don't need the ATmega micocontroller at all.



 

 

Back
Top