Andy,
When you say message comunications, are you refering to a varaible passing some sort of data? or are you talking about a physical wire that sends high/low signals to each processor (or FSMs)?
The Subsumption architecture that I am working on does not include comunications between each module which is why I was saying that the order by which the bahaviours in the main loop are placed will afect the subsumption order. The higest priority behaviour should apear last in the main loop because if a high priority situation occures that modue will subsume all other module’s outputs. Perhaps you are following the more complex architecture where mine is based on the general idea but much more simplified.
Here is my Pbasic code:
It’s a work in progress so there will be some discrepancies
[code]’ {$STAMP BS2}
’ {$PBASIC 2.5}
'========================================================================
'Finite State Machine & Subsumption Architecture
'========================================================================
'---- I/O Definitions ]-------------------------------------------------
Ping PIN 15
’ ----- Constants ]-------------------------------------------------------
pDUR VAR Byte
PACT CON 5
Trigger CON 5 ’ trigger pulse = 10 uS
Scale CON $200 ’ raw x 2.00 = uS
RawToIn CON 889 ’ 1 / 73.746 (with **)
RawToCm CON 2257 ’ 1 / 29.034 (with **)
IsHigh CON 1 ’ for PULSOUT
IsLow CON 0
’ ----- Variables ]-------------------------------------------------------
rawDist VAR Word ’ raw measurement
inches VAR Word
cm VAR Word
ileft VAR IN9 'IR LED outputs
iright VAR IN0 'i=(see code)
IEN CON 5 'enable FOR 555
ilast VAR Byte 'hit counter
i VAR Byte 'LOOP counter, whatever
tmp VAR Word 'temporary holder
seed VAR Word 'RANDOM number seed
'These are FOR the servo routines
LEFT CON 15 'left wheel port
RIGHT CON 3 'right wheel port
SACT CON 5 'times through act routine
drive VAR Word 'wheel command combo
ldrive VAR drive.BYTE1 'left wheel command
rdrive VAR drive.BYTE0 'right wheel command
aDur VAR Byte 'duration of pulse left
'Servo drive commands
fd CON $6432 'forward
rv CON $3264 'REVERSE
st CON $4b4b 'STOP
tr CON $644b 'turn right
tl CON $4b32 'turn left
rr CON $6464 'rotate right
rl CON $3232 'rotate left
'wander values
wstate VAR Byte 'shared Byte
wDir VAR Word 'wander value
wDur VAR Byte 'wander duration
'set up FOR running
wstate =0 'initial wander state
main: 'this is the main activity LOOP
GOSUB wander
GOSUB avoid 'Last module ( Higest Priority )
GOSUB act 'Move servos based on modules output
GOTO main
'========================================
'Behaviors follow
'========================================
wander:
'randomly wander around
BRANCH wstate,[wcDir,wcDur]
'state 2 immed. follows
wDur = wDur - 1
IF wDur > 0 THEN wDone1
drive = wDir 'get direction
wstate = 0 'reset state
wDone1: 'completed
RETURN
wcDir: 'choose direction
RANDOM seed 'RANDOM direction
i = seed & %111 'mask off FOR 0-7 only
LOOKUP i,[tr,fd,fd,fd,rr,fd,fd,tl],wDir 'chose direction
wstate = 1 'NEXT state
RETURN
wcDur: 'choose duration
RANDOM seed 'RANDOM direction AND duration
wDur = (seed & %111111) + 20 'mask FOR 64 choices
wstate = 2 'NEXT state
RETURN
avoid:'PING routine
IF pDur > 0 THEN pDec 'already doing one, got here
pDur = PACT 'times through this one
Read_Sonar:
Ping = IsLow ’ make trigger 0-1-0
PULSOUT Ping, Trigger ’ activate sensor
PULSIN Ping, IsHigh, rawDist ’ measure echo pulse
rawDist = rawDist */ Scale ’ convert to uS
rawDist = rawDist / 2
inches = rawDist ** RawToIn ’ convert to inches
cm = rawDist ** RawToCm ’ convert to centimeters
DEBUG CRSRXY, 15, 3, ' update report screen
DEC rawDist, CLREOL,
CRSRXY, 15, 4,
DEC inches, CLREOL,
CRSRXY, 15, 5,
DEC cm, CLREOL
pDec: 'decrement stuff
pDur = pDur - 1
pDone:
RETURN
act: 'moves servo motors
IF aDur > 0 THEN aDec 'already doing one, got here
aDur = SACT 'times through this one
PULSOUT LEFT,ldrive * 10
DEBUG HOME, ? ldrive,CR
DEBUG ? rdrive ,CR
DEBUG ? aDur
PULSOUT RIGHT,rdrive * 10
aDec: 'decrement stuff
aDur = aDur - 1
aDone:
RETURN[/code]