Author Topic: Camera Control:Tilt & Pan Servos from within Basic ?  (Read 2068 times)

0 Members and 1 Guest are viewing this topic.

Offline azyTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Camera Control:Tilt & Pan Servos from within Basic ?
« on: November 12, 2010, 11:09:07 PM »
I Need to figure out a way to control a couple of servos using any standalone basic programming dialect very pref Qbasic Freebasic etc

TO CLARIFY The basic program ill need to write will be running on a windows pc (XP) and controlling two servos attached to the pc (purpose of Tilt and Pan for a camera)

What hardware can i buy that will allow me to do this ?








so ill need some USB servos ? or some kind of board i can plug in, i need to be able to talk directly to the board, or pass paramaters to the software that comes with the board. My computer program written in Qbasic/FreeBasi etc needs to control the servos


In full

Using a webcam camera and some servos is the way i want to go forward. The  good but Expensive Logitech QuickCam Pro 9000 HD Carl Zeis lens Autofocus etc (some sexy boards options out there I know, but the setups look way over my head)

I have some rough but works Basic code that saves webcam images to a folder on my windows computer, so taking pictures i partially solved

I have some very sophisticated brains software and i need to control a camera with it. The brain outputs its desires to a .txt file ( take a picture now, pan left a bit, tilt up a bit iny any format i want)

I need to write another program to take these text instructions and get the camera and servos to do the stuff i want. I'm not that good at programming, 99% of my skills are in Basic so doing tricky stuff in C wont be possible





I should point out that I'm not after an autonomous robot, face tracking , line following, remote control or remote viewing robot. There are lots off of the shelf solutions out there. My robot brain will look at the images and decide for itself what to do in a humanlike way, so it must be able to control the movement of its eyes without any human intervention or running preprogrammed scripts.

Thanks in advance

ps the brain runs on a small network of PCs, i can dedicate 1 PC to a camera and another to servo control if necessary. The images taken are then processed by other computers on the network. Ultimately id like to be able to control the zoom, but just controlling pan and tilt will get me 90% of the visual data i need. Im running Windows XP sp2 or sp3 & have never used Linux

« Last Edit: November 14, 2010, 03:19:52 AM by azy »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Inteligent Camera Control Tilt Pan Servos with Qbasic ?
« Reply #1 on: November 13, 2010, 12:07:12 PM »
Hi,

Knock yourself out here
Regards,
S°ren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline azyTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Inteligent Camera Control Tilt Pan Servos with Qbasic ?
« Reply #2 on: November 14, 2010, 02:49:19 AM »
Thanks for the link, I'm drowning in hardware reviews, but i cant seem to find any articles about controlling the hardware in realtime from user written software..eg a program they have written thats running on a windows pc


output from "Mybrainsoftware Program.exe" = 5

if input to "myservcontroller program.exe" = 5 then move servo left 2 degrees

Before anyone asks.....These are two seperate programs running, so that if my servo prog crashes it doesnt crash the brain prog

I need to write  a "myservcontroller program" preferably in basic but don't have a clue what hardware will be compatible/controlable from within  basic


I'm a total noob at building robots, coding boards, ports etc but need to build the tilt n pan setup as a  necessity for my brainsoftware  So im looking for hardware that can be controled directly from basic, polling ports what have you

anyone here using basic to control servos?
« Last Edit: November 14, 2010, 03:28:18 AM by azy »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Inteligent Camera Control Tilt Pan Servos with Qbasic ?
« Reply #3 on: November 14, 2010, 08:43:57 AM »
Hi,

[...] anyone here using basic to control servos?
Do you have an LPT-port or does it need to be USB?
(Does GW have USB control at all, or do you have to go via a serial port routine?)

I have used TB/PBP to make very high resolution timing stuff on LPT ports, but TB/PBP is a far cry from GWBASIC - While the latter is an interpreter, the former are real compilers, generating fast, small and very efficient exe's.
I wouldn't use GW, especially if you are worried about stability (and because it is a bit ugly to put it mildly) and I wouldn't make the entire project so patchwork'ish - too many places for errors to creep in.

XP and up runs everything in virtual machines, so will never see the actual hardware and whenever the OS needs to give a larger time-slot to other processes, your timing will be seriously F'd up - only way around that is to run in ring 0 and to do that, you'd need to program a DLL.
If you want the easy way out, run DOS on a single machine, then you have free access to LPT and serial ports and since it's running only one process at a time, you have iron clad control of timing.

The DLL inpout32.dll might help you with LPT or serial ports.

A physical smaller and better IMO alternative would be to use a Ácontroller for the servo timing stuff and just communicate the "left 2░" or whatever to it via SPI, IIC, serial, USB or whatever.
Regards,
S°ren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline azyTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Inteligent Camera Control Tilt Pan Servos with Qbasic ?
« Reply #4 on: November 14, 2010, 10:35:56 PM »
Hi,

[...] anyone here using basic to control servos?

A physical smaller and better IMO alternative would be to use a controller for the servo timing stuff and just communicate the "left 2░" or whatever to it via SPI, IIC, serial, USB or whatever.


this method sounds interesting. whats a Ácontroller ? i just need it to control 2 servos in realtime

i dint mind what kind of ports / hardware i use , I'm just trying to avoid brainstrain ref coding outside my simple skillset as far as i can

buy black box + 2 servos, plug in and configure with bundled software, then write some of my own code to send it a simple signal to the port its plugged into, that would be ideal (i have no idea how to send a simple signal to a port but i should be able to copy some code of someone)


Additional information...to give you a broader picture
servo position feedback. I'm going to do this by housing the camera in a glass box marked with points, that way, i know for sure which way the camera is pointed as this is embedded in every image captured. I only need rough control over the servos, +/- 10 degrees not a problem as a camera (unlike the human eye) see equally well across the entire image and not just in the middle. My eye sees by taking a series of stills, the brain figures out (guesses) what happened in between. and creates a storyboard. you can still do the 100m hurdles just by blinking your eyes open now and then if you have an accurate internal model of the world. The ability to read back the position of the servos from the port would be nice, but is not essential and i wouldn't bank on that data anyway as seeing is be living. By passing Servo slop etc. Of course using both methods would provide belt and braces calibration. But for now I'm just DESPERATE to get my eye looking around under my brainsoftwares control.  Currently I'm listening to the drone of a synthesised voice telling me left a bit, left a bit more and moving the cam by hand. One quickly tires of being a slave to a profram you have written lol !
« Last Edit: November 14, 2010, 11:29:29 PM by azy »

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Camera Control:Tilt & Pan Servos from within Basic ?
« Reply #5 on: November 14, 2010, 11:23:23 PM »
If you're looking for a really easy hardware implementation: http://www.pololu.com/catalog/product/1350

Have fun!

Offline azyTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Camera Control:Tilt & Pan Servos from within Basic ?
« Reply #6 on: November 14, 2010, 11:35:02 PM »
Yes i did see that and dloaded pololu_usb_sdk_101104.zip (cheap & small )

trouble is it needs to be compiled in c or somthing, I dont have a C compiler and have no idea how to use it to glue all the files together if i did. so the unzipped contents are just all greek to me

Is there a standalone exe i can dload, if only so i can see what the software looks like when its running ? this would realy help

im considering getting my brainsoftware to create a txt file with some instructions

then add some lines of c to open and read that file , as a simple way of passing parameters across (just for now) If you dont know c then you dont know anything. so even doing this is gonna take me a week of my life.
« Last Edit: November 14, 2010, 11:43:05 PM by azy »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Camera Control:Tilt & Pan Servos from within Basic ?
« Reply #7 on: November 15, 2010, 05:20:22 AM »
Hi,

Do you have an LPT port available and a means to call another program (GW used to have the SHELL command that could run a program)?

If you have an LPT and if you get the interfacing solved (with eg. a DLL), I wouldn't mind coding up an executable that is passed some wanted servo positions and then controlling a couple of servos from the LPT port (If run under XP or higher, you may experience glitches due to other stuff or the OS getting their time slices and then hogging the machine though).
I wouldn't have a chance to test it though, as I have no LPT port on the PC I'm using presently.


