Cogs and Methods and confusion...
Wolfbrother
Posts: 129
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
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
It should work nicely.
Also, use view port for debuging. Its on the parallax propeller download page.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Signature space for rent!
Send $1 to CannibalRobotics.com.
John Abshier
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.
So either initialise position to something useful before starting the cogs or synchronise the cogs in some other way.
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
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
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