PBasic Problems: Wheel_Motion.bs2
koolitude
Posts: 37
I've been trying to modified the Wheel_Motion.bs2 : http://www.parallax.com/dl/sw/Encoder.zip
Since I would like to use a digital compass (together with the encoders) to provide feedback signals to control my robot, I try to add a GetBearing subrountine (a subrountine to read the compass bearing using I2C) to the DoMove subrountine (the original subrountine to perform wheels coordination in Wheel_Motion.bs2).
The compass provides information which serves as the absolute reference for the robot.· The idea is to correct the error due to the·problem of relative referencing method·used by wheel coordination.·
So, I try to read the compass before every signal pulse to be generated by the DoMove subrountine to the servo motors.· However, whenever I add GetBearing into DoMove, the DoMove will be executed again and again.
In other words, originally without adding GetBearing, DoMove will be executed once; after adding GetBearing to the first line of DoMove, it·repeats itself a few seconds after finishing the previous DoMove.
It is quite abnormal as the GetBearing subrountine has nothing to do with the DoMove subrountine; the former one is just to read the compass using I2C protocol while the later one is just an algorithm to determine the value to pulse the servo motors.·
I am so confused.· I would be grateful if you could give me some advices.
Attached please also find the modifed .bs2 file·(Wheel_Motion_Compass) on which·I'm now working.
Thank you very much.
P.S. I'm using a CMPS03 compass module: http://www.robot-electronics.co.uk/htm/cmps3doc.shtml
Post Edited (koolitude) : 3/16/2007 7:29:56 AM GMT
Since I would like to use a digital compass (together with the encoders) to provide feedback signals to control my robot, I try to add a GetBearing subrountine (a subrountine to read the compass bearing using I2C) to the DoMove subrountine (the original subrountine to perform wheels coordination in Wheel_Motion.bs2).
The compass provides information which serves as the absolute reference for the robot.· The idea is to correct the error due to the·problem of relative referencing method·used by wheel coordination.·
So, I try to read the compass before every signal pulse to be generated by the DoMove subrountine to the servo motors.· However, whenever I add GetBearing into DoMove, the DoMove will be executed again and again.
In other words, originally without adding GetBearing, DoMove will be executed once; after adding GetBearing to the first line of DoMove, it·repeats itself a few seconds after finishing the previous DoMove.
It is quite abnormal as the GetBearing subrountine has nothing to do with the DoMove subrountine; the former one is just to read the compass using I2C protocol while the later one is just an algorithm to determine the value to pulse the servo motors.·
I am so confused.· I would be grateful if you could give me some advices.
Attached please also find the modifed .bs2 file·(Wheel_Motion_Compass) on which·I'm now working.
Thank you very much.
P.S. I'm using a CMPS03 compass module: http://www.robot-electronics.co.uk/htm/cmps3doc.shtml
Post Edited (koolitude) : 3/16/2007 7:29:56 AM GMT
Comments
··Main -> Move -> DoMove -> GetBearing -> I2CWordRead -> I2CStart
The limit is four.
-Phil
So... in order to solve this, I gotta combine some subrountines into one, right?
or... there is another smarter way to fix this problem?
Thank you very much!
-Phil
cuz I would like to check the compass bearing just before any single pulse to be generated by DoMove...
If I call GetBearing from Main, then I just check the compass bearing once for every Move I called...
Anyway, thank you very much for your suggestion..
Post Edited (koolitude) : 4/10/2007 10:06:41 AM GMT