Show Posts
Pages: 1 ... 28 29 [30] 31 32 ... 96
436  Using Arduino / Programming Questions / Re: Extracting numbers, to put in 3 array, from a string (Computer side code added) on: July 12, 2013, 09:54:18 pm
Code:
  // Read serial input:
  if (Serial.available() > 0) {
    inChar = Serial.read();
  }

That reads a character if one is available and then proceeds even if one is *not* available!

Try replacing it with this:
Code:
  // Read serial input:
  while(Serial.available() < 1);
  inChar = Serial.read();
 

You will also run into problems eventually because it is a bad idea to use the String class.
But give my fix a try first and let's see if the code parses the string properly.

Pete
437  Using Arduino / Programming Questions / Re: Extracting number from a string (Computer side code added) on: July 12, 2013, 09:25:12 pm
Read this: How to post code properly

Pete
438  Using Arduino / Programming Questions / Re: Reverse Geocache Box coding problem on: July 11, 2013, 10:24:32 pm
Code:
  if (mySerial.available() > 0)
  {
    Serial.write(mySerial.read());                         // send raw GPS data to serial monitor
   
    if (tinygps.encode(mySerial.read()))

You read two consecutive characters from mySerial but "mySerial.available() > 0" only guarantees you that there is at least one. I think what you may have intended here was something like this:
Code:
    char c = mySerial.read();
    Serial.write(c);
    if (tinygps.encode(c))


Pete

439  Using Arduino / Programming Questions / Re: New user unable to verify or compile on: July 09, 2013, 02:28:06 pm
I think you need to post the code (between code tags) which causes the error and it might help to post all the error messages you are getting.

Pete
440  Using Arduino / Programming Questions / Re: New user unable to verify or compile on: July 09, 2013, 02:12:25 pm
Quote
my pc runs windows 7 64-bit and i have version 1.0.5 of the arduino software which is run in compatibility mode for windows 2000
I'm also using Win7 (Pro) 64-bit with 1.0.5 but I haven't had to run it in compatibility mode. Did you have problems that required it?

Pete
441  Topics / Science and Measurement / Re: Playing with FFT on: July 07, 2013, 12:39:54 pm
Quote
for (i=0; i<511; i++) {
  k = 1023*sin(2*pi*f/i);
}

Divide by zero. And the time difference between samples, since it is 1/i, will not be constant.

Pete
442  Using Arduino / Programming Questions / Re: MatrixMath numbers smaller than e^-5 PROBLEM on: July 06, 2013, 10:16:26 pm
You probably need to specify that more decimal places should be printed:
Code:
Serial.println(a,8);

Pete
443  Using Arduino / Audio / Re: Generate tone without tone library on: July 06, 2013, 01:34:14 pm
Try this:
Code:
#define PERIOD (1000000L/(FREQ*2))

Also, read How to post code properly and do it.

Pete
444  Topics / Science and Measurement / Re: Playing with FFT on: July 05, 2013, 08:44:21 pm
Quote
if you set A=1, all your samples will be small values
More to the point, if you are using the same library as I am, the samples are all 8-bit integers so if A=1 the only values you would be giving the FFT would be -1, 0 and +1 which would result in a very noisy signal!

Pete
445  Topics / Science and Measurement / Re: Playing with FFT on: July 05, 2013, 08:20:36 pm
The sine function has values between plus one and minus one so if you set A=1, all your samples will be small values. With a clean signal you should still be able to pick out the tone but it is a lot easier when the amplitude is larger.

Quote
I still have a lot of other numbers in other bins. Is that normal to FFT?
You have exhausted what I know about the FFT :-) You can get noise in the resulting signal but it should be significantly lower than the tone you're looking for. I also get strange results with some signals and I haven't been able to figure out why it happens.

Pete
446  Using Arduino / Programming Questions / Re: EEPROM I2C communication on: July 05, 2013, 02:22:16 pm
Your code works for me.
If an I2C scanner sees the address of the EEPROM the code should work.

Pete
447  Topics / Science and Measurement / Re: Playing with FFT on: July 04, 2013, 08:09:32 pm
Code:
k = 127*sin(2*3.14 * 100 * t )
The problem is with the values of t that you use. The basic formula is, as you have it there, A*sin(2*3.14 * f * t)
where A is amplitude, f is the frequency in Hertz, and t is in seconds.
But in your loop the values of t are 0, 1, 2, 3 etc. So your code is "sampling" the 100Hz sine wave once every second - i.e. at t=0 seconds, then t=1 second, etc.
To sample the sine wave at, say, 1000Hz you would need to generate samples for t = 0, .001, .002, .003 etc. which would require that t be a floating point value and increment it by .001 each time through the loop.
For a simulated sampling rate of 38.5kHz you would need to increment t by .000025974.
With 256 samples you will be generating the equivalent of 6.65ms.

BTW, I don't know how sensitive the FFT will be to numerical errors but I would suggest that you use a more precise value for pi. use 127*sin(2*PI*100*t)

Pete
448  Using Arduino / Audio / Re: Please help with arduino fft library on: July 04, 2013, 05:57:32 pm
I don't think your test code is generating a useful sine wave. Have a look at the code I reference in this thread:
http://forum.arduino.cc/index.php?topic=96562.0

Pete
449  Using Arduino / Programming Questions / Re: EEPROM I2C communication on: July 03, 2013, 04:19:58 pm
You need to put
Wire.begin()
in setup before using the EEPROM.

Pete
450  Using Arduino / Programming Questions / Re: EEPROM I2C communication on: July 03, 2013, 02:44:35 pm
Both of those functions return the number of bytes read or written. First thing to try is to print out both of them.
If they both report the correct number, I'd guess that it is a wiring error.
One thing to also try is an I2C bus scanner to make sure that the EEPROM is detectable on the bus.
http://playground.arduino.cc/Main/I2cScanner

Which Arduino are you using?

Pete
Pages: 1 ... 28 29 [30] 31 32 ... 96