Shop OBEX P1 Docs P2 Docs Learn Events
Some phenomenons in my experiment. — Parallax Forums

Some phenomenons in my experiment.

kevinspacekevinspace Posts: 56
edited 2011-01-24 19:51 in Propeller 1
Hello, everybody.
After my test, I discover there are some phenomenons in my experiment.
This is my program1:
Program1diagram.JPG

And this is my program2:
Program2diagram.JPG

Above the description, I discovered the results of the program1 and program2 which were different.

Could anybody explain the phenomenon?

This is my test code
code.rar

Thanks a lot.
440 x 587 - 44K
438 x 570 - 39K

Comments

  • JasonDorieJasonDorie Posts: 1,930
    edited 2011-01-24 19:51
    I haven't looked too closely at the code, but in both cases you are starting the controller for Servo #2 before you tell Servo #1 where to go, and are updating both servos every 5 seconds. Since you start the Servo #2 controller very shortly before the code for Servo #1, Servo #2 lags behind by 5 seconds.

    The code in Control_servo2 is running in parallel with the code in Control_servo1 immediately after the coginit function, so Control_servo2 is calling SERVO.SetRamp at the same time the Servo1 function is calling SERVO.Start, and so on.

    Your code is running like this:
    Servo1          Servo2
    
                    Start
                    Get position of Servo1  (notice that Servo1 hasn't even started running yet)
                    Move to that position
    
    Move to 1500
    
                    Wait 5 seconds
    Wait 5 seconds
    
                    Get position of Servo1
                    Move to that position
    Move to 2300
    
                    Wait 5 seconds
    Wait 5 seconds
    
Sign In or Register to comment.