Show Posts
Pages: 1 ... 24 25 [26] 27 28 ... 105
376  Community / Bar Sport / Re: Finally, a use for spam! on: November 18, 2013, 03:17:30 pm
You do not want to filter mail disguised as spam to be filtered.
I realize that and I'm sure the NSA does too.

377  Community / Bar Sport / Re: Finally, a use for spam! on: November 18, 2013, 10:52:37 am
If anyone can come up with a really effective spam filter, the NSA ought to be able to do it, and probably have. But they'll keep it secret for a hundred years.

378  Using Arduino / Project Guidance / Re: What is wrong with my coding as the GPS gives the lattitude and longitude = 0. on: November 16, 2013, 10:30:07 am
And read this carefully: How to post code properly

and then fix up the code in your post so that it has code tags.

379  Using Arduino / Networking, Protocols, and Devices / Re: Scanning for I2C devices.... on: November 15, 2013, 11:59:16 am
If you don't like that one, try Nick Gammon's I2C scanner:

380  Using Arduino / Programming Questions / Re: how to make code restart on: November 14, 2013, 05:12:21 pm
Before you post any more code which is splatted all over the page, read this carefully: How to post code properly

You can post your code here if you like, but if you have been told not to do so by your prof/lecturer then you can be fairly sure that they keep an eye on this forum for posts like yours. Kinda obvious thing for them to do.

A few things for you to ponder though:
int i_redLedC = 7;    
int i_amberLedC = 6;
int i_greenLedC = 5;

int i_redLedD = 7;    
int i_amberLedD = 6;
int i_greenLedD = 5;

Doesn't something strike you as odd about these?

As His Grumpiness has pointed out, it takes about two minutes to go through the while loop once, so are you actually waiting 6 minutes for it to finish going round the loop three times? If you are, how do you know that it isn't getting out of that loop? Unless I've missed something after a cursory glance at the code, it looks to me like it has no choice but to finish after it's executed the while loop 3 times.

Unlike His Grumpiness, I'd say that for now your best bet is to get it working with delay() and then if you have any time left before this is due, try to figure out how to do this without delay() (hmmm - is there a pun in there?).

You really need to read up on the use of Serial.available() and also take into account that when you type something followed by Enter to the Serial monitor, it will send carriage return and/or linefeed as well.

381  Community / Exhibition / Gallery / Re: GPS logger on: November 14, 2013, 04:14:13 pm
If it is running on a battery, which it does when I'm driving and it's recording the track, there's no point trying to talk to the Serial port. I suppose it doesn't really matter - the bits won't go anywhere :-).
If I'm testing it at home, then I do want to see the failure message on the Serial monitor. Basically, it's a bit of old debugging.

