Show Posts
Pages: 1 ... 59 60 [61] 62 63 ... 93
901  Using Arduino / Project Guidance / Re: Parsing image for processing on Arduino on: April 10, 2012, 07:44:05 am
Thanks for the compliment!  You DO have great control of the sensitivity.  Just use a bigger threshold to detect change. 

Unfortunately it doesn't work when there are big dark shadows.  The change in the noisy pixels is greater than most real changes you'd wish to detect.  It also does not work in the dark to detect a laser dot.  Turning a laser on and off has no impact on the size compared to the noise.  With a 1W IR it looks like a huge spotlight to the camera, but it doesn't help.  It would not work great with the wind blowing the trees.  There will always be a change, although not as much as you think!  If the trees are far enough away, even during a storm, the size does not change.  It is ideal for a static, well lit, scene.  Then you can make it sensitive enough to detect your fingers moving at 10m.  Or less sensitive to detect only when you're walking.  You can choose.  Listed above are the only limitations I've found. 

Next stop is to detect even a few pixels of change during daylight.  They must be near each other.  In a static scene.  Ignoring noise in the shadows.  This must be done on the PC.  I should be able to detect a powerful IR laser dot during the day with this method.  But there's no need for this, as you can detect motion without the laser.
902  Using Arduino / Project Guidance / Re: Transmitting Webcam Stream via RF on: April 10, 2012, 07:27:00 am
If you want to save battery power, or trigger an alarm on Uno, buy a Grove serial JPG camera.
If you want to save the images to SD, without an RF transmitter, serial JPG is the answer.
It can sleep and only transmit when there's movement.
You can measure this with PIR or any other sensor, in addition to the camera itself.
Put all 3 of them to sleep for an interval:
Uno
XBee
Grove camera

This would use much less power than an always on 2.4Ghz sender.
Mine uses 200ma compared to an average of 2ma for Grove.
I suppose you could put any transmitter to sleep to save power.
903  Using Arduino / Project Guidance / Re: fiber optic balloons on: April 10, 2012, 07:13:22 am
Last year I've been playing with hot air solar balloons.  Can barely lift a Nano with GPS.  I like your idea better.
Why not aim a laser at it instead? 
904  Using Arduino / Project Guidance / Re: HMC5883L compass huge error on: April 10, 2012, 07:05:46 am
It's a popular chip.  I've tried 3 different examples.  All the same results. 
The X reading is consistent.  The Y reading is consistent.  Perhaps they need to be scaled to match each other in magnitude?
905  Using Arduino / Project Guidance / Re: HMC5883L compass huge error on: April 10, 2012, 12:31:35 am
Tried all the gain settings using a different Example and library code. 
When I face it's arbitrary North I get 0, 50, 130, 320 for N,E,S,W
That is 0,-40,-50,+50 errors
or 50,0,0,100 errors if I use S as my reference.
What next?
Use the other chip...
906  Using Arduino / Project Guidance / Re: HMC5883L compass huge error on: April 09, 2012, 11:42:01 pm
Good points to both of you.  I didn't like the way the code looked so I fixed it anyway.  I don't see how that can possibly be related to my problem.  Funny, it seemed to help a little!  I'd like to point out that it is probably a hardware issue.  I have used other example code without modification and it still cannot find North and South correctly.  How can I fix this problem?  Lookup table?  The number are consistently wrong.  When I draw lines on a paper and put it back to those lines, it always reads exactly the same number of degrees when it's kept level.  But off by 20-90 degrees from the orientation of my house.  I've moved it 2 feet from my laptop to avoid interference.  It seems consistent no matter where I place the unit before I rotate it.  Any more ideas?
907  Using Arduino / Motors, Mechanics, and Power / Re: New 28BYJ-48 library on: April 09, 2012, 11:21:52 pm
It's not in the format of an Arduino library yet.  It's a single file no .H including all the functions and loop().  In some ways this makes it easier to experiment and change my functions.  When we're done changing it I know how to make it into a real Library.

Here it is again, same as before:
908  Using Arduino / Project Guidance / Re: simple tracking device on: April 09, 2012, 09:40:15 pm
I'm looking forward to seeing how this turns out?  I will pursue the Serial JPG camera method, we can compare in the end.
909  Using Arduino / Project Guidance / Re: Arduino Web Client to External Server on: April 09, 2012, 09:38:17 pm
Yes, I agree the PC browser must have Javascript for those 2.  Certainly mine does.  What does the Processing code need to make this work?  Did I do something wrong when I translated it from Arduino to Processing?  I assume it worked on Uno?
910  Using Arduino / Project Guidance / Re: Building A self-balancing bicycle on: April 09, 2012, 09:31:09 pm
@retro- That only applies at speed.  Pushing the opposite handlebar.  Below about 20 mph it works the opposite.  At slow speed we balance a motorcycle with our weight shift, and large turns of the bars/bike.
911  Using Arduino / Project Guidance / HMC5883L compass huge error [SOLVED] on: April 09, 2012, 09:27:41 pm
It's a compass when it's held level.  It's repeatable to within 1 degree when you hold it level and don't move, in any direction.  But it can be off by 90 degrees in an absolute sense.  Not accurate at all for finding North.  Any ideas?  Mistakes in code?

