Camera pan control
Archiver
Posts: 46,084
Greetings, I have a BS2 with a LCD display and a Mini-SSC servo controller.
I would like to use the system as a pan controller for a small "lipstick
camera". I have everything working, but I would like the servo to stop
moving when the button is released. The way the program works now, when the
left button is pressed the servo pans from the right limit to the left limit
and stops. The same limit to limit movement happens when the right button
is pressed. Is there a simple way to scan the push buttons while the servo
moves (i.e. multitasking) or do I have to step the servo only one degree at
a time and then scan the pushbuttons and repeat the sequence?
Thanks for any help you can give me!
<Program follows>
' ==BPK/BPI CONTROL CONSTANTS==========================
I con 254 ' Instruction prefix for LCD.
LCDCLS con 1 ' Clear-screen instruction for LCD.
LINE1 con 128 ' Beginning of line 1.
LINE2 con 192 ' Beginning of line 2.
DIRPOS con 202 ' Position: char 6 of 2nd line.
S_PIN con 0 ' Serial output to Backpack/LCD.
N9600 con $4054 ' 9600 baud.
'==button variables=======
a var bit 'right button
b var bit 'left button
input 3
input 4
'==SERVO variables==
svo con 0 'use servo 0.
sync con 255 'mini ssc sync byte.
pos var byte 'byte variable holds position value.
n24n con $418D 'baudmode: 2400.
n96n con $4054 'baudmode: 9600.
'==LCD Initialize==
pause 1000 ' Wait a second.
' Clear the LCD, print labels "-* Camera pan *-" and "direction" on 2nd
line.
serout S_PIN,N9600,[noparse][[/noparse]I,LCDCLS,I,LINE1,"-* Camera Pan *-",I,LINE2,"Direction"]
'==Main Program loop==
Again:
serout S_PIN,N9600,[noparse][[/noparse]I,DIRPOS] 'Move to beginning of bar.
gosub buttons 'read button inputs.
goto Again 'Do it continuously.
'==Subroutines==
buttons:
a = in3 'Right button.
b = in4 'Left button.
if a=1 then arrowr 'If R button pressed, display > on LCD, move servo.
if b=1 then arrowl 'If L button pressed, display < on LCD, move servo.
if a<>1 then noarrow 'if no buttons are pressed, display --- on LCD.
if b<>1 then noarrow
return
arrowr:
serout S_PIN,n9600,[noparse][[/noparse]"<<<<<<"] 'display < on LCD.
for pos=1 to 254 step 1 'rotate clockwise in 1 unit steps.
serout 2,n24n,[noparse][[/noparse]sync,svo,pos] 'command the mini ssc.
next 'next position
return
arrowl:
serout S_PIN,n9600,[noparse][[/noparse]">>>>>>"] 'display > on LCD.
for pos=254 to 1 step 1 'rotate anti-clockwise in 1 unit steps.
serout 2,n24n,[noparse][[/noparse]sync,svo,pos] 'command the mini ssc.
next 'next position.
return
noarrow:
serout S_PIN,n9600,[noparse][[/noparse]" -- "] 'display - on display, no servo movement.
return
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
I would like to use the system as a pan controller for a small "lipstick
camera". I have everything working, but I would like the servo to stop
moving when the button is released. The way the program works now, when the
left button is pressed the servo pans from the right limit to the left limit
and stops. The same limit to limit movement happens when the right button
is pressed. Is there a simple way to scan the push buttons while the servo
moves (i.e. multitasking) or do I have to step the servo only one degree at
a time and then scan the pushbuttons and repeat the sequence?
Thanks for any help you can give me!
<Program follows>
' ==BPK/BPI CONTROL CONSTANTS==========================
I con 254 ' Instruction prefix for LCD.
LCDCLS con 1 ' Clear-screen instruction for LCD.
LINE1 con 128 ' Beginning of line 1.
LINE2 con 192 ' Beginning of line 2.
DIRPOS con 202 ' Position: char 6 of 2nd line.
S_PIN con 0 ' Serial output to Backpack/LCD.
N9600 con $4054 ' 9600 baud.
'==button variables=======
a var bit 'right button
b var bit 'left button
input 3
input 4
'==SERVO variables==
svo con 0 'use servo 0.
sync con 255 'mini ssc sync byte.
pos var byte 'byte variable holds position value.
n24n con $418D 'baudmode: 2400.
n96n con $4054 'baudmode: 9600.
'==LCD Initialize==
pause 1000 ' Wait a second.
' Clear the LCD, print labels "-* Camera pan *-" and "direction" on 2nd
line.
serout S_PIN,N9600,[noparse][[/noparse]I,LCDCLS,I,LINE1,"-* Camera Pan *-",I,LINE2,"Direction"]
'==Main Program loop==
Again:
serout S_PIN,N9600,[noparse][[/noparse]I,DIRPOS] 'Move to beginning of bar.
gosub buttons 'read button inputs.
goto Again 'Do it continuously.
'==Subroutines==
buttons:
a = in3 'Right button.
b = in4 'Left button.
if a=1 then arrowr 'If R button pressed, display > on LCD, move servo.
if b=1 then arrowl 'If L button pressed, display < on LCD, move servo.
if a<>1 then noarrow 'if no buttons are pressed, display --- on LCD.
if b<>1 then noarrow
return
arrowr:
serout S_PIN,n9600,[noparse][[/noparse]"<<<<<<"] 'display < on LCD.
for pos=1 to 254 step 1 'rotate clockwise in 1 unit steps.
serout 2,n24n,[noparse][[/noparse]sync,svo,pos] 'command the mini ssc.
next 'next position
return
arrowl:
serout S_PIN,n9600,[noparse][[/noparse]">>>>>>"] 'display > on LCD.
for pos=254 to 1 step 1 'rotate anti-clockwise in 1 unit steps.
serout 2,n24n,[noparse][[/noparse]sync,svo,pos] 'command the mini ssc.
next 'next position.
return
noarrow:
serout S_PIN,n9600,[noparse][[/noparse]" -- "] 'display - on display, no servo movement.
return
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
Comments
I would like to use the system as a pan controller for a small "lipstick
camera". I have everything working, but I would like the servo to stop
moving when the button is released. The way the program works now, when the
left button is pressed the servo pans from the right limit to the left limit
and stops. The same limit to limit movement happens when the right button
is pressed. Is there a simple way to scan the push buttons while the servo
moves (i.e. multitasking) or do I have to step the servo only one degree at
a time and then scan the pushbuttons and repeat the sequence?
Thanks for any help you can give me!
<Program follows>
' ==BPK/BPI CONTROL CONSTANTS==========================
I con 254 ' Instruction prefix for LCD.
LCDCLS con 1 ' Clear-screen instruction for LCD.
LINE1 con 128 ' Beginning of line 1.
LINE2 con 192 ' Beginning of line 2.
DIRPOS con 202 ' Position: char 6 of 2nd line.
S_PIN con 0 ' Serial output to Backpack/LCD.
N9600 con $4054 ' 9600 baud.
'==button variables=======
a var bit 'right button
b var bit 'left button
input 3
input 4
'==SERVO variables==
svo con 0 'use servo 0.
sync con 255 'mini ssc sync byte.
pos var byte 'byte variable holds position value.
n24n con $418D 'baudmode: 2400.
n96n con $4054 'baudmode: 9600.
'==LCD Initialize==
pause 1000 ' Wait a second.
' Clear the LCD, print labels "-* Camera pan *-" and "direction" on 2nd
line.
serout S_PIN,N9600,[noparse][[/noparse]I,LCDCLS,I,LINE1,"-* Camera Pan *-",I,LINE2,"Direction"]
'==Main Program loop==
Again:
serout S_PIN,N9600,[noparse][[/noparse]I,DIRPOS] 'Move to beginning of bar.
gosub buttons 'read button inputs.
goto Again 'Do it continuously.
'==Subroutines==
buttons:
a = in3 'Right button.
b = in4 'Left button.
if a=1 then arrowr 'If R button pressed, display > on LCD, move servo.
if b=1 then arrowl 'If L button pressed, display < on LCD, move servo.
if a<>1 then noarrow 'if no buttons are pressed, display --- on LCD.
if b<>1 then noarrow
return
arrowr:
serout S_PIN,n9600,[noparse][[/noparse]"<<<<<<"] 'display < on LCD.
for pos=1 to 254 step 1 'rotate clockwise in 1 unit steps.
serout 2,n24n,[noparse][[/noparse]sync,svo,pos] 'command the mini ssc.
next 'next position
return
arrowl:
serout S_PIN,n9600,[noparse][[/noparse]">>>>>>"] 'display > on LCD.
for pos=254 to 1 step 1 'rotate anti-clockwise in 1 unit steps.
serout 2,n24n,[noparse][[/noparse]sync,svo,pos] 'command the mini ssc.
next 'next position.
return
noarrow:
serout S_PIN,n9600,[noparse][[/noparse]" -- "] 'display - on display, no servo movement.
return
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> LCD display and a Mini-SCC servo controller.
> .. I would like the servo to stop moving when the button is released
> .. scan the push butttons while the servo moves (i.e. multitaskin
Hi Mike,
Thhe button scan and the servo control can all be put into one short main
loop.
' pushbuttons active when in3=1 or in4=1
loop:
pos = pos+in3 max 254 - in4 min 1 ' note A
serout lcd_pin,n9600,[noparse][[/noparse]REP 61+in4-in3\1-(pos.nib0 max 1)*in3|in4] ' note
B
serout servo_pin,n2400,[noparse][[/noparse]sync,svo,pos]
pause 10 ' give it time, as necessary
goto loop
note A) The position variable goes up or down depending on which button is
pressed (=1). Limits of 254 and 1 are enforced. No change if both are up
or both are down.
note prints "<" (ascii 60) or ">" (ascii 62) on LCD. See Stamp manual
debug command for syntax of the REP modifier. The number before the "\" is
the ascii code to print, and the number after the "\" is how many times to
print it. The expresion, 1-(pos.nib0 max 1)&in3&in4&~(in3&in4), causes it
to print only when one and only one button is active and even then, only on
every 16th value of the position variable, so it doesn't flood the LCD.
-- Tracy Allen
Electronically Monitored Ecosystems
http://www.emesystems.com
originally wanted it to. Nice, simple and clean. I just have
to make my watertite camera enclosure and mount it on the roof.
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
etc. ??
Mike S wrote:
> Thanks Tracy! I tried the program and it works just the way I
> originally wanted it to. Nice, simple and clean. I just have
> to make my watertite camera enclosure and mount it on the roof.
>
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
--
ARC in Nawlins
Against stupidity, the Gods themselves contend in vain!
eventually posting some when I get more of the construction completed. I'll
borrow a camera and take some pictures, etc. over the weekend and post them.
I actually wanted to see if I could get the controller and software working
because I figured that I would consume the majority of my time. I do have
access to lots of older cameras and other "major" pieces that I need for the
project, so everything should come together quickly.
There is a new building being built on the college campus where I work and I
have "volunteered" to be the official daily photographer. The pictures that
I have been taking with a handheld camera can be seen at:
http://mauicc.hawaii.edu. Click on "Information Technology", scroll down
and click on "Tour model of Future Technology Facility" on the right side of
the screen and then click on "Building N construction site photo history".
I currently walk up to the third floor of the library next door and point my
camera out the windows and take pictures. I would like to eventually make a
weatherproof enclosure that can sit on the roof so I can capture images from
a video camera on the roof of the library. The trouble is that if I open
the windows (in the air conditioned building) the students who are studying
in the cubicals on the third floor are disturbed by the construction noise
and wind. I also need to keep cleaning the windows since they face into the
wind. Did I also mention that the campus is located 500 feet downwind from
the shoreline? Lots of salt air and salt crystals on eveything ;-)
Original Message
From: "A.Ron Carmichael" <arc@i...>
To: basicstamps@egroups.com
Sent: May 23, 2000 7:06:49 PM GMT
Subject: Re: [noparse][[/noparse]basicstamps] re: camera pan control
do you have a synopsis posted on the net anywhere with pictures, diagrams,
etc. ??
______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup