Tuesday, 28 May 2019

Pan/Tilt Head Using the NodeMCU L293D shield and TowerPro MG-996R Servomotor

Left: Dual TowerPro MG-996R, right: L293D NodeMCU ESp-12E Shield Click on picture for youtube video
I had always wanted a pan/tilt head. There is some deterrence value to the baleful gaze of a pan/tilt camera following your every move. While pan/tilt cameras are cheap and easily available, they are less useful at night: their range is a lot shorter.  It would be nice to move an LED torchlight together with the camera.

You could tape an LED torch onto your favorite IP camera, but the mechanism is often made of  plastic and the extra weight wears it out fast. A homebrew pan/tilt head would be nice ...

The L293D NodeMCU ESP-12E motor shield was such an easy build (see part 1, part 2, and part 3) I quickly bought two Towerpro MG-996R servomotors for just RM22.90 (about USD5) each and matching mounting brackets for RM10.30.

Towerpro MG-996R Servomotor

And matching accessories

The brackets were listed in lelong.com as:

"Arduino Multi Purpose Servo Motor Holder Bracket MG995 MG996"


Arduino Multi Purpose Servo Motor Holder Bracket MG995 MG996

I found the mechanical assembly work quite mystifying, but Starmaxtrek's youtube video was a godsend:

Click on picture for Youtube video on mechanical assembly
Documentation for the MG-996R took a little digging, but you can find a copy here.

For testing, I shorted VM to VCC on the L293D and powered everything from VCC using a USB smartphone charger.  The only change in the ESP-12E program was to change the PWM frequency to 50Hz:
  analogWriteFreq(50);

For my setup I found the servomotors reacted only to PWM values between 1-25%. The shaft rotated some 120 degrees and the pan/tilt head whirred about with a gentle menace.

The youtube video is here.

Life is good - Happy Trails.

3 comments: