-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfaradayScanAnalysis.c
67 lines (53 loc) · 1.6 KB
/
faradayScanAnalysis.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
Program to record polarization.
RasPi connected to USB 1208LS.
FARADAY SCAN
use Aout 0 to set laser wavelength. see page 98-100
usage
$ sudo ./faradayscan <aoutstart> <aoutstop> <deltaaout> <comments_no_spaces>
2015-12-31
added error calculations. see page 5 and 6 of "FALL15" lab book
*/
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <asm/types.h>
#include "mathTools.h" //includes stdDeviation
#include "fileTools.h" //includes stdDeviation
#include "faradayScanAnalysisTools.h"
#define PI 3.14159265358979
#define NUMSTEPS 350
#define WAITTIME 2
#define BUFSIZE 1024
int main (int argc, char **argv)
{
int runs, revolutions, dataPointsPerRev;
char fileName[1024],buffer[1024];
if (argc==2){
strcpy(fileName,argv[1]);
} else {
printf("usage '~$ sudo ./faradayscanAnalysis <fileName>'\n");
return 1;
}
getCommentLineFromFile(fileName,"#NumVolts:",buffer);
runs=atoi(buffer);
getCommentLineFromFile(fileName,"#Revolutions:",buffer);
revolutions=atoi(buffer);
getCommentLineFromFile(fileName,"#DataPointsPerRev:",buffer);
dataPointsPerRev=atoi(buffer);
printf("COMMENT LINES: NUMVOLT=%d, REV=%d, DPPR=%d",runs,revolutions,dataPointsPerRev);
printf("Processing Data...");
analyzeData(fileName, runs,revolutions,dataPointsPerRev,FOI);
printf("Plotting Data...\n");
char* extensionStart=strstr(fileName,".dat");
strcpy(extensionStart,"RotationAnalysis.dat");
plotData(fileName);
return 0;
}