请选择 进入手机版 | 继续访问电脑版

DIY编程器网

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 11996|回复: 8

K-Type Thermocouple PID Controller

  [复制链接]
发表于 2012-1-12 22:48:13 | 显示全部楼层 |阅读模式
Worklog - The System overall (September 18 2011)

My new Aoyue 968 hot-air SMD station

I plan to make a pre-heater for my SMD works, and i will need a controller for the air heater. From my job i know the PID controllers and how efficient they are, but i did not really know how they work. After some research i did, i sound the "secrets" of the PID systems (and i also wrote a theory for PID systems). So, now i feel ready to turn theory into product. Many will say again that i could spent $40 to get a PID controller... Yes, i know... But i DON'T want to. For me, making projects is not a chore, it is my hobby, i do it for fun.



The Idea
Here is what i plan to make. It will be a board with 2 rows of 3 7-segment displays. The top row will show the actual temperature and the bottom the set temperature. Like my soldering station, i will use the MAX6675 - Cold-Junction-Compensated K-Thermocouple-to-Digital Converter from Maxim. This chip converts a thermocouple pair temperature into digital readout, and also compensates the cold junction temperature.
I plan to use a PIC 16F1937 or one of my new 16F1939 SMD chips. Most probably i will use the huge PDIP chip, because i have a lot of them still in my stock. There will be 2 potentiometers for setting the temperature and the air flow. So the controller will have a PWM output for controlling the fan speed. For the heater, i will use the same method as i use for my soldering station. A BT136D TRIAC can deliver enough current to control a 900 watts heater. A MOC3021 optocoupler will control the gate of the TRIAC
This will be my first project that i will use more SMD components than through-hole components, so i'm very excited!







The Circuit
I will do no prototyping for this project, so i need to be extra careful and double check everything. Here is the schematic diagram for the controller board (click to enlarge):




The image is not very clear and i have used a lot of busses to simplify, so i have to upload the eagle files as well. I usually do not upload such files but this time i must. So, here they are:


[url=] K-Type Thermocouple PID Controller - Eagle Schematic V1.0[/url]



Bill Of Materials
Resistors
R1Resistor 220 Ohm 1/4 Watt 5% Carbon Film
R2Resistor 220 Ohm 1/4 Watt 5% Carbon Film
R3Resistor 22 Ohm 1/4 Watt 5% Carbon Film
R4Resistor 220 Ohm 1/4 Watt 5% Carbon Film
R5Resistor 22 Ohm 1/4 Watt 5% Carbon Film
R6Resistor 220 Ohm 1/4 Watt 5% Carbon Film
R7Potentiometer 5  KOhm Linear Rotary 1/2W
R8Resistor 22 Ohm 1/4 Watt 5% Carbon Film
R9Resistor 22 Ohm 1/4 Watt 5% Carbon Film
R10Resistor 22 Ohm 1/4 Watt 5% Carbon Film
R11Resistor 22 Ohm 1/4 Watt 5% Carbon Film
R12Resistor 22 Ohm 1/4 Watt 5% Carbon Film
R13Potentiometer 5  KOhm Linear Rotary 1/2W
R14Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film
R15Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film
R16Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film
R17Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film
R18Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film
R19Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film
R20Resistor 10 KOhm 1/4 Watt 5% Carbon Film
R21Resistor 1 KOhm 1/4 Watt 5% Carbon Film
R22Resistor 3.3 KOhm 1/4 Watt 5% Carbon Film
R23Resistor 1.8 KOhm 1/4 Watt 5% Carbon Film
R24Resistor 870 Ohm 1/4 Watt 5% Carbon Film
R25Resistor 1.8 KOhm 1/4 Watt 5% Carbon Film

Capacitors
C1Electrolytic Capacitor 1000 uF 16 Volts
C2Electrolytic Capacitor 1 uF 50 Volts
C3Electrolytic Capacitor 1000 uF 16 Volts
C4Electrolytic Capacitor 1 uF 50 Volts
C5Ceramic Capacitor 0.1 uF 50 Volts
C6Ceramic Capacitor 0.1 uF 50 Volts

Transistors-Diodes
T1BT136D Sensitive gate TRIAC
T2BC517 NPN Darlington Transistor
D71N4148 Switching Diode

Integrated Circuits
IC1PIC 16F1937 Microcontroller
IC27805 Positive Voltage Regulator
IC3MAX 6675 Cold-junction compensated K-Thermocouple to digital converter (0°C to +1024°C)
IC4CD4511BC BCD to 7-Segment Latch/Decoder/Driver
IC5ULN2003A High Voltage - High Current Darlington Arrays
IC6MOC3021 Random Phase Optoisolator TRIAC Driver Output
IC7DF02M 1.5 Ampere Bridge Rectifiers

Misc
L1100uH Inductor


 楼主| 发表于 2012-1-12 22:49:05 | 显示全部楼层
