Difference between revisions of "Temperature control"
(Created page with "= intro = I wanted to demonstrate that temperature control using three of our boards would be easy. I will replicate this experiemnt at home to make a "sous vide" setup short...") |
|||
(8 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
= Putting the hardware together = |
= Putting the hardware together = |
||
I took my ftdi_atmega |
I took my ftdi_atmega |
||
[[File:tempcontroller_01_ftdi_atmega.jpg|200px|thumb|none|FTDI ATMEGA PCB]] |
|||
and used a standard 6 pin SPI cable to connect it to my spi_temp board. |
|||
[[File:tempcontroller_02_spi_temp.jpg|200px|thumb|none|spi_temp board]] |
|||
The spi cable was then daisychained to the next board: spi_relay |
|||
[[File:tempcontroller_03_spi_relay.jpg|200px|thumb|none|spi_relay board]] |
|||
The Relay was hooked up to an extension cord. This way the relay would control the power to the extension cord. |
|||
[[File:tempcontroller_04_relay_and_extensioncord.jpg|200px|thumb|none|spi_relay and the extension cord]] |
|||
Next I hooked up the coffee pot to the extension cord. |
|||
[[File:tempcontroller_05_coffee_pot.jpg|200px|thumb|none|coffee machine]] |
|||
and I extended the LM35 sensor (and waterproofed it). I put the sensor in the water in the coffee pot. |
|||
= Writing the software = |
|||
I took the spi_atmega demo application, and modified it to add temperature control. This was really easy: |
|||
<code> |
|||
if (wanted_temp && tchanged) { |
|||
long t0; |
|||
unsigned char heater; |
|||
static unsigned char curheater = -1; |
|||
t0 = SPI_getu16 (SPI_TEMP, 0x28); |
|||
//pputs ("t0 = ");hexshort (t0); |
|||
t0 = (t0 * 1000/11) >> 16; |
|||
// pputs (" t0 = ");hexshort (t0); |
|||
heater = (t0 < wanted_temp); |
|||
pputs (" t0 = ");hexshort (t0); |
|||
pputs (" wt = ");hexbyte (wanted_temp); |
|||
pputs (" heat = ");hexbyte (heater); |
|||
pputs (".\n\r"); |
|||
if (curheater != heater) { |
|||
spi_setreg_u8 (SPI_RELAY, 0x20, heater); |
|||
curheater = heater; |
|||
pputs ("Turned heater "); |
|||
if (heater) pputs ("on"); |
|||
else pputs ("off"); |
|||
pputs ("\r\n"); |
|||
} |
|||
} |
|||
</code> |
|||
This gets executed every second (because of the tchanged), It gets the temperature reading, converts it to centigrade and then compares it with the wanted temperature. In the mean time it logs some variables for debugging. |
|||
This is very simple on-off control. This, it turns out is not ideal with the slow response of the coffee machine. The temperature overshoots the intended temperature by quite a lot. This can be fixed by using a proper PID control algorithm. With a different heater setup this would not be necessary. |
Latest revision as of 12:07, 11 November 2015
intro
I wanted to demonstrate that temperature control using three of our boards would be easy. I will replicate this experiemnt at home to make a "sous vide" setup shortly.
Putting the hardware together
I took my ftdi_atmega
and used a standard 6 pin SPI cable to connect it to my spi_temp board.
The spi cable was then daisychained to the next board: spi_relay
The Relay was hooked up to an extension cord. This way the relay would control the power to the extension cord.
Next I hooked up the coffee pot to the extension cord.
and I extended the LM35 sensor (and waterproofed it). I put the sensor in the water in the coffee pot.
Writing the software
I took the spi_atmega demo application, and modified it to add temperature control. This was really easy:
if (wanted_temp && tchanged) {
long t0;
unsigned char heater;
static unsigned char curheater = -1;
t0 = SPI_getu16 (SPI_TEMP, 0x28);
//pputs ("t0 = ");hexshort (t0);
t0 = (t0 * 1000/11) >> 16;
// pputs (" t0 = ");hexshort (t0);
heater = (t0 < wanted_temp);
pputs (" t0 = ");hexshort (t0);
pputs (" wt = ");hexbyte (wanted_temp);
pputs (" heat = ");hexbyte (heater);
pputs (".\n\r");
if (curheater != heater) {
spi_setreg_u8 (SPI_RELAY, 0x20, heater);
curheater = heater;
pputs ("Turned heater ");
if (heater) pputs ("on");
else pputs ("off");
pputs ("\r\n");
}
}
This gets executed every second (because of the tchanged), It gets the temperature reading, converts it to centigrade and then compares it with the wanted temperature. In the mean time it logs some variables for debugging.
This is very simple on-off control. This, it turns out is not ideal with the slow response of the coffee machine. The temperature overshoots the intended temperature by quite a lot. This can be fixed by using a proper PID control algorithm. With a different heater setup this would not be necessary.