Shop OBEX P1 Docs P2 Docs Learn Events
Propeller architecture and instantaneously changing methods in a cog. — Parallax Forums

Propeller architecture and instantaneously changing methods in a cog.

RichardFRichardF Posts: 168
edited 2007-05-29 09:39 in Propeller 1
I am just starting to learn about the the Propeller. It is my understanding that in order to send a new method to a cog that is alreading processing a method, I must first stop the cog then send the new method.·Can someone tell me how many clock cycles are "lost" (no processing taking place) during the stop cog then ·start new method process?·Us humans can stop and start a new process with essentially no lost time, I am interested in how close the Propeller chip can come to emulating the human process of listening to a command simultaneously while carrying out a process, then shifting to a new process based on that command with no lost time. For example, if·I am·reading out loud·at 100·words per minute and you tell me to slow to 50, I can do that instantaneously. I don't think the Propeller can do that, am I wrong?

Thank you,
Richard

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-28 23:05
    It takes a minimum of about 100us to start a new program in a cog. Most of this time is spent copying the code for the cog from main memory to the cog's memory (which is essentially done in hardware as part of the COGNEW or COGINIT instruction). Usually this is done as part of a program's initialization. If there's room in a cog for both pieces of code (for the two different functions), it's much better for the cog itself to just transfer from one routine to another. To some extent this is done in the FullDuplexSerial driver with the receive and transmit functions split-up and interleaved. There's been a discussion of a "large memory model" which would use a very efficient interpreter interleaved with in-cog subroutine calls for complex operations and there's a multi-tasking functionality included. Search this forum for "large memory model" and have a look.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-05-28 23:16
    Methods, which refers to Spin routines, aren't held in a cog. The cog holds a Spin Interpreted which reads the Spin tokens from main memory. If you have someSpin method that is being executed, that due to some conditional, calls a new method, there is no time wasted other than that of the normal overhead.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting, and XBee Wireless Adapters
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • RichardFRichardF Posts: 168
    edited 2007-05-28 23:26
    Mike,
    Thank you for your reply. My interest is in robotics, which I have some experience in using the Basic Stamp 2. The BS2 is so slow that many of the robot actions are unrealistic. In most cases changing any programmed motions causes a noticeable stop/start delay, because with the BS2 only one process at a time can be carried out. So, if I want my robot to process new information from say an IR return, I can't send motion information to the wheels at the same time; old robot just stops until the IR info is assimulated and a new course of action is determined. I think with the Propeller I can have one cog sending signals to the drive motor controllers while another cog is getting new navigation info, and another cog is using that new nav info to determine a new course of action. When all that is determined the motor controller cog need only receive a new set of wheel drive instructions, and that will occur so fast that it will be undetectable to the eye. Am I correct in these assumptions?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-28 23:46
    Yes. Again, you usually don't start up a cog when something happens. You start it up during initialization, then it waits for something to happen. In assembly, the completion of some kind of wait usually takes nanoseconds. In Spin, it takes a few microseconds. Either way, it's faster than what you seem to want.
  • M. K. BorriM. K. Borri Posts: 279
    edited 2007-05-29 09:39
    I've used "cog catch and release" in my dynamic math library, it mostly works for what I need it to do. It IS an admitted big ugly hack on top of float32 though....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallax.com/showthread.php?p=650217

    meow, i have my own topic now? (sorta)
Sign In or Register to comment.