382  Community / Exhibition / Gallery / Re: GPS logger on: November 14, 2013, 02:01:12 pm
I write a record every 5 seconds so there's plenty of time to open the file, seek to near the end, write the new stuff and close it again. Like this:
  unsigned long filesize = myFile.fileSize();
  // back up the file pointer to just before the closing tags
  filesize -= 27;
  if(!myFile.seekSet(filesize)) {
#ifndef BATTERY
    // Can't win 'em all. Print error message, but can't do anything
    // other than keep going and hope for the best!
    Serial.println("Seek failed");
  // print the GPS data to the file
  // This will be overwritten by the next write to the file, if there is one,
  // and if there isn't, the file is complete and will read as a valid GPX

383  Community / Exhibition / Gallery / Re: GPS logger on: November 14, 2013, 11:23:56 am
If you don't actually need the .CSV file itself, you could record the data directly to the SD card as a GPX file which can be read by Google Earth and Garmin software (amongst others). Saves having to translate the file but makes the file somewhat larger - but that's not usually an issue.

I made essentially the same kind of logger using an Adafruit Ultimate GPS, Teensy 3 (Correction: It's a Teensy 2) and the PJRC uSD card/adapter. It is nowhere near as good looking as your installation though :-)

384  Using Arduino / Programming Questions / Re: LCD Weird Characters on: November 12, 2013, 10:37:04 pm
I think you need to put lcd.clear() after the lcd.begin().

385  Using Arduino / Networking, Protocols, and Devices / Re: internet protocol causing problems ?? on: November 12, 2013, 01:44:17 pm
I don't know how the String library works but I presume that this code ...
void loop()
  String inChar;

... creates a new String on every entry to the loop() function even if the String is not used. Since loop() is executed thousands of times a second you might run into problems very quickly.
Even if it doesn't, use of String is a confounding issue. It would be best to remove it to either prove that it is or isn't the problem.

386  Using Arduino / Networking, Protocols, and Devices / Re: internet protocol causing problems ?? on: November 12, 2013, 12:16:10 pm
Using the String library causes problems. You would be a lot better off using null-terminated C strings (character arrays) especially if you are using a 328-based Arduino which has only 2k of static ram.

387  Using Arduino / Project Guidance / Re: Practicalities of setting an RTC and not overwriting on: November 12, 2013, 12:06:55 pm
If the real sketch, then surely I'd have to hardcode the time into the sketch just in case it decided to reset the time.
Presumably, you are only going to run the "set the time" sketch when you know that the clock has been reset. If you are going to have to recompile and upload something anyway, it might as well be the "real" sketch which detects that the clock is messed up and resets it. Then you only have one sketch to maintain.
If you want to be sure that you can force the "real" sketch to reset the clock even if it makes sense (e.g. the date got altered but otherwise looks correct), add a digital input which when LOW indicates that the reboot should set the clock even if the clock looks OK.

388  Using Arduino / Project Guidance / Re: Practicalities of setting an RTC and not overwriting on: November 12, 2013, 10:28:35 am
The sketch could first read the date and time and if all the registers are zero, or 255, or otherwise don't make sense then the sketch resets the clock.

389  Using Arduino / Audio / Re: Is my Arduino really doing FFT? on: November 11, 2013, 03:42:52 pm
I purposely didn't use k = 0 because the input would have to be completely silent for it to return a positive value
No. The k=0 term is the DC component of the input signal. With an input signal like this:
input[counter] = sin((2 * PI * 1 * counter) / FFTSIZE)
the values stored in the input array will have values which vary between -1 and +1. They vary equally above and below zero so the magnitude of the first bin will be zero. If instead your signal was:
input[counter] = 5 + sin((2 * PI * 1 * counter) / FFTSIZE)
the 5 would raise the whole signal so that it is in the range 4 to 6. That would cause a large magnitude in the first frequency bin.

which should give me only the first 64 frequency bins.
Yeah, I missed that.

Does that just increase the amplitude of the waves?
Yes. Instead of sin() it has 7*sin() so it will increase the amplitude of the sin wave by a factor of 7. The cosine will be ten times greater and both will be reflected in the output with higher values in the respective bins.
I tried out the code
so you should have noticed that the amplitudes were higher than before - one in the SIN column and the other in the COS column.

when the input is finished receiving data, the Arduino can pull out the values and do the DFT
The SD card would only slow things down even more.

implementing the analog input for the Arduino
I'll let somebody else handle that.

390  Using Arduino / Audio / Re: Is my Arduino really doing FFT? on: November 11, 2013, 12:04:49 pm
That is a lot closer.
A couple of minor things:
- in the loop which does the DFT you start with "for(k=1;" it should be "for(k=0;".
- You print the header " SIN    COS    SUM", but you print the results in the order COS SIN SUM
- the SUM that you print isn't needed. The useful number to print is the magnitude of each bin. Instead of printing sine-cosine you need to print sqrt(sine*sine + cosine*cosine).
- just FYI: the number of samples does not have to be the same as the size of the DFT. The number of samples can be, and usually is, larger than the DFT size.

In the video, he explains at one point that the numbers that you get from the DFT aren't the actual amplitudes of each frequency. You have to divide by (N/2) where N is the number of samples. So, the magnitude of each frequency bin is sqrt(sine*sine + cosine*cosine) but the amplitude of the frequency is sqrt(sine*sine + cosine*cosine)/(N/2). In your sketch the two sines (remember the header is wrong) have a value of 64. Your number of samples is 128 so dividing by 64 gives a result of 1 which is correct because both sine waves have an amplitude of 1.
Fix up your sketch to use "for(k=0;", change the header to " COS    SIN    SUM" and try:
    input[counter] = 7*sin((2 * PI * 1 * counter) / FFTSIZE) + 10*cos((2 * PI * 8 * counter) / FFTSIZE);

In the resulting table you will now get one large spike in the SIN column corresponding to the first term (frequency 1) and an even larger spike in the  COS column corresponding to the second term (frequency 8 ). When you use "for(k=0;", you count the lines starting from zero so that frequency 1 will be the second line and frequency 8 will be the ninth line.

I am finding it a little hard to understand "j"
It is the square root of -1 (and, BTW, in mathematics texts it is represented by "i" instead of "j"). If you're 13 years old, you may have run into the concept of imaginary numbers when solving the roots of a quadratic equation, but it'll be a while before you cover complex numbers which is what the DFT uses. For what you are doing, you don't need to worry about it. The number that you need from the DFT is the amplitude of each frequency and when you compute the magnitude of each frequency bin using sqrt(sine*sine + cosine*cosine), it makes the j disappear.

However, if you want to do sound localization and voice recognition you have a very long way to go.
The code isn't fast
That is one of the problems you will run into on the UNO. It does not have floating point instructions so calculations involving sin(), cos() and floating point arithmetic are very slow. You aren't going to be able to sample the data fast enough to get a meaningful result without using a lookup table for the sin/cos and other tricks to speed up the process.

Pages: 1 ... 24 25 [26] 27 28 ... 105