-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetProbeLaser.c
59 lines (41 loc) · 1.19 KB
/
setProbeLaser.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
/*
program to set analog output
RasPi connected to USB 1208LS.
Sets analog voltage for probe laser. Uses Analog out port 0. Final output to probe laser is through
op-amp circuit. see page 98. Page 99 shows calibration data.
Usage '$ sudo ./setProbeLaser xxx' where xxx is an integer value between 0 and 1024
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <sys/types.h>
#include <asm/types.h>
#include "interfacing/sacherLaser.h"
#include "interfacing/USB1208.h"
int main (int argc, char *argv[])
{
float value;
if (argc==2) {
value=atof(argv[1]);
}else{
printf("Usage '$ sudo ./setProbeLaser xxx' where xxx is a float value between 65.0 and 170.0 \n");
value=getSacherCurrent();
printf("Laser is currently at %3.1f mA\n",value*1000);
return 0;
}
if (value<0) value=0;
if (value>170) value=170;
initializeBoard();
initializeUSB1208();
initializeSacher();
printf("Going to set laser current to: %f mA\n",value*1000);
setSacherCurrent(value);
value=getSacherCurrent();
printf("Laser is currently at %3.1f mA\n",value*1000);
closeUSB1208();
return 0;
}