Pages: [1]   Go Down
Author Topic: Simple arduino routerbot  (Read 1495 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm making a simple routerbot using an arduino (below link). I've found that while using the arduino with an ethernet shield and controlling two continous rotation servos, the servos generally have too much twitching going on. That being said, using an ssc-32 servo controller supplied info from the arduino seems to be very stable. I'm using a D-Link wireless adapter on the laptop to connect to a non hacked netgear wireless router, which connects to the ethernet shield via a cat5 patch cord. I use a simple web page on the pc to send the commands to the arduino setup.

http://www.lynxmotion.net/viewtopic.php?f=20&t=6343
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Boston Suburbs
Offline Offline
God Member
*****
Karma: 14
Posts: 955
I am above your silly so-called "Laws", Mister Ohm.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Very cool.  Now, what you do is build an army of them that run on solar cells (hmm, not outlandish so far).  Each one keeps going until it's received signal from the previous node drops to a certain level, at which point it becomes a "repeater" as a bridge.  If it's received signal drops below a certain point, it would backtrack until it found signal.. and if signal is above a certain point, the node would pull up stakes and set out to find a new "home".

It would run as a self-healing WiFi network, which would be extremely fault-tolerant and self-repairing.. nodes simply seek to extend range at all times while still remaining interconnected.  One might base the "homing" rules on being able to get connection to two or more nodes to set up camp.. I'd be surprised if this type of thing hasn't been worked out before.  For you guys that remember radio days, wouldn't a self-ranging free-roaming repeater network have been fun?

Outlandish.. for a hobbyist, yes.  However, you might be surprised what NASA and the Military might make feasible, if they like a technology... happened many times before..  and imagine a battlefield network that autonomously repairs itself and re-ranges based on an updatable (as they are interconnected) rule set..  
« Last Edit: October 17, 2010, 07:56:48 pm by focalist » Logged

When the testing is complete there will be... cake.

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah! Moved the servos to pins 6 and 7 and the twitching seems to pretty much gone away. Pins 8 and above must have some additional timing activities going on. Very steady so far.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Below is the basic code for the simple Arduino server setup and the HTML control page.

Arduino server code:
Code:
//zoomkat 10-17-10
//routerbot code
//for use with IDE 0018
//open serial monitor to see what the arduino receives
// http://arduino.cc/en/uploads/Tutorial/String.zip for WString.h

#include <WString.h>
#include <Ethernet.h>
#include <Servo.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(84); //server port

String readString = String(100);
String servo1 = String(10);
String servo2 = String(10);

 
Servo myservo1;  // create servo object to control a servo
Servo myservo2;
 //////////////////////

void setup(){

//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();

//enable serial data print
Serial.begin(9600);
myservo1.attach(7);
myservo2.attach(6);
Serial.println("bot1"); // so I can keep track of what is loaded
}

void loop(){
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();

//read char by char HTTP request
if (readString.length() < 100) {

//store characters to string
readString.append(c);
}

//if HTTP request has ended
if (c == '\n') {

///////////////
Serial.println(readString);

//readString looks like "GET /?-1500-1500 HTTP/1.1"

      if (readString.length() >0) {
      Serial.println(readString);
            
      servo1 = readString.substring(7, 11);
      servo2 = readString.substring(12, 16);
      
      Serial.println(servo1);
      Serial.println(servo2);
      
      int n1;
      int n2;
      
      n1 = atoi(servo1); //convert string to number
      n2 = atoi(servo2);
      myservo1.writeMicroseconds(n1);
      myservo2.writeMicroseconds(n2);
      
      //myservo.write(n);
      readString="";
      }
  ///////////////////
  
  //now output HTML data header
  client.println("HTTP/1.1 204 Zoomkat");
  client.println();
  client.println();
  delay(1);
  //stopping client
client.stop();

/////////////////////
//clearing string for next read
readString="";
  
}}}}}


Control web page:
Code:
<HTML>
<HEAD>
<H3>Zoomkat's Routerbot<BR> Web Control Page</H3>
<TITLE>Zoomkat's Routerbot Control Page</TITLE>
</HEAD>
<BODY>

Foward-*Stop*-Reverse
<BR>

<a href="http://192.168.1.102:84/?-1000-2000" target="inlineframe">F-F</a>|
<a href="http://192.168.1.102:84/?-1450-1550" target="inlineframe">S-F</a>|
<a href="http://192.168.1.102:84/?-1500-1500" target="inlineframe">*-Stop-*</a>|
<a href="http://192.168.1.102:84/?-1550-1450" target="inlineframe">S-R</a>|
<a href="http://192.168.1.102:84/?-2000-1000" target="inlineframe">F-R</a>|
<BR>
<BR>
Turn-L-*Stop*-Turn-R
<BR>
<a href="http://192.168.1.102:84/?-1000-1000" target="inlineframe">F-L</a>|
<a href="http://192.168.1.102:84/?-1450-1450" target="inlineframe">S-L</a>|
<a href="http://192.168.1.102:84/?-1500-1500" target="inlineframe">*-Stop-*</a>|
<a href="http://192.168.1.102:84/?-1550-1550" target="inlineframe">S-R</a>|
<a href="http://192.168.1.102:84/?-2000-2000" target="inlineframe">F-R</a>|
<BR>
<IFRAME name=inlineframe
src="res://D:\WINDOWS\System32\shdoclc.dll/dnserror.htm" width=1
height=1> this will hold the html answer of the moves
</IFRAME>

