Cog help...
grasshopper
Posts: 438
I am having trouble running Cogs that process data and pass it to another cog. All the example Cogs i see either just light up and led or pwm a pin. Then the other examples just start and immediately go into assembly code. Please list a good cog example that is commented well.
All i want to do is run a Cog - measure temperature and average it. Then My main Cog can read the temperature at will.
Also If i am running FLoat32 " it uses 2 cogs" to do math and I call it in 2 separate Objects, will it then load Float32 twice in effect taking up 4 cogs?
Thanks in advance.
All i want to do is run a Cog - measure temperature and average it. Then My main Cog can read the temperature at will.
Also If i am running FLoat32 " it uses 2 cogs" to do math and I call it in 2 separate Objects, will it then load Float32 twice in effect taking up 4 cogs?
Thanks in advance.
Comments
the Temp Getting Object that t i am trying to report to my main program
And My main Cog code
Problem is that the Temperature is not getting the TEmperature
I think you have junk a lot of this and rethink it. I suspect that you need to separate the functions of reading the raw A/D data and doing the calculations, put just the reading of the A/D into one cog and all the calculations into your main routine.
for analysing the things in detail it is a MUST to have your COMPLETE code.
In the PropIDE under main-menu there is a item archive... (see attached picture)
If loaded your mainfile into the IDE and use archive ALL files related to that project
will be packed together in a zipfile. If you attach this to a posting it's possible to download it and
there will be everything inside for compiling your project
Making superquick postings makes it superslow to get a solution
because everybody has to ask back for the rest of the details
So please please please archive your code and attach it to a posting
Use the Reply-post function instead of the quick reply
then click on Attachment-Manager you get a new Window
search for your archive and upload it
The forum is willing to help if you provide detailed information combined with a concrete question
best regards
Stefan
I guess I was wanting someone to show me how to properly use cogs. I cant find reasonable information in the Propeller manual. One area i am suffering in is this
I know that when starting a cog you need some stack space, but how much do i have to play with and how do i decide that i have allocated enough? Its this type of unclear information that i cant seem to get.
Any help about running (loops), receiving, sending information to a custom cog would be greatly apreacated. I can light leds all day unfortunately my Boss want more than a Leds.
P.S. -- Stock market is going mad (get in now) !!
This article by Jon Williams is what I'm starting with. In the article he describes a tool that Phil Pilgrim wrote to help determine the stack required by an object. Might be of some help.
http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol7/col/NV134.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
There's no rule as it all depends on what you do with those Cogs, some need lots of stack some
need very little. The best rule of thumb is to start high and reduce if RAM starts to get tight. Just
20 stack items as in you example seems low to me.
It is possible to analyse the code and determine how much stack is used from the entry of any
particular method call but it's a lot of hard work and something left tot he compiler to report back
on. Unfortunately PropTool doesn't provide that information and nor does any utility I know of. It's
doable but no one's done it yet.
Have you looked at the *.pdf I posted, in my previous post? The tool that Phil came up with·is described on page 7 of that document and starts in the section titled: Stacking It All Up.
Since I'm just now starting to write code that runs in parallel instead of linear, I was going to use this technique for determining the stack size of the objects that in intend on writing.
Code that goes along with the article is here: http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol7/code/NV134.zip
And I've attached my version of it modified to use the TV_Text object, in my code I have not yet added Phil's stack_monitor object.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Post Edited (Mike Cook) : 9/19/2008 3:44:38 AM GMT
Hippy whats the max stack space available ? 512 is my best guess but not sure.
@ grasshopper : You can have as much stack space as you want; it's just a long array of any size.