Difference between revisions of "Team:UMaryland/Design"

Line 268: Line 268:
 
<p style="text-align:center;font-size:32;font-family: Tahoma, Geneva, sans-serif;"><b>CODE</b></p>
 
<p style="text-align:center;font-size:32;font-family: Tahoma, Geneva, sans-serif;"><b>CODE</b></p>
  
<div id="showwithbox_id" onclick="document.getElementById('spoilerwithbox_id').style.display=''; document.getElementById('showwithbox_id').style.display='none';" style="margin:auto;padding:5px;border:dotted 1px; width:1000px; height:100px;background-color:#F2F5A9;">Click to see code<!--Ironic that I had to code this in order to display this other code!--></div><div id="spoilerwithbox_id" onclick="document.getElementById('spoilerwithbox_id').style.display='none'; document.getElementById('showwithbox_id').style.display='';" style="margin:auto;padding:5px;display:none;border:dotted 1px; width:1000px;background-color:#F2F5A9;">
+
<div id="showwithbox_id" onclick="document.getElementById('spoilerwithbox_id').style.display=''; document.getElementById('showwithbox_id').style.display='none';" style="margin:auto;padding:5px;border:dotted 1px; width:1000px; height:100px;background-color:#e33930;">Click to see code<!--Ironic that I had to code this in order to display this other code!--></div><div id="spoilerwithbox_id" onclick="document.getElementById('spoilerwithbox_id').style.display='none'; document.getElementById('showwithbox_id').style.display='';" style="margin:auto;padding:5px;display:none;border:dotted 1px; width:1000px;background-color:#F2F5A9;">
  
 +
<pre>
 
<pre>
 
<pre>
 
<font color="#000000">#include</font> <font color="#434f54">&lt;</font><font color="#000000">PID_v1</font><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font>
 
<font color="#000000">#include</font> <font color="#434f54">&lt;</font><font color="#000000">PID_v1</font><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font>
Line 275: Line 276:
 
<font color="#000000">#include</font> <font color="#434f54">&lt;</font><b><font color="#d35400">LiquidCrystal</font></b><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font>
 
<font color="#000000">#include</font> <font color="#434f54">&lt;</font><b><font color="#d35400">LiquidCrystal</font></b><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font>
 
   
 
   
<font color="#7e7e7e">/*The PID functions by adjusting a certain output in order to &nbsp;</font><font color="#7e7e7e"> * minimize the error between two values, which are the setpoint </font><font color="#7e7e7e"> * and the input.</font><font color="#7e7e7e"> * The PID function itself creates a PID controller and takes </font><font color="#7e7e7e"> * five parameters:</font><font color="#7e7e7e"> * Input: The value that needs to be controlled</font><font color="#7e7e7e"> * Output: The value that the PID will adjust</font><font color="#7e7e7e"> * Setpoint: The value that the input will be maintained at</font><font color="#7e7e7e"> * Kp,Ki,KD: Parameters that will affect how the output is adjusted</font><font color="#7e7e7e"> * Direct: Defines which direction the output will proceed given an error</font><font color="#7e7e7e"> */</font>
+
<font color="#434f54">//The PID functions by adjusting a certain output in order to &nbsp;</font>
 +
<font color="#434f54">// minimize the error between two values, which are the setpoint </font>
 +
<font color="#434f54">// and the input.</font>
 +
<font color="#434f54">// The PID function itself creates a PID controller and takes </font>
 +
<font color="#434f54">// five parameters:</font>
 +
<font color="#434f54">// Input: The value that needs to be controlled</font>
 +
<font color="#434f54">// Output: The value that the PID will adjust</font>
 +
<font color="#434f54">// Setpoint: The value that the input will be maintained at</font>
 +
<font color="#434f54">// Kp,Ki,KD: Parameters that will affect how the output is adjusted</font>
 +
<font color="#434f54">// Direct: Defines which direction the output will proceed given an error</font>
 +
 
   
 
   
 
