Shop OBEX P1 Docs P2 Docs Learn Events
Programming the Propeller Demo Board — Parallax Forums

Programming the Propeller Demo Board

gdrowellgdrowell Posts: 7
edited 2011-04-14 19:45 in Propeller 1
Hello All,

I am in need to know how to program the propeller to do simple arithmetic between multiple cogs and report it back to a master cog. It starts with the master cog sending out a set of numbers, then (at least two) cogs would do some simple math (cog 2 would do addition of the numbers then divide by 3; cog 3 would subract the numbers than multiply by 3) then report the answers back to the master cog. The master cog would then take the average of the two reported answers from cog 2 and cog 3. Any help with programming this would be superb. Thanks in advance.

Comments

  • Bill HenningBill Henning Posts: 6,445
    edited 2011-04-14 16:27
    Welcome to the Propeller!

    You will need to use the hub memory to pass data between the cogs.

    I think you will find the forum is full of helpful people who will gladly help when someone is stuck - but won't solve homework problems for students.
  • gdrowellgdrowell Posts: 7
    edited 2011-04-14 17:07
    Thanks for the welcoming Mr. Hennnig.

    Although I am new to the propeller chip software and Spin, I am not looking for a given solution, but I am looking for any information needed to complete my project. I will definitely look in to the Hub memory information. Thanks for the insight.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-04-14 19:45
    Maybe I'm confused about this, but I think you can declare variables in the VAR block so they become global to the present object, and then those variables will appear global to whatever various cogs might get called up by that same object. Is this correct?

    The scope of global variables is not limited to a single cog either. An object’s public and private methods naturally have access to its global variables regardless of what cog they are running on. If the object launches some of its methods into multiple cogs, each of those methods, and thus the cogs they are running on, have access to those variables.
    This feature allows a single object to easily manage aspects of multiple processes in a centralized way. For example, a sophisticated object may take advantage of this to instantly affect “global” settings used by every multi-processed code entity that it created.
    Of course, care should be used to ensure that multiple processing on the same block of variables does not create undesirable situations....
Sign In or Register to comment.