Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Programming Questions / Re: how to seperate the binary code on: January 17, 2014, 01:48:40 am
It's not an easy problem to decode Morse code. First off, you can't just separate your string of 1's and 0's into pieces 6 bits long. Some characters are long ('h' is 10101010) and others are short ('e' is 10). By the way, the example you give for 's' (3 dots) looks correct (101010), but 'a' (dot dash) should be 101110, not 101000. Most importantly, you need to have a way to know when a character ends. In Morse code the space between characters is the same length as a dash, which would be three zeros in your system. First find a way to determine when a character has ended.

Once you have accomplished that, each character can be isolated. Then simply multiply each bit of the character by increasing powers of a number, say 2. For example, multiply the first bit by 2, the second bit by 4, the third bit by 8 and so on, adding up the numbers as you go. With this method each character will have a unique value that can be identified in a look-up table or a switch() statement.

Good luck!
2  Topics / Science and Measurement / Re: Bullet Speed Sensors on: January 07, 2014, 10:32:41 pm
Quote
...but bear in mind that each analogRead takes around 100 microseconds, which may make a significant error.
You might be better off just using the analogue comparator.

True, 100 microseconds does seem like a long time, but remember at a speed of say 4000 feet/second a bullet would travel only 0.4 feet during an analogRead(). An error of that size seems insignificant over the distances cited by the OP.
3  Topics / Science and Measurement / Re: Bullet Speed Sensors on: January 07, 2014, 01:45:48 am
For an extremely simple solution you could try using 2 electret microphones - one at the gun and the other at the target. I've used this method to measure the speed of airsoft BBs in my living room. My code is below if you are interested:

Code:
// Calculates projectile speed from interval between
// sound of firing and sound of impact with 2 microphones
// Tom Fangrow, 5/26/13

int c, done=0;
unsigned long start=0, finish=0;
float distance=14.5, interval, velocity;

void setup() {
  Serial.begin(9600);       
}

void loop() {
  while(!start) {
    c = analogRead(0);          // firing sound
    if(c>900) {
      start = micros();
    }
  }
  while(!finish) {
    c = analogRead(5);          // target sound
    if(c>900) {
      finish = micros();
    }
  }
  while(!done) {
    interval = float(finish-start);
    velocity = distance*1000000/interval;
    Serial.print("Velocity is ");
    Serial.print(velocity);
    Serial.println(" ft/sec");
    done=1;
  }
}
4  Using Arduino / LEDs and Multiplexing / Re: Two 595 Shift Regs, 4+ 7-Segment LED Displays, Artifacting on: April 27, 2013, 12:41:48 am
Quote
I keep getting these random artifacts chacters.

Are you sure they are random? In the photos where you display only one letter at a time, the "artifact" segment number is the same as the letter number. For example, when letter 1 is on, the artifact is segment 1; when letter 2 is on, the artifact is segment 2, and so on. Is this a coincidence?
5  Using Arduino / LEDs and Multiplexing / Re: Two 595 Shift Regs, 4+ 7-Segment LED Displays, Artifacting on: April 26, 2013, 07:15:56 pm
The value of H has 2 more digits (...14...) than the first part of HELO. Since I don't know what your code does, maybe this is the problem.

// H = 1315141711
// E = 2625242322
// L = 353332
// O = 414243454647   
// HELO = 131517112625242322353332414243454647
6  Using Arduino / Project Guidance / Re: Taking a shot at specific gravity measurements on: March 02, 2013, 11:32:48 pm
There have been many ideas expressed here, but I think the simplest and most robust solution is using a submerged mass suspended by a string as suggested by liudr. If I was making my own beer (I wish I was) it's the method I would use. Here are a few of the benefits:

1. If you want to leave it there all the time, you can.
2. It's easy to move to another tank if desired.
3. It will be immune to foam on the surface or submerged particles.
4. If you suspect bubbles have formed on it, just lower it until it hits bottom to knock them off.
5. If you suspect the liquid is stratified, simply take measurements at different levels to verify.
6. The weight and volume of the mass is not important, as long as it's large compared to the string.
7. It requires exactly 1 calibration ever - by taking 1 measurement in plain water.