<font color="#434f54">// Define PID varaibles</font>
 
<font color="#434f54">// Define PID varaibles</font>
Line 365: Line 376:
 
<font color="#000000">{</font>
 
<font color="#000000">{</font>
 
  &nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">&lt;</font> <font color="#000000">cyclenum</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">&lt;</font> <font color="#000000">cyclenum</font><font color="#000000">)</font> <font color="#000000">{</font>
  &nbsp;&nbsp;&nbsp;<font color="#7e7e7e">/**The following code is only implemented once as the first cycle of the PCR</font><font color="#7e7e7e"> &nbsp;&nbsp;&nbsp;&nbsp;* This allows for the user to set conditions which may be different from the subsequent </font><font color="#7e7e7e"> &nbsp;&nbsp;&nbsp;&nbsp;* cycles. The code, however, works in much the same way as the other cycles</font><font color="#7e7e7e"> &nbsp;&nbsp;&nbsp;&nbsp;* at the most basic level. It divides each cycle into subcycles: activation, pcr and extension</font><font color="#7e7e7e"> &nbsp;&nbsp;&nbsp;&nbsp;* and enters each step based on stepnow(which denotes how many subcyles the program has entered) divisiblity by 3. </font><font color="#7e7e7e"> &nbsp;&nbsp;&nbsp;&nbsp;* The remainder for activation will always be 1, </font><font color="#7e7e7e"> &nbsp;&nbsp;&nbsp;&nbsp;* the remainder for pcr will be 2 and the remainder for extension will be 3</font><font color="#7e7e7e"> &nbsp;&nbsp;&nbsp;&nbsp;*/</font>
+
  &nbsp;&nbsp;&nbsp;<font color="#434f54">//The following code is only implemented once as the first cycle of the PCR</font>
 +
&nbsp;&nbsp;&nbsp;<font color="#434f54">// This allows for the user to set conditions which may be different from the subsequent </font>
 +
&nbsp;&nbsp;&nbsp;<font color="#434f54">// cycles. The code, however, works in much the same way as the other cycles</font>
 +
&nbsp;&nbsp;&nbsp;<font color="#434f54">// at the most basic level. It divides each cycle into subcycles: activation, pcr and extension</font>
 +
&nbsp;&nbsp;&nbsp;<font color="#434f54">// and enters each step based on stepnow(which denotes how many subcyles the program has entered) divisiblity by 3. </font>
 +
&nbsp;&nbsp;&nbsp;<font color="#434f54">// The remainder for activation will always be 1, </font>
 +
&nbsp;&nbsp;&nbsp;<font color="#434f54">// the remainder for pcr will be 2 and the remainder for extension will be 3</font>
 +
&nbsp;&nbsp;&nbsp;&nbsp;
 
  &nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//Begins activation of the PCR by checking that this is the first cycle and that the current subcycle is activation </font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//Begins activation of the PCR by checking that this is the first cycle and that the current subcycle is activation </font>
 
  &nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">%</font> <font color="#000000">3</font><font color="#000000">)</font> <font color="#434f54">==</font> <font color="#000000">1</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">cycle</font> <font color="#434f54">==</font> <font color="#000000">2</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">%</font> <font color="#000000">3</font><font color="#000000">)</font> <font color="#434f54">==</font> <font color="#000000">1</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">cycle</font> <font color="#434f54">==</font> <font color="#000000">2</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
Line 379: Line 397:
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">laststep</font><font color="#434f54">++</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">laststep</font><font color="#434f54">++</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//If the pcr has maintained the setpoint for the desired amount of time, it will enter this loop and begin cooling</font>
+
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//If the pcr has maintained the setpoint for the desired amount </font>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//of time, it will enter this loop and begin cooling</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#d35400">millis</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#434f54">&gt;</font> <font color="#000000">(</font><font color="#000000">t1Melt</font> <font color="#434f54">+</font> <font color="#000000">cycleStart</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">laststep</font> <font color="#434f54">==</font> <font color="#000000">stepnow</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#d35400">millis</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#434f54">&gt;</font> <font color="#000000">(</font><font color="#000000">t1Melt</font> <font color="#434f54">+</font> <font color="#000000">cycleStart</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">laststep</font> <font color="#434f54">==</font> <font color="#000000">stepnow</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">stepnow</font><font color="#434f54">++</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">stepnow</font><font color="#434f54">++</font><font color="#000000">;</font>
Line 398: Line 417:
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">laststep</font><font color="#434f54">++</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">laststep</font><font color="#434f54">++</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//checks if the machine has maintained the temperature for the desired amount of time, and begins the next step</font>
+
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//checks if the machine has maintained the temperature for </font>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//the desired amount of time, and begins the next step</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#d35400">millis</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#434f54">&gt;</font> <font color="#000000">(</font><font color="#000000">t1PCR</font> <font color="#434f54">+</font> <font color="#000000">cycleStart</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">laststep</font> <font color="#434f54">==</font> <font color="#000000">stepnow</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">cycle</font> <font color="#434f54">==</font> <font color="#000000">2</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#d35400">millis</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#434f54">&gt;</font> <font color="#000000">(</font><font color="#000000">t1PCR</font> <font color="#434f54">+</font> <font color="#000000">cycleStart</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">laststep</font> <font color="#434f54">==</font> <font color="#000000">stepnow</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">cycle</font> <font color="#434f54">==</font> <font color="#000000">2</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">stepnow</font><font color="#434f54">++</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">stepnow</font><font color="#434f54">++</font><font color="#000000">;</font>
Line 416: Line 436:
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">laststep</font><font color="#434f54">++</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">laststep</font><font color="#434f54">++</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//checks if the machine has maintained the temperature for the desired amount of time, and begins the next step</font>
+
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">//checks if the machine has maintained the temperature </font>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">// for the desired amount of time, and begins the next step</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#d35400">millis</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#434f54">&gt;</font> <font color="#000000">(</font><font color="#000000">textension1</font> <font color="#434f54">+</font> <font color="#000000">cycleStart</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">laststep</font> <font color="#434f54">==</font> <font color="#000000">stepnow</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#d35400">millis</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#434f54">&gt;</font> <font color="#000000">(</font><font color="#000000">textension1</font> <font color="#434f54">+</font> <font color="#000000">cycleStart</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">laststep</font> <font color="#434f54">==</font> <font color="#000000">stepnow</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">pcr</font> <font color="#434f54">=</font> <font color="#00979c">"heating to melt "</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">pcr</font> <font color="#434f54">=</font> <font color="#00979c">"heating to melt "</font><font color="#000000">;</font>
Line 425: Line 446:
 
  &nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
  
<font color="#7e7e7e">/**</font><font color="#7e7e7e"> * Begins the intermediate steps which work in an identical manner to the startup cycle </font><font color="#7e7e7e"> * and may differ only in the alloted temperatures and times for each subcycle</font><font color="#7e7e7e"> */</font>
+
 
 +
<font color="#434f54">//Begins the intermediate steps which work in an identical manner to the startup cycle </font>
 +
<font color="#434f54">//and may differ only in the alloted temperatures and times for each subcycle</font>
 +
 
 
  &nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">%</font> <font color="#000000">3</font><font color="#000000">)</font> <font color="#434f54">==</font> <font color="#000000">1</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">cycle</font> <font color="#434f54">!</font><font color="#434f54">=</font> <font color="#000000">2</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">%</font> <font color="#000000">3</font><font color="#000000">)</font> <font color="#434f54">==</font> <font color="#000000">1</font><font color="#000000">)</font> <font color="#434f54">&&</font> <font color="#000000">(</font><font color="#000000">cycle</font> <font color="#434f54">!</font><font color="#434f54">=</font> <font color="#000000">2</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">Setpoint</font> <font color="#434f54">=</font> <font color="#000000">meltT</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">Setpoint</font> <font color="#434f54">=</font> <font color="#000000">meltT</font><font color="#000000">;</font>
Line 470: Line 494:
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
  &nbsp;<font color="#7e7e7e">/*</font><font color="#7e7e7e"> &nbsp;&nbsp;* Begins the last step, which again works in a similar fashion to the other steps, but may differ in the </font><font color="#7e7e7e"> &nbsp;&nbsp;* final extension temperature</font><font color="#7e7e7e"> &nbsp;&nbsp;*/</font>
+
&nbsp;
 +
  &nbsp;<font color="#434f54">// Begins the last step, which again works in a similar fashion </font>
 +
&nbsp;<font color="#434f54">// to the other steps, but may differ in the final extension temperature</font>
 +
&nbsp;&nbsp;
 
  &nbsp;<font color="#000000">}</font> <font color="#5e6d03">else</font> <font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">&gt;</font><font color="#434f54">=</font> <font color="#000000">cyclenum</font> <font color="#434f54">&&</font> <font color="#000000">stepnow</font> <font color="#434f54">&lt;</font><font color="#434f54">=</font> <font color="#000000">cyclenum</font> <font color="#434f54">+</font> <font color="#000000">2</font> <font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;<font color="#000000">}</font> <font color="#5e6d03">else</font> <font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">&gt;</font><font color="#434f54">=</font> <font color="#000000">cyclenum</font> <font color="#434f54">&&</font> <font color="#000000">stepnow</font> <font color="#434f54">&lt;</font><font color="#434f54">=</font> <font color="#000000">cyclenum</font> <font color="#434f54">+</font> <font color="#000000">2</font> <font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">%</font> <font color="#000000">3</font><font color="#000000">)</font> <font color="#434f54">==</font> <font color="#000000">1</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">(</font><font color="#000000">stepnow</font> <font color="#434f54">%</font> <font color="#000000">3</font><font color="#000000">)</font> <font color="#434f54">==</font> <font color="#000000">1</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font>
Line 517: Line 544:
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
  &nbsp;<font color="#7e7e7e">/**</font><font color="#7e7e7e"> &nbsp;&nbsp;* Once the last step has been completed, determined by stepnow being greater than cyclenum+2,</font><font color="#7e7e7e"> &nbsp;&nbsp;* the code will tell the pcr to hold at 4 C. It will continue looping at this step indefinitely</font><font color="#7e7e7e"> &nbsp;&nbsp;* because the conditions will no longer satisfy any of the other if statement</font><font color="#7e7e7e"> &nbsp;&nbsp;*/</font>
+
  &nbsp;
 +
&nbsp;&nbsp;<font color="#434f54">// Once the last step has been completed, determined by </font>
 +
&nbsp;&nbsp;<font color="#434f54">// stepnow being greater than cyclenum+2,the code will tell the </font>
 +
&nbsp;&nbsp;<font color="#434f54">// pcr to hold at 4 C. It will continue looping at this step indefinitely</font>
 +
&nbsp;&nbsp;<font color="#434f54">// because the conditions will no longer satisfy any of the other if statement</font>
 +
&nbsp;&nbsp;
 
  &nbsp;<font color="#000000">}</font> <font color="#5e6d03">else</font> <font color="#000000">{</font>
 
  &nbsp;<font color="#000000">}</font> <font color="#5e6d03">else</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#00979c">int</font> <font color="#000000">strt</font> <font color="#434f54">=</font> <font color="#000000">1</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#00979c">int</font> <font color="#000000">strt</font> <font color="#434f54">=</font> <font color="#000000">1</font><font color="#000000">;</font>
