-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeithleyInterface.cpp
More file actions
95 lines (83 loc) · 2.16 KB
/
Copy pathkeithleyInterface.cpp
File metadata and controls
95 lines (83 loc) · 2.16 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
84
85
86
87
88
89
90
91
92
93
94
/*
* keithleyInterface.cpp
*
* Created on: 27.02.2012
* Author: Felix Bachmair
*/
#include "keithleyInterface.h"
using namespace std;
keithleyInterface::keithleyInterface() {
// TODO Auto-generated constructor stub
port = "/dev/ttyF1";
this->printTime();
isOpen = false;
isFake = false;
verbosity = 0;
com = 0;
keithley=0;
cout<<"Created new keithley Interface..."<<endl;
}
keithleyInterface::~keithleyInterface() {
// TODO Auto-generated destructor stub
delete keithley;
delete com;
}
void keithleyInterface::SetPort(std::string port){
this->port = port;
}
void keithleyInterface::initilaiseKeithley() {
if(keithley==0)
return;
keithley->EnalbeControlBeeper();
keithley->SelectRearTerminals();
keithley->SelectFixedVoltageSourcingMode();
keithley->EnableConcurrentMeasurments();
keithley->SelectRepeatFilterType();
keithley->SetFilterCount(2);
keithley->EnableFilter();
keithley->EnableConcurrentMeasurments();
keithley->SetCurrentCompliance(100e-6);
keithley->SelectCurrentMeasureRange(20e-6);
keithley->SetCurrentMeasurementSpeed(10);
keithley->SetImmediateVoltageLevel(-150);
}
int keithleyInterface::printTime() {
/*time print*/
t = time(NULL);
local = localtime(&t);
if (verbosity)
printf("\nStart time and date: %s\n", asctime(local));
return 0;
}
int keithleyInterface::convertToInteger(uint16_t data0, uint16_t data1) {
int result = (data0 + (data1 << 16));
// printf("convert to integer: %X %X %d\n", data0,data1,result);
return result;
}
float keithleyInterface::convertToFloat(uint16_t data0, uint16_t data1) {
int value = convertToInteger(data0, data1);
float result = *((float*) &value);
// printf("convert to Float %f\n",result);
return result;
}
int keithleyInterface::closeDevice() {
delete keithley;
keithley=0;
delete com;
com =0;
return 0;
}
int keithleyInterface::openDevice() {
if(com==0)
com = new linux_rs232(port.c_str());
if(keithley==0)
keithley = new KEITHLEY_SourceMeter_2400(com);
initilaiseKeithley();
return 1;//todo
}
void keithleyInterface::setVerbosity(uint16_t verb) {
this->verbosity = verb;
}
void keithleyInterface::SelectRearTerminals(){
if(keithley!=0)keithley->SelectRearTerminals();
}