Hey everybody,<div><br></div><div>Thanks for the help getting my flow control set up. Here is an update on the project.</div><div><a href="http://www.youtube.com/watch?v=LjQE70b3GY4">http://www.youtube.com/watch?v=LjQE70b3GY4</a></div>
<div><br></div><div>Bryant<br><br><div class="gmail_quote">On Mon, Sep 3, 2012 at 5:02 PM, Fred Barnes <span dir="ltr">&lt;<a href="mailto:F.R.M.Barnes@kent.ac.uk" target="_blank">F.R.M.Barnes@kent.ac.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi Bryant,<br>
<div class="im"><br>
&gt; Here is what I got so far. The problem is, all the pumps turn on at the<br>
&gt; same time, run for the proper amount of time, then wait for the maximum<br>
&gt; wait time. For example, the pump on pin 12 is governing the off time. After<br>
&gt; 4s all the pumps kick on, 13 is on for 1s, 12 for 2s and 11 for .7s, once<br>
&gt; 12 is done it waits 4s then everything starts at the same time.<br>
&gt;<br>
&gt; Can somebody help me out?<br>
&gt;<br>
&gt;<br>
&gt; #INCLUDE &quot;plumbing.module&quot;<br>
&gt; PROC do (VAL INT pin, VAL INT timeOn, VAL INT timeOff)<br>
&gt;   SEQ<br>
&gt;     digital.mode (pin, OUTPUT)<br>
&gt;     digital.write (pin, HIGH)<br>
&gt;     delay(timeOn)<br>
&gt;     digital.mode (pin, OUTPUT)<br>
&gt;     digital.write(pin, LOW)<br>
&gt;     delay(timeOff)<br>
&gt; :<br>
&gt;<br>
&gt; PROC main ()<br>
&gt;   WHILE TRUE<br>
&gt;     PAR<br>
&gt;       do(13, 1000, 2000)<br>
&gt;       do(12, 2000, 4000)<br>
&gt;       do(11, 700, 1500)<br>
&gt; :<br>
<br>
</div>If I understand correctly, you just need to move the logic around a bit.<br>
What happens with the PAR is that all the sub-processes do their own<br>
thing, but then wait for each other to finish (as per PAR semantics),<br>
at which point the WHILE loop flies around and everything starts all<br>
over again.<br>
<br>
It sounds like you want these things to be entirely independent, so<br>
(fairly simply) move the WHILE loop inside the process, e.g.:<br>
<br>
PROC do (VAL INT pin, timeOn, timeOff)<br>
<div class="im">  WHILE TRUE<br>
    SEQ<br>
      ... do stuff<br>
</div>:<br>
<br>
PROC main ()<br>
<div class="im">  PAR<br>
    do(13, 1000, 2000)<br>
    do(12, 2000, 4000)<br>
    do(11, 700, 1500)<br>
:<br>
<br>
<br>
</div>Alternatively, and equivalent to the above [but not your original code],<br>
you could just mangle PROC main() to swap the WHILE and PAR around:<br>
<br>
PROC main ()<br>
  PAR<br>
    WHILE TRUE<br>
      do(13, 1000, 2000)<br>
    WHILE TRUE<br>
      do(12, 2000, 4000)<br>
    WHILE TRUE<br>
      do(11, 700, 1500)<br>
:<br>
<br>
<br>
However, having the WHILE loop inside the &#39;do&#39; process is cleaner and a<br>
little more obvious -- unless there are situations where you don&#39;t want this<br>
behaviour.<br>
<br>
<br>
Hope that helps,<br>
<br>
-- Fred<br>
</blockquote></div><br></div>