Line 532: Line 564:
  
 
  &nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#000000">}</font>
  &nbsp;&nbsp;&nbsp;<font color="#434f54">//Once the pcr has reached 37 C, the pcr will print out that the pcr has shutt off</font>
+
  &nbsp;&nbsp;&nbsp;<font color="#434f54">//Once the pcr has reached 37 C, the pcr will </font>
 +
&nbsp;&nbsp;&nbsp;<font color="#434f54">//print out that the pcr has shutt off</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">Input</font> <font color="#434f54">-</font> <font color="#000000">38</font> <font color="#434f54">+</font> <font color="#000000">1</font><font color="#000000">)</font> <font color="#434f54">&lt;</font> <font color="#000000">0</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">Input</font> <font color="#434f54">-</font> <font color="#000000">38</font> <font color="#434f54">+</font> <font color="#000000">1</font><font color="#000000">)</font> <font color="#434f54">&lt;</font> <font color="#000000">0</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">signalr1</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;&nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">signalr1</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font>
Line 555: Line 588:
 
  &nbsp;&nbsp;&nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">signalr2</font><font color="#434f54">,</font> <font color="#00979c">LOW</font><font color="#000000">)</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">signalr2</font><font color="#434f54">,</font> <font color="#00979c">LOW</font><font color="#000000">)</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#00979c">"COOLING"</font><font color="#000000">)</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#00979c">"COOLING"</font><font color="#000000">)</font><font color="#000000">;</font>
  <font color="#434f54">// if the pcr machine's temperature reaches 97, cooling will automatically be initiated and a death message will be displayed</font>