Microcontrollers are what we all use here. They are complete working computers in a chip (with ALU, memory etc. the whole enchilada) and need no periferals.
Here's a Pic of a PIC:

So far the worlds smallest  ;D
But, if you have to ask, I believe it would set you back in time much more than what you seem to be willing to tolerate, as you have to learn to program and "burn" them (and build or buy the equipment for the latter).


Servos will be much more precise than 10░.
You cannot read their position, but you don't have to, as a (R/C) servo will always be at the commanded position (unless physically stopped at another position of course) - and you have to update this position each 20ms (50 times a second).
Regards,
S°ren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline azyTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Camera Control:Tilt & Pan Servos from within Basic ?
« Reply #8 on: November 16, 2010, 12:06:59 AM »
Freebasic is the basic I'm mainly using, i can do a bit of Qbasic ( got a GW basic book sat on my shelf not used it for years)

http://www.freebasic.net/

Freebasic is free , very powerfull , its compiled , not interpreted at run time. Has windows and dos versions. I use the windows version.

Ive not looked into how FBasic can talk to ports and such, its got includes and dlls , halfway house between c and basic. It has Qbasic compatibility modes, goto's allowed ...lol , the other modes have powerful structured programming features

I have never done any programming that talks to ports etc, roboty type code. My focus up to now has been AI running in virtual environments. I got the "brainssoftware" sorted, I'm just looking at a blackhole of knowledge deficit when it comes to interfacing hardware.

I guess i should try and get some collaboration going cos it looks like I'm heading into a world of pain trying to do this on my own.

had to google LTP port even.(yeah i got 1) I could build a computer from a pile of sand, i understand the principles...but its all theory and no practice.

I need to make simple calls from my brainsoftware, that will trigger a script stored in a chip or the bundled software that's controlling the hardware. Getting the "Brain" computer talking to the "body computer"

I'm using more than one computer to split the load, so computers that do body stuff can concentrate on that (less lag, fewer crashes) information is passed between them by writing and snooping text files. No good for table tennis reaction times, but fast enough for comprehension of the world in most cases.

Looks like most robot peeps code up a mini brain on a chip, my brain is more reflective than reactive.

My brain asks itself stuff like "should i be looking at the ball or something else" = reflective

"I see the ball and im gonna follow it" = reactive

-------------------------------------------

The brain is pretty fuzzy and is pretty loose spec. The  hardwareaccuracy I need is pretty loose spec. This system is much slower but has a huge amount of flexibility....self calibration. Programs or computers can crash but the show still goes on so long as the higher brain is still going.

This is a different way of doing things, brain off chip rather than on it, and that means that communication between the two systems has to be bridged

----------------------------------------------

Ive got to build a body one way or another, Ive got no choice in the matter, my brain cant advance further without one (which is the primary objective) Forgive me if i sound impatient. I'm just looking at all you amazing hardware & drooling, I'm like a frustrated kid in a sweet shop staring at all those jars that are out of reach.

My project is the next step up from AIKO, the brain actually does some high level thinking for itself. If you want it to follow a ball first of all you have to get its attention and then you have to explain to it what you want it to do. In short you have to persuade it into making your commands its top priority (talking to it through a microphone or typing through a keyboard). If it doesn't want to look at the ball...it wont !

I can of course make it follow the ball in manual control mode, but i have to switch of the higher brain in order to do this.


Overview of what ive got and what i need to do
http://www.societyofrobots.com/robotforum/index.php?topic=12597.0

« Last Edit: November 16, 2010, 02:05:30 AM by azy »

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: Camera Control:Tilt & Pan Servos from within Basic ?
« Reply #9 on: November 16, 2010, 06:54:04 AM »
I just typed "freebasic servo" into google and got this:

http://www.freebasic.net/forum/viewtopic.php?p=92158

 A program to control a servo controller in the freebasic support forum.

Offline azyTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Camera Control:Tilt & Pan Servos from within Basic ?
« Reply #10 on: November 16, 2010, 02:08:54 PM »
Ive decided to offer some beers to anyone who can solve the problem, as its over my head


Go here to earn your beer tolkens

http://www.societyofrobots.com/robotforum/index.php?topic=12617.msg94492#msg94492

 


Get Your Ad Here