Multiple Object starts
kenmac
Posts: 96
I am confused about starting multiple Objects from the top Object.
As an example:
I tried the following, using LED's to indicate that the object is running:
Top object "test1.spin" needs to start 3 others "test2.spin, test3.spin, test4.spin" and continue with it's own code.
test1.spin
test2.spin
The other two Objects are similar to test2.spin, just using a different pin output.
The outputs just operate LED's .
I expected all Objects to run, plus the main one, but what happens is that only the first one actually runs.
It seems that the first has to complete before the next can start.
If that happens, then the next Object called will run.
This in effect is still serial control - how do we get them to run in parallel?
I tried opening Cogs in each - that didn't change anything.
The only way I could get them working in parallel was to incorporate the other Object methods within the top Object, then starting them in separate Cogs.
I have obviously missed something here, or completely misunderstood how it works.
kenmac
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Perth, Western Australia
Time Zone = GMT + 8
As an example:
I tried the following, using LED's to indicate that the object is running:
Top object "test1.spin" needs to start 3 others "test2.spin, test3.spin, test4.spin" and continue with it's own code.
test1.spin
Obj t1:"test2" t2:"test3" t4:"test4" pub main t1.start t2.start t3.start start pub start repeat dira[noparse][[/noparse]16]~~ !outa[noparse][[/noparse]16] waitcnt(5_000_000 + cnt)
test2.spin
pub start repeat dira[noparse][[/noparse]17]~~ !outa[noparse][[/noparse]17] waitcnt(8_000_000 + cnt)
The other two Objects are similar to test2.spin, just using a different pin output.
The outputs just operate LED's .
I expected all Objects to run, plus the main one, but what happens is that only the first one actually runs.
It seems that the first has to complete before the next can start.
If that happens, then the next Object called will run.
This in effect is still serial control - how do we get them to run in parallel?
I tried opening Cogs in each - that didn't change anything.
The only way I could get them working in parallel was to incorporate the other Object methods within the top Object, then starting them in separate Cogs.
I have obviously missed something here, or completely misunderstood how it works.
kenmac
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Perth, Western Australia
Time Zone = GMT + 8
Comments
As I said, I tried running the individual called Objects in their own Cogs.
The result is the same - the first called Object (test2) is the only one to run.
kenmac
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Perth, Western Australia
Time Zone = GMT + 8
just post your COMPLETE Sourcecode. Really ALL files that you use
in the code posted yet there are no cognew-commands at all
starting a new cog can ONLY be done by a cognew-command
i think then it will be easy to find the point
and then it will be easy to correct it to make it run as you want it to run
best regards
Stefan
You say you tried that, but the only way we have of letting you know what you did wrong is if you post that code with the COGINITs or COGNEWs in.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
That was a typo - the code was so simple I just typed it in.
It is of course t3:"test4"
It's OK now - I have sorted it out.
I have two different boards in use, one a developing project and the other the propstick
When I started I was using the project board with it's associated pin numbers.
Halfway thru testing I swapped to the propstick, which only has other pins in use.
Of course, I forgot to change the code pin numbers, didn't I?
It turned out that when I was testing the "including the Cogs" part, it was using the propstick.
In that situation, it was working OK, but the LED's didn't light because they were on the wrong pins, except for test2!
So, I basically fooled myself!
At least I have confirmed that the method works, which I can now translate into the project.
I must be getting too old for this stuff.
Thanks for your input .
kenmac
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Perth, Western Australia
Time Zone = GMT + 8