forked from PhamDuyAnh/Arduino_Plasma_THC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduino_THC_rotary.ino
113 lines (94 loc) · 2.5 KB
/
Arduino_THC_rotary.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
Project: THC for Plasma CNC controller
Platform: Arduino UNO R3
Created: April 2015
Version: 02.00
By: Pham Duy Anh - [email protected]
Require:
-> input
<- output
-> serial Tx
-> serial Rx
-> reset
-> rotary encoder digital - interrupt
-> rotary encoder digital - interrupt
-> totary button digital
-> plasma Torch on digital
-> plasma Arc Ok analog or digital)
-> plasma arc voltage analog 0-5V
<- Arc Ok optocoupler
<- torch Up optocoupler
<- torch Down optocuopler
<- LCD
<- LCD
<- LCD
<- LCD
<- LCD
<- LCD
*/
#define encoderPinA 2 //PORTD 2 - INT0
#define encoderPinB 3 //PORTD 3 - INT1
#define buttonPin 4 //PORTD 4
#define outputOkPin A5 //PORTC 5
#define outputUpPin A4 //PORTC 4
#define outputDnPin A3 //PORTC 3
#define inputNA A2
#define arcVoltPin A0 //PORTC 0
#define defaultLCDtime 500 // s * 100
/*
Parameter
* DT - Delay time - Delay time of output closed despite no supply voltage, when the system detects the main (cutting) arc, 0.1~19.9s.
* HyS - Hysreresis - The hysteresis voltage - a rangge in which the voltage is measured, in which ther are signals controlling Up/Down, (+-1V ~ +-15V)
* StU - Started Voltage - Value of the off load voltage detection in the plasma cutter - uesd to detect the main (cutting) arc: 50~300V.
* dTime
* divRato
*/
#define _SetV 0
#define _DT 1
#define _HyS 2
#define _StV 3
int SetV, DT, HyS, StV;
//int divRato = 43 ;
int divRato = 51 ;
int ArcV;
int oldValue;
// Array of Param
// SetV, DT, HYS, StV, divRato,
// Param Address 0, 1, 2, 3, 4,
int Param[5] = {SetV, DT, HyS, StV, divRato};
byte ParamItem = 5;
// Enable to do THC
boolean Do;
// Encoder, menu, pos
int encoderVal;
byte menu = 0;
byte pos = 0;
byte show = 0;
unsigned int LCDtime = 0;
void setup()
{
Setup_Encoder();
Setup_LCD();
Setup_THC();
Setup_Timer2();
//Read parameter from EEPROM
ReadData();
//Set value for all parameter
SetV = Param[_SetV];
DT = Param[_DT];
HyS = Param[_HyS];
StV = Param[_StV];
//Preset value for encoder
encoderVal = SetV;
Serial.begin(9600);
}
void loop()
{
//Read voltage value from ADC
ArcV = double(analogRead(arcVoltPin)) * double(100.00 / divRato);
checkButton();
checkMenu();
doTHC();
doLCD();
//RS232();
}