-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetHeliumTarget.c
More file actions
83 lines (68 loc) · 1.93 KB
/
setHeliumTarget.c
File metadata and controls
83 lines (68 loc) · 1.93 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
program to set analog output for helium target
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 ./setHeliumTarget 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/interfacing.h"
#include "interfacing/USB1208.h"
#include "interfacing/RS485Devices.h"
#include "interfacing/Sorensen120.h"
#define GPIBBRIDGE1 0XC9 // the gpib bridge can have many gpib devices attached to it, so will also need the GPIB address of each
// this is the GPIB addresses of each respective instrument attached to this bridge
#define SORENSEN120 0x0C
int main (int argc, char *argv[])
{
float value = 0,hpValue=0, sorensenValue=0;
int i, retryCounter;
if (argc==2) {
value=atof(argv[1]);
}else{
printf("Usage '$ sudo ./setHeliumTarget xxx' where xxx is a voltage between 0 and 180 \n");
value=0;
}
if (value<0)value=0;
else if (value < 60)
{
sorensenValue=0;
hpValue=value;
}
else if (value < 120)
{
sorensenValue=60;
hpValue=value-sorensenValue;
}
else if (value < 180)
{
sorensenValue=120;
hpValue=value-sorensenValue;
}
else value=180;
initializeBoard();
initializeUSB1208();
setUSB1208AnalogOut(HETARGET,(int)hpValue/HPCAL);
i=resetGPIBBridge(GPIBBRIDGE1);
delay(200);
i=initSorensen120(SORENSEN120,GPIBBRIDGE1);
i = setSorensen120Volts(sorensenValue,SORENSEN120,GPIBBRIDGE1);
retryCounter=0;
if(i!=0 && retryCounter < 5){
retryCounter++;
printf("Error setting Sorensen Code: %d\n",i);
printf("Trying to set again after .5 s\n");
delay(500);
i = setSorensen120Volts(sorensenValue,SORENSEN120,GPIBBRIDGE1);
}
closeUSB1208();
return 0;
}