After I completed this project I looked around the internet and found several other examples of this type of thing. But I hope the documentation here is still useful as I don't recall any examples showing detail of how to use the Arduino and more specifically, the Xport in the designs.
Here are the pieces I used:
* Arduino (http://www.arduino.cc/)
* Arduino ethernet shield (http://ladyada.net/make/eshield/index.html)
* Latronix Xport Direct (http://www.lantronix.com/device-networking/embedded-device-servers/xport-direct.html)
* 2 servos from my crashed RC glider
* The mechanical bits. I used machined aluminum but you can use anything you like
CODE
I started with Ladyada's examples (http://ladyada.net/make/eshield/examples.html)
You can find my Arduino code here: http://docs.google.com/Doc?id=dhjz44fg_5ct5p2374
You'll need to make sure you include the necessary libraries (AF_Xport.h, AFSoftSerial.h, ServoTimer1.h) which are needed by the code.
The code is fairly straightforward except for the bits about the web page. Being an HTML rookie, I struggled a bit, but keeping things simple and using MS Frontpage as a crutch, I managed to create a very simple webpage. And it needs to be simple to fit within the limited memory of the Arduino. The large char strings early on in the code store the HTML. Note that for every quotation mark in your HTML, you need to add a \ before so that you don't terminate the string.
One key is to enable a variable via the webpage pushbuttons. Each pushbutton assigns a different value to the variable which tells the program which servo to turn as well as the direction. This line of code was important to understanding how web pages transmit user input:
found = strstr(linebuffer, "?servo="); // "?inputfield=" GET request
Printing out the line buffer in the serial window allows you to see exactly the info that your web page is sending out upon a button push. You look for this information in the line buffer and then extract the useful part - in this case, the value to indicate which button was pushed.
Another slight glitch I found was that the baudrate had to be reduced from that used in ladyada's example. I don't know why.
WEBPAGE SETUP
One more area of complication is accessing the webpages. The Linksys webcam has its own internal webserver. This is accessed remotely by enabling port forwarding on your router. To access this remotely, make use of your computer's ip address (not your local network) followed by a colon, and then the port that the webcam uses. For example (this is a fake ip addy): http://208.168.201.37:1024
The Linksys happens to use 1024 as its port. You do exactly the same for the Xport, except it uses a different port which is specified during the Xport setup process (see the ladyada site for instructions). In my case it was 10001.
Note that your ip provider probably provides a dynamic ip address to your computer, meaning that it may change over some time (days, weeks, months). To deal with this situation you may want to make use of a DNS service provider. I used dyndns.com which is a free service. This allowed me to use a semi-custom name that is linked to your computer's ip address (for example, something like http://yourname.dnsdojo.net:10001/). When your ip address changes, software on your computer updates the DNS service provider.
Here's an example of the router setup to enable the port forwarding:
ELECTRONICS
These are stupidly simple. I merely plugged the servos into ground and pins 9 and 10.
MECHANICS
I was lucky to have access to aluminum scraps and a machine shop. I have limited skills with the equipment but was able to fashion some workable parts. You can easily use any material you like. I happened to put the pan servo mechanism on the bottom and then attached the tilt mechanism to that.
The entire mechanism was mounted on a tripod using a tapped 1/4" hole in the baseplate. Here are some additional pics of the mechanism.
Very Cool... Can you verify the link to google docs for your code? I currently get a blank page.
ReplyDeleteSorry for the missing code - I will have this fixed in a few hours...
ReplyDeleteThis is great! So... When are you going to make that webpage accessible so WE can move it around? ;)
ReplyDeleteVery cool, I am planning on using a similar servo setup to build a laser pointer controlling robot to play with the cats when we are not around.
ReplyDeleteVery nice, I did a quick'n'dirt port for the wiznet module which can be found here:
ReplyDeletehttp://de.pastebin.ca/1511389
Servos are connected to port 2 and 3, you need the SoftServo Library (www.arduino.cc)
I will return here again!
ReplyDeleteI am very interested in your use of the hardware counter with the encoder. Could you please help me with some code to just do that and output the number?
ReplyDeleteThanks,
Cory
xport has been discontinued do you think that the new model can be used ?
ReplyDeletehttp://www.lantronix.com/device-networking/embedded-device-servers/xport-direct-plus.html
I am using an xport direct+ in, for your intents and purposes, a similar project and it works fine.
ReplyDeleteI do have 1 issue though, and I'm wondering if you (Dennis, the author) have had any like problems. That is, the webpage occasionally doesn't appear to load, but when I check the source, it's all the HTML that should be printed. It just appears like a blank page. Reloading the page usually fixes it, but still, that shouldn't need to be done. Any ideas?
great job. Im looking at arduino, and have a little electronic experience from high school. Do you recommend any good online stores to but general electronics kits and components?
ReplyDeletei'm needing to know how to create the small webpage with the up,down,left,right,center controls and i need to know how to make the webpage control the arduino. please email me at thegoodrobot@Yahoo.com
ReplyDeleteHey man,
ReplyDeleteFirstly I would like to say I am a huge fan of your work.
Me and my friends were trying to do the Arduino Webcam Servo Project. We have done everything exactly as you instructed.
But it does not work. The code compiles onto the arduino properly. We have configured the shield via telnet exactly like you specified. The wirings have been done exactly as the pins you specified too. But the html loaded on the system does not want to load. It keeps timing out regardless of however ways we have tried.
Also one point to note is that since the XPort direct has been discontinued so we are using hte XPort direct+ !
We are eagerly hoping from a response from you,
Thanking you in advance
sincerely,
Mehran Reza
mehran.m.reza@gmail.com
Hi Dennis,
ReplyDeleteI have questions regarding some sensor integration with Arduino.
Can you help me?
Thanks,
Venkat
Hi! What type of strange gun appears in the video, inside a sort of briefcase?
ReplyDeleteGreat project BTW!!!
Thanks