I noticed no one posted any equations to calculate specific gravity. Not even those who claimed to have an understanding...  so I'll post equations for liudr's method only:

Code:
float mAir;       // mass suspended in air (load cell measurement)
float mWater;     // mass suspended in water (load cell measurement)
float mBeer;      // mass suspended in beer (load cell measuremet)
float bfWater;    // buoyant force in water
float bfBeer;     // buoyant force in beer
float sgBeer;     // specific gravity of beer

...

bfBeer = mAir - mBeer;
bfWater = mAir - mWater;

sgBeer = bfBeer / bfWater;
7  Using Arduino / Programming Questions / Re: morse code flasher - lookup table question on: February 18, 2013, 12:03:13 am
Quote
JavaMan, In looking back over the posts, I realize that I overlooked your post.  What you have written is VERY similar to what I had in mind when I wrote the pseudocode, with the exception of your case statement.  I visualized using a lookup_table (array).

Very nice!  Very clean code!

Thanks!

AlphaTango,

Thanks for the kind words. I used the case statement instead of an array because it seemed like a more intuitive way to add additional characters. By the way, the comment regarding frequency adjustment is an artifact of another version that beeps instead of flashes.

Tom
8  Using Arduino / Programming Questions / Re: Creating Square Waves with Programmable Frequencies? on: February 12, 2013, 11:32:24 pm
Write your own function like this:

Code:
void squareWave(int freq) {
  float x = 500/freq;
  digitalWrite(speedoPin, HIGH);
  delay(x);
  digitalWrite(speedoPin, LOW);
  delay(x);
}

This code will give you a square wave with 50% duty cycle
9  Using Arduino / Programming Questions / Re: morse code flasher - lookup table question on: February 10, 2013, 11:51:37 pm
You can try this code I wrote last May, it's tested and works on my Uno rev3.

Code:
// flashes  morse code from text on serial port
// special characters to adjust wpm and frequency

