-
Notifications
You must be signed in to change notification settings - Fork 16
/
_thc.ino
78 lines (71 loc) · 1.44 KB
/
_thc.ino
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
unsigned int delayTime;
unsigned int SetVx10;
void Setup_THC()
{
pinMode(outputUpPin, OUTPUT);
pinMode(outputOkPin, OUTPUT);
pinMode(outputDnPin, OUTPUT);
pinMode(13, OUTPUT); // CKD test signal.
}
void doTHC()
{
if (Do)
{
Do = false;
LCDtime ++;
show ++;
// CKD test signal.
bitWrite(PORTB, 5, !bitRead(PORTB, 5));
if (LCDtime > defaultLCDtime)
{
menu = 0;
pos = 0;
LCDtime = 0;
encoderVal = SetV;
}
if ((500 < ArcV) & (ArcV < 2500))
{
if (ArcV > StV * 10) delayTime ++;
if (delayTime >= DT * 10)
{
SetVx10 = SetV * 10;
delayTime = DT * 10;
bitWrite(PORTC, 5, 1);
if (ArcV >= SetVx10 + HyS)
{
bitWrite(PORTC, 4, 0);
bitWrite(PORTC, 3, 1);
}
else if (ArcV <= SetVx10 - HyS)
{
bitWrite(PORTC, 4, 1);
bitWrite(PORTC, 3, 0);
}
else
{
bitWrite(PORTC, 4, 0);
bitWrite(PORTC, 3, 0);
}
}
}
else if (menu != 12)
{
delayTime = 0;
bitWrite(PORTC, 4, 0);
bitWrite(PORTC, 5, 0);
bitWrite(PORTC, 3, 0);
}
}
}
void RS232()
{
Serial.print("SetV:");
Serial.print(SetVx10);
Serial.print(" ArcV:");
Serial.print(ArcV);
Serial.print(" StV:");
Serial.print(StV);
Serial.print(" DTime:");
Serial.print(delayTime);
Serial.println("");
}