<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PART 2: PWM-Generation, function of the counter??? in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/PART-2-PWM-Generation-function-of-the-counter/m-p/124572#M145</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;SPAN style="color: #ff0000;"&gt;This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fforums.freescale.com%2Ffreescale%2Fboard%2Fmessage%3Fboard.id%3D16BITCOMM%26message.id%3D54" rel="nofollow noopener noreferrer" target="_blank"&gt;READ PART 1&lt;/A&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Wed Jun 29, 2005 9:12 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt; I have some questions (and possibly some hints also) for you:&lt;BR /&gt;&lt;BR /&gt; You are trying to build a temperature controller, right? What is the object which you'd like to control? Just the DS-chip itself or is the chip connected to something else like a heatsink of a processor? Do you have any requirements with respect to how accurate or how fast the temperature should be controlled?&lt;BR /&gt;&lt;BR /&gt; Shall the fan be automatically controlled according to the temperature (closed-loop) or do you just want to set a fan speed manually and see how the temperature changes?&lt;BR /&gt;&lt;BR /&gt; If automatic control is desired: the easiest is to work like a thermostat. Example: the temperature should be regulated to 20 degrees centigrade.&lt;BR /&gt; If temp&amp;gt;21 the fan turns ON with full power&lt;BR /&gt; If temp&amp;lt;19 the fan turns OFF&lt;BR /&gt; The DS1721 has this functionality integrated and a dedicated output (Tout) for it, you just have to wire it directly to your MOSFET.&lt;BR /&gt;&lt;BR /&gt; Second option would be something like a PID controller (continous control) where the fan speed would be automatically adjusted by the algorithm to a value where it keeps the temperature stable. This algorithm is a bit more complex (math), here are some (quickly googled) links which could help you if you are interested:&lt;BR /&gt; &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fbestune.50megs.com%2Fpiddesign.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://bestune.50megs.com/piddesign.htm&lt;/A&gt;&lt;BR /&gt; &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FPID_controller" rel="nofollow noopener noreferrer" target="_blank"&gt;http://en.wikipedia.org/wiki/PID_controller&lt;/A&gt;&lt;BR /&gt; &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.tcnj.edu%2F%7Ergraham%2FPID-tuning.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.tcnj.edu/~rgraham/PID-tuning.html&lt;/A&gt;&lt;BR /&gt; &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lakeshore.com%2Fpdf_files%2FAppendices%2FLSTC_appendixF_l.pdf" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.lakeshore.com/pdf_files/Appendices/LSTC_appendixF_l.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt; Best of luck,&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Thu Jun 30, 2005 6:41 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;First, thank you very much! I´m very grateful about your assistance and your effort.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border:0px solid black;"&gt;&lt;SPAN class="genmed"&gt;&lt;STRONG&gt;Quote:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="quote" style="border:0px solid black;"&gt;You are trying to build a temperature controller, right? What is the object which you'd like to control? Just the DS-chip itself or is the chip connected to something else like a heatsink of a processor?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN class="postbody"&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;BR /&gt;Yes, right! Addicted to the temperature, I have to control a little pump and a fan. But first, I have to program the DS1631. But I couldn´t start to program and test the chip, because there are problems with the consigment. &lt;A href="http://www.freegeeks.net/modules/Forums/images/smiles/icon_sad.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt="Sad" border="0" src="http://www.freegeeks.net/modules/Forums/images/smiles/icon_sad.gif" /&gt;&lt;/A&gt;&lt;BR /&gt;Thus, I can only work in theory at first and try to find the potential problems.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border:0px solid black;"&gt;&lt;SPAN class="genmed"&gt;&lt;STRONG&gt;Quote:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="quote" style="border:0px solid black;"&gt;Do you have any requirements with respect to how accurate or how fast the temperature should be controlled?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN class="postbody"&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;BR /&gt;No, I think the process is not all too time-critical and the accuracy of +/- 1 C listed in the datasheet is passable.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border:0px solid black;"&gt;&lt;SPAN class="genmed"&gt;&lt;STRONG&gt;Quote:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="quote" style="border:0px solid black;"&gt;Shall the fan be automatically controlled according to the temperature (closed-loop) or do you just want to set a fan speed manually and see how the temperature changes?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN class="postbody"&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;Temperature is converted into decimal description&lt;BR /&gt;By room-temperature it is i.e. configured like this: pwmper=100 and pwmdty=20. When the temperature increases up to 30 degree the pwmdty is i.e. =40. Thus, addicted to the temperature, I control the velocity of the active components by controlling the adjusting of the DutyCycle&lt;BR /&gt;That is my consideration about the controlling. Perhaps it is very circuitous, but I don´t have another ideas.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border:0px solid black;"&gt;&lt;SPAN class="genmed"&gt;&lt;STRONG&gt;Quote:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="quote" style="border:0px solid black;"&gt;the easiest is to work like a thermostat.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN class="postbody"&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;BR /&gt;Yes, the thermostat function is a good possibilty. But I thought, that I can´t use the thermostat in conjunction with the mosfet and PWM. Thus, either ON or OFF, but not control the velocity over PWM!!!&lt;BR /&gt;Hmm, the second option sounds interesting. I will view the links and then ... schaun mer ma!!! &lt;A href="http://www.freegeeks.net/modules/Forums/images/smiles/icon_smile.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt="Smile" border="0" src="http://www.freegeeks.net/modules/Forums/images/smiles/icon_smile.gif" /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Wed Jul 06, 2005 12:36 pm&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;Regarding the thermostat function: I think you should be able to wire the MOSFET directly to the DS-chip, and yes, it will only turn the fan ON or OFF (no continous control). It is however simple and efficient (which is why thermostats are used in the real world). Unfortunately, once the switching-temperatures are set inside the DS, you don't need your microcontroller anymore, which would then take the fun out of the project, right? &lt;A href="http://www.freegeeks.net/modules/Forums/images/smiles/icon_wink.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt="Wink" border="0" src="http://www.freegeeks.net/modules/Forums/images/smiles/icon_wink.gif" /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt; The reason for using a thermostat or P/PID controller instead of your basic idea is:&lt;BR /&gt; * they compensate well for disturbances (change of ambient temperature, change of fan, change of water in a tank etc.)&lt;BR /&gt; * they allow you to change your setpoint (desired temperature) without recalculating/retesting every value&lt;BR /&gt;&lt;BR /&gt; You do however need to find the correct gain-values, which would need some experimenting (see Ziegler-Nichols method &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.jashaw.com%2Fznclosed.htm%29" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.jashaw.com/znclosed.htm)&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt; Very basic control loop of a PI-controller would look like this (off the top of my head, no guarantees)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;while(1){&amp;nbsp;&amp;nbsp; actual = ReadAnalogInput();&amp;nbsp;&amp;nbsp; error = desired-actual;&amp;nbsp;&amp;nbsp; errorIntegral = errorIntegral + error;&amp;nbsp;&amp;nbsp; PWMchange = error*K_prop + errorIntegral*K_int;&amp;nbsp;&amp;nbsp; PWMduty = PWMduty + PWMchange; } &lt;/PRE&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Jul 08, 2005 5:05 pm&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Sorry, have been working too much with differential equations lately, an extra integrator snuck into the code. Corrected version:&lt;BR /&gt;&lt;BR /&gt; &lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;while(1){&amp;nbsp;&amp;nbsp; actual = ReadAnalogInput();&amp;nbsp;&amp;nbsp; error = desired-actual;&amp;nbsp;&amp;nbsp; errorIntegral = errorIntegral + error;&amp;nbsp;&amp;nbsp; PWMduty = error*K_prop + errorIntegral*K_int; } &lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Jan 2006 05:37:12 GMT</pubDate>
    <dc:creator>RChapman</dc:creator>
    <dc:date>2006-01-27T05:37:12Z</dc:date>
    <item>
      <title>PART 2: PWM-Generation, function of the counter???</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/PART-2-PWM-Generation-function-of-the-counter/m-p/124572#M145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;SPAN style="color: #ff0000;"&gt;This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fforums.freescale.com%2Ffreescale%2Fboard%2Fmessage%3Fboard.id%3D16BITCOMM%26message.id%3D54" rel="nofollow noopener noreferrer" target="_blank"&gt;READ PART 1&lt;/A&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Wed Jun 29, 2005 9:12 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt; I have some questions (and possibly some hints also) for you:&lt;BR /&gt;&lt;BR /&gt; You are trying to build a temperature controller, right? What is the object which you'd like to control? Just the DS-chip itself or is the chip connected to something else like a heatsink of a processor? Do you have any requirements with respect to how accurate or how fast the temperature should be controlled?&lt;BR /&gt;&lt;BR /&gt; Shall the fan be automatically controlled according to the temperature (closed-loop) or do you just want to set a fan speed manually and see how the temperature changes?&lt;BR /&gt;&lt;BR /&gt; If automatic control is desired: the easiest is to work like a thermostat. Example: the temperature should be regulated to 20 degrees centigrade.&lt;BR /&gt; If temp&amp;gt;21 the fan turns ON with full power&lt;BR /&gt; If temp&amp;lt;19 the fan turns OFF&lt;BR /&gt; The DS1721 has this functionality integrated and a dedicated output (Tout) for it, you just have to wire it directly to your MOSFET.&lt;BR /&gt;&lt;BR /&gt; Second option would be something like a PID controller (continous control) where the fan speed would be automatically adjusted by the algorithm to a value where it keeps the temperature stable. This algorithm is a bit more complex (math), here are some (quickly googled) links which could help you if you are interested:&lt;BR /&gt; &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fbestune.50megs.com%2Fpiddesign.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://bestune.50megs.com/piddesign.htm&lt;/A&gt;&lt;BR /&gt; &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FPID_controller" rel="nofollow noopener noreferrer" target="_blank"&gt;http://en.wikipedia.org/wiki/PID_controller&lt;/A&gt;&lt;BR /&gt; &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.tcnj.edu%2F%7Ergraham%2FPID-tuning.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.tcnj.edu/~rgraham/PID-tuning.html&lt;/A&gt;&lt;BR /&gt; &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lakeshore.com%2Fpdf_files%2FAppendices%2FLSTC_appendixF_l.pdf" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.lakeshore.com/pdf_files/Appendices/LSTC_appendixF_l.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt; Best of luck,&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Thu Jun 30, 2005 6:41 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;First, thank you very much! I´m very grateful about your assistance and your effort.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border:0px solid black;"&gt;&lt;SPAN class="genmed"&gt;&lt;STRONG&gt;Quote:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="quote" style="border:0px solid black;"&gt;You are trying to build a temperature controller, right? What is the object which you'd like to control? Just the DS-chip itself or is the chip connected to something else like a heatsink of a processor?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN class="postbody"&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;BR /&gt;Yes, right! Addicted to the temperature, I have to control a little pump and a fan. But first, I have to program the DS1631. But I couldn´t start to program and test the chip, because there are problems with the consigment. &lt;A href="http://www.freegeeks.net/modules/Forums/images/smiles/icon_sad.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt="Sad" border="0" src="http://www.freegeeks.net/modules/Forums/images/smiles/icon_sad.gif" /&gt;&lt;/A&gt;&lt;BR /&gt;Thus, I can only work in theory at first and try to find the potential problems.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border:0px solid black;"&gt;&lt;SPAN class="genmed"&gt;&lt;STRONG&gt;Quote:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="quote" style="border:0px solid black;"&gt;Do you have any requirements with respect to how accurate or how fast the temperature should be controlled?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN class="postbody"&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;BR /&gt;No, I think the process is not all too time-critical and the accuracy of +/- 1 C listed in the datasheet is passable.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border:0px solid black;"&gt;&lt;SPAN class="genmed"&gt;&lt;STRONG&gt;Quote:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="quote" style="border:0px solid black;"&gt;Shall the fan be automatically controlled according to the temperature (closed-loop) or do you just want to set a fan speed manually and see how the temperature changes?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN class="postbody"&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;Temperature is converted into decimal description&lt;BR /&gt;By room-temperature it is i.e. configured like this: pwmper=100 and pwmdty=20. When the temperature increases up to 30 degree the pwmdty is i.e. =40. Thus, addicted to the temperature, I control the velocity of the active components by controlling the adjusting of the DutyCycle&lt;BR /&gt;That is my consideration about the controlling. Perhaps it is very circuitous, but I don´t have another ideas.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border:0px solid black;"&gt;&lt;SPAN class="genmed"&gt;&lt;STRONG&gt;Quote:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="quote" style="border:0px solid black;"&gt;the easiest is to work like a thermostat.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN class="postbody"&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;BR /&gt;Yes, the thermostat function is a good possibilty. But I thought, that I can´t use the thermostat in conjunction with the mosfet and PWM. Thus, either ON or OFF, but not control the velocity over PWM!!!&lt;BR /&gt;Hmm, the second option sounds interesting. I will view the links and then ... schaun mer ma!!! &lt;A href="http://www.freegeeks.net/modules/Forums/images/smiles/icon_smile.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt="Smile" border="0" src="http://www.freegeeks.net/modules/Forums/images/smiles/icon_smile.gif" /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Wed Jul 06, 2005 12:36 pm&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;Regarding the thermostat function: I think you should be able to wire the MOSFET directly to the DS-chip, and yes, it will only turn the fan ON or OFF (no continous control). It is however simple and efficient (which is why thermostats are used in the real world). Unfortunately, once the switching-temperatures are set inside the DS, you don't need your microcontroller anymore, which would then take the fun out of the project, right? &lt;A href="http://www.freegeeks.net/modules/Forums/images/smiles/icon_wink.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt="Wink" border="0" src="http://www.freegeeks.net/modules/Forums/images/smiles/icon_wink.gif" /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt; The reason for using a thermostat or P/PID controller instead of your basic idea is:&lt;BR /&gt; * they compensate well for disturbances (change of ambient temperature, change of fan, change of water in a tank etc.)&lt;BR /&gt; * they allow you to change your setpoint (desired temperature) without recalculating/retesting every value&lt;BR /&gt;&lt;BR /&gt; You do however need to find the correct gain-values, which would need some experimenting (see Ziegler-Nichols method &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.jashaw.com%2Fznclosed.htm%29" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.jashaw.com/znclosed.htm)&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt; Very basic control loop of a PI-controller would look like this (off the top of my head, no guarantees)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;while(1){&amp;nbsp;&amp;nbsp; actual = ReadAnalogInput();&amp;nbsp;&amp;nbsp; error = desired-actual;&amp;nbsp;&amp;nbsp; errorIntegral = errorIntegral + error;&amp;nbsp;&amp;nbsp; PWMchange = error*K_prop + errorIntegral*K_int;&amp;nbsp;&amp;nbsp; PWMduty = PWMduty + PWMchange; } &lt;/PRE&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Jul 08, 2005 5:05 pm&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Sorry, have been working too much with differential equations lately, an extra integrator snuck into the code. Corrected version:&lt;BR /&gt;&lt;BR /&gt; &lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;while(1){&amp;nbsp;&amp;nbsp; actual = ReadAnalogInput();&amp;nbsp;&amp;nbsp; error = desired-actual;&amp;nbsp;&amp;nbsp; errorIntegral = errorIntegral + error;&amp;nbsp;&amp;nbsp; PWMduty = error*K_prop + errorIntegral*K_int; } &lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jan 2006 05:37:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/PART-2-PWM-Generation-function-of-the-counter/m-p/124572#M145</guid>
      <dc:creator>RChapman</dc:creator>
      <dc:date>2006-01-27T05:37:12Z</dc:date>
    </item>
  </channel>
</rss>