I am not going to prototype anything on a breadboard due to the complexity of the system. Instead, i decided to go directly onto a PCB. After all, there will be design errors and changes, so i can name this PCB as "prototype board" and save a ton of wires connected on breadboards. The procedure i followed is the same as i always do, my favorite, the photographic method. I used my PCB Photographic Artwork Transfer UV Cabinet to transfer the artwork from paper to PCB, and then my PCB Etching Bath with Heater and Agitation to etch the board. Here is the result: (click to enlarge)




This time the result was even better. I reduced the exposure time from 750 to 600''. For the story, i began exposures as long as 950'' which had very bad results, then i droped doen to 850, 800, 750 and now 600. I think i will try one at 500''. There are still lots of throuhg-hole components but this is going to change gradually, as i empty the through-hole stock that i have.

I drilled the holes for the through-hole components
I solder them, as well as the wire-bridges
Then i soldered the MAX6675 and all the SMD components








Through-hole to SMD
I now had to solder the 6 7-segment displays, but i had big plans for those . They are through-hole components but i plan to solder them as if they were SMDs. Why? Well, first of all i save myself from drilling another 60 boring holes. But basically, if it is better to solder them on the bottom layer, so that i can mount the board directly onto the box.

The displays are normally through-hole
I put the first row in a pre-drilled PCB which i will use as a stencil
And i bend the pins 90 degrees
This is the result so far
I do the same for the other side
Ready!


So now, i can solder them as SMD components on the bottom side of the PCB. This is the result (click to enlarge):



 楼主| 发表于 2012-1-12 22:50:06 | 显示全部楼层
There are still some minor things to do with the PCB before it is ready to hook it up in the power supply. First of all, i had to put the reset button. Also, i had to slightly mod the 4-pin connector for the fans. A PC fan connector has 4 pins but the back side is made to fit also a 3-pins connector. This way, both a 3 or 4 wire fan can be inserted. After all, both fan types have the same pinout for the first 3 wires. They only differ on the 4th wire.

I soldered the switch on a 2-pin connector.
This is the back side of the button
I sliced the plastick back behind the 4th pin of the an connector
This way, both a 3 and 4-wire fan can be correctly orientated


Then, i made the 2-buttons,the LED wire and the potentiometer connectors:

[B]I had no better buttons to use, but i have already order a few[/B]
I have a 5-positions connector because i may want to add more buttons
I have one 3mm LED and one 5mm LED
I think i will keep this set-up. The green LED will be for the power.
There are 2 potentiometers, one for the temperature and one for the fan speed
The potentiometers are directly connected to the analog inputs of the PIC


I got a K-type thermocouple from ebay with small mass, but still it does not react very fast in changes. So, i will use one typical K-type thermocouple from a multimeter. I do not have one right now in stock, but i think that right now its on the plane for Greece.
At last, i am now ready to plug all the connectors on the PCB and hook it on the power supply. I do not expect to see much... As a matter of fact, i will see absolutely nothing, for the PIC that i use has a totally empty flash. I am ready to plug the programmer and start playing... Here is the PCB (as always, click to enlarge):










Boot me up! (August 30 2011)
I wrote a quick and dirty software for the PIC to read the thermocouple. Actually, i copied the routine from my Soldering Station because i use the same chip to interface and compensate the thermocouple. So far, the PCB does nothing more than reading the temperature from the thermocouple, but i'm excited because the 7-segment displays work like a charm. The 4511 driver to drive the segments and the ULN2003 to drive the digits was a really good idea and i will use it for my future projects. Once again i was impressed by the precision of the thermocouple. It is really impressive what 2 dissimilar wires can do!






A problem with the PCB ruined the day
Well, it was expected to happen... After all, this PCB is the prototype, so i should not get mad... Anyway, here is the thing: First of all, i wanted to test the TMR1 gate function of the PIC and set it to measure the fan RPM. I may use this method for my next project (PC fan controller), so i added the brown wire to the PCB. I may remove it afterwards, because i do not really want to have RPM feedback from the fan. The fan will run with PWM pulses in an open loop.
The thing that really messed me up is the PWM output. I've done this error many times, the very same error. I get the PWM output from the wrong PIC pin. This time, instead of taking the PWM ouput from pin 8 (SEG21/CCP3/P3A/AN5/RE0), i took it from pin 5 (SEG15/VREF+/C1IN+/AN3/RA3). So i had to cut the line from pin 5 and connect a wire (the white wire) to get the PWM from the correct pin. The result is a fully functional but ugly PCB



 楼主| 发表于 2012-1-12 22:50:57 | 显示全部楼层
I kept this dryer many months for such an occasion. It was a present that my girlfriend found in a shampoo package. She asked me if i wanted to keep this, and instead of a hair dryer i actually saw motor and a heater .

This is the hair dryer
And this is an exploded view
The heater resistor is 800 watts!



The motor is a 12V DC, it has 4 diodes to rectify the AC
I will remove the wire and the switch from the heater resistor
And i will keep the fan blades. The motor sounds like a train


The heater comes with a built-in mechanical bimetallic thermostat because we don't want the lady to have a thermal shock. I measured the temperature before i hack it, and it was 80 to 90oC. When i removed the thermostat the temperature climbed up to 300oC before i unplug it.