It's mounted upside down in my application so I fixed it in the code by 360-heading.  It seems to work very differently when I mount it right side up, but upon further analysis, the error is the same just reversed?

Could I use a simple translation table to translate the error degrees to the correct number?  
At least it's consistent!

I don't see the point of making it 3D using accell data on my board.  The Z data is consistent and constant when I hold it level, it is near the maximum amount when you rotate it.  So I don't understand how knowing the orientation, if it's changing, plus Z data, will help?

It's not as accurate in an absolute sense as this:
HMC6452  
No complicated math if you hold it near level!

Code:
/*
Arduino example for interfacing with the HMC5883L
by: Jordan McConnell SparkFun Electronics
created on: 6/30/11
*/
#include <Wire.h> //I2C Arduino Library
#define address 0x1E //0011110b, I2C 7bit address of HMC5883

int cnt=0;
int x,y,z;
long xx,yy,zz;

void setup(){
  //Initialize Serial and I2C communications
  Serial.begin(9600);
  Wire.begin();  
  //Put the HMC5883 IC into the correct operating mode
  Wire.beginTransmission(address); //open communication with HMC5883
  Wire.send(0x02); //select mode register
  Wire.send(0x00); //continuous measurement mode
  Wire.endTransmission();
}
void loop(){  
  //Tell the HMC5883 where to begin reading data
  Wire.beginTransmission(address);
  Wire.send(0x03); //select register 3, X MSB register
  Wire.endTransmission();
  //Read data from each axis, 2 registers per axis
  Wire.requestFrom(address, 6);
  if(6<=Wire.available()){
    x = Wire.receive()<<8; //X msb
    x |= Wire.receive(); //X lsb
    z = Wire.receive()<<8; //Z msb
    z |= Wire.receive(); //Z lsb
    y = Wire.receive()<<8; //Y msb
    y |= Wire.receive(); //Y lsb
  }
  /*
  //Print out values of each axis
  Serial.print("x: ");
  Serial.print(x);
  Serial.print("  y: ");
  Serial.print(y);
  Serial.print("  z: ");
  Serial.println(z);
  */
//Serial.print(z);Serial.write(32);
//repeatable within 1 deg, but off by 90 deg?
if(avgxyz())
if(zz>4800){  //near level 5200 max down, in MA
  //Serial.print(xx);Serial.write(32);Serial.println(yy);
  float heading=atan2(yy,xx);
  heading*=(180/M_PI);
  //declination here degrees
  if(heading<0)heading+=360;
  if(heading>360)heading-=360;  //for + declination only  
  //upside down on board so...
  heading=360-heading;
  Serial.println(heading);
  }
delay(50);  //50 or 150 more acc 3s
}
boolean avgxyz(){
const int N=20;  //matches delay 20*50=1s
boolean b;
cnt++;
if(cnt%N==1)xx=yy=zz=0;
xx+=x;
yy+=y;
zz+=z;
if(b=!(cnt%N)){
  xx=xx*10/N;yy=yy*10/N;zz=zz*10/N; }
return(b);
}
912  Using Arduino / Project Guidance / Re: Arduino Web Client to External Server on: April 09, 2012, 04:59:42 pm
This is an alternative if you don't have an Ethernet Shield.  Works great with XBee to get data from Uno to PC.
This is Processing code for PC, not Arduino code:

It serves a simple web page with pin values.  You must write the Arduino code to send the data serially to PC first.
But that's the easy part right?

