Shop OBEX P1 Docs P2 Docs Learn Events
Cogs and Methods and confusion... — Parallax Forums

Cogs and Methods and confusion...

WolfbrotherWolfbrother Posts: 129
edited 2010-01-09 16:44 in Propeller 1
Hi all,

I'm still not done with the stepper motor debacle of the past week, but thought I would work on the servo motors portion of the design. I downloaded a nice servo driver from the OBEX and thought it would be no problem to update this to do two servo motors. I must admit, I don't get it. I followed the lesson 5 lab on Methods and Cogs·with LEDs and thought I understood and then modified the code to call two cogs that would control a servo on pin 7 and a separate one on pin 8. I have attached my code. Here's what I don't get at all. When I download it to my propeller robot control board, the servo on pin 8 spins just fine, pin 7 just sits. Until the one on pin 8 does it's spins 26 times and then the one on pin 7 wakes up and works as well. I'm sure there's a reason, but I can't see it. Could someone tell me what I am missing that it works this way.

Also, this may be really dumb and I apologize in advance, but with this processor do people typically have some sort of debugger where you can execute the code and see what's happening. What's the recommendation there? ·I basically bruteforce method with Debug on the basic stamp and can sort of figure out what's going on. I can't find the equivalent on the propeller.

My goal for this program is to have these two motors running separately and as part of a larger system with a DC motor, a stepper and a hall effect sensor.

Thanks,

Dave

Comments

  • KyeKye Posts: 2,200
    edited 2010-01-09 02:48
    Try my dual servo driver in the obex. Its called "dual servo driver".

    It should work nicely.

    Also, use view port for debuging. Its on the parallax propeller download page.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2010-01-09 03:19
    ViewPort is a great debugging tool.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Signature space for rent!
    Send $1 to CannibalRobotics.com.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-01-09 04:56
    Why not use one of the servo objects that come with the Spin Tool (Servo23v5 or PWM_32_v2)? Each can drive multiple servos.

    John Abshier
  • WolfbrotherWolfbrother Posts: 129
    edited 2010-01-09 06:22
    This code is from the OBEX, it's the RC servo control that was a featured object this past week. I'm all for using someone's object, what I am not getting is why I can't call the object/method in my program. I am thinking I am doing it just like the demos I ran through, but the first motor called doesn't spin until the other one has spun 26 times. I don't get that at all. From what I understand if my program looks like
    line #1 PUB Demo
    line #2 cognew(MoveMotor(7),@Stack[noparse][[/noparse]0])
    line #3 cognew(MoveMotor(8),@Stack[noparse][[/noparse]10])

    Then Line #2 should start executing and open a new cog (I'm guessing COG1), then the next line in the main program (running on COG0) executes and starts a new cog (COG2). It should be almost the same time to execute, why would it wait for so long?

    I downloaded the Viewport 30 day version, this should really help me out, thanks.
  • kuronekokuroneko Posts: 3,623
    edited 2010-01-09 06:39
    Wolfbrother said...
    It should be almost the same time to execute, why would it wait for so long?
    It seems that the first cog samples position before you initialise it to 50 (i.e. 0). Which means its first waitcnt waits for about 53 sec (rollover). Then it joins the other one.

    So either initialise position to something useful before starting the cogs or synchronise the cogs in some other way.
  • WolfbrotherWolfbrother Posts: 129
    edited 2010-01-09 06:50
    Hi Kuroneko,

    Thank you. I tried exactly what you said and it works just fine. I should have noticed that I initalize the pin and didn't have a valid value of position. I would have taken forever to figure that one out.

    Thanks to everyone for helping me.

    Dave
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-01-09 08:42
    Hi Wolfbrother,

    if you are familiar with the DEBUG-command of the Basic stamp

    The equivalent on the propeller is to use a serial driver like FullDuplexSerialPlus
    which you find here C:\Program Files\Parallax Inc\Propeller Tool v1.2.6\Examples\PE Kit\6 - Objects Lab\FullDuplexSerialPlus.spin

    See attached file
    best regards

    Stefan
  • WolfbrotherWolfbrother Posts: 129
    edited 2010-01-09 16:44
    Hi Stefan,

    That's perfect. Thanks, I'll use that today to help me debug. Although now that I have seen this Viewport app, I think I am wanting that one..

    Thanks,

    Dave
Sign In or Register to comment.