Show Posts
Pages: 1 ... 6 7 [8]
106  Using Arduino / Programming Questions / Re: Recursive Printing to Serial Port on: December 15, 2011, 03:11:57 pm
Sorry about the cross-posting... I won't do it again, but...
1) Your answer wasn't all that great.
2) Other folks understood the "rubbish" title and gave the answer I was looking for.

Please don't be Grumpy, Mike.
107  Using Arduino / Programming Questions / Recursive Printing to Serial Port on: December 15, 2011, 11:43:49 am
Is there a way to print to the serial port with Serial.print, then print over what I just printed? I'm displaying data from FFT bins and rather than the data scrolling down the window, I'd like the "Bin x value = " to appear static and only the actual value after the equals to update.

So after a print of all the bin values, I'd like to move the cursor up a defined number of lines to the beginning of the display then print over what was just printed with the next set of values?
108  Using Arduino / Programming Questions / Recursive Print to Serial Port on: December 15, 2011, 09:57:29 am
Not sure if this is the right part of the forum for this question, but is there a way to print to the serial port, then print over what I just printed? I'm displaying data from FFT bins and rather than the data scrolling down the window, I'd like the "Bin x value = " to appear static and only the actual value after the equals to update.

Is there a way to back up a defined number of lines with Serial.print, then print over what was just printed with the next set of values?
109  Using Arduino / Audio / Re: Limiting fix_fft to a Band on: December 14, 2011, 12:26:03 pm
> What is the code you are running?
Thought it was the code from color_music, the site you'd referenced. I'll double-check.

> With color_music I'd expect 2.2 kHz / 32 bins.
Yes, that's what I expected but getting double that. I provided tones up to 4kHz and the expected bins (69Hz/bin) showed the signal.

> I already told you, look for MsTimer2 or similar library...
Sorry, now I remember but couldn't find the reference earlier to the library name in this posting thread.

> ...you need to decide if input data processed w/o interruption.
My application is similar to color_music. I'm looking to flash LEDs to beat of the music and change sequences of flashes to the beat as well.Think I can live with non-real time sampling... a "gap" 12-14 mS should be okay.

110  Using Arduino / Audio / Re: Limiting fix_fft to a Band on: December 14, 2011, 07:54:37 am
Connected a function generator and, with a 2Vpp sinewave offset by 1V (0V to 2V), bins 1 to 63 are each 69.2Hz wide up to 4.3kHz. This makes sense given a 9kHz default sample rate. Level of the 2V sine (which was measured approximately on a scope before connection) in the expected bin is just over 10,000, so for a 5V sine would be likely 32,768 That makes sense also.

I'd like to cut the overall band to 1/2 or even 1/4, a 2.2kHz or 1.1kHz overall range with 35Hz and 18Hz wide bands respectively, so I need to decrease the sampling rate by 1/2 or 1/4, correct? How would I accomplish this with the Uno and what other changes to the code would be required?
111  Using Arduino / Audio / Re: Limiting fix_fft to a Band on: December 13, 2011, 07:33:39 am
I thought about the "mirror image" but when I insert a wire into A0 input I get 60/120Hz pickup that gives larger numbers in bins 1 and 2, and 3 which doesn't appear mirrored anywhere. "Bin 33 is reflection 31, 34 - 30, and so on up to 63 - 1". Don't understand...  which is a reflection of which? So 9kHz is default ADC on the Arduino Uno?

As for level, 8192 corresponds to 2.5V or 5V? I have a function generator that I should use to inject sine tones at known freq/ampl to see what the output does. Considering trying DFT instead of FFT so I can select frequencies of interest to transform and will run quicker. Maybe?

BTW, is it chilly there in Montreal this morning? Manchester, NH is 23deg. F!
112  Using Arduino / Audio / Re: Limiting fix_fft to a Band on: December 12, 2011, 10:34:59 pm
Have the 16-bit code running, but confused... the text for the "color organ" project says fx is 32 bins but the code is outputting 64 bins.

Also, how do I set sample rate and spectral resolution? Is it in here somewhere?
 #define N_WAVE          1024    /* full length of Sinewave[] */
 #define LOG2_N_WAVE     10   /* log2(N_WAVE) */

 #define FFT_SIZE    64
 #define log2FFT      6
 #define N             (2 * FFT_SIZE)
 #define log2N        (log2FFT + 1)

And... what does the value in each bin represent? I know it's amplitude but what is it relative to?

I hate to keep asking questions... is this stuff documented anywhere?
113  Using Arduino / Audio / Re: Limiting fix_fft to a Band on: December 12, 2011, 07:54:18 am
Thanks! I'll check the 16-bit code out tonight. Tried the 8-bit code expecting to get an array of zeros (no input signal) but get... absolutely nothing... an array of nulls. Assuming the 8-bit (256 counts) will give me 5V/256 = 19mV resolution, 16-bit is 5/65536 or about 76uV, which seems way smaller than I need. Actually, a 9kHz sample rate may be fine. That gives me bins to around 4kHz (9k/2), right? Could be a "nice to have"  for future exploration.
114  Using Arduino / Audio / Re: Limiting fix_fft to a Band on: December 11, 2011, 09:36:56 pm
Okay, thanks. I was thinking the 8-bit FFT so perhaps I'll try the 16-bit. Can't tell from the link if the "music_color" sketch includes all the code (the 8-bit code had .h, and .cpp files). Still not clear how I set the sampling rate, spectral resolution, and sampling period in the FFT code.
115  Using Arduino / Audio / Re: Audio to react to ambient sound & local processing on: December 10, 2011, 10:50:21 am
Some interesting things can be done with the PWM driving LEDs, specifically in getting a smooth transition between LEDs. Using "analogWrite(pin, lvl)" where pin is the digital output pin and lvl is the desired level (0 to 256), rather than turn the LED on "hard", increase the brightness by ramping up the value of "lvl".

for (lvl= 0; lvl <= 256; lvl+=1){
     analogWrite(pin, lvl);
}

The basic loop might react too quickly so slow it down using an interval and delay...

for (lvl = 0; lvl <= 256; lvl+=5){  // ramp in step intervals of 5
     analogWrite(pin, lvl);
     delay(10);  // delay 10ms
}

Play with the step interval and delay until you get what you want.

You can do the opposite to slowly dim the LED.
116  Using Arduino / Audio / Limiting fix_fft to a Band on: December 10, 2011, 10:16:54 am
Want to do some drum beat analysis with Arduino.
How do configure fix_fft to only work on the band of 0Hz to 256Hz and only 32 bins?
Will 32 bins run faster than 64? Only interested in frequencies below 256Hz (doesn't have to be exactly 256, it's just the nearest power of 2) so figure if I constrain the FFT to that range, it'll execute faster.
I assume the data array contains the returned frequency bins' values?
Pages: 1 ... 6 7 [8]