Code:
import processing.net.*;
Server myServer;
void setup(){
size(200,200);
//myClient=new Client(this,"192.168.1.2",80);
myServer=new Server(this,69);
}
void draw(){
delay(1000);  //reduce CPU
Client client=myServer.available();
if(client!=null) {
println("New connection");
boolean currentLineIsBlank = true;

while (true) {  //uses break
char c=char(client.read());
if(c!=-1) {
        // Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
  if (c == '\n' && currentLineIsBlank) {
    client.write("HTTP/1.1 200 OK\n");
    client.write("Content-Type: text/html\n");
    client.write("Connnection: close\n");
    client.write("\n");
    client.write("<!DOCTYPE HTML>\n");
    client.write("<html>\n");
        // add a meta refresh tag, so the browser pulls again every 5 seconds:
    client.write("<meta http-equiv=\"refresh\" content=\"5\">\n");
    client.write("Hi\n");
   
    //client.write your digital and analog pin values from XBee here
   
    client.write("</html>\n");
    break;   
    }
  if (c == '\n') currentLineIsBlank = true;
  else if (c != '\r') currentLineIsBlank = false;
}}
delay(10);
client.stop();
}}  //draw, new connection
913  Using Arduino / Project Guidance / Re: Arduino Web Client to External Server on: April 09, 2012, 04:49:15 pm
I changed your code to work on PC with Processing.  Will be getting data from XBee to serve it.
Why does DIY buttons work, but not the other 2 on PC?

Code:
import processing.net.*;
Server myServer;
String readString=".";
void setup(){
size(200,200);
//myClient=new Client(this,"192.168.1.2",80);
myServer=new Server(this,69);
}
void draw(){
delay(1000);  //reduce CPU
Client client=myServer.available();
if(client!=null) {
println("New connection");
boolean currentLineIsBlank = true;

while (true) {  //uses break
char c=char(client.read());
if(c!=-1) {
        // Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
  if (readString.length() < 100) readString+=c;
  if (c == '\n' && currentLineIsBlank) {
   
          client.write("HTTP/1.1 200 OK\n"); //send new page
          client.write("Content-Type: text/html\n");
          client.write("\n");

          client.write("<HTML>\n");
          client.write("<HEAD>\n");
          client.write("<TITLE>Arduino GET test page</TITLE>\n");
          client.write("</HEAD>\n");
          client.write("<BODY>\n");

          client.write("<H1>Zoomkat's simple Arduino button</H1>\n");
         
          // DIY buttons
          client.write("<a href=\"/?on\"\">ON</a>\n");
          client.write("<a href=\"/?off\"\">OFF</a><br />\n");

          // mousedown buttons
          client.write("<br><input type=\"button\" value=\"ON\" onmousedown=\"location.href ('/?on');\"/>\n");
          client.write("<input type=\"button\" value=\"OFF\" onmousedown=\"location.href ('/?off');\"/>\n");       
         
          // mousedown radio buttons
          client.write("<br><br><input type=\"radio\" value=\"ON\" onmousedown=\"location.href ('/?on');\"\">ON</>\n");
          client.write("<input type=\"radio\" value=\"OFF\" onmousedown=\"location.href ('/?off');\"\">OFF</>\n");       
 
          client.write("</BODY>\n");
          client.write("</HTML>\n");
         
//println(readString);
          if(readString.indexOf("on") >0) print("On");
          if(readString.indexOf("off") >0) print("Off");
          readString=".";
   
    break;   
    }
  if (c == '\n') currentLineIsBlank = true;
  else if (c != '\r') currentLineIsBlank = false;
}}
delay(1);
client.stop();
}}  //draw, new connection
914  Using Arduino / Project Guidance / Re: Serial communication stops after long periods. on: April 09, 2012, 11:22:57 am
I had a similar problem.  The TX light stops blinking.  The Sketch continues to run, but the PC doesn't see the data.  It has something to do with the USB chip on the Uno.  When you run the same sketch on a Pro mini using only 1 wire connected to the serial TX, obviously an LED will still blink if you connect one.  You can read this data with serial TTL to USB converter.  I'm not saying the USB chip is defective or stops on it's own.  It's reacting to something on the PC.  Perhaps closing the PC port inadvertently.  I'm going to say something obvious here:  Something is changing on the PC causing this to happen after a few hours.  You can prove this by disconnecting the USB cable, then restarting the sketch without it.

A power surge from the refrigerator could effect the USB chip without resetting the 328?
915  Using Arduino / Project Guidance / Re: simple tracking device on: April 09, 2012, 10:57:38 am
I've been able to track a laser dot, the reflection, with a camera on a servo. 
I'm curious to see how you do it without a camera?
All you need is a light sensor that varies with the angle?
For example 2 sensors with a thin wall between them so one side is partially blocked until it's straight on?
If there is other light sources you will need to modulate it somehow.

It's easy to detect a dot in the dark with a camera.
How can I do it when it's light, with IR laser?  Here's my idea:
Sample 2 frames, laser off, then on.
Calculate the threshold where 99% pixels are darker.
Count number of pixels above this, compare on to off.
The count alone will tell you IF there's a dot.
The pixels that changed, where.
This will work when the scene is moving a little, wind blowing trees.

When the scene is completely static, you can look for any pixels that got brighter near to each other.
Brighter by more than a constant threshold.
What do you think?
Pages: 1 ... 59 60 [61] 62 63 ... 93