Oven with web app for control and temperature charts

I have updated my oven project to use Agents and not rely at all on Xively or COSM.

the electric imp IDE and service is just great for doing this kind of development. The various datalogging options including copy/paste from the planner log and the robust crash handling, etc. have served me really well.

I am cheating a bit here in creating a new post for my old project but the software and operation are so different now…

Here are links to the source




optional PHP

and here is a link to a project page that I built on Tumblr. There are some videos there (time-lapse) showing the action. I know it is boring for many but if you are trying to build something at all similar I think it will help to have this reference.

project page

Using a Tumblr static page is a bit of an experiment. I know that others have expressed interest in standardizing a way of documenting projects. In this case an Instructable is not appropriate because so many others have documented converting toaster ovens to reflow ovens. Nobody does it the same way twice and also my hardware is just not that presentable. A step-by-step just was not going to work. Likewise github could be used for code but my source code is extremely unlikely to be maintained or forked so all I needed was a repository so others can have a glance at it. I used Dropbox for that.

I tried to keep all the logic in the Device code even including the ‘enabled’ states of the radio buttons. The Agent acts almost strictly as a pass-thru and the web page acts as a datalogger, provides visualization and obviously provides the UI.

I also log each oven cycle to a new .csv in my web server using a PHP script but this part could be omitted.

The page could have been served by the agent (self-hosted) except that Highcharts does not provide SSL (https) to serve their library and my web hosting account will also not do that. I use just http and that allows everything to work well without cross-domain errors.

and hide the agent url by using local storage. i got that bit and also got my start with jquerymobile from member @controlCloud - many thanks!

The code for queuing http responses came from beardedinventor - again many thanks!. That enabled me to set up long-polling for quick response and to allow any browser that loads the page to stay in sync. I tested with Android, Chrome, Desktop Safari and Firefox. I think it works with all of these. I never could get it to work with the Kindle Fire and was not successful getting debugging tools hooked up.

The project page will also link to page in which I explain the development of the P, I and D constants and also on in which I show one possible way to attach a thermocouple to the PCB.

I have used this oven to make several boards with Pb solder and have used it as a preheater. I have not used it to do lead-free yet.

I absolutely welcome critical feedback on the code, etc. I do know that my Device code is a little hard to read, sorry.


Nice! I’m going to work through your project and build one. I’m might see if I can get everything to run through the agent, and not have to use an external web server. I suppose the logged data needs to go somewhere… and I haven’t done anything with Firebase yet, so maybe I’ll give that a shot. Thanks for sharing!

great! I am happy to hear it may be helpful to you.

The web page does capture the times and temperatures in a text box so you can do a crude sort of datalogging by copying data out of the textbox using the clipboard. I have heard that there are not good tools for saving files from browsers because for security reasons this is not deemed a good action.

There probably are services that will do datalogging. I come across them from time to time but have yet to have found one that stands out and I cannot recall any names from memory. Perhaps this can be done via API to google docs?

Getting Highcharts to work would be a challenge because of the self-hosted imp being SSL (https connection) and highcharts not supporting this. maybe there is another charting tool that could be referenced? maybe you can roll your own with html 5 canvas elements?

I am afraid I must backtrack a bit on my browser compatibility. After I wrestled the iPad from my kid last night I found the oven code was not working. It definitely had worked at some point. It is the long-polling technique that causes difficulty with Safari and especially with iOS. I suggest skipping that part and have the Device respond immediately to http requests that get passed to the Agent. With this more typical method one would use the setInterval function to have the browser poll each second or so. After you get that working then you can move on to the long-polling if you wish - at least that is my suggestion.

@mjkuwp94 it’s bummer that hightcharts doesn’t support an https CDN. I’ve always self hosted so never been an issue over https. I’ve used several other JS charting solutions but highcharts is so easy for an amateur programmer like me. I to have noticed that javasceipt timers don’t restart when a safari page looses focus/slept. I’ve been looking at using https://tempo-db.com/ have got it working using Chrome-postman just haven’t found the time to write some agent code yet.

Take a look at D3.js

It is very powerful, produces beautiful graphs, and has a hosted version of it :slight_smile:

D3.js has been suggested to me by a coworker but after I had such an easy start with Highcharts I didn’t look further. I have just checked it now and it also seems to not have an SSL option thought it could be that I just don’t know where to look.

temp-db does look pretty reasonable. I may look into that for other projects -thanks!

Nice project. I just use one of these http://www.amazon.com/Panasonic-NB-G100P-7-2-Quart-1300-Watt-Infrared/dp/B000063UZV turned to full power, wait for it to reflow, give it an extra 5 seconds, then turn off and open door. Never had a problem making prototype PCBs.

thereza, thanks! and yes I do see that many people have perfect success with various methods of manual control. If you want to follow a profile it also would not be hard at all to read a temperature sensor and control the oven by hand. It is mostly full on- very light load - full on, then off. Part of my goal was to learn PID control and other things so that is why I did it.

btw, I just did an experiment to hold the html of the page inside the agent; “self-host” or “agent-host” whatever you wish to call it.

it worked!

I used the cloudflare CDN for highcharts. I didn’t test in all browsers but I don’t know why it would be any different.

I had to change the referer and the Access-Control-Allow-Origin and I also changed the code so that the URL of the agent was directly in the code rather than using the localStorage call.

I plan to stick with hosting the html on my hostgator account. It has password protection and I do like my workflow better using the external editor. Even so, it was cool to see that many people will be able to build nice systems with just the imp service and one or two other cloud services and using CDNs.

