Inter-Cog Communication
ReiserificK
Posts: 24
Hi everyone, I have been working on a SPIN program to control a formerly-remote-conrol car, and I am having some problems. I've done some searching but havent come up with anything directly related to my main problem. I am using one cog to send pulses to the motor controllers and another to poll sensors/make decisions. I am currently storing commands in the form of numbers in a word/long (cant remember which size is readable/writeable in one clock cycle, I'll have the source in front of me tomorrow) and passing the address of these variables to the new cog as it starts. I havent gotten this to work, and I havent figured out a debug method yet (lcd,terminal,etc). However, I think the problem involves the motor control cog reading these variables, as the code works on its own. Am I going about this in the right manner? How would you guys suggest I transmit commands between cogs? Any suggestions greatly appreciated.
Thanks very much
Thanks very much
Comments
http://obex.parallax.com/objects/91/
I did not write it
Also, note that the ramp ability isn't really implemented yet. It has a bug, and I haven't gotten around to fixing it. However, the inter cog communication is still viable and works well.
Here is a link where I disscussed propeller general questions, including inter object and cog communication.
http://forums.parallax.com/showthread.php?p=765086
variable-access across cogs
here is a code-example showing access to a variable from different cogs within the same *.SPIN-File
you simple use the NAME of the variable itself
with this democode you should get an output to your terminalsoftware similar to this
As you can see from this demo
as long as you want to use a variable from the SAME *.SPIN-file
you just use the NAME of the variable
It is the same as long as you want to access the variable in the SAME object
(which is defined in another *.SPIN-File)
therefore the variable has to be defined INSIDE that object (that *.SPIN-file)
to get access to variables ACROSS OBJECTS the variable is defined in one object
and the OTHER objects can access this variable through the RAM-Adress of this variable
you get the RAM-Adress of a variable with the "@"-operator
best regards
Stefan
remember also that you have to serialize the access to the variable.· Read or Write operations required to use prop lock mechanism.
jm.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker