PDA

View Full Version : Help with code running in 2 cogs



MacGeek117
01-23-2008, 03:14 AM
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 (http://www.parallax.com/)
www.goldmine-elec.com (http://www.goldmine-elec.com)
www.expresspcb.com (http://www.expresspcb.com)
www.jameco.com (http://www.jameco.com)

Dgswaner
01-23-2008, 05:15 AM
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

mosquito56
01-23-2008, 06:03 AM
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.

MacGeek117
01-23-2008, 06:30 AM
No, just the main cog.
RoboGeek

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

Adam Savage, Mythbusters
www.parallax.com (http://www.parallax.com/)
www.goldmine-elec.com (http://www.goldmine-elec.com)
www.expresspcb.com (http://www.expresspcb.com)
www.jameco.com (http://www.jameco.com)
и

JMLStamp2p
01-23-2008, 08:27 PM
Can you post your code, Im trying to do the same thing.
JMLStamp2p

MacGeek117
01-23-2008, 11:40 PM
Code is poosted in the first post.
RoboGeek

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

Adam Savage, Mythbusters
www.parallax.com (http://www.parallax.com/)
www.goldmine-elec.com (http://www.goldmine-elec.com)
www.expresspcb.com (http://www.expresspcb.com)
www.jameco.com (http://www.jameco.com)
и

MacGeek117
01-24-2008, 02:34 AM
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 (http://www.parallax.com/)
www.goldmine-elec.com (http://www.goldmine-elec.com)
www.expresspcb.com (http://www.expresspcb.com)
www.jameco.com (http://www.jameco.com)
и

MacGeek117
01-24-2008, 02:46 AM
The Receive cog isn't even running.
RoboGeek

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

Adam Savage, Mythbusters
www.parallax.com (http://www.parallax.com/)
www.goldmine-elec.com (http://www.goldmine-elec.com)
www.expresspcb.com (http://www.expresspcb.com)
www.jameco.com (http://www.jameco.com)
и

JMLStamp2p
01-25-2008, 06:55 AM
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 :>)

MacGeek117
01-25-2008, 10:01 AM
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!http://forums.parallax.com/images/smilies/mad.gif

RoboGeek

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

Adam Savage, Mythbusters
www.parallax.com (http://www.parallax.com/)
www.goldmine-elec.com (http://www.goldmine-elec.com)
www.expresspcb.com (http://www.expresspcb.com)
www.jameco.com (http://www.jameco.com)
и

MacGeek117
01-26-2008, 11:10 PM
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 (http://www.parallax.com/)
www.goldmine-elec.com (http://www.goldmine-elec.com)
www.expresspcb.com (http://www.expresspcb.com)
www.jameco.com (http://www.jameco.com)
и

JMLStamp2p
01-26-2008, 11:15 PM
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.

MacGeek117
01-27-2008, 06:36 AM
I sent the code.
RoboGeek

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

Adam Savage, Mythbusters
www.parallax.com (http://www.parallax.com/)
www.goldmine-elec.com (http://www.goldmine-elec.com)
www.expresspcb.com (http://www.expresspcb.com)
www.jameco.com (http://www.jameco.com)
и

JMLStamp2p
01-29-2008, 06:53 AM
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.

MacGeek117
01-29-2008, 09:53 AM
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 (http://www.parallax.com/)
www.goldmine-elec.com (http://www.goldmine-elec.com)
www.expresspcb.com (http://www.expresspcb.com)
www.jameco.com (http://www.jameco.com)


Post Edited (RoboGeek) : 1/29/2008 2:58:45 AM GMT