Is there a way to pass a variable between cogs in code?
Steel
Posts: 313
...or do you need to connect 2 pins together?
I am looking at having 1 cog communicate with a PC.· Another Cog outputting a value.· Whenever a value is recieved by Cog1, I would like it to update cog2.
As far as I can read, Cogs really work as independent processors...but there is a hub, so I was thinking that there would be memory in the hub that cogs could use to communicate with each other.
I am a bit confused.· I know that I could just jump 2 pins together, and have 1 cog talk to the other cog that way, but is there a way in code such as Cog1.Variable = Cog2.Variable?
please help.
Thanks.
I am looking at having 1 cog communicate with a PC.· Another Cog outputting a value.· Whenever a value is recieved by Cog1, I would like it to update cog2.
As far as I can read, Cogs really work as independent processors...but there is a hub, so I was thinking that there would be memory in the hub that cogs could use to communicate with each other.
I am a bit confused.· I know that I could just jump 2 pins together, and have 1 cog talk to the other cog that way, but is there a way in code such as Cog1.Variable = Cog2.Variable?
please help.
Thanks.
Comments
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
So you can access all your SPIN variables straightforward without minding in which COG SPIN interpreters are running your program.
Please do not mix up the instantiation of an object with the use of a COG!
I just want to make sure...Im sorry.
This is pseudo-code below without the 'locks'...but will this work? This seems much easier than I imagined when I got the chip...
{Declare variable in spin}
VAR
·· Word MyVar
{Begin Program}
PUB Run_Program
··· 'code - the below is just an example...
··· Cognew(SerialIN)
····Cognew(Data_Out)
PUB Serial_IN
··· REPEAT
······ 'Code here to continously save data to 'MyVar'
PUB Data_Out
····REPEAT
···· 'code here to continously output data from 'MyVar'
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Sorry for the waste of bandwidth
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Whether this is worth the trouble is another consideration. (I bought a pair of 40x2 char LCDs for $13 from Allelectronics, so I've been boning up on spec sheets...)