Jon M
09-13-2007, 10:25 PM
Hi Guys, firstly thanks for your help with my last thread, I've moved on a bit but stuck again...
I'm trying to use 1 method by 2 cogs.· If I only start the 1st cog, by commenting out the 2nd, all is fine and routine performs as it is supposed to.· If I try to start both cogs the 1st one stops working as it should although the cog is starting successfully I think.
The first_len and second_len is provided by the master object that calls startcogs.
VAR
· long stack[500]
· word e_count
· byte cl
· byte sen
PUB startcogs(first_len,second_len)
· cognew (main(1,first_len),@stack[0]
· cognew (main(2,second_len),@stack[250]
PUB main(num,length)
· dira[7..17] ~
· dira[18..25] ~~
· outa[18..25] ~
· if num==1
··· cl:=20
··· sen:=12
··· outa[24]~~················································ · ' visually shows 1st cog has started
· if num==2
··· cl:=21
··· sen:=13
··· outa[25]~~················································ · ' visually shows 2nd cog has started
· repeat
···· repeat until ina[sen]==0································· ' wait here for sensor to be covered
·····e_count~
···· repeat while e_count<length
······ if ina[14]==0
········e_count++
······· repeat until ina[14]==1
·····outa[cl]~~
···· e_count~
···· repeat while e_count<128
······ if ina[14]==0
······· e_count++
······· repeat while ina[14]==1
·····outa[cl]~
···· repeat until ina[sen]==1
Many thanks
Jon
I'm trying to use 1 method by 2 cogs.· If I only start the 1st cog, by commenting out the 2nd, all is fine and routine performs as it is supposed to.· If I try to start both cogs the 1st one stops working as it should although the cog is starting successfully I think.
The first_len and second_len is provided by the master object that calls startcogs.
VAR
· long stack[500]
· word e_count
· byte cl
· byte sen
PUB startcogs(first_len,second_len)
· cognew (main(1,first_len),@stack[0]
· cognew (main(2,second_len),@stack[250]
PUB main(num,length)
· dira[7..17] ~
· dira[18..25] ~~
· outa[18..25] ~
· if num==1
··· cl:=20
··· sen:=12
··· outa[24]~~················································ · ' visually shows 1st cog has started
· if num==2
··· cl:=21
··· sen:=13
··· outa[25]~~················································ · ' visually shows 2nd cog has started
· repeat
···· repeat until ina[sen]==0································· ' wait here for sensor to be covered
·····e_count~
···· repeat while e_count<length
······ if ina[14]==0
········e_count++
······· repeat until ina[14]==1
·····outa[cl]~~
···· e_count~
···· repeat while e_count<128
······ if ina[14]==0
······· e_count++
······· repeat while ina[14]==1
·····outa[cl]~
···· repeat until ina[sen]==1
Many thanks
Jon