Shop OBEX P1 Docs P2 Docs Learn Events
Help with code running in 2 cogs — Parallax Forums

Help with code running in 2 cogs

MacGeek117MacGeek117 Posts: 747
edited 2008-01-29 02:53 in Propeller 1
I'm trying to figure out what's wrong with my serial protocol, and I've narrowed the first problem to a recieve function. When I have it in the main program (see Comm Test 1) it works fine, but when I try to put it in a separate cog (see Comm Test 2), it malfunctions, spitting out garbage characters.
RoboGeek

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"

Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com

Comments

  • DgswanerDgswaner Posts: 795
    edited 2008-01-22 22:15
    I think you need to declare a separate stack variable for the new cog. or make your stack size bigger, I could be totally wrong but that's where I would start.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • mosquito56mosquito56 Posts: 387
    edited 2008-01-22 23:03
    Are you trying to run output thru pin 30,31 on both cogs?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ······· "What do you mean, it doesn't have any tubes?"

    ······· "No such thing as a dumb question" unless it's on the internet

    Technologically challenged individual, Please have pity.
  • MacGeek117MacGeek117 Posts: 747
    edited 2008-01-22 23:30
    No, just the main cog.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.jameco.com
    ·
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-01-23 13:27
    Can you post your code, Im trying to do the same thing.
    JMLStamp2p
  • MacGeek117MacGeek117 Posts: 747
    edited 2008-01-23 16:40
    Code is poosted in the first post.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.jameco.com
    ·
  • MacGeek117MacGeek117 Posts: 747
    edited 2008-01-23 19:34
    I tried allocating more stack, and now it acks like it found the slave, even though the slave isn't even connected.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.jameco.com
    ·
  • MacGeek117MacGeek117 Posts: 747
    edited 2008-01-23 19:46
    The Receive cog isn't even running.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.jameco.com
    ·
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-01-24 23:55
    Robogeek,
    When I try to open your sample code it fails. It sounds like we are trying to accomplish the same thing and could probally help each other.
    JMLStamp2p

    PS: I am using two props and two trancievers to communicate between each other for a timer circuit at our industrial plant. Could use some help :>)
  • MacGeek117MacGeek117 Posts: 747
    edited 2008-01-25 03:01
    JMLStamp2p, PM me with the details of your project.

    I have posted the most recent code.

    The green LED is there to let me know if the receive cogs detects the slave. It never lights up!mad.gif

    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.jameco.com
    ·
  • MacGeek117MacGeek117 Posts: 747
    edited 2008-01-26 16:10
    I do really need help on this. This code is the backbone of my project! If you need more info than is provided, please ask.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.jameco.com
    ·
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-01-26 16:15
    RoboGeek,
    For some reason I cannot open your code, could you save it as a text file and send it to
    JMLStamp2p@aol.com
    Thanks,
    John.
  • MacGeek117MacGeek117 Posts: 747
    edited 2008-01-26 23:36
    I sent the code.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.jameco.com
    ·
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-01-28 23:53
    Hello RoboGeek,
    Let me run over your code to begin with to make sure I understand it correctly.

    CommTestRX:

    I see that you are starting your serial set-up through Full_Duplex_Serial "Which starts a new cog in itself". Then you are starting another new cog to handle the Check_For_ID Method and your leaving the return result as is without adjusting it. The next line "repeat until ops:= true" is handled by original startup cog and the New "Check_For_ID" cog is running in a loop checking to see if its return result is == to ID. If it does let byte varible ops := True. When ops is True then the original cog calls Full_Duplex_Serial which transmits "master".

    Before we go on please let me know if I am interperting your code correctly and tell me how you have your Hardware set up.

    1) Did you mean to declare your varible Char as "Char" or "_Char" ?
    2) You may want to install a "Stop" Method before comm.Start to prevent your Stack from overflow "until" you get your code completed, may prevent garbage.
    3)I have found that keeping things simple to begin with untill the code works is best and therefore giving your cognew command a Alias for the Result varible might be better.
    Success := (Cog := cognew (Check_For-ID(own), @Stack) + 1
    Therfore making your boolean result value "Success" either "0" no cog has been started or "1-8" if a cog was started.
  • MacGeek117MacGeek117 Posts: 747
    edited 2008-01-29 02:53
    Yes, you are right.
    1. ignore 'Char'. I didn't know if I was going to use it
    2. I will try this
    3. Will try this also
    Thanks for your help!
    RoboGeek

    P.S. Also, I know the slave code works, It's just the master code that's not working.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.jameco.com


    Post Edited (RoboGeek) : 1/29/2008 2:58:45 AM GMT
Sign In or Register to comment.