-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdg.sh
112 lines (87 loc) · 2.16 KB
/
sdg.sh
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
#!/bin/bash
# SDG IP address
address="192.0.2.1"
# Frequency in Herz.
# You need a amateur radio license to transmit into an antenna!
freq="7039900"
#freq="14096900"
#freq="28125700"
# FSK shift in Hz
shift="4"
# Amplitude in Vpp, see: http://wera.cen.uni-hamburg.de/DBM.shtml
ampl=0.632 # 0 dBm
# Gate waveform name
wave="call"
# Duration of 1 transmission (keep it < 10 min)
period="360"
trap ctrl_c INT
stty -echoctl # hide ^C
send() {
lxi scpi -a "${address}" "$1"
}
ctrl_c() {
echo "Ctrl-C pressed, switching off outputs."
send "C1:OUTP OFF"
send "C2:OUTP OFF"
echo "Goodbye."
exit
}
# Print identification
send "*IDN?"
# Turn off output channel 1 and 2
send "C1:OUTP OFF"
send "C2:OUTP OFF"
# Enable external 10 MHz clock input
send "ROSC EXT"
# Configure output load channel 1 and 2
send "C1:OUTP LOAD,50"
send "C2:OUTP LOAD,50"
# Enable screen saver
send "SCSV 1"
configure_fsk() {
# Disable wave combine
send "C1:CMBN OFF"
send "C2:CMBN OFF"
# Configure wave channel 1
send "C1:BSWV WVTP,SINE,FRQ,${freq},AMP,${ampl},OFST,0,PHSE,0"
# Load Arb wave channel 2
send "C2:ARWV NAME,${wave}"
send "c2:BSWV PERI,${period},AMP,5,OFST,2.5,PHSE,0"
# Modulation channel 1
send "C1:MDWV FSK"
send "C1:MDWV STATE,ON"
send "C1:MDWV FSK,SRC,EXT"
send "C1:MDWV FSK,HFRQ,$(( freq + shift ))"
}
wait_for_minute() {
if [ "$1" = "0" ]; then
next="$(date --date='10 min' +%H:%M:%S| cut -b 1-4)$1:$2"
else
next="$(date +%H:%M:%S| cut -b 1-4)$1:$2"
fi
echo "Next TX at: $next"
current_epoch=$(date +%s.%N)
target_epoch=$(date -d "$next" +%s.%N)
sleep_seconds=$(echo "$target_epoch - $current_epoch"|bc)
sleep "$sleep_seconds"
}
# Loop
while true
do
configure_fsk
echo "======================================"
echo "Next TX freq: ${freq} Hz, ampl: ${ampl} Vpp"
# Start at every 10th minute
wait_for_minute 0 00
echo "$(date) - TX ON"
# Turn on sig gen.
send "C1:MDWV STATE,ON"
send "C2:OUTP ON"
send "C1:OUTP ON"
sleep "${period}" # After this period the whole message is sent.
# Turn off sig gen.
send "C1:OUTP OFF"
send "C2:OUTP OFF"
send "C1:MDWV STATE,OFF"
echo "$(date) - TX OFF"
done