Shop OBEX P1 Docs P2 Docs Learn Events
Can 2 cogs display data onto a single VGA simultaneously? — Parallax Forums

Can 2 cogs display data onto a single VGA simultaneously?

ElectricAyeElectricAye Posts: 4,561
edited 2009-05-14 03:44 in Propeller 1
Hi all,

I was just wondering if two cogs could display data to a single VGA using VGA_Text. Would the different data simply go to its designated location on the screen or would 2 cogs interfere with each other and totally screw up the display?

thanks,
Mark

Comments

  • RaymanRayman Posts: 14,827
    edited 2009-05-13 19:27
    It won't work unless you add code to syncronize the cogs...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • RaymanRayman Posts: 14,827
    edited 2009-05-13 19:36
    Check out this page where I synced 3 VGA cogs to do a 6-bit photo:

    http://www.rayslogic.com/propeller/Programming/6-Bit%20Bitmap%20App/6BitBitmap.htm





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-05-13 19:41
    Hello ElectricAye,

    there is a solution to this which I will describe below.

    If you just call the methods the screen will screw up when both cogs try to write at the same time.
    the VGA_Text-object uses an array to store the characters and the different methods for writing to the
    screen use the variables long col, row, color

    Now imagine two independent running cogs change the values of these variables at the same time. This will screw it up.

    If you would start two VGA_Text-objects using the same pin this will even screw up the signal.

    Now the solution. You have to use a bufferarray
    the different cogs write not directly to the display but to a buffer-array
    this means the two cogs do NOT use the VGA_text-methods but other methods that write to a bufferarray representing the screen

    Then there has to be a third cog (or a repeated called method that reads the bufferarray and writes to the screen.
    This method writes always the COMPLETE buffer to the screen.

    If the bufferarray-writemethods use a columm and row positioning ALL the time. The screen can only get screwed up
    by wrong col-row-offset settings. This means as long as the user takes care of the col-row-offsets in that way
    that cog 1 uses f.e. col 0-10 and cog 2 col 11-32 or any other dividing the screen in a cog-1-part and a cog-2-part it will work

    best regards

    Stefan
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-05-13 21:39
    To Rayman and Stefan,

    Thanks so much for your swift replies. I've been pondering what you've said and the solution sounds like it's above my IQ level to deal with at this point. I suppose a simpler approach to my general problem might be to have a single cog responsible for VGA display of all data and then use HUB RAM to communicate between various cogs. But I guess now I have to deal with the possibility of what happens if the "VGA display cog" tries to read the contents of a HUB RAM address while another "sensor reading" cog is trying to write to that very same HUB RAM address at the very same time.

    Hmmm.....

    This multi-cog thing is super-cool but it also gets complicated at times like this.

    thanks again,
    Mark

    smile.gif
  • kwinnkwinn Posts: 8,697
    edited 2009-05-14 01:26
    I thought the hub mechanism took care of accessing the hub ram by giving access to one cog at a time. After looking at the high res text driver I am fairly certain that any cog can write a byte to the character buffer and the text would be displayed as long as no other cog changed that byte.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-05-14 03:08
    kwinn said...
    I thought the hub mechanism took care of accessing the hub ram by giving access to one cog at a time....

    By golly, kwinn, I think you're right! So I guess I don't have to worry about the "VGA display cog" reading the contents of a HUB RAM address while the "sensor reading" cog is trying to write to that very same HUB RAM address at the very same time.

    Thanks for reminding me of that mechanism!

    smile.gifsmile.gifsmile.gif
    Mark

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Watching the world pass me by, one photon at a time.
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-05-14 03:35
    Yes, the VGA cog(s) just display the data from hub. So you can use other cogs to update the hub memory without regard to the cog(s) doing the actual VGA generation. Depending on flicker in updating, you may need to sync your code to the screen sync pulses although I suggest you worry about that later.

    I actually not sure what you are trying to achieve. I suggest you download the VGA demos and have a play with them. Ignore the pasm VGA code for now as it only displays the data - try modifying the spin demo section and see instant results smile.gif

    I say cog(s) because think there are actually 2 cogs providing the display interlacing with each other, but I could be wrong. At least that was the way Chip originally intended it anyway.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: Micros eg Altair, and Terminals eg VT100 (Index)
    · Search the Propeller forums (via Google)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-05-14 03:44
    Cluso99 said...
    ...

    I actually not sure what you are trying to achieve. ...

    It's nothing fancy. I just wanted to have mouse control over a few variables while a few cogs are counting pulses, etc. I got the VGA and mouse incrementer/decrementer working today and got confused about how to display the cursor position and data (pulse counts, time, date, threshold voltages, etc.) all on the same VGA screen. I think I get it now. For this clueless newbie, RAM HUB is my beacon of hope.

    thanks, you guys,
    Mark

    smile.gif
Sign In or Register to comment.