DIY编程器网

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 5524|回复: 1
打印 上一主题 下一主题

PID controlled reflow oven

[复制链接]
跳转到指定楼层
楼主
发表于 2013-9-11 07:59:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
      Intro      The idea to build a reflow oven (Wikipedia) was taken from thomaspfeifer.net. For those who don't speak german: He regulates temperature via a PWM controlled solid state relais, which just switches the heaters on and off. The temperature is interpolated from a measurement with a little 1N4148 diode. To control the much needed temperature profiles (read the reflow soldering guide for reference) a little PC programm allows to input certain curves. His design seems very simple yet effective but I didn't like three things:  
hooking up a PC via serial -> no room for that  1N4148 as temperature sensor -> a -40 to 300°C KTY 84 is like 0.8 and most likely more accurate and long-lasting  a 10 5A solid state relais for PWM control might be nice -> but a relais will do since temperature doesn't change that quick anyway         So I created a new design adding a couple of things I'd like to have. First of all I replaced the 1N4148 with a KTY84 sensor, giving me a saver feeling than letting a 4148 stew in a 250°C oven. To get some kind of feedback I added a HD44780 compatible 4x20 display (~ 8 on ebay). This display also allows to input temperature profiles via a menu directly. You can adjust temperature and time of a drying phase and a reflow phase. Those values get stored in EEPROM, so that they aren't gone next time you switch on the oven.  
      Since the oven I got for my conversion is quite strong with 1.5kW, but very cheap of quality and therefor extremely poor insulated, I had serious problems controlling temperature precisely without too much overshooting. I've tried adding simple P-controlling algorithms but merely couldn't get a satisfying result. Either the temperature rise was slowed down too much, or I still overshot my target by... a lot. The only solution I got was to add a quite complex PID control, but more on that later.  
      
    Hardware    The curcuit of the oven is as simple as it gets. There's just a timer and a bi-metal switch. When the timer is running the oven heats till the bi-metal switches of again at a certain temperature. You might think that the bi-metal switch is at least calibrated but even that wasn't the case. With the switch at it's limit (230°C) I could heat the whole thing way past 250°C before it finally switched off. So I decided to keep the bi-metal switch in my curcuit as some kind of safety device. The timer was replaced by a PIC16F887 controlled relay. (connections in the bottom left corner of the board)  
         
                        download schematic  
  download board                     
  download partlist        
        The board was designed so that the display fits right onto the 16pin connector at the top. The KTY84 temperature sensor is red by ADC1 (AN0) at pin #2. The relay is switched with pin #7 with an IRF4905 FET. The push-bottons at the bottom right are to navigate through the menu and start the heating cycle. I actually ended up only using up/down and enter... but whatever.  
      One of the only modifications you got to do at the oven is to place the sensor somewhere, where you could measure the actual temperature inside. At first I've tried to just stick/glue it on the outside of the inner chamber but that produced a lot of crappy measurements. A better idea was to drill a hole into the oven and place the sensor right under the heating coil. I put the sensor connectors into some heat resistent tube and wrapped AL foil around. This installation provided faster responses to temperature changes then the one before.  
                                                                           
             After the sensor was placed inside the oven I took the drill and made 4 holes in the top for mounting the board. Thinking about that... it might not have been the smartest thing to do since the oven is very poorly insulated as I mentioned before and the surface tends to get very hot. At least I provided about a 1cm of space between the board and the oven surface and the board stays within "touchable" (<60°C) temperatures. To prevent the whole metall case from getting charged with 230V I put a 3mm wooden plate between the board and the case.   
                
                         By the way! Beeing a greedy bastard I thought I could power the whole thing with a cheap 12V 800mA wall power supply. Doing that I had unsteady "blueouts" where my display suddenly went all blue and lost any data. I assume (didn't measure any of that) it just couldn't handle little voltage drops I must have had because of quite fast relay switching times. Even adding some bigger caps (ok, I admit I didn't have any at my display before) couldn't solve the problem. You might consider to solder at least 100n between the first two pins (VCC and GND) of the display connector. It might save you some trouble.   
       Software        Most of the software (probably 90%+) is display formatting and "making things look nice", so please don't pay too much attention on that. I know that some of the comments in code are german, but I'll try to explain how things work. The whole programm is roughly split into the 3 standard parts:   
Initialization    Mainloop    ISR                The initialization part contains the initializations (who would have thought that?) of the PIC16F887 own ADC, Timer0 and Timer2, as well as an init of the HD44780 compatible display and the PID control. Depending on whether init you call these functions are stored in "adc_pic16f887.c", "lcd_with_hd44780.c", "pid.c" and "timers_pic16f887.c". Beside those inits another function is called to create 3 extra characters (arrows and °) on the HD44780. Just in case all relevent variables are set to their starting values again, right before a start message is sent to the display. Timer0, which is responsible for the key debounce in ISR, gets started, allowing the user to browse through the menu, adjusting temperatures and times or start the heating cycle. Ok, now that I promised you a menu we might back this up a little. Instead of writing endless pages of explanations I've decided to throw in a little video tutorial on this... This is mainly due to the enormous LACK of information on the internet about LCD menus in general. Either people just suggest to create somd kind of structure (because it's no big deal right?) or refer to finite state machines. Two sentence answers to quite complex problems, classic. The following link will bring you to my tutorial.   
         -> Goto videotutorial #1 - LCD menus   
          Ok, now that we got that covered back to the mainloop. Don't let all those delay and output functions confuse you! The mainloop is kept very simple. After a lot of display formatting and showing the user selected temperatures and times there is just one simple infinite while loop. Inside this loop there is an if-instruction waiting for timer2 to set the pid_flag. It's set periodically every second. This mainly has two reasons. First and most important is to avoid that the integral portion integrates itself to death. This might happen due to a oversized I-portion itself, or due to too short delays between the "pid_Controller" function call. And secondly it's because a little standard relay can't be switched much faster than every other second. For practical information about PID control please check "Atmel AN937", "Atmel AN964", "Microchip AVR221" and "PID Without a PID". Reading them gives you a basic understanding on how control algorithms are realized in code. Specially AVR221 provided useful for me and I used big code sections of it.   
         Inside the if-function all that's left is sequentially executing the two phases.   
  • heating up to drying temperature (preheat_temp)
  • holding that temperature for a certain time (preheat_time)
  • heating up to reflow temperature (preak_temp)
  • holding that temperature for a certain time (peak_temp)
  • cooling down to a safe temperature (<60°C) and software reboot (basically an assembler jump to address 0x00)
            A variable called phase is used to save and check the current phase. Whenever the desired temperature or time has been achieved the variable phase is incremented and the next state of the cycle can beginn. Beside the LCD outputs there is an "ADC_convert_and_interpolate" function call which measures and calculates the current temperature, as well as an "pid_Controller" function call which calculates the controller output. In this case a positive return value switches the relay ON, a negative value switches it OFF.   
                           
      download MPLAB project - switch case menu
   download MPLAB project - structure menu
   compiled with Hitech C PIC16 lite   
               Notice that I don't take credit for the HD44780 control and the delay functions. All LCD relevant code was written by Isaac Marino Bavaresco and just slightly modified by me by adding a write string function The amazingly precise set of delay functions was taken from microchipc.com. Another thing worth mentioning would be my favourite bootloader, the ds30 Loader. Go ahead and try it, make sure to donate a couple of bucks to Mikael Gustafsson.   

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏1 分享分享 支持支持 反对反对
沙发
发表于 2015-10-21 22:13:27 | 只看该作者
感谢楼主提供这么好的交流平台
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|文字版|手机版|DIY编程器网 ( 桂ICP备14005565号-1 )

GMT+8, 2024-12-26 14:16 , 耗时 0.083171 秒, 17 个查询请求 , Gzip 开启.

各位嘉宾言论仅代表个人观点,非属DIY编程器网立场。

桂公网安备 45031202000115号

DIY编程器群(超员):41210778 DIY编程器

DIY编程器群1(满员):3044634 DIY编程器1

diy编程器群2:551025008 diy编程器群2

QQ:28000622;Email:libyoufer@sina.com

本站由桂林市临桂区技兴电子商务经营部独家赞助。旨在技术交流,请自觉遵守国家法律法规,一旦发现将做封号删号处理。

快速回复 返回顶部 返回列表