Announcement

Collapse
No announcement yet.

Continuous Servo Motor GamePad control ???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Continuous Servo Motor GamePad control ???

    Hi,

    We are trying to use a continuous servo motor as a conveyor belt. Here's a screen shot of our code:

    https://www.dropbox.com/s/u7cdayo84a...entor.pdf?dl=0

    The motor tries to spin, but doesn't seem controlled by the GamePad controller. The other functions of the GamePad work properly, (we've done DC motors, but this is our first servo motor program). We probably don't have it right. How can we have the motor spin one way when we press DPad Left, and the opposite way when we press DPad Right, and not spin when the GamePad isn't pressed.

    Thanks for any help! Team 6041

  • #2
    We've tried different things with the "Direction" "Position" and moving around the Call. We can't figure it out, and it isn't covered in the Intelitek lesson, just a regular servo.

    Comment


    • #3
      Originally posted by RoboticsFun View Post
      Hi,

      We are trying to use a continuous servo motor as a conveyor belt. Here's a screen shot of our code:

      https://www.dropbox.com/s/u7cdayo84a...entor.pdf?dl=0

      The motor tries to spin, but doesn't seem controlled by the GamePad controller. The other functions of the GamePad work properly, (we've done DC motors, but this is our first servo motor program). We probably don't have it right. How can we have the motor spin one way when we press DPad Left, and the opposite way when we press DPad Right, and not spin when the GamePad isn't pressed.

      Thanks for any help! Team 6041
      I don't have direct experience with a continuous servo but I'm under the impression that you need to give a series of positions to get it to rotate continuously. Because TeleOp mode in App Inventor is based on a continuous loop you need the loop to give it a sequence of positions. If I'm right, this will be much more complicated than your current code. You could change your current code to set a direction variable based on whether left or right has been pressed. For instance, left could cause you to set the direction variable to a small positive value and right could cause you to set it to a small negative value. In addition to the direction variable you could have a position variable that is initialized to the initial desired position of the servo. Each time around the loop you could add the value of the direction variable to the position variable and then send the new position value to servo. The value of the direction variable would needs to be quite small because teleop loop is executed many times per second.

      ...Bruce

      ...Bruce

      Comment


      • #4
        Originally posted by schaferbw View Post
        I don't have direct experience with a continuous servo but I'm under the impression that you need to give a series of positions to get it to rotate continuously. Because TeleOp mode in App Inventor is based on a continuous loop you need the loop to give it a sequence of positions. If I'm right, this will be much more complicated than your current code. You could change your current code to set a direction variable based on whether left or right has been pressed. For instance, left could cause you to set the direction variable to a small positive value and right could cause you to set it to a small negative value. In addition to the direction variable you could have a position variable that is initialized to the initial desired position of the servo. Each time around the loop you could add the value of the direction variable to the position variable and then send the new position value to servo. The value of the direction variable would needs to be quite small because teleop loop is executed many times per second.
        Normally, the range of the servo position is between 0 and 1 in App Inventor. If the servo controller allows for values larger than 1 for continuous servos, you may be able to keep increasing the position using the direction variable. Otherwise, you will need to limit the value in the same way that an analog clock has limited values -- rotating from 1 to 12 and then back to 1 again. The math mod function can be useful for this or you can use an IF-then-else. You may need to do some experiments to determine the range for the servo position.

        Comment


        • #5
          Originally posted by schaferbw View Post
          I don't have direct experience with a continuous servo but I'm under the impression that you need to give a series of positions to get it to rotate continuously. Because TeleOp mode in App Inventor is based on a continuous loop you need the loop to give it a sequence of positions. If I'm right, this will be much more complicated than your current code. You could change your current code to set a direction variable based on whether left or right has been pressed. For instance, left could cause you to set the direction variable to a small positive value and right could cause you to set it to a small negative value. In addition to the direction variable you could have a position variable that is initialized to the initial desired position of the servo. Each time around the loop you could add the value of the direction variable to the position variable and then send the new position value to servo. The value of the direction variable would needs to be quite small because teleop loop is executed many times per second.

          ...Bruce

          ...Bruce
          Thanks for the reply. We definitely want to keep things simple. If we have to, we will talk to the builders to switch it back to a DC motor since we know how to program that. But if anyone has experience with that motor, we are interested in the code.

          Comment


          • #6
            Originally posted by schaferbw View Post
            Normally, the range of the servo position is between 0 and 1 in App Inventor. If the servo controller allows for values larger than 1 for continuous servos, you may be able to keep increasing the position using the direction variable. Otherwise, you will need to limit the value in the same way that an analog clock has limited values -- rotating from 1 to 12 and then back to 1 again. The math mod function can be useful for this or you can use an IF-then-else. You may need to do some experiments to determine the range for the servo position.
            We've programmed a regular servo motor using this same TeleOp program concurrently, and that servo is working properly. This continuous servo motor is not, it is turning on before the gamepad buttons are even pressed, and even though it is trying to spin, it barely does. You can tell it is powered though. The regular servo is working as expected. I don't know if adjusting ranges will fix that other technical issue it has. The DC motor programming is pretty straightforward, so we thought the servos would be also.

            Comment


            • #7
              After more testing, this is kind of what we wanted (screenshot code):

              https://www.dropbox.com/s/kox70f6uk5...r%202.pdf?dl=0

              I took out the Call button and the program seems fine without it. The motor is moving a little more in a controlled fashion, but I'm still going to mess around with it for precision. Wanted to share it just in case someone else was interested.

              Comment


              • #8
                A continuous servo rotates continuously in one direction when the "position" is set to "1" and in the opposite direction when the "position" is set to "0". It stops and holds position when the "position" is set to "0.5". We actually found that one of our continuous servos would not stop unless we set it to "0.55". The speed of the rotation can be adjusted by using values between "0.5" and "1" in one direction or between "0.5" and "0" in the other direction. We did not use the servo "direction" setting since it is not really necessary, but it may be useful?

                Comment


                • #9
                  Originally posted by arlielong View Post
                  A continuous servo rotates continuously in one direction when the "position" is set to "1" and in the opposite direction when the "position" is set to "0". It stops and holds position when the "position" is set to "0.5". We actually found that one of our continuous servos would not stop unless we set it to "0.55". The speed of the rotation can be adjusted by using values between "0.5" and "1" in one direction or between "0.5" and "0" in the other direction. We did not use the servo "direction" setting since it is not really necessary, but it may be useful?
                  A much simpler solution! I'm glad my approach isn't necessary for continuous sensors.

                  ...Bruce

                  Comment


                  • #10
                    Originally posted by arlielong View Post
                    A continuous servo rotates continuously in one direction when the "position" is set to "1" and in the opposite direction when the "position" is set to "0". It stops and holds position when the "position" is set to "0.5". We actually found that one of our continuous servos would not stop unless we set it to "0.55". The speed of the rotation can be adjusted by using values between "0.5" and "1" in one direction or between "0.5" and "0" in the other direction. We did not use the servo "direction" setting since it is not really necessary, but it may be useful?
                    In reply #7, you can see my code is set to "position 1" and "position 0". The motor does not keep rotating, it seems to act like a regular 180 degree motor. Did you program that with a Gamepad type of button or in an autonomous setting? We are trying to set it up with the Gamepad buttons, press a button and it spins one way, press another button to spin the opposite direction. Right now, it does that but stops.

                    Comment


                    • #11
                      And are the programming blocks in Designer the same for the Continuous Rotation Servo and for the regular Servo? I used the same one for both.

                      Comment


                      • #12
                        Originally posted by RoboticsFun View Post
                        And are the programming blocks in Designer the same for the Continuous Rotation Servo and for the regular Servo? I used the same one for both.
                        Yes, I think so. A continuous servo is a servo that has has its key feature disabled. To quote the Adafruit web site, "The first continuous rotation servos were simply hacked RC servos. Enterprising hobbyists removed the physical hard-stops and hard-wired the controller feedback to think it was always at the middle position. Since the controllers are 'proportional', the motor speed and direction is proportional to the difference between the command position and the measured position. This simple hack results in a miniature self-contained reversible, speed controlled gear-motor."

                        Comment


                        • #13
                          Originally posted by RoboticsFun View Post
                          In reply #7, you can see my code is set to "position 1" and "position 0". The motor does not keep rotating, it seems to act like a regular 180 degree motor. Did you program that with a Gamepad type of button or in an autonomous setting? We are trying to set it up with the Gamepad buttons, press a button and it spins one way, press another button to spin the opposite direction. Right now, it does that but stops.
                          It does sound like your servo is a 180 degree servo rather than a continuous. A continuous servo is created by "hacking" a regular servo to think it's always at the mid position. Perhaps yours hasn't been hacked.

                          Comment


                          • #14
                            This is how we program a continuous rotation servo using the DPAD_Left and Right

                            IF FtcGamePad2.DpadLeft
                            THEN set RPinion_Servo.Position to 0.9
                            ELSE IF FtcGamePad2.DpadRight
                            THEN set RPinion_Servo.Position to 0.1
                            ELSE set RPinion_Servo.Position to 0.5

                            And this works perfectly. As long as we're pressing and holding Dpad_Left it moves Left and as long as we're pressing Dpad_Right it moves right. When we're not pressing either, it stops.

                            I hope this helps!

                            Comment


                            • #15
                              Just to report, our problem was hardware, not programming. The conveyor belt was too overloaded. Once it was simplified, our continuous motor now spins as designed. Thanks for all the tips, the programming so far is working now!

                              Comment

                              Working...
                              X