Bescor MP-101 and Arduino V2

This is a followup of a better way to control the Bescor using the Arduino UNO from this tutorial  (Update: Working on a new setup and hopefully have the code up soon.)

 

Here’s a breakdown of how the original controller works .

 

White = up

Blue = down

Yellow = left

Green = right

Black = Ground

Red = 5v

Purple = Speed

When a button is pressed, an electrical current passes through one of the directional wires to the Bescor.  The red wire is 5v and sends the current through the slider that changes the voltage and returns to the Bescor through the purple wire.

I’m still experimenting, but here’s how I connected the wires to the Arduino using the original Bescor controller

White = pin 8

Blue = pin 9

Yellow = pin 10

Green = pin 12

Purple = pin 3

Without looking inside the Bescor, I didn’t know if this is the best setup.  I tried connecting the direction wires and ground to control the speed, but it didn’t work.  The solution was to use the purple wire as my speed control and change the voltage like on the Bescor controller slider using PWM.  The direction can be controlled by setting the digital pins HIGH “on” or LOW “off”.

Here’s the code:

/*
*
* This program controls the Bescor MP-101 Pan/Tilt system using the Wii Nunchuck
*
* Copyright (c) 2012 Matt Alford, http://www.protechy.com
* Date: April 19, 2012
*
* Nunchuck Library created by Gabriel Bianconi, http://www.gabrielbianconi.com/
*
*/

#include
#include "ArduinoNunchuk.h" // The library used by the Nunchuck

#define left 12 //Pin 12 controls left pan
#define right 10 //Pin 10 controls right pan
#define down 9 //Pin 9 controls down tilt
#define up 8 //Pin 8 controls up tilt
#define spd 3 //Pin 3 controls speed

ArduinoNunchuk nunchuk = ArduinoNunchuk();

int varx = 0; // The x-axis variable to store the value coming from the Nunchuck
int vary = 0; // The y-axis variable to store the value coming from the Nunchuck
int absx = 0; // The x-axis variable used to store the absolute value.
int absy = 0; // The y-axis variable used to store the absolute value.

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

//This sets the PWM frequencies for pins 3 and 11.
TCCR2B = TCCR2B & 0b11111000 | 0x07; //There maybe a better method to control the range of the speed.

nunchuk.init(); //Initialize the Nunchuck code
}

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

// 130 is the distance from 0 on the joystick
varx = nunchuk.analogX - 130; // nunchuk.analogX is the value of the x-axis
vary = nunchuk.analogY - 130; // nunchuk.analogY is the value of the y-axis

// The values used for speed
absx = varx;
absx = abs(absx); // Convert the x-axis value to an absolute value
absy = vary;
absy = abs(absy);

// Tilt based on the input from the joystick
if (vary >= 8)
{
digitalWrite(up, HIGH);
analogWrite(spd, absy);
}

else if (vary <= -8)
{
digitalWrite(down, HIGH); // Direction of the tilt "down"
analogWrite(spd, absy);
}

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

// Pan based on the input from the joystick
if (varx >= 8)
{
digitalWrite(left, HIGH);
analogWrite(spd, absx);
}

else if (varx <= -8)
{
digitalWrite(right, HIGH);
analogWrite(spd, absx);
}

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

 

I still want to improve the code, but I want to thank  Bill Porter & Rick Gernhardt for the ideas.

Submit a Comment

Your email address will not be published.