Shop OBEX P1 Docs P2 Docs Learn Events
Looking for a format... — Parallax Forums

Looking for a format...

I was wondering if there, or someone has, a format to follow, in SPIN that will load a program in COG0, then/also load 7 different programs in COGS 1 through 7. The programs in COGs 1 through 7 will do there own thing, constantly computing a VARIABLE and then putting it in the HUBS RAM for the first COG (COG0) to in turn constantly display on an LCD the VARIABLE values...

Perhaps a better word for format, would be a templete.

Hope this isn't too silly of a question...thank you...DennO

Comments

  • Here is a link to the Ed Kit text. Have a look at chapter 5: Methods and Cogs Lab. It is heavy slogging, but if you study it and follow the examples, you will have what you want.
  • dennO,

    What exactly is it that you are trying to do because do you really need every Cog to be doing something?
  • PublisonPublison Posts: 12,366
    edited 2017-12-27 19:44
    denno wrote: »
    I was wondering if there, or someone has, a format to follow, in SPIN that will load a program in COG0, then/also load 7 different programs in COGS 1 through 7. The programs in COGs 1 through 7 will do there own thing, constantly computing a VARIABLE and then putting it in the HUBS RAM for the first COG (COG0) to in turn constantly display on an LCD the VARIABLE values...

    Perhaps a better word for format, would be a templete.

    Hope this isn't too silly of a question...thank you...DennO

    Here is a program that talks to all the Cogs, if you don't mind a little wiring.:

    http://obex.parallax.com/object/61

    Not sure if it is what you were looking for.

  • Heater.Heater. Posts: 21,230
    Why do you want to do something special there?

    When you load Spin code to a Propeller it runs in COG 0. So nothing special to do there.

    You can then start a method from any Spin objects you have written on COGS 1 to 7. This is all quite normal Spin programming.

    By way of "template" pretty much all the objects in obex are such templates. As is any other non trivial program you find on the forum and elsewhere.



  • A random number generator would be a good program to load into each Cog for a "Quick and Dirty" demo.
  • Cluso99Cluso99 Posts: 18,069
    edited 2017-12-28 00:14
    Just write each program for each cog in either PASM or SPIN, and then start each cog from spin in cog 0, pointing to the hub start of the program, and optionally passing the hub start address for the mailboxes.

    IIRC there is a demo led flashing multiple cog program that comes with the PropTool program. Think it's in the exercises folders.
  • @denno,

    Attached is an example that (hopefully) illustrates what you're asking. Each cog runs its own method of a simple repeat loop, updates its own VAR, and the main cog displays each var on a Parallax serial LCD (#27976, #27977, #27979).

    Cheers,
    Jesse
  • avsa242...having trouble unzipping your attachment. Anyway you can unzip it for me and resend the the example...thank you. Not sure why it will not unzip...

    And, thanks to all for your help...has anyone worked with the new FLIP from Parallax?

    DennO
  • denno wrote: »
    avsa242...having trouble unzipping your attachment. Anyway you can unzip it for me and resend the the example...thank you. Not sure why it will not unzip...

    And, thanks to all for your help...has anyone worked with the new FLIP from Parallax?

    DennO


    Strange...I just tried to download and unzip it just to verify and it seems okay here. I'll try attaching the individual files.
  • I have double checked on the unzipping with this computer, and it would appear that my unzipper has timed out, because I did not purchase it....thanks for the individual files...I now have a much better idea, on how to proceed, where I have 7 different temperatutre probes in different locations....being displayed. Yes, I can and have used a standard BS2sx to do the job, but I want to break into the Propeller....DennO
  • dennO,

    How are you reading the temperature?
    Are your probes "smart" or are you using a chip such as an ADC to get temperature readings.

    If you are just periodically reading each probe in order then I don't see why this couldn't be done with just 1 Cog.

    In the book Parallel Processing with the Propeller Microcontroller, there is a PASM (Parallax Assembly) program that reads a 2-Channel ADC on 1 Cog and feeds the values to a Spin program.
    I think that is what you are trying to do.

    If you don't need the temperature often, say every 30 seconds or a minute, then Spin itself should be more than fast enough to get your readings.
    The Propeller is considerably faster and more powerful than the BS2sx.
    Actually, if you want, you can use one of the standard video drivers to print the readings on a TV or a VGA monitor, and still have a few Cogs to spare.
    I know that TV_Text is very easy to use and functions similar to DEBUG.
  • JonnyMacJonnyMac Posts: 8,918
    edited 2017-12-30 20:02
    I would suggest you handle temperature reading as a separate object; this will reduce redundant code and keep your application code cleaner. You can also create an array of the same object type. Today I am working on an escape room puzzle program that has four sensors for coded laser tag guns. This lets me do something like this:
    obj                              
                                     
    ' main                                                          ' * master Spin cog                   
      time       : "jm_time_80"                                     '   timing and delays (80MHz system) 
      prng       : "jm_prng"                                        '   pseudo-random number generator     
      io         : "jm_io"                                          '   essential io
      outs       : "jm_pwm8"                                        ' * pwm driver for outputs
      sensor[4]  : "jm_milestag-plus_rx"                            ' * Milestag IR input     
      term       : "jm_fullduplexserial"                            ' * serial IO for terminal
    ' background                                                    ' * background inputs scanning, timer 
      
    ' * uses cog when loaded
    
    Then...
    pub scan_sensors | n
    
      repeat n from 0 to 3
        if (sensor[n].ready)
          process_sensor(n)
          sensor[n].enable
    
Sign In or Register to comment.