char c;                  // read off serial port
int pin = 8;
float dot = 200.0;       // duration of dot for 5 wpm
void setup() {
  pinMode(8, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  while(Serial.available()) {
    c = Serial.read();
    switch(c) {
      case '!' : dot*=1.1; break;        // slower by 10%
      case '@' : dot*=.9; break;         // faster by 10%
      case '%' : report(); break;        // show status
      case ' ' : delay(7*dot); break;
      case 'a' : flash("01"); break;
      case 'b' : flash("1000"); break;
      case 'c' : flash("1010"); break;
      case 'd' : flash("100"); break;
      case 'e' : flash("0"); break;
      case 'f' : flash("0010"); break;
      case 'g' : flash("110"); break;
      case 'h' : flash("0000"); break;
      case 'i' : flash("00"); break;
      case 'j' : flash("0111"); break;
      case 'k' : flash("101"); break;
      case 'l' : flash("0100"); break;
      case 'm' : flash("11"); break;
      case 'n' : flash("10"); break;
      case 'o' : flash("111"); break;
      case 'p' : flash("0110"); break;
      case 'q' : flash("1101"); break;
      case 'r' : flash("010"); break;
      case 's' : flash("000"); break;
      case 't' : flash("1"); break;
      case 'u' : flash("001"); break;
      case 'v' : flash("0001"); break;
      case 'w' : flash("011"); break;
      case 'x' : flash("1001"); break;
      case 'y' : flash("1011"); break;
      case 'z' : flash("1100"); break;
      case 'A' : flash("01"); break;
      case 'B' : flash("1000"); break;
      case 'C' : flash("1010"); break;
      case 'D' : flash("100"); break;
      case 'E' : flash("0"); break;
      case 'F' : flash("0010"); break;
      case 'G' : flash("110"); break;
      case 'H' : flash("0000"); break;
      case 'I' : flash("00"); break;
      case 'J' : flash("0111"); break;
      case 'K' : flash("101"); break;
      case 'L' : flash("0100"); break;
      case 'M' : flash("11"); break;
      case 'N' : flash("10"); break;
      case 'O' : flash("111"); break;
      case 'P' : flash("0110"); break;
      case 'Q' : flash("1011"); break;
      case 'R' : flash("010"); break;
      case 'S' : flash("000"); break;
      case 'T' : flash("1"); break;
      case 'U' : flash("001"); break;
      case 'V' : flash("0001"); break;
      case 'W' : flash("011"); break;
      case 'X' : flash("1001"); break;
      case 'Y' : flash("1011"); break;
      case 'Z' : flash("1100"); break;
      case '0' : flash("11111"); break;
      case '1' : flash("01111"); break;
      case '2' : flash("00111"); break;
      case '3' : flash("00011"); break;
      case '4' : flash("00001"); break;
      case '5' : flash("00000"); break;
      case '6' : flash("10000"); break;
      case '7' : flash("11000"); break;
      case '8' : flash("11100"); break;
      case '9' : flash("11110"); break;
      case '.' : flash("010101"); break;
      case ',' : flash("110011"); break;
      default  : delay(7*dot); break;
    }
  }
}

void flash(char x[]) {
  for(int i=0; i<strlen(x); i++) {
    if(x[i]=='1') {
      digitalWrite(pin, HIGH);        // dash
      delay(3*dot);
      digitalWrite(pin, LOW);
    }
    else {
      digitalWrite(pin, HIGH);        // dot
      delay(dot);
      digitalWrite(pin, LOW);
    }
  delay(dot);               // end of flash
  }
  delay(3*dot);             // end of character
}

void report() {
  Serial.print(1000/dot);
  Serial.print(" wpm, ");
}
 
10  Using Arduino / LEDs and Multiplexing / Re: Newby needs help with Scrolling text help on: January 01, 2013, 06:29:53 pm
Not sure about everything that is wrong (especially the wiring), but the decade counter must be reset after every character. You are doing it only once in the setup(). Also the clock must be pulsed once for each row, but it looks like you are doing it for every column of every row.   
11  Community / Bar Sport / Re: Radio Shack Inventory (Arduino) on: December 21, 2012, 01:55:15 am
Quote
Surely you know the reference, or if not, throw away two hours of your life and write them off as spent poorly, and watch the movie.

Thanks for that. I had not heard of the movie, but I shall make a New Year's resolution to see it.
12  Community / Bar Sport / Re: Radio Shack Inventory (Arduino) on: December 17, 2012, 01:36:11 am
I actually bought my Uno R3 at a Radio Shack in San Clemente, CA back in April. Also the "Getting Started..." book, a PIR sensor, and a few components. Only later did I discover Jameco, Mouser, Futurlec, Sparkfun, Tayda, and many others. Now I mostly buy everything online, but if I need something right now I go to Radio Shack. The last time I was there they had Uno, Mega, Nano, motor shield, wifi shield, ethernet shield and a couple of Arduino starter kits.

By the way, OP, what IS that thing on your tongue????
13  Using Arduino / Sensors / Re: Density sensor of solids on: November 25, 2012, 11:06:26 pm
Quote
I need to know if a piece of wood have structural conditions or not.

You might consider measuring the hardness of the wood with a durometer tester.
www.fvfowler.com/resource/pdf/2304/2304_374-375.pdf

14  Using Arduino / Project Guidance / Re: GPS under the skin on: October 25, 2012, 08:59:56 pm
Quote
Thoughts? Ideas?

Sure, I have a thought. Steal the dog, but leave the collar alone. Nothing is transmitted. Eventually the battery will go dead and the collar can be safely removed.
15  Using Arduino / Project Guidance / Re: Pedal power meter on: October 25, 2012, 08:36:31 pm
Quote
Comments on what I’m planning and/or alternative methods of doing it are also welcome.

What do you care about power to the pedals? What you want is thrust! Since thrust depends entirely on propeller rotation, all you have to do is measure the propeller rpm.
Pages: [1] 2 3 ... 8