</body>
</html>
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

London
Offline Offline
Sr. Member
****
Karma: 0
Posts: 330
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Very nice.
Have you looked at the wireless shields from async labs.
You could lose the wifi router and save a lot of power.
http://www.asynclabs.com/store?page=shop.browse&category_id=6

Gordon
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A router may be able to have more wireless power than a wifi shield, and an IP cam can be plugged into the router so the bot can have eyes. Probably for max range two routers in bridging mode with hi gain antennas would be the ticket. My router uses ~180ma at 12v, but it is just a $40 netgear from walmart.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Updated code for use with arduino 0021 IDE.

Code:
//zoomkat 10-22-10
//routerbot code
//for use with Arduino 0021 IDE
//open serial monitor to see what the arduino receives
//

#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(84); //server port

String readString, servo1, servo2;
 
Servo myservo1;  // create servo object to control a servo
Servo myservo2;
 //////////////////////

void setup(){

//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();

//enable serial data print
Serial.begin(9600);
myservo1.attach(7);
myservo2.attach(6);
Serial.println("bot1"); // so I can keep track of what is loaded
}

void loop(){
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();

//read char by char HTTP request
if (readString.length() < 100) {

//store characters to string
readString += c;
}

//if HTTP request has ended
if (c == '\n') {

///////////////
Serial.println(readString);

//readString looks like "GET /?-1500-1500 HTTP/1.1"

      if (readString.length() >0) {
      Serial.println(readString);
            
      servo1 = readString.substring(7, 11);
      servo2 = readString.substring(12, 16);
      
      Serial.println(servo1);
      Serial.println(servo2);
      
      int n1;
      int n2;
      
      char carray1[6];
      servo1.toCharArray(carray1, sizeof(carray1));
      n1 = atoi(carray1);
      
      char carray2[6];
      servo2.toCharArray(carray2, sizeof(carray2));
      n2 = atoi(carray2);
      
      myservo1.writeMicroseconds(n1);
      myservo2.writeMicroseconds(n2);
      
      //myservo.write(n);
      readString="";
      }
  ///////////////////
  
  //now output HTML data header
  client.println("HTTP/1.1 204 Zoomkat");
  client.println();
  client.println();
  delay(1);
  //stopping client
client.stop();

/////////////////////
//clearing string for next read
readString="";
  
}}}}}

« Last Edit: October 22, 2010, 02:09:12 pm by zoomkat » Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Full Member
***
Karma: 4
Posts: 218
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well look I read the posts and went to the web site but I have a question that brought me here in the first place .

If I connected the robot to a camera could I control the camera picture sent from some remote location. I have a camera feeding images to an ftp site from whence I download an image a second to my home 50 miles away. The camera is run by a remote pc through a mobile dongle to my ISP site storage.

I would like to be able to pan and zoom the image from home
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe something like my cam below?

http://web.comporium.net/~shb/wc2000-PT-script.htm
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Full Member
***
Karma: 4
Posts: 218
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd really like to see it but I get the following

"Firefox doesn't know how to open this address, because the protocol (res) isn't associated with any program."

I can  see the page but nothing works?===take that back ,I was not patient enough and I did not use the controls properly

I have it now -dont know what the above message does but the rest is working .Thanks I'll study this

Mannn   thats bloody brilliant first time I have seen that.
« Last Edit: October 24, 2010, 05:36:02 am by april.steel » Logged

0
Offline Offline
Full Member
***
Karma: 4
Posts: 218
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see that this works but is about 6 years old. Would u do anything differently today? Looking particularly at the dos programming and web page display would u make any changes?

What about how you control the pan & tilt?
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I see that this works but is about 6 years old. Would u do anything differently today? Looking particularly at the dos programming and web page display would u make any changes?

What about how you control the pan & tilt?

I haven't seen anything simpler for web control via a pc/apache combo. Simple web control page and and CGI batch file made in notepad is something anybody can put together. The pan/tilt is made from two hobby servos, which are controlled from a servo control chip. The cgi batch file sends the position commands out the serial port to the servo control chip. If one is interested in getting data back from an external device, then two way serial port access is needed. A simple two way serial cgi program can be made (below) to send the request to the external gizmo, and then receive the info and pass it on th apache to send back to the client brouser. The same setup ca be used with an arduino with an ethernet shield, connected to the internet.

http://www.lynxmotion.net/viewtopic.php?f=28&t=1874
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: [1]   Go Up
Jump to: