Hi all,
very new user here. Apologies for the very newbie questions, but I have already learned a lot just by browsing the boards here, and hope to achieve what I set out to do with Moteino.
My project is wireless control of a pan/tilt camera head, the popular Bescor MP-101. Naturally, before testing it out wirelessly, I wanted to make sure that it works wired, and here is where I got stuck.
Here is the wiring diagram for the head:
http://protechy.com/bescor-mp-101-hack-part-1/
I have set up four momentary switches on a protoboard, and connected Bescor ground to GND, and Bescor pins 2, 4, 5 and 6 to Moteino output (as per code):
#define BUTTON_LEFT 3
#define BUTTON_RIGHT 4
#define BUTTON_UP 5
#define BUTTON_DOWN 6
#define ACT_LEFT 14
#define ACT_RIGHT 15
#define ACT_UP 16
#define ACT_DOWN 14
#define DELAY 100
void setup()
{
pinMode(BUTTON_LEFT, INPUT);
pinMode(BUTTON_RIGHT, INPUT);
pinMode(BUTTON_UP, INPUT);
pinMode(BUTTON_DOWN, INPUT);
digitalWrite(BUTTON_LEFT, HIGH); // pull-up
digitalWrite(BUTTON_RIGHT, HIGH); // pull-up
digitalWrite(BUTTON_UP, HIGH); // pull-up
digitalWrite(BUTTON_DOWN, HIGH); // pull-up
pinMode(8, OUTPUT);
pinMode(14, OUTPUT);
Serial.begin(115200);
}
int handle_button()
{
int button_pressed = 0;
if (!digitalRead(BUTTON_LEFT)) { button_pressed = button_pressed + 1; }
if (!digitalRead(BUTTON_RIGHT)) { button_pressed = button_pressed + 2; }
if (!digitalRead(BUTTON_UP)) { button_pressed = button_pressed + 4; }
if (!digitalRead(BUTTON_DOWN)) { button_pressed = button_pressed + 8; }
return button_pressed;
}
void loop()
{
int button_combo = handle_button();
if (button_combo == 1) { digitalWrite(8, LOW); }
else if (button_combo == 2) { digitalWrite(14, LOW); }
else if (button_combo == 3) { digitalWrite(8, LOW); digitalWrite(14, LOW); }
else {
digitalWrite(8, HIGH);
digitalWrite(14, HIGH);
}
delay(100);
//Serial.print(button_combo);
Serial.print(digitalRead(8));
Serial.print(digitalRead(14));
Serial.println();
//delay(DELAY);
}
The code works fine if only one wire from the Bescor is connected apart from GND, but not if all four are. :( The Bescor works by connecting each of the above pins from its cable (2,4,5,6) to its GND, which is what I am trying to do.
Any thoughts? I know the answer should be simple, I just can't see it. :(
I have no idea what the Bescor is or does, or what the 4 wires are for, you might want to include that.
Anyway I think you are missing debouncing your buttons (https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=arduino%20debounce%20buttons).
InSides - From the code on part 2 of that website it looks like the Bescor uses PWM to control movement. I don't see a PWM setup or an analogwrite() anywhere in your code. There are plenty of troubleshooting tips and test code in the comments there as well. Try some of those out and see how you do.
Quote from: Felix on January 21, 2016, 11:22:32 AM
I have no idea what the Bescor is or does, or what the 4 wires are for, you might want to include that.
Anyway I think you are missing debouncing your buttons (https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=arduino%20debounce%20buttons).
Hi Felix, you are correct. Apologies for the scarce information.
The Bescor MP-101 (http://www.bescor.com/MP101.htm (http://www.bescor.com/MP101.htm)) is a pan and tilt head for small cameras. It uses two DC motors to perform the movements, and is controlled by a wired remote connecting to a 7P DIN port - left, right, up and down control are connected by one wire each (hence the four wires). The wired remote works by simply connecting each of the four wires to GND (provided on the DIN connector).
I would like to replicate that functionality with Moteino, but using momentary switches for doing the physical input. Reason for this is I plan to use an arcade joystick in the future.
Now, the input portion of the code seems to work quite good. The handle_button() function returns an integer which carries the information of any switch connected (or any combination of switches - this is important as I might want to do a combined pan/tilt movement).
My troubles begin when I connect the wires that go to the Bescor, to the output pins on Moteino. I will read up more on debouncing and PWM.
Quote from: spambake on January 21, 2016, 02:33:38 PM
InSides - From the code on part 2 of that website it looks like the Bescor uses PWM to control movement. I don't see a PWM setup or an analogwrite() anywhere in your code. There are plenty of troubleshooting tips and test code in the comments there as well. Try some of those out and see how you do.
Thank you for that note - I did use analogWrite() at a few points, but the sketch I submitted does not reflect that. Will read up more on PWM and see if that works.
What really confused me is the code shown in this video, which apparently works. It is rather simpler than the PWM approach - but it doesn't really say exactly how he had connected the Bescor wires.
https://www.youtube.com/watch?v=7JUZWLJZEVM
Ok, thanks for the extra info and video, it's helpful to have it here rather than everyone reading this thread going and reading different pieces of information elsewhere.
Quite an interesting project. There was a project where someone used Moteino+GPS on an RC airplane to report position information down to a camera that had pan/tilt functionality + a video camera so it would autonomously record the flying aircraft and free his hands which were busy controlling the aircraft :) .. check it out:
Blog Post Here (http://lowpowerlab.com/blog/2015/06/19/autonomous-recorder-of-gps-moteino-target-moving-objects/)
(https://c1.staticflickr.com/1/546/18334903863_360b437886_o.jpg)
So i guess in your case its a bit similar in that you are trying to remotely control the camera pan/tilt device.
Let us know your progress and if you get past the stage where you're just trying to do it from the Moteino without the RF/radio involved.
Hi Felix, et al,
a very quick update. The code now works just fine, thanks to all your generous suggestions.
PWM was indeed the thing, and a weekend off did the track. BStott's pot and servo project helped immensely, as well.
A long way to go still, but the basic code can be found at the GitHub repo:
https://github.com/idebate/wireless-camera-control
Currently works only with a switch-based joystick (think arcade) - next iteration to use a 3-axis joystick in order for speed to be controlled as well (through analogWrite()).
Once the project is done, will fully document it here, if OK with you?
Quote from: InSides on February 16, 2016, 09:12:58 AM
Hi Felix, et al,
a very quick update. The code now works just fine, thanks to all your generous suggestions.
[...]
Once the project is done, will fully document it here, if OK with you?
Thanks for the update, please do share when your project is complete! :)