General Propeller interaction questions
Kris Cardoen
Posts: 46
Hi,
I'm quite new to propeller programming, so I have a few general questions
1. The communication between cogs can be made by using public varaibles? For instance one cog waits with repeat until a global variable changes, before is starts a certain action. Is that a correct appoach?
2. How do one use multible prop boards? Do you connect a few imput/output ports between the different controllers and use hi/Lo signals for interaction? Or is there a more efficient way. I would use the two boards in the same robot, so wireless is not required.
3. Since I use several obex objects, I would like to know if there is a easy way to check the number of concurrent cogs in use. I know the command to identify the current cog, but since the objects manage the allocation and usage themselves in the backgound an overview of cogs usered per prop board would be nice....if possible of course
Any hints or info would be much appricated. No complex examples just the general information plz.
Regards,
Kris
I'm quite new to propeller programming, so I have a few general questions
1. The communication between cogs can be made by using public varaibles? For instance one cog waits with repeat until a global variable changes, before is starts a certain action. Is that a correct appoach?
2. How do one use multible prop boards? Do you connect a few imput/output ports between the different controllers and use hi/Lo signals for interaction? Or is there a more efficient way. I would use the two boards in the same robot, so wireless is not required.
3. Since I use several obex objects, I would like to know if there is a easy way to check the number of concurrent cogs in use. I know the command to identify the current cog, but since the objects manage the allocation and usage themselves in the backgound an overview of cogs usered per prop board would be nice....if possible of course
Any hints or info would be much appricated. No complex examples just the general information plz.
Regards,
Kris
Comments
2. You can use serial objects such as FullDuplexSerialPlus to communicate between Propellers. Just connect the TX line of the one Propeller to the RX line of the other, and vice versa.
3. No. Cog allocation is dynamic, not compile time, so the compiler can't know how many cogs are in use. You'll have to walk through your code yourself to see how many cogs are in use.
2) It's usually best to put a 2.2K resistor between the two Propeller pins that are connected together. This protects the I/O pins from damage from programming errors where both I/O pins are set to output mode, but with one outputting a low level and the other outputting a high level.
3) OBEX objects usually indicate in their documentation whether they start up a cog to perform their actions or not. Anything that's buffered will usually use a cog.
If the cogs are running Spin code then you can communicate with global variables from within a single object. So yes, you can have one cog wait for a global variable to change before starting a different portion of the program.
If the cog is running PASM code then you'll need to use the technique Mike mentioned.
There's lots of different ways this has been done. A serial connection is probably the easiest. You'll need to decide what protocol to use. Do you use an end of message character? Fix length messages? Indicate the size of the message somewhere in a header? There are pros and cons to each approach.
There's an object that does this. I don't recall the name of it. I haven't used it myself. I just keep track of how many cogs I've used.
I often add a comment in the "OBJ" section next to any objects that use a separate cog.
Thread... http://forums.parallax.com/showthread.php?139897-Display-Prop-Info-(clockfreq-avail-cogs)
It's also in the OBEX Tools section, and its part of my version of a Propeller OS (type ver although it aso displays this on booting).
Conversely in most programs a fixed number of cogs is started and run for the life of the program.
Given that why bother. A quick scan through the source of the objects you are using will tell you how many cogs the program will need. Probably easier/quicker to do than setting up some code to count them for you at run time.
At which point I'd think "not going to get much then am I".