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"><<a href="mailto:F.R.M.Barnes@kent.ac.uk" target="_blank">F.R.M.Barnes@kent.ac.uk</a>></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>
> Here is what I got so far. The problem is, all the pumps turn on at the<br>
> same time, run for the proper amount of time, then wait for the maximum<br>
> wait time. For example, the pump on pin 12 is governing the off time. After<br>
> 4s all the pumps kick on, 13 is on for 1s, 12 for 2s and 11 for .7s, once<br>
> 12 is done it waits 4s then everything starts at the same time.<br>
><br>
> Can somebody help me out?<br>
><br>
><br>
> #INCLUDE "plumbing.module"<br>
> PROC do (VAL INT pin, VAL INT timeOn, VAL INT timeOff)<br>
> SEQ<br>
> digital.mode (pin, OUTPUT)<br>
> digital.write (pin, HIGH)<br>
> delay(timeOn)<br>
> digital.mode (pin, OUTPUT)<br>
> digital.write(pin, LOW)<br>
> delay(timeOff)<br>
> :<br>
><br>
> PROC main ()<br>
> WHILE TRUE<br>
> PAR<br>
> do(13, 1000, 2000)<br>
> do(12, 2000, 4000)<br>
> do(11, 700, 1500)<br>
> :<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 'do' process is cleaner and a<br>
little more obvious -- unless there are situations where you don't want this<br>
behaviour.<br>
<br>
<br>
Hope that helps,<br>
<br>
-- Fred<br>
</blockquote></div><br></div>