One of the things on my list is figure out some authentication for agent hosted webpages. I had followed the Google OAUTH example a while back and it worked, but I didn’t follow through to actually see if it could be implemented through to anything else. @beardedinventor could probably enlighten us. Have you guys set up any imp hosted pages that require oauth?

I haven’t done this yet, but it’s on my list (my oh so long list).

It shouldn’t be terribly difficult to do - just a matter of sitting down and doing it!

Yep. I think I am going to bump that near the top of mine and work on it. I’d like to have a nice agent hosted page for each of my Imps, and Oauth on all the ones whose function is private.

oh, I had never heard of that. Are you concerned about someone coming across your web app by accident? or by robot? Does Google index these sites?

I wonder if you can just put a string of random (but known) characters at the end of your URL and code the agent to only respond if those are part of the URL.

I’d try myself but…lunchtime is over : )

Yep, that is essentially like adding an API-Key, which is what I do with Pitchfork. Its a little cumbersome though, if you have to type in the address. Id like to able to use more human friendly addresses like garage.domain.com, and point them at my agent URL’s. OAuth would just give you a very high level of authentication, and if you are using Chrome it should be able to log you right in on a trusted device.

When someone asks me about PID control loops, I always direct them here:

I’m not saying you’re a dummy, but it explains it in simple, basic terms.

I think it would be easy to implement in a function, I just haven’t had time to do that yet.

One other thing … The PID loop can be simplified for many applications. Derivative usually doesn’t have to be used, and “integral” can be defined as “rate”. So you need “Proportional (gain)” and a “rate”. You see how far off you are between setpoint and actual value and then multiply that “error” by a preset gain to determine how far to change the output from its existing value. The “rate” will determine how many times per second (or minute) that you wish to recalculate a new output.

Thank you @mlseim for the link. It will be really helpful for those that need an introduction to PID - as I did a while back.

The PID loop is working, except for re-writes that I might do to modernize the code.
the code is all available -links in the first post.

PI control is used for the loop that controls slope and PID is used for the one that controls temperature (they are not active at the same time). In the profiles I only use a PID loop that controls the temperature slope. This is unconventional but for this unique case it has worked so far.

here is the way I do the profile - pulling the numbers from memory and they may change a little bit…

  1. no closed-loop control, just warm at 20% duty cycle until 40C is hit.
  2. Control point is 1.4 degrees C per second
  3. When temperature reaches 100C, Control point is the slope required to reach 150C in 120 seconds. Each 0.5 seconds (the control “rate”) a new slope is calculated and this new slope is the new command. Of course of the temperature overshoots there is not much the oven can do other than wait for the temperature to fall. I try to avoid this situation.
  4. When time expires on the soak, control is 1.5C / second until the peak temperature is reached.
  5. under my control, remove the board from the oven and cool it by setting it on a plate and/or cooling with a fan.

As I get further along maybe I will find a scenario that the loop does not respond well to and in that case I may have to go back to the books or to that link.

The oven also has a preheater mode that sets control to a fixed temperature setpoint. For this mode I use PID control. The heating elements are quartz? tubes around metal wires. there is significant lag between the command to the wires and the rate of heating and that is where I think the “D” term helps me because the elements will also take a while to turn off and this term will ‘see’ the fast-rising temperature and act against the command to reduce it and help to avoid overshoot.

one enhancement of this project would be to plot the P, I and D contribution to the command along the chart and you could see it in action to help with the tuning. It would be quite trivial to add this.

You can see my PI terms here

PI terms for slope control

and for temperature, PID here

PID terms for temperature

I explained the units in physical terms so that one can use those formulas to create PID terms even if they choose a different scale factor or different integrating period. You can even change the Wattage if you have a stronger oven or reduce it if your oven is similar in power but larger in size. Of course I don’t expect this to result in perfect tunings but maybe it will get you in the ballpark.

Oh man … this is where the Imp website really needs a project section. Everything pertaining to PID would be in one article, each project would have its own page, etc. I know they are working on it (I hope they are). We need this so bad.

Stuff like this discussion is scattered all over the place in this forum. Same thing for power supply, battery and overall Imp power discussions.

Some of us are using Instructables, some using GitHub, some using our own websites … this has to all come together in one place.

@mjkuwp94 this is a good project - thanks for posting. Something to add to my list of projects that most likely won’t get done in my remaining lifetime! Too many projects… too little time…

I updated the Device, Agent and web code today, pasting in what I have been using. The Device code is totally re-written.

the main points are:

the Agent code writes to tempo-db.com

The oven’s Device code has two PID loops, using only one at a time. For preheat mode it uses temperature PID. For reflow profiles it uses a slope control PID loop.

The power level is plotted on the chart

The preheater mode presets the integrating term based on knowledge of the power level required to overcome heat loss at different operating temps.

This page has the general information including the explanation of the PID constants and their real physical units and meaning.

reflow oven page on tumblr

@mjkuwp94 thanks for this how tempo db working out?

TempoDB is working well so far - for what I have asked of it. The last thing I worked on was changing from writing to a single series at one time - to multiple series in the same command with the same timestamp.

I have it running for a few projects. I have a couple of imp-based electrical power meters and TempoDB is a little more applicable for those projects.

I think the next thing I will try is to do a read request and plot it with Highcharts.

For this oven I rely more on my php script to capture the log of a single oven cycle.