+
  <font color="#434f54">// if the pcr machine's temperature reaches 97, cooling will </font>
 +
<font color="#434f54">// &nbsp;&nbsp;automatically be initiated and a death message will be displayed</font>
 
  &nbsp;<font color="#000000">}</font><font color="#5e6d03">else</font> <font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">Input</font> <font color="#434f54">-</font> <font color="#000000">deathT</font> <font color="#434f54">+</font><font color="#000000">1</font><font color="#000000">)</font> <font color="#434f54">&gt;</font> <font color="#000000">0</font><font color="#000000">)</font><font color="#000000">{</font>
 
  &nbsp;<font color="#000000">}</font><font color="#5e6d03">else</font> <font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">(</font><font color="#000000">Input</font> <font color="#434f54">-</font> <font color="#000000">deathT</font> <font color="#434f54">+</font><font color="#000000">1</font><font color="#000000">)</font> <font color="#434f54">&gt;</font> <font color="#000000">0</font><font color="#000000">)</font><font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">signalr1</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">signalr1</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font>
Line 561: Line 595:
 
  &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#00979c">"DEATH"</font><font color="#000000">)</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#00979c">"DEATH"</font><font color="#000000">)</font><font color="#000000">;</font>
  
<font color="#7e7e7e">/* these two statements work on the maintaining the temperature, by controlling heating and cooling when there is overshoot or undershoot </font><font color="#7e7e7e"> &nbsp;&nbsp;in the temperature*/</font>
+
<font color="#434f54">// these two statements work on the maintaining the temperature, by </font>
 +
<font color="#434f54">// controlling heating and cooling when there is overshoot or undershoot </font>
 +
<font color="#434f54">// in the temperature</font>
 
  &nbsp;<font color="#000000">}</font> <font color="#5e6d03">else</font> <font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">Output</font> <font color="#434f54">&gt;</font> <font color="#000000">now</font> <font color="#434f54">-</font> <font color="#000000">windowStartTime</font> <font color="#434f54">-</font> <font color="#000000">1</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;<font color="#000000">}</font> <font color="#5e6d03">else</font> <font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">Output</font> <font color="#434f54">&gt;</font> <font color="#000000">now</font> <font color="#434f54">-</font> <font color="#000000">windowStartTime</font> <font color="#434f54">-</font> <font color="#000000">1</font><font color="#000000">)</font> <font color="#000000">{</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">signalr1</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font>
 
  &nbsp;&nbsp;&nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">signalr1</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font>

Revision as of 22:34, 18 September 2015