Showing posts with label tilt. Show all posts
Showing posts with label tilt. Show all posts

Friday, February 17, 2017

Raspberry Pi and the Duinotech Servo (SG90) Pan and Tilt Bracket

Building the Duinotech Pan and Tilt Bracket (Part 2)



Back from our necessary detour to put together some python servo code, we will continue with the build of the Duinotech pan and tilt bracket. The first part of the build is available in part 1.



Assembling the Tilt Unit



  • Mount the servo so that the shaft aligns with the pivot hole and attach with the two screws as shown.



  • Fit the single-armed servo horn into the recess in the pan-base and attach it with one of the smallest screws. I had to trim the end of the servo horn to allow it to fit.



  1. Align the servo shaft from the tilt bracket with the hole in the servo horn.
  2. Snap the tilt bracket into place, using a small screwdriver as a lever to lift the pivot hole over the pivot pin on the tilt-base.



  • Make sure that the tilt bracket can move through the full 180 degrees of servo motion. If not, detach it from the servo horn, rotate and re-install.
  • Complete the assembly by securing the horn to the shaft with a short screw.
  • Use one of the shorter screws to attach the base to the servo shaft. The longer mounting screws packed with some servos will damage the servo if screwed in too far.



Testing both Servos


Using the python servo library we created earlier we can test both the pan and tilt functionality. Our pan control input is connected to GPIO 5 and tilt to GPIO 6. There is just enough 5V pins to connect two servos, moving forward we will need a 5V rail for additional sensors (like ultrasonic). At the same time we will install a ground rail to make wiring easier.

To start try testing the two servos independently, run RS_Servo and change the control pin to the relevant number. Note the min and max duty cycle for each servo, we will use these in the Robot class that we will develop next. The Robot class will be the software framework on which we will add additional functionality.

In the interim, once you have calibrated your servo's using RS_Servo, you can use the following test program to run both servo's through their paces. Note that I have set min and max duty cycles for both servo's when I initialise them.

# PT_Test.py - Test Pan and Tilt Servo's
#
# 18 February 2017

import RPi.GPIO as GPIO
from RS_Servo import Servo

# create new servo's to be controlled from GPIO pins 5 & 6
pan_servo = Servo(5, 3, 11)    
tilt_servo = Servo(6, 2, 11)

# start PWM for servo's
pan_servo.start()
tilt_servo.start()

print(pan_servo)
print(tilt_servo)
print("Servo instances: ", Servo.count())

try:
    while True:
        print("\nScanning (CTRL c to exit)...")
        pan_servo.scan()
        tilt_servo.scan()
except KeyboardInterrupt:
    print("\n-- CTRL-C: Terminating program --")
finally:
    print("Cleaning up PWM and GPIO...")
    pan_servo.cleanup()
    tilt_servo.cleanup()
    GPIO.cleanup()
    print("Done.")


Sunday, February 12, 2017

Raspberry Pi and the Duinotech Servo (SG90) Pan and Tilt Bracket

Building the Duinotech Pan and Tilt Bracket (Part 1)


As part of our mission to build Alexa M (a Raspberry Pi based robot with voice recognition), we have decided to include an ultrasonic sensor and/or camera. To that end we will include a pan/tilt bracket with a couple of servos.

The kit we chose was the duinotech Pan and Tilt Action Camera Bracket Mount for 9G Servos. This is cheap and designed to operate with two of the TowerPro SG90 MicroServo's.

While they are cheap, construction details are best described as scant (or perhaps missing). You do get a before and after shot, but the after shot only shows one servo.



It looks like Adafruit supply a similar unit, so here are the construction details from them.

Assembling the Base (Pan Unit)

  • Insert the servo into one side of the pan bracket.
  • Make sure that the servo shaft is at the opposite side from the pivot point for the tilt bracket.
  • Assemble the second side of the pan bracket to enclose the servo.
  • Attach the two halves of the pan bracket using two of the small screws.



  • Attach the 4-armed servo horn to the servo shaft using one of the short screws as shown.
  • Use one of the shorter screws to attach the base to the servo shaft. The longer mounting screws packed with some servos will damage the servo if screwed in too far.
  • Align the servo horn so that the longer arms are vertical when the servo is at the midpoint of its rotation - don't worry too much about this you will need to move it when you calibrate the servo.
  • Attach the base to the servo horn, using 4 of the smallest screws as shown. I had to trim the horn so it would fit in the base.


Before assembling the tilt bracket in the next post we will test our pan servo with the Raspberry Pi and create a servo library that we can reuse.

Raspberry Pi Robot - Alexa M

Raspberry Pi Robot


As mentioned in an earlier post we recently acquired an Amazon Echo Dot. We have also been playing around with a 2WD robot chassis and the Raspberry Pi. Put all these together and you have the makings of an interesting robot. The folks over at Dexter Industries obviously had the same idea.


We are going to have a crack at making our own version - called Alexa M (to differentiate it from our Echo Dot). We will do this in stages to ensure each part works!

In part 1, we will construct a pan/tilt bracket which could hold an ultrasonic sensor or a camera.