Bescor MP-101 Hack Part 2

In part 2, we’ll upload our sketch to the Arduino.

Step 1: Plugin the Arduino to the Computer

Connect the Arduino using an usb cable.  Note:  Disconnect the DIN cable from the Bescor before proceeding.

Open up the Arduino program and make sure the Arduino is selected on the right COM port.

Com Port

Step 2: Upload the Sketch

This sketch is a work in progress and can be modified and used freely.

Updated: 4-6-2015
https://github.com/mattalford/ArduinoPanTilt/blob/master/ArduinoPanTilt.ino

Sketch

Press the right arrow to upload the sketch.

Sweet and simple!  Please ask any questions if I missed something.

27 Comments

  1. Hi,

    I’m looking at getting the Bescor and Arduino combo to do some time lapse photography. I’ve never worked with an Arduino but have programming experience, would it be possible to hard-code a program (for instance 1 step right every 2 minutes and 1 step up every 4 minutes and have it run without the nun-chuck (or possibly use the nun-chuck as a start command.) I figure a loop could do the movement with pauses I just wasn’t sure if it was possible to have the Arduino complete a program without external input. Is such a program possible? Any hints?

    Reply
    • Yes, it’s possible. You could code it like the Arduino blink sketch.
      void loop() {
      digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
      delay(1000); // wait for a second
      digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
      delay(1000); // wait for a second
      }

      void loop() {
      analogWrite(right, 100);
      digitalWrite(left, LOW);
      delay(1000);
      analogWrite(right, 0);
      digitalWrite(left, LOW);
      delay(1000);
      }
      Unfortunately, the dc motors do not have position feedback, so it’ll take some trial and error to get the right pauses and use a intervalometer.

      Reply
    • I’m using a similar method. Is a breadboard necessary or can I connect the wires directly to the pins on the Arduino?

      Reply
      • Yes, you can directly solder to the Arduino pins.

        Reply
  2. I’m trying to use a Arduino Micro and stuff it all inside the Nunchuck for easier transport with the MP101. Can someone help with the minor code changes. I get these errors:

    sketch_jun18b.ino: In function ‘void setup()’:
    sketch_jun18b:21: error: ‘TCCR2B’ was not declared in this scope
    sketch_jun18b.ino: In function ‘void nunchuck_setpowerpins()’:
    sketch_jun18b:35: error: ‘PORTC3’ was not declared in this scope
    sketch_jun18b:35: error: ‘PORTC2’ was not declared in this scope

    Thanks, Kaitein

    Reply
    • You can delete this code because the Arduino Micro is not compatible with the Arduino Uno. The analog pins 2 & 3 can be replaced for the ground and 3.3v pins on the Micro.

      TCCR2B = TCCR2B & 0b11111000 | 0x07; //Adusting PWM frequencies for testing pins 11 and 3
      TCCR1B = TCCR1B & 0b11111000 | 0x05; //Pins 9 and 10

      nunchuck_setpowerpins(); // use analog pins 2 & 3 as gnd & pwr (uncomment to use WiiChuck)

      //To power the WiiChuck Adapter
      static void nunchuck_setpowerpins()
      {
      #define pwrpin PORTC3
      #define gndpin PORTC2
      DDRC |= _BV(pwrpin) | _BV(gndpin);
      PORTC &=~ _BV(gndpin);
      PORTC |= _BV(pwrpin);
      delay(100); // wait for things to stabilize
      }

      Reply
      • I’ll give it shot. Thanks for the quick reply and help,

        Reply
  3. Thanks Matt. It works now. I’ll send a link to a picture/vid when I get it all put together. Again thanks for helping out an Arduino newbie.

    Reply
  4. Will try your hack today)) The sketch is uploaded, waiting for the Nunchuck)

    Reply
  5. Got a nunchuk, all is working, but its difficult to do very slow pan and tilt (the reason i began to do this project) and especially combination  slow of pan and tilt. With which modification of the scetch we can decrease the max speed of rotation (i’m absolutely newbie in c++, yesterday bought arduino 🙂 )

    Reply
    • // The values used for speed

      absx = abs(varx); // Convert the x-axis value to an absolute value
      absy = abs(vary);

      You can adjust the speed here.

      Eg. absx = abs(varx*0.5); // Convert the x-axis value to an absolute value

      This would half the speed.

      Reply
  6. Hi Matt,

    Very interested in your work. I’ve purchased the bescor 101 for my church and the hope is that we can use arduino to possibly control the panning enough to make it not jerky. Figured it would be a learning process.

    What do you think about our idea? Is it possible to slow the pan down on the bescor enough to “smoothly” pan back and forth with a speaker.

    I figured that the software coding is possible but a limit would be reached with the bescor unit itself. Any thoughts?

    Reply
    • Yes, it will be a learning process and depending on how close the camera is, about 50ft will be too jerky zoomed in. The closer the better if your subject is not moving quickly side to side.

      Reply
  7. Matt,hi, i dont speek english well,its possible with the Bescor MP-101 and Arduino move in two axis x and y in the same time?

    Reply
  8. Anyone else getting an error ‘WiiChuck’ does not name a type ?

    Reply
  9. I figured out my ‘WiiChuck’ error.  Turns out that the WiiChuck library I downloaded from the Arduino site was an older version and didn’t work with my third party Wii Nunchuck.

    Reply
  10. This was a great project. I made some mods to the code to incorporate a dynamic speed control using the C and Z buttons. I use the C button to achieve 0.5x speed, the Z button gives me 1.5x speed and pushing both together resets the speed back to 1x. I tried to comment the code as best as I could. Through a lot of trial and error testing, I found these to be acceptable values. Anything greater than 1.7x speed freezes the MP-101, and I saw no discernable difference between 1.5x and 1.7x. I’ve found this speed control improves performance by allowing smoother track. Hope this is useful! Sorry for the double post, I pasted in HTML before, hopefully this is more clear.

     

    /*
    *
    * This sketch controls the Bescor MP-101 Pan/Tilt system using the Wii Nunchuck
    *
    * Copyright (c) 2015 Matt Alford, http://www.protechy.com
    * Date: April 6, 2015
    *
    * This program is free software: you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation, either version 3 of the License, or
    * (at your option) any later version.

    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details.

    * You should have received a copy of the GNU General Public License
    * along with this program. If not, see <http://www.gnu.org/licenses></http:&gt;.
    * I am not responsible for any damage that may occur from the use of this software.
    * Nunchuck Library http://playground.arduino.cc/Main/WiiChuckClass
    *
    */

    #include “Wire.h”
    #include “WiiChuck.h” // The library used by the Nunchuck

    #define left 11 //Pin 11 controls left pan
    #define right 3 //Pin 3 controls right pan
    #define up 10 //Pin 10 controls up tilt
    #define down 9 //Pin 9 controls down tilt

    WiiChuck chuck = WiiChuck();

    int varx, vary, absx, absy, mapx, mapy, resetsum = 0;
    //added an integer variable resetsum to help me detect a simultaneous button push

    float speedmod = 1;
    //added a variable to control speed using C and Z buttons, used in conjunction with the varx and vary variables
    boolean lastZ, lastC;
    //added button C and Z variables

    void setup()
    {
    Serial.begin(115200); // Opening the serial port

    TCCR2B = TCCR2B & 0b11111000 | 0x07; //Adjusting PWM frequencies for testing pins 11 and 3
    TCCR1B = TCCR1B & 0b11111000 | 0x05; //Pins 9 and 10

    nunchuck_setpowerpins(); // use analog pins 2 & 3 as gnd & pwr (uncomment to use WiiChuck)

    chuck.begin();
    chuck.update();
    }

    //To power the WiiChuck Adapter
    static void nunchuck_setpowerpins()
    {
    #define pwrpin PORTC3
    #define gndpin PORTC2
    DDRC |= _BV(pwrpin) | _BV(gndpin);
    PORTC &=~ _BV(gndpin);
    PORTC |= _BV(pwrpin);
    delay(100); // wait for things to stabilize
    }

    void loop() {
    chuck.update(); // The Nunchuck values update in the loop

    // 130 is the distance from 0 on the joystick
    varx = chuck.readJoyX(); // nunchuk.analogX is the value of the x-axis
    vary = chuck.readJoyY(); // nunchuk.analogY is the value of the y-axis
    lastC = chuck.buttonC; // this is the boolean value of button C, 1 = pressed
    lastZ = chuck.buttonZ; // this is the boolean value of button Z, 1 = pressed

    // The values used for speed

    absx = abs(varx*speedmod); // Convert the x-axis value to an absolute value
    absy = abs(vary*speedmod);

    // Map the x/y value to get the full range

    mapx = map(absx, 0, 100, 0, 115);
    mapy = map(absy, 0, 100, 0, 115);

    //A sum of two variables to see if buttons C and Z have been pressed together

    resetsum = lastC+lastZ;

    //Changes speed in real time by using the C and Z buttons

    //By pressing the C button, the speed is halved by changing the speedmod=0.5

    if (lastC != 0)
    {
    speedmod = 0.5;
    }

    //By pressing Z, the speed is increased by 1.5X by changing speedmod=1.5

    if (lastZ != 0)
    {
    speedmod = 1.5;
    }

    //reset the speedmod variable back to 1 when C and Z are pressed simultaneously, with a small delay to reset account for uneven button release time

    if (resetsum == 2)
    {
    speedmod = 1;
    delay (150);
    }
    // Tilt based on the input from the joystick
    // I used the serial output to check the stability of these values and “tightented” the edges to make the stick more sensitive, your nunchuck may differ, so alter the vary > x according to your offsets

    if (vary > 3)
    {

    analogWrite(up, mapy);
    digitalWrite(down, LOW);
    }

    else if (vary < 3)
    {

    analogWrite(down, mapy);
    digitalWrite(up, LOW);
    }

    // Stop tilt
    else
    {
    analogWrite(up, LOW);
    analogWrite(down, LOW);
    }

    // Pan based on the input from the joystick
    // I used the serial output to check the stability of these values and “tightented” the edges to make the stick more sensitive, your nunchuck may differ, so alter the varx > x according to your offsets

    if (varx > -4)
    {

    analogWrite(right, mapx);
    digitalWrite(left, LOW);

    }

    else if (varx < -4)
    {
    analogWrite(left, mapx);
    digitalWrite(right, LOW);

    }

    // Stop pan
    else
    {
    analogWrite(right, LOW);
    analogWrite(left, LOW);
    }

    Serial.print(chuck.readJoyX());
    Serial.print(“X, “);
    Serial.print(chuck.readJoyY());
    Serial.print(“Y, “);
    Serial.print(mapx);
    Serial.print(“MapX, “);
    Serial.print(mapy);
    Serial.print(“MapY, “);
    Serial.print(varx);
    Serial.print(“varx, “);
    Serial.print(vary);
    Serial.print(“vary, “);
    //added these variables to serial output to ensure they are working properly
    Serial.print(lastC);
    Serial.print(“lastC, “);
    Serial.print(lastZ);
    Serial.print(“lastZ, “);
    Serial.print(speedmod);
    Serial.print(“speedmod, “);
    Serial.println();
    }

    Reply
    • Hi quarthex!
      I can compile and send your code to my Arduino Uno r3.
      It gives me an error include “excepts” in wichuck.h library line.
      Any advice for a arduino noob?

       

      Reply
      • Solved.
        Was the direct copy/paste from web.
        The ” symbol was not correct.

        Reply
  11. Fascinating project!   I’ve been looking at several tutorials to build out a remote control for the Bescor.  One thing that I find all the tutorials are missing is a return to zero position.  I’d love to pre-define a position as the home position for the camera.  Has anyone done this before?

    Reply
    • Same question

      Reply
      • I haven’t done this but, it could be possible with a combination of gears around the base and a potentiometer.

        Reply
  12. Hello,

    I am actually looking for a modification that makes the pan-head rotate faster (pan left/right). I use it to record youth sport events and need the rotation to be faster. Even when the slider on the control is set all the way to the fast position, there are times when it is still not fast enough to keep up with the pace of the action on the field (especially when the action is happening at a close angle to the camera).

    Every modification I have found online is to actually make the speed slower (for a higher precision). But are there any modifications to make it faster?

    Thanks,

    ggee

    Reply
  13. I want to do this project but i want to control the motor with the up down left right keys of my computer is it possible for the Arduino to take input from the computer.

    Reply
    • Yes, you can connect to the Arduino usb and use the serial port to send commands from the computer.

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *