-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoPAX100.ino
339 lines (293 loc) · 9.61 KB
/
AutoPAX100.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
/*
AutoPAX100
This sketch reads the analog value from the Band pin on the ACC connector of the Xiegu G90
transceiver and automatically switches the LPFX7 LPF to the correct band. The sketch should
also automatically disable and bypass the PAX100 amplifier and LPF when an unsupported band
is selected.
A 16 column 2 row display shows the status of the amp
There are a few ways this could be wired up. I chose to use this circuit to "replace" only the push-
buttons on the LPFX7 and maintain as much of the original LPFX7 functionality as possible. This
includes the relay latching mechanism. It would be pretty trivial to modify this sketch to drive
the relay coils directly in the event of a broken LPFX-7 or even another LPF that doesn't have the
latching circuitry.
The circuit:
- Power is provided to the 5v pin via an LM7805 regulator with filtering capacitors
- G90 Aux port Pin 2 (Red) connected to analog pin 0.
- G90 Aux port Pin 7 (Violet) connected to ground
- Bypass SPST Power Relay connected to Digital Pin 2
- Provides 12v to the amplifier
- A SPDT relay connects to the output of Digital Pin 2.
The NC side of the relay routes the RF signal around the amp and filter directly to the output connector
The NO side of the signal routes the RF signal in to the PAX100 and LPFX7
- 10-15M LPF select switch connectied via solid-state relay to digital pin 3
- 17-20M LPF select switch connectied via solid-state relay to digital pin 4
- 40M LPF select switch connectied via solid-state relay to digital pin 5
- 80M LPF select switch connectied via solid-state relay to digital pin 6
- Output from the 10M enable LED is connected via level shifter to analog pin 0
- Output from the 20M enable LED is connected via level shifter to analog pin 1
- Output from the 40M enable LED is connected via level shifter to analog pin 2
- Output from the 80M enable LED is connected via level shifter to analog pin 3
- TX/RX signal connected via level shifter to analog pin 3
- LCD RS pin to digital pin 7
- LCD Enable pin to digital pin 8
- LCD D4 pin to digital pin 9
- LCD D5 pin to digital pin 10
- LCD D6 pin to digital pin 11
- LCD D7 pin to digital pin 12
- LCD R/W pin to ground
- 10K trimpot:
- ends to +5V and ground
- wiper to LCD VO pin (pin 3)
created 29 Jan. 2021
by Ben Kuhn, KU0HN
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 7, en = 8, d4 = 9, d5 = 10, d6 = 11, d7 = 12;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Define the analog pin used to read the band pin from the radio
const int bandPin = A7;
// Define digital pins used to activate the 4 available filters
const int activate10 = 3;
const int activate20 = 4;
const int activate40 = 5;
const int activate80 = 6;
// Define pins used to read current filter activation status
const int read10 = A0;
const int read20 = A1;
const int read40 = A2;
const int read80 = A3;
// Define pin used for the power bypass relay and set it for output
const int ampRelay = 2;
// Define the pin used to detect +8v from the radio
const int radioOn = A4;
// Define pin used to detect the TX signal
const int txEnabled = 13;
// Variable to store the band data
int bandPinValue = 0;
// Variables to store the current LPF state
bool status10 = LOW;
bool status20 = LOW;
bool status40 = LOW;
bool status80 = LOW;
// Variable to store the Bypass Relay state
bool ampEnabled = LOW;
// Variable to store the current LPF setting
int filterState = 0;
void setup() {
// Uncomment for serial debugging
//Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Set LPF select pins to output
pinMode(activate10, OUTPUT);
pinMode(activate20, OUTPUT);
pinMode(activate40, OUTPUT);
pinMode(activate80, OUTPUT);
// Set LPF status pins to input
pinMode(read10, INPUT);
pinMode(read20, INPUT);
pinMode(read40, INPUT);
pinMode(read80, INPUT);
// Set the amp bypass relay control to output
pinMode(ampRelay, OUTPUT);
// Set the TX signal detect pin to input
pinMode(txEnabled, INPUT);
// Bypass the amp while we wait for things to settle down.
bypassAmp();
}
int getRadioBand() {
// Read band information from the radio interface
bandPinValue = analogRead(bandPin);
// Convert value from ADC to a meaningful band
// See Values.txt for ADC values from testing. Giving a bit (10) each direction in case a low or high
// battery voltage condition or something causes voltage to sag or be a bit high.
if ((bandPinValue > 40) && (bandPinValue < 60)) {
return 160;
}
else if ((bandPinValue > 90) && (bandPinValue < 110)) {
return 80;
}
else if ((bandPinValue > 140) && (bandPinValue < 160)) {
return 60;
}
else if ((bandPinValue > 190) && (bandPinValue < 210)) {
return 40;
}
else if ((bandPinValue > 240) && (bandPinValue < 260)) {
return 30;
}
else if ((bandPinValue > 290) && (bandPinValue < 310)) {
return 20;
}
else if ((bandPinValue > 340) && (bandPinValue < 360)) {
return 17;
}
else if ((bandPinValue > 390) && (bandPinValue < 410)) {
return 15;
}
else if ((bandPinValue > 440) && (bandPinValue < 515)) {
//There is a voltage split in the middle of 12 meters (annoyingly) so we are combining 10 and 12
return 10;
}
else {
//return 0 for error if nothing else matches
return 0;
}
}
int isFilterActive() {
// Read the output from the LPF to see what filter, if any, are active
if (digitalRead(read10) == HIGH) {
return 10;
}
else if (digitalRead(read20) == HIGH) {
return 20;
}
else if (digitalRead(read40) == HIGH) {
return 40;
}
else if (digitalRead(read80) == HIGH) {
return 80;
}
// Return 0 if the filter is off
else {
return 0;
}
}
void bypassAmp() {
// Cut power to the amp and LPF, and bypass radio output direct to the antenna
digitalWrite(ampRelay, LOW);
// Set the LPF state to 0 so we know to toggle it next time the band changes.
filterState = 0;
}
void enableAmp() {
// Cut power to the amp and LPF, and bypass radio output direct to the antenna
digitalWrite(ampRelay, HIGH);
}
void setBand(int bandSet) {
// Activate the appropriate LPF for the given band
if (bandSet == 80) {
if (filterState != 80) {
digitalWrite(activate80, HIGH);
//We just need a momentary pulse to latch the relay so wait 10ms and go low again
delay(10);
digitalWrite(activate80, LOW);
filterState = 80;
}
}
else if (bandSet == 40) {
if (filterState != 40) {
digitalWrite(activate40, HIGH);
//We just need a momentary pulse to latch the relay so wait 10ms and go low again
delay(10);
digitalWrite(activate40, LOW);
filterState = 40;
}
}
else if (bandSet == 20) {
if (filterState != 20) {
digitalWrite(activate20, HIGH);
//We just need a momentary pulse to latch the relay so wait 10ms and go low again
delay(10);
digitalWrite(activate20, LOW);
filterState = 20;
}
}
else {
if (filterState != 10) {
digitalWrite(activate10, HIGH);
//We just need a momentary pulse to latch the relay so wait 10ms and go low again
delay(10);
digitalWrite(activate10, LOW);
filterState = 10;
}
}
}
void displayBand(int dispBand) {
//Display the current band on the top right of the LCD display
if (dispBand == 10) {
// First Row
lcd.home();
lcd.print("10/12 Meters ");
// Second Row
lcd.setCursor(5,1);
lcd.print("Active");
}
else if ((dispBand == 15) || (dispBand == 17) || (dispBand == 20) || (dispBand == 40) || (dispBand == 80)){
lcd.home();
lcd.print(dispBand);
lcd.print(" Meters ");
// Second Row
lcd.setCursor(5,1);
lcd.print("Active");
}
else {
lcd.home();
lcd.print(dispBand);
lcd.print(" Meters ");
// Display Bypass on second row of display
lcd.setCursor(5,1);
lcd.print("Bypass");
}
}
void loop() {
//digitalWrite(activate10, HIGH);
// Read band value from the radio
int band = getRadioBand();
// Serial Debugging
// Serial.println(band);
// Keep the AGC Calm
delay(2);
// Set filter and amplifier status based on band value from the radio
if ((band == 10) || (band == 15)) { // 10, 12, and 15 meters share a filter
//if (isFilterActive() != 10) {
setBand(10);
//}
enableAmp();
displayBand(band);
}
else if ((band == 17) || (band == 20)) { // 17 and 20 meters share a filter
if (isFilterActive() != 20) {
setBand(20);
}
enableAmp();
displayBand(band);
}
else if (band == 30) { // No filter for 30 meters, bypass amp.
displayBand(band);
bypassAmp();
}
else if (band == 40) { // 40 Meters
if (isFilterActive() != 40) {
setBand(40);
}
enableAmp();
displayBand(band);
}
else if (band == 60) { // No filter for 60 meters, bypass amp.
displayBand(band);
bypassAmp();
}
else if (band == 80) { // 80 Meters
if (isFilterActive() != 80) {
setBand(80);
}
enableAmp();
displayBand(band);
}
else if (band == 160) { // No filter for 160 meters, bypass amp.
displayBand(band);
bypassAmp();
// Display Bypass on second row of display
}
else { //Any other value is a communication error with the rig. Bypass amp for safety and display an error message.
lcd.home();
lcd.print(" Rig Comm Error ");
// Display Bypass on second row of display
lcd.setCursor(5,1);
lcd.print("Bypass");
bypassAmp();
}
}