Calibration

Now that the arm and chassis are built, we need to calibrate the motors and servos to ensure that they react in the correct way to the commands from the web application. In the case of the servos, do not attempt to move them too far as this will cause damage to them or other parts of the robotic arm.

Chassis motors

Firstly, we will ensure that the chassis motors behave correctly. This is simply a case of running the motors in each of their directions to ensure that the chassis moves in the direction intended.

When running in forward or reverse motion, if one motor is running in the wrong direction, this can be corrected by swapping the polarity of the motor. You can swap the polarity by swapping the connections on the two wires leading to it from the relay board.

When the motor runs in the clockwise or counter clockwise rotation, if the base rotates in the wrong direction, then both motors need to have their polarity swapped.

Arm 2 and hand servos

Since these two servos operate independently, they are fairly simple to calibrate, as all that needs to be done is to find the limits of the range you want the servos to move in.

To find this, we will use the RPIO library from the Python console to set different values on the servo:

  1. First, from an SSH session on the Pi, open a new Python console as root (root access is required as the library needs to access memory directly to control the GPIO pins):
    sudo python
    
  2. Next, import the RPIO library using the following line and create a Servo object:
    import RPIO.PWM as pwm
    s = pwm.Servo()
  3. Now, you can set the position of the servo using the following line of code, where GPIO is the GPIO number the servo is connected to and VALUE is the timing value for the PWM signal sent to the servo (this should be between 500 and 2500):
    s.set_servo(GPIO, VALUE)
  4. Repeat the last step until you find good values for the maximum and minimum values of the servo that give reasonable limits to the motion of the servo.

Once the optimal value has been found, it should be entered in the robot_arm.conf configuration file in the appropriate _MAX and _MIN configuration options.

The arm 1 servos

Since these two servos operate parallely with each other, the calibration procedure is slightly more complex. We must first determine a point on both the servos where they are in equal positions and are not moving to try and cancel each other out.

  1. Firstly, open a Python console as before:
    sudo python
    
  2. Import the GPIO library:
    import RPIO.PWM as pwm
  3. Next, create two servo objects, one for each servo:
    s1 = pwm.Servo()
    s2 = pwm.Servo()
  4. Now, set a starting value (VALUE) for the first servo (on GPIO number, GPIO) that is within the range of movement for the lower section of the arm (1500 is a good starting value; however, you may need to experiment to find the best value):
    s1.set_servo(GPIO, VALUE)
  5. Now, we need to find a value (VALUE) on the second servo (on GPIO number, GPIO) at which both servos are at rest and not trying to move. This indicates that the two servos are in the same position. Note that you may need to move the arm slightly to stop the servos from trying to move. The weight of the arm may keep the servos in motion even though they are in the same position:
    s2.set_servo(GPIO, VALUE)
  6. Once the two servos are in the same position, make a note of the two values (for example, 1400 and 1600) and calculate the midpoint of the two (1500). This value should also be a position in which both the servos will be in the same position.
  7. Now that we know this value, we can define the sets function, which will set both the servos to a given offset, allowing us to derive the upper and lower limits for both servos. Here, GPIO_1 and GPIO_2 are the GPIO numbers that each servo is connected to and VAL is the midpoint value calculated in the previous step:
    def sets(position_delta):
        s1.set_servo(GPIO_1, VAL + position_delta)
        s2.set_servo(GPIO_2, VAL – position_delta)
  8. We can now use trial and error, as with the previous servos, to find the optimal maximum and minimum servos positions by making calls to the sets function:
    sets(-300)
    sets(0)
    sets(1000)
    …
  9. Now that we have the maximum and minimum values that can be passed to the sets function, we can easily derive the values that need to be set in the configuration file as (where VAL is the calculated midpoint, SETS_MIN and SETS_MAX are the maximum and minimum values passed to the sets function, SETS_MIN is negative, and SETS_MAX is positive):
    • ARM_1_A_SERVO_MIN = VAL + SETS_MIN
    • ARM_1_A_SERVO_MAX = VAL + SETS_MAX
    • ARM_1_B_SERVO_MIN = VAL - SETS_MAX
    • ARM_1_B_SERVO_MAX = VAL – SETS_MIN

Once these values are derived, they can be entered into the robot_arm.conf configuration file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.27.72