Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 535 → Rev 536

/programy/C/ix86/signals/correlation
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programy/C/ix86/signals/correlation.c
63,6 → 63,7
{
int i,n,m,delay;
double r;
FILE *out;
 
linear_chirp(sample,SAMPLES,100,0); // vyrobi vzorek signalu
linear_chirp(signal,SIGNAL_SAMPLES,500,1000); // vyrobi signal ve kterem se vzorek hleda
81,15 → 82,15
}
}
 
 
out=fopen("output.txt",'w');
for(i=0;i<SAMPLES;i++)
{
// fprintf(stdout,"%3u ",i); // vypise cislo bunky v poli (spozdeni)
fprintf(stdout,"%2i ",sample[i]);
// fprintf(stdout,"%2d ",signal[i]);
// fprintf(stdout,"%3.2f\n",correlation[i]); // vypise hodnotu korelace nejvissi cislo je nejvetsi korelace.
// fprintf(out,"%3.2f\n",correlation[i]); // vypise hodnotu korelace nejvissi cislo je nejvetsi korelace.
}
fprintf(stdout,"\nvzorek v signalu zacina na miste: %3u \n",delay);
 
fclose(out);
exit(1);
}
/programy/C/ix86/sound/DOC/foto/sonar_system_configuration.JPG
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/ix86/sound/DOC/foto/sonar_transceiver_system.JPG
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/ix86/sound/sonar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programy/C/ix86/sound/sonar.c
17,7 → 17,7
 
static char *device = "plughw:0,0"; /* playback device */
static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */
static unsigned int rate = 44100; /* stream rate */
static unsigned int rate = 98000; /* stream rate */
static unsigned int channels = 1; /* count of channels */
static unsigned int buffer_time = 500000; /* ring buffer length in us */
static unsigned int period_time = 100000; /* period time in us */
188,7 → 188,7
 
static const float f0 = 1000;
static const float fmax = 5000;
static const float Tw = 0.2;
static const float Tw = 0.002;
static float k;
 
unsigned int n=0;
287,7 → 287,7
snd_async_handler_t *chandler, *phandler;
int count;
unsigned int i,j,m,n;
unsigned int delay; //store delay of maximal correlation
unsigned int delay[10]; //store delay of signifed correlation
double r;
double correlation[1000000]; //array to store correlation curve
 
384,10 → 384,6
}
printf("\nData transmitted... \nprocessing...\n");
 
out=fopen("./output.txt","w");
for(i=0;i<=100000;i++) fprintf(out,"%6d %6d %6d \n",i,chirp[i],signal[i]);
fclose(out);
 
#define SIGNAL_SAMPLES 100000
 
for(n=0; n < (SIGNAL_SAMPLES - chirp_size);n++){ //spocita korelaci pro mozna spozdeni
397,17 → 393,22
}
 
r=0;
for(n=0; n < (SIGNAL_SAMPLES - chirp_size);n++){ //najde nejvetsi shodu (pro nazornost v samostatnem cyklu)
 
for(n=0; n < (SIGNAL_SAMPLES - chirp_size);n++){ //najde nejvetsi korelace
if (r < correlation[n]){
delay = n;
delay[1] = n;
r = correlation[n];
}
}
 
printf("\nEcho zacina na: %d vzorku.\n", delay);
printf("Casove na: %f s\n", ((float)delay/rate));
printf("vzdalenost: %f m\n", (SOUND_SPEED*(float)delay/rate));
out=fopen("./output.txt","w");
for(i=0;i<=100000;i++) fprintf(out,"%6d %6d %6d %6.2f\n",i,chirp[i],signal[i],correlation[i]);
fclose(out);
 
printf("\nEcho zacina na: %d vzorku.\n", delay[1]);
printf("Casove na: %f s\n", ((float)delay[1]/rate));
printf("vzdalenost: %f m\n", (SOUND_SPEED*(float)delay[1]/rate));
 
snd_pcm_close(playback_handle);
snd_pcm_close(capture_handle);
return 0;