Home Forums PS2X PlayStation 2 Controller Library Support Forum a function with a total of 1500ms delays makes it unstable

This topic contains 3 replies, has 2 voices, and was last updated by  Bill 4 years, 5 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3261

    wkinne
    Member

    I am trying to write code for my hexapod, but when I write a walkForward function add delays into the walking sequence to give the servos time to move to the new positions I am limited to less than 1500 ms total for the function. If I go beyond that, the arduino stats reporting buttons being pushed and released that are not being touched. I have experimented and it is a total of all delays that messes things up.

    Any ideas why and if there is a way around it?

    Also I get a delay when pushing buttons, I assume it is the “delay(50);” statement at the end of your sample that s causing it, but if I remove the delay the arduino quits finding the PS2 controller.

    Any ideas?

    This will work:

     

    void walkForward()

    {

    Serial.println(“Forward working”);

    legOneServoTwo.write(UP);

    legFourServoTwo.write(UP);

    legFiveServoTwo.write(UP);

    delay(225);                                                         // this delay is to give to servos time to

    legOneServoOne.write(FORWARD);        // move  before the next part of a step

    legTwoServoOne.write(BACKWARD);    // but if I increase the delays to 250 the

    legFourServoOne.write(FORWARD);     // arduino gets unstable and goes crazy

    legThreeServoOne.write(BACKWARD);

    legFiveServoOne.write(FORWARD);

    legSixServoOne.write(BACKWARD);

    delay(225);

    legOneServoTwo.write(DOWN);

    legFourServoTwo.write(DOWN);

    legFiveServoTwo.write(DOWN);

    delay(225);

    legTwoServoTwo.write(UP);

    legThreeServoTwo.write(UP);

    legSixServoTwo.write(UP);

    delay(225);

    legTwoServoOne.write(FORWARD);

    legOneServoOne.write(BACKWARD);

    legThreeServoOne.write(FORWARD);

    legFourServoOne.write(BACKWARD);

    legSixServoOne.write(FORWARD);

    legFiveServoOne.write(BACKWARD);

    delay(225);

    legTwoServoTwo.write(DOWN);

    legThreeServoTwo.write(DOWN);

    legSixServoTwo.write(DOWN);

    delay(225);

    }

     

    But if delay is increased to 250 then it goes crazy.

     

    tia

    wkinne

    #3262

    wkinne
    Member

    I have been able to lower the “delay(50);) to “delay(10);” but my hexapod still continues to walk for several seconds after I release the joystick.

     

    Anyone have any ideas how to fix this?

     

    tia

    wkinne

    • This reply was modified 4 years, 6 months ago by  wkinne.
    #3264

    wkinne
    Member

    Does anyone know if the delay in my hexapod is caused by the PS2 library or the arduino script?

    #3287

    Bill
    Member

    wkinne,

    you’d have to post all of your code before anyone could really help.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.