The heater comes with a built-in bimetallic thermostat
I bridged the thermostat with a thick wire
I added 2 new wires to power the heater
I will use the plastic cover cone to drive the air through the heater
This is the final assembly of the heater.
The base diameter fits perfectly on this PC fan







A faster thermocouple (September 10 2011)
I tried the thermocouple that i got from ebay to see how it reacts in temperature changes. This thermocouple has a large mass to heat, so the reaction is not very fast. So i decided to change the thermocouple with a smaller mass to have faster reaction to temperature changes:

This is the thermocouple with the large mass and slow reaction
And this is a typical fast-acting K-type thermocouple for multimeters
I don't need the socket for the multimeter
This is what i'm going to use


The thermocouple is ready to work with the controller, and the controller is ready to be programmed!






The new (and hopefully final) schematic (September 13 2011)
So, if you have already read the previous pages and more specifically page #3, you may have notice that i made a few mistakes on the PCB which i had to fix them with two wire bridges. I tested the board with these wires and it seems that it works perfectly. So, here is the new (and hopefully last) schematic diagram of the PID controller:




Yet again, due to the fact that the image above is low resolution and the schematic is not very clear, i upload the eagle files for this project:

[url=] K-Type Thermocouple PID Controller - Eagle Schematic V1.1[/url]




Explosion is something that can happen while prototyping (September 16 2011)
This is what happened: A little tiny bug in the software caused the output to go high rapidly. I was testing the controller while i was playing my favorite game. The incident first excited my nose. The heater became very hot, about 350oC, and the plastic cover took fire. But that's only the beginning. I tried to pull the thermocouple back and put off the fire, but the plastic had already melt and the thermocouple stuck in there. So i pulled it with force, but unfortunately the thermocouple wire touched the 220V resistor...

This is what happens when 220V goes through the MAX6675
The plastic went on fire
And the thermocouple got a nice plastic coating ;)


So there will be a small delay to repair the controller...

 楼主| 发表于 2012-1-12 22:51:21 | 显示全部楼层
So, i began repairing the controller. The casualties from this mistake are:

The MAX6675 had a really bad day...The PIC has one (or more) defective ports. Although it works, its not reliable any more. I will keep it for experiments though.The 4511 is not workingThe TRIC reacts very strange - not normal operation
Ok, it happens... I replaced all the above-mentioned parts and the controller works again just fine.

These chips had a bad day... Must be changed
The triac is nor operating normally, so i will change it as well
I enjoy using my new hot-air soldering station for the SMD
Finally, the controller operates normally.




The PIC Software
Version 1.1 - September 20 2011 - Changelog:

[Bugfix] I fixed the bug when calculating the derivative term which could cause output oscillations.[Performance] I changed the output burst control and now it runs without causing delay to the A/D module.
[url=] K-Type Thermocouple PID Controller - Assembly listing - V1.1[/url]

[url=] K-Type Thermocouple PID Controller - HEX file - V1.1[/url]








Version 1.0 - September 19 2011

Here is the very first PIC software for the controller (Version 1.0):

The assembly file was corrupted so i lost version 1.0 assembly listing.

[url=] K-Type Thermocouple PID Controller - HEX file - V1.0[/url]


The PC fan is controlled with PWM pulses. The first potentiometer adjusts the duty cycle of the pulses and therefore the speed of the fan can be directly adjusted. The software can read the speed of the fan for security reasons: If the fan stalls for any reason, the heater must immediately be turned off.
The PID routine has these parameters:
GAIN_P_Constant: The gain multiplier for the Proportional termGAIN_I_Constant: The gain multiplier for the Integral termGAIN_D_Constant: The gain multiplier for the Derivative termTIME_I_Constant: The time interval for the Integral accumulationTIME_D_Constant: The time interval for the Derivative calculation
These parameters are currently constants, but i plan to preserve some EEPROM space to save them there and also i will probably make a UI routine to change them from the controller buttons directly.
The heater control is done with bursts. Each burst has a length of about 250 mSec. The mains power supply has a frequency of 50 Hz (period=20mSec). So, during each burst, at least 12 full AC periods go through the triac to the heater. The interval between the bursts depends on the PID output calculation.
The buttons have currently no operation. I currently use the LEDs only for debugging reasons. The red LED corresponds to the power bursts of the heater. The green LED changes state every time an integral value is accumulated. I plan to change the function of the green LED and i will use it as a power indicator: If the controller has power, the LED will be always on. I kinda like the way that the red LED operates, so i may keep it as is.

发表于 2012-2-9 21:36:00 | 显示全部楼层
佩服你,能发这么好的帖子,厉害
发表于 2012-6-15 16:30:48 | 显示全部楼层

38

过来一起顶!
发表于 2015-10-26 21:38:52 | 显示全部楼层
这个很好,学习了,多谢楼主
发表于 2017-2-11 14:34:28 | 显示全部楼层
这个很好,学习了,多谢楼主
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-3-29 04:49 , 耗时 0.116324 秒, 19 个查询请求 , Gzip 开启.

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

桂公网安备 45031202000115号

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

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

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

QQ:28000622;Email:libyoufer@sina.com

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

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