[C.CC USERS] Help needed with PRI ALT
Carl Ritson
C.G.Ritson at kent.ac.uk
Thu Dec 20 14:24:58 GMT 2012
Hi James,
Because your PRI ALT is in a tight loop with a SKIP guard the system
scheduler never gets a chance to run and no other processes can be run
and read/drive the pins. At least that is what it looks like is
happening to me.
You have three option:
1. Add a delay after digital.write (SprayLED, HIGH).
2. Add a RESCHEDULE() after digital.write (SprayLED, HIGH).
3. Use a timer guard to activate digital.write (SprayLED, HIGH) if
CatIn! and CatOut! do not signal within a set time period.
All of these will allow the scheduler to run the other processes.
Cheers,
Carl
2012/12/20 James Brown <james.brown4994 at gmail.com>:
> Can anyone help me with PRI ALT.
>
> I am a beginner and have been trying to figure out how to use occam to build
> a simple cat deterrent.
>
> I have the following code. It is not representative of what I want it to do
> eventually but rather to experiment with PRI ALT.
>
> I am expecting that a signal from CatOut or CatIn should drive ArmedLED low
> or high. However it appears to ignore these signals. I appears always to
> default to final TRUE & SKIP condition. I am stuck and I don't know how to
> debug it. Any ideas gratefully received.
>
> #INCLUDE "plumbing.module"
>
> VAL OutPin IS 2 :
> VAL InPin IS 3 :
> VAL ArmedLED IS 12 :
> VAL SprayLED IS 13 :
>
> PROC blink.pin (CHAN SIGNAL out!)
> WHILE TRUE
> SEQ
> delay (500)
> out ! SIGNAL
> :
>
> PROC monitor.pir ()
> SEQ
> digital.mode (InPin, INPUT)
> digital.mode (OutPin, INPUT)
> digital.mode (ArmedLED, OUTPUT)
> digital.mode (SprayLED, OUTPUT)
> digital.write (ArmedLED, LOW)
> digital.write (SprayLED, LOW)
> CHAN SIGNAL CatIn, CatOut:
> PAR
> blink.pin (CatOut!)
> delay (300)
> blink.pin (CatIn!)
> WHILE TRUE
> PRI ALT
> CatOut ? SIGNAL
> digital.write (ArmedLED, LOW)
> CatIn ? SIGNAL
> digital.write (ArmedLED, HIGH)
> TRUE & SKIP
> digital.write (SprayLED, HIGH)
> :
>
>
> _______________________________________________
> users mailing list
> users at concurrency.cc
> http://lists.concurrency.cc/mailman/listinfo/users
>
More information about the users
mailing list