-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetWavePlate.c
More file actions
60 lines (49 loc) · 1.56 KB
/
setWavePlate.c
File metadata and controls
60 lines (49 loc) · 1.56 KB
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
/*
* stepmotor.c
********************************************************************
GPIO 4 output -> clock source for stepper motor. one clock transistion = 0->1 == one step
GPIO 2 output -> binary direction (1=up, 0=down)
compile
~ $ gcc -o setPlaneAngle setPlaneAngle.c -l wiringPi
execute
~ $ sudo ./setPlaneAngle angleinmrad
where steps is integer number of steps and dir is 0 or 1
***********************************************************************
*/
#include <stdio.h>
#include <wiringPi.h>
#include <stdlib.h>
#include "interfacing/interfacing.h"
#include "fileTools.h"
int main (int argc, char *argv[]) {
wiringPiSetup();
int newpos,i;
int line=0;
char wavePlatePositionFileName[]="/home/pi/RbControl/system.cfg";
char buffer[1024];
FILE *wavePlatePositionFile;
if (argc ==2) {
newpos = atoi(argv[1]);
} else {
printf("Usage: sudo ./setWavePlate <step location>\n");
return 1;
}
setMotor(2,newpos);
line=getLineNumberForComment(wavePlatePositionFileName,"#PumpQWPAngle(step):");
if(line==-1){
printf("Error! Not able to find wave Plate position in file\n");
return -1;
}else{
wavePlatePositionFile=fopen(wavePlatePositionFileName,"r+");
if(!wavePlatePositionFile){
printf("Unable to open wavePlatePositionFile\n");
exit(1);
}
for(i=0;i<line;i++){
fgets(buffer,1024,wavePlatePositionFile);
}
fprintf(wavePlatePositionFile,"#PumpQWPAngle(step):\t%03d\n",newpos);
fclose(wavePlatePositionFile);
return 0;
}
}