Radar Distance Mesurement, Start FFT directly from the ADC? Newbie ;)

Status
Not open for further replies.

Slowy

New member
Hello everyone,

I hope its the right area asking for this.
I´m realy a newbob with programming and microcontrollers. I've done some simple sketches with Arduino boards but they are allmost to slow for my applications..
Now i want to try teensy, couse they are much faster etc.

My Project/Data:
Distance Mesurement with an FMCW Radar (IVS-565 from Innosent)
Signal output about 0-4V
Actually I use Teensy 3.5 (3.6 and 3.2 are possible)
No Audio Board

My Signal on an Oszi:
Unbenannt.jpg

My Problem:
Find a fast enough uC to performe a FFT 1024/2048.
I've allready used the Audio.h functions. The problem is that the sample rates are extremly high (about 44,1kHz) for my signal (200Hz till max. 2.5kHz).
With that sample speed i can performe max. 43Hz for each Frequenzy Pin.
That is almost to much, I still need about 5-10Hz for a good distance feedback.
If i understand it right,.. the Audio.h lib can read only Signals Vpp 1.2V=? Is it only for the line-in/micro from the AudioBoard or also for the ADC read from the Teensy=?

My Questions:
1) Is it possible to change the Audio.h Sample rates till 5kHz=? I think so but i dont know how, and if its possible i think its hard for a newbie to realize it^^
2) Is it possible to start the Audio.h FFT directly from an ADC? I allready use a Simple sketch to digitalize my Signal with Teensy3.5 and the ADC.h Lib but if i start an FFT with the Audio.h Lib it wound work. :confused:
3) Maby there are other ways to performe a FFT without using the Audio.h functions=?
4) How the arm_math.h fft work? Maby there are exist some "simple" sketches which i can studie=?

My simple adc.h file with perfect ADC results:

#include <TimerOne.h>
#include <ADC.h>

long val = 0;
long val1 = 0;
String nextVal = "";
int stepAmount = 20;

const int readPin = A9; // ADC0

ADC *adc = new ADC(); // adc object;

void setup() {

Serial.begin(9600);
analogWriteResolution(12);
Timer1.initialize(45);
Timer1.attachInterrupt(updateDAC); // update DAC output every .0002 sec (5000Hz)

pinMode(readPin, INPUT);

pinMode(A10, INPUT); //Diff Channel 0 Positive ADC0
pinMode(A11, INPUT); //Diff Channel 0 Negative ADC0

adc->setReference(ADC_REFERENCE::REF_3V3, ADC_0);
adc->setAveraging(16, ADC_0); // set number of averages
adc->setResolution(16, ADC_0); // set bits of resolution
adc->setConversionSpeed(ADC_CONVERSION_SPEED::VERY_LOW_SPEED, ADC_0); // change the conversion speed
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_LOW_SPEED, ADC_0); // change the sampling speed


}

void getNextVal() {
if (nextVal == "")
{
val1 = val1 + stepAmount;
nextVal = String(val1);

// reverse the direction
if (val1 == 0 || val1 >= 4090) {
stepAmount = -stepAmount ;
}
}
}

void updateDAC() {
if (nextVal != "") {
val = nextVal.toInt();
nextVal = "";
analogWrite(A21, val);
getNextVal();
}
getNextVal();
}

void loop() {
int value;

value = adc->analogRead(readPin); // read a new value, will return ADC_ERROR_VALUE if the comparison is false.
Serial.println(value*3.3/adc->getMaxValue(ADC_0), DEC);
}

My testsketch to try with the audio.h lib

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>


// GUItool: begin automatically generated code
//AudioInputI2S i2s1; //xy=139,91
//AudioMixer4 mixer1; //xy=312,134
//AudioOutputI2S i2s2; //xy=392,32
AudioAnalyzeFFT1024 fft1024; //xy=467,147
//AudioConnection patchCord1(i2s1, 0, mixer1, 0);
//AudioConnection patchCord2(i2s1, 0, i2s2, 0);
//AudioConnection patchCord3(i2s1, 1, mixer1, 1);
//AudioConnection patchCord4(i2s1, 1, i2s2, 1);
//AudioConnection patchCord5(mixer1, fft1024);
//AudioControlSGTL5000 audioShield; //xy=366,225

AudioSynthWaveform waveform1;
AudioOutputAnalog dacs1;
AudioConnection patchCord3(waveform1, 0, dacs1, 0);
AudioInputAnalog adc1(A9);
AudioConnection patchCord2(adc1, 0, fft1024, 0);

// GUItool: end automatically generated code


int wave_type[] = {
WAVEFORM_SINE,
WAVEFORM_TRIANGLE,
WAVEFORM_SAWTOOTH,
WAVEFORM_SAWTOOTH_REVERSE,
WAVEFORM_SQUARE,
WAVEFORM_PULSE,
WAVEFORM_SAMPLE_HOLD,
WAVEFORM_ARBITRARY,
};
String wave_name[] = {
"WAVEFORM_SINE",
"WAVEFORM_TRIANGLE",
"WAVEFORM_SAWTOOTH",
"WAVEFORM_SAWTOOTH_REVERSE",
"WAVEFORM_SQUARE",
"WAVEFORM_PULSE",
"WAVEFORM_SAMPLE_HOLD",
"WAVEFORM_ARBITRARY",
};

//const int myInput = AUDIO_INPUT_LINEIN;
//const int myInput = AUDIO_INPUT_MIC;


// The scale sets how much sound is needed in each frequency range to
// show all 8 bars. Higher numbers are more sensitive.
float scale = 60.0;

// An array to hold the 16 frequency bands
float level[16];

// This array holds the on-screen levels. When the signal drops quickly,
// these are used to lower the on-screen level 1 bar per update, which
// looks more pleasing to corresponds to human sound perception.
int shown[16];

void setup() {
// Audio requires memory to work.
Serial.begin(250000);
AudioMemory(20);
pinMode(A9, INPUT);

waveform1.amplitude(1.0);
waveform1.pulseWidth(0.5);
waveform1.frequency(50);

waveform1.begin(wave_type[1]); //1=Dreieck 2=Sägezahn UP-Sweep ausgabe an DAC0 PIN A21
}


void loop() {

if (fft1024.available()) {
// read the 512 FFT frequencies into 16 levels
// music is heard in octaves, but the FFT data
// is linear, so for the higher octaves, read
// many FFT bins together.
level[0] = fft1024.read(2, 3);
level[1] = fft1024.read(4, 5);
level[2] = fft1024.read(5, 6);
level[3] = fft1024.read(7, 8);
level[4] = fft1024.read(9, 10);
level[5] = fft1024.read(11, 12);
level[6] = fft1024.read(13, 14);
level[7] = fft1024.read(15, 16);
level[8] = fft1024.read(17, 18);
level[9] = fft1024.read(19, 20);
level[10] = fft1024.read(21, 22);
level[11] = fft1024.read(23, 24);
level[12] = fft1024.read(25, 26);
level[13] = fft1024.read(27, 28);
level[14] = fft1024.read(29, 30);
level[15] = fft1024.read(31, 32);
// See this conversation to change this to more or less than 16 log-scaled bands?
// https://forum.pjrc.com/threads/3267...-for-FFT-bin-selection-for-any-given-of-bands

// if you have the volume pot soldered to your audio shield
// uncomment this line to make it adjust the full scale signal
//scale = 8.0 + analogRead(A1) / 5.0;


for (int i=0; i<16; i++) {
Serial.print(level*3);
//Serial.print(shown);
Serial.print(" ");
}
//Serial.print(" cpu:");
//Serial.println(AudioProcessorUsageMax());
}
}


I hope someone could help me with some Informations and Ideas.
Maby every little Input can help me to understand more about Teensy and use various Librarys ;)
I have many more questtions but i think this should be enough for the moment^^
Thanks everyone for reading my hyroglyps ^^

Sorry for my bad english :(
 
Status
Not open for further replies.
Back
Top