Webcam pan and tilt

boriz

Senior Member
Pantroller (Pan Tilt Controller) is a small windows program that drives a PICAXE which controls two servos. The servos pan and tilt a webcam. The PICAXE used is a 14M, but it will probably run on an 08M. Here is the PICAXE source code:
Code:
servo 4,150:servo 5,150
pause 2000
do
	setfreq m8
	serin 1,n2400,("X"),b0
	serin 1,n2400,("Y"),b1
	setfreq m4
	high 3
	servo 4,b1:servo 5,b0
	pause 15
	low 3
loop
I was having lots of trouble trying to receive both X and Y bytes on the same line, like ‘serin 1,n2400,("XY"),b0,b1’. Eventually tried splitting them and it worked.

This ZIP file (http://www.zen86415.zen.co.uk/pantroller.zip) contains the PC program that drives the PICAXE through the serial programming cable (COM1). In the ZIP is a screenshot, the source code in Ebasic (http://www.ionicwind.com/) and the compiled executable. The source, should you with to study it, is best viewed with all the proper context colouring etc. provided by the free Ebasic editor/compiler.

Screenshot:


The button functions are self explanatory. The box labelled ‘Pan’ has two functions. In addition to displaying the current pan position of the webcam, it can control the mechanism directly using the mouse. Just click and drag the target inside the box and the webcam will follow.

Here is a video of mouse-panning in action: http://www.zen86415.zen.co.uk/pantilt.MOV (5.7Mb Right-click>Save as...) Sorry it’s an MOV file, but that’s how it comes out of my Olympus digital camera.

I have posted here because the project is not complete. I will eventually be adding several bits and bats. It works well on my PC but feedback as to whether it works on other PCs would be useful.
 

moxhamj

New Member
Very impressive. I think it is ready to go in the "completed projects" section. Once you get it completed, it could also be worth an Instructable.
 
Awesome work!!! My latest efforts have been around creating a telepresence robot (a robot that can be remote controlled from any internet browser)... I've been using RoboRealm as the vision webserver, but was looking to enhance the user interface. I love how you have the pan area where you can just use your mouse to drag the "x". What additions are you planning to make?
 
Last edited:

hippy

Technical Support
Staff member
I was having lots of trouble trying to receive both X and Y bytes on the same line, like ‘serin 1,n2400,("XY"),b0,b1’. Eventually tried splitting them and it worked.
Firmware version 9.A ?

If so that's a 'known bug' and should have been fixed for version 9.B

There really should be a published list of known bugs so people don't waste hours trying to make things work which never will.
 

boriz

Senior Member
Thanks.

@Hippy:
Editor reports VER 9.B (14M)

From manual2.pdf: “Note that the microcontroller may not be able to keep up with processing complicated datagrams at higher speeds - in this case it is recommened (sic) that the transmitting device leaves a short delay (e.g. 2ms) between each byte.“

Is this saying that if I want to RX something like this ‘SERIN 1,T2400,(“TEST”),b0’, I have to use something like this to TX:

Send “T”
Pause 2
Send “E”
Pause 2
Send “S”
Pause 2
Send “T”
Pause 2
Send chr$(databyte)
?

I seem to have no problem at all with this:
(PC) Send “TEST”+chr$(databyte1)
(AXE) SERIN 1,T2400,(“TEST”),b0

But no success at all with this:
(PC) Send “TEST”+chr$(databyte1)+chr$(databyte2)
(AXE) SERIN 1,T2400,(“TEST”),b0,b1

Or this:
(PC) Send “TEST”+chr$(databyte1) : pause 10 : Send chr$(databyte2)
(AXE) SERIN 1,T2400,(“TEST”),b0,b1

At the moment, as a compromise, I’m using this:
(PC) Send “X”+chr$(databyte1) : pause 3 : send “Y”+chr$(databyte2)
(AXE) SERIN 1,T2400,(“X”),b0 : SERIN 1,T2400,(“Y”),b1

And it seems to be working well.

@Steve:
At the moment, the circuit is on a solderless prototyping board (BreadBoard). That’s probably how it is going to stay for a while. I might experiment with using an additional physical proportional joystick, and an RF link to the camera mount. I’m also hoping to have a bash at some image processing – motion detection, object detection , face tracking etc.
 

boriz

Senior Member
No point?

The only connections are A) Serial programming cable, B) 1 LED, C) 2 Servos. All wired exactly as indicated in the manuals.
 

Wrenow

Senior Member
Which means that this could be easily ported to the AXE-024 3 servo controller, methinks. Correct? Nice, handy little jewel, that.

Cheers,

Wreno
 
Top