Panteltje's Linux DVD software page

Panteltje's camera control page

~

In this archive you find the program and circuit diagram for a camera position control system.
This system can be controlled via a RS232 serial link from a PC.

The system is based on a Microchip PIC 16F648 microcontroller.
Control for 4 RC servos and one digital on / off channel is available.
The servos can drive x and y motion for the camera, focus, and zoom if available.
The on off channel is connected to a LED and available for general purpuses.

A 6 V DC supply is needed, with enough current capability to drive the servos.
Any RC servo that uses Graupner-J/R connectors should work.

Communication with the PC works at 19200 Bd, 1 start bit, 8 data bits, 2 stop bits, no parity.
You should have hardware handshaking OFF in you communication program.

Format commands:
x = pan, y = tilt, f = focus, z = zoom.
Range commands is 0 - 255.
There is no overflow check in digits so x121212121ENTER will cause funny effects.
If you type no digits, but just ENTER after the command character, or ENTER all
by itself, the current position is not altered.
Beware of servo values < 100 and > 200, motor may draw a lot of current if it
keeps trying to go past end stop.

SEE THE MENU DISPLAYED FOR THE LATEST COMMANDS AND KEYS!


Some commands available:
a set auto pan speed: a246ENTER (nnnn = 0-254).
b sets LED off.
c PWM down.
d sets defaults, all servos in mid position, LED off, auto pan off.
f servo: f150ENTER for 1.5 mS (midrange) (0-255).
h help, not implemented, refers to README.
M save status and settings in an EEPROM memory area: n2ENTER (valid area 0-9).
n sets PWM pulse duration (for analog out or lamp control) n128ENTER for 50 % duty cycle (0-255).
O servo pulses off (any other character except s for status will switch it on again).
P starts auto panning (left to right), setting a value for x sets it off.
q auto panning speed decrease one step.
r load settings from an EEPROM memory area: r3ENTER (valid area = 0-9), on power up settings are taken from memory 0.
s print status all commands.
T RB5 pin high.
t RB5 pin low.
v PWM up.
w auto panning speed increase one step.
x servo: x150ENTER for 1.5 mS (midrange) (0-255).
y servo: y150ENTER for 1.5 mS (midrange) (0-255).
z servo: z150ENTER for 1.5 mS (midrange) (0-255).
, moves one step left.
. moves one step right.
/ moves one step down.
' moves one step up.
[ focus one step closer.
] focus one step further away.
- zoom in one step.
= zoom out one step.
spacebar sets LED on, can be used as fire button for example.

The one step commands are protected from lower then 0 and > 255
You can also select a destination servo for the numeric commands with:
xENTER
yENTER
zENTER
fENTER

Once you have selected x, y, f, or z, you can type:
123ENTER again and again, and address the last selected.
(any number between 0 and 255 folowed by ENTER).

NEW in this release:


Auto sequence timer error fixed.
Fixed double status display in interrupt.
If RB0/INT pulled low, control G (Bell) is send, this should ring the bell on the terminal.
Also the message 'INTERRUPT' is displayed at the bottom of the screen.
This can for example be used to take action if an IR motion sensor
contact is connected to the INT pin.
Make sure you filter that pin or use an opto-coupler.
Added commands E and e, E causes a jump to preset 9 if RB0/INT goes low.
This can for example be used to point at a door upon interrupt.
You can use auto-sequencing in preset 9, to get back to preset 0 (or
any other preset).
In such a case you will hear a beep, the camera will point at the door for the time
specified in preset 9, and then go back to preset 0 with for example auto panning.

OTHER FEATURES

PWM:
PWM can be set with nxxxENTER, or 'v' and 'c' for up and down.
This can for example be used to control a light bulb or create an analog voltage.
RB5 pin 11 can be set and reset with 'T' and 't' as general purpose output.

Presets:
You can save 10 positions (n=0-9), in fact the complete status is saved.
To save
MnENTER

To get back a position:
rnENTER

The positions are saved in EEPROM in the 16F648A, and the settings are saved after a power down.
This allows you to have the camera start with auto panning for example after a power off.

Auto sequencing:
The software can sequence between max. 10 positions fully programmable in memory.
The time spend per position can be set from about 1 to 200 seconds.
The sequence list is a linked list, where for every position you can select any next one.
To save the setting in a position:
MnENTER where n is the position number 0-9

Other:
The reason why M and not m, O and not o, P and not p is to give some
protection against accidently entering these commands on the keyboard
(you will have to press shift key too).
In case of caps lock all bets are off.

In case of an EEPROM programming error in the presets, an error report is given.
Click here to download the archive with in it the circuit diagram, asm code, and hex file:
camc_pic-0.7.1.tgz

This is a simplified version designed for tracking satellites with 2 RC servos (azimuth and elevation).
Azimuth should be set with z123CRLF, and elevation with x123CRLF.
There is a 'servo off' command with OCRLF.
All other functions are dsiabled.
sending azimuth or elevation will switch the servos on again.
It is best to have the antenna (yagi) properly mechanically balanced, this reduces load on the servo motors and power consumption.
Click here to download the archive with in it the circuit diagram, asm code, and hex file:
camc_pic-0.7.1-tracking.tgz

simple C source for driver via ttyS0 (com1), compile with gcc -o cco cco.c
This program, cco, will pass commands to camc_pic,
The 'up' command ' has been translated to '?', all other commands are as in camc_pic.
For example typing 'cco ?' (without the quotes) will move the camera one step up.
This can be used from a script for example, or from the command line.
In all other cases one should use a terminal program, to see the camc_pic status reply.
If you want to use the program as non root, perhaps from Apache webserver, then you will have to change
the permissions on /dev/ttyS0 like this:
chmod o+rw /dev/ttyS0
Be aware of any security risks this may have!
Personally I use gphoto2 as root running from the script /usr/local/sbin/take-pic.
This looks for a semaphore flag: /tmp/gp_semaphore
The Apache server has permission to write to /tmp !
So a cgi script on the server sets this flag ever second, and does server push for the picture data.
Email me for details of these bash, cgi, and php camera scripts,
for security reasons I do not publish these here.
You can sometimes see the camera page here.


Click here for some other programs I make available under the GPL.

Click here to send mail