DIY编程器网
标题: K-Type Thermocouple PID Controller [打印本页]
作者: liyf 时间: 2012-1-12 22:48
标题: K-Type Thermocouple PID Controller
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
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 |
R1 | Resistor 220 Ohm 1/4 Watt 5% Carbon Film | |
R2 | Resistor 220 Ohm 1/4 Watt 5% Carbon Film | |
R3 | Resistor 22 Ohm 1/4 Watt 5% Carbon Film |
|
R4 | Resistor 220 Ohm 1/4 Watt 5% Carbon Film | |
R5 | Resistor 22 Ohm 1/4 Watt 5% Carbon Film |
|
R6 | Resistor 220 Ohm 1/4 Watt 5% Carbon Film | |
R7 | Potentiometer 5 KOhm Linear Rotary 1/2W |
|
R8 | Resistor 22 Ohm 1/4 Watt 5% Carbon Film |
|
R9 | Resistor 22 Ohm 1/4 Watt 5% Carbon Film |
|
R10 | Resistor 22 Ohm 1/4 Watt 5% Carbon Film |
|
R11 | Resistor 22 Ohm 1/4 Watt 5% Carbon Film |
|
R12 | Resistor 22 Ohm 1/4 Watt 5% Carbon Film |
|
R13 | Potentiometer 5 KOhm Linear Rotary 1/2W |
|
R14 | Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film | |
R15 | Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film | |
R16 | Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film | |
R17 | Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film | |
R18 | Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film | |
R19 | Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film | |
R20 | Resistor 10 KOhm 1/4 Watt 5% Carbon Film | |
R21 | Resistor 1 KOhm 1/4 Watt 5% Carbon Film | |
R22 | Resistor 3.3 KOhm 1/4 Watt 5% Carbon Film |
|
R23 | Resistor 1.8 KOhm 1/4 Watt 5% Carbon Film |
|
R24 | Resistor 870 Ohm 1/4 Watt 5% Carbon Film |
|
R25 | Resistor 1.8 KOhm 1/4 Watt 5% Carbon Film |
|
|
Capacitors |
C1 | Electrolytic Capacitor 1000 uF 16 Volts |
|
C2 | Electrolytic Capacitor 1 uF 50 Volts |
|
C3 | Electrolytic Capacitor 1000 uF 16 Volts |
|
C4 | Electrolytic Capacitor 1 uF 50 Volts |
|
C5 | Ceramic Capacitor 0.1 uF 50 Volts |
|
C6 | Ceramic Capacitor 0.1 uF 50 Volts |
|
|
Transistors-Diodes |
T1 | BT136D Sensitive gate TRIAC | |
T2 | BC517 NPN Darlington Transistor | |
D7 | 1N4148 Switching Diode | |
|
Integrated Circuits |
IC1 | PIC 16F1937 Microcontroller | |
IC2 | 7805 Positive Voltage Regulator | |
IC3 | MAX 6675 Cold-junction compensated K-Thermocouple to digital converter (0°C to +1024°C) | |
IC4 | CD4511BC BCD to 7-Segment Latch/Decoder/Driver | |
IC5 | ULN2003A High Voltage - High Current Darlington Arrays | |
IC6 | MOC3021 Random Phase Optoisolator TRIAC Driver Output | |
IC7 | DF02M 1.5 Ampere Bridge Rectifiers | |
|
Misc |
L1 | 100uH Inductor |
作者: liyf 时间: 2012-1-12 22:49
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):
作者: liyf 时间: 2012-1-12 22:50
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
作者: liyf 时间: 2012-1-12 22:50
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...
作者: liyf 时间: 2012-1-12 22:51
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 term GAIN_I_Constant: The gain multiplier for the Integral term GAIN_D_Constant: The gain multiplier for the Derivative term TIME_I_Constant: The time interval for the Integral accumulation TIME_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
佩服你,能发这么好的帖子,厉害
作者: ffey8810 时间: 2012-6-15 16:30
标题: 38
过来一起顶!
作者: robter 时间: 2015-10-26 21:38
这个很好,学习了,多谢楼主
作者: gl542400 时间: 2017-2-11 14:34
这个很好,学习了,多谢楼主
欢迎光临 DIY编程器网 (http://diybcq.com./) |
Powered by Discuz! X3.2 |