-
Notifications
You must be signed in to change notification settings - Fork 3
/
si5351_beacon_6m.ino
166 lines (138 loc) · 3.11 KB
/
si5351_beacon_6m.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
/*
Si5351 morse beacon.
Thomas S. Knutsen <[email protected]>
Based on the simple Morse Beacon by: Mark VandeWettering K6HX http://brainwagon.org
To calibrate the TCXO run the calibrate routine with the NT7s SI5351 library.
Input the frequency offset from 10MHz in "calvalue"
The Beacon message can be any length. Only large letters, numbers and . , ? /
Published on a "do as you want" licence. We would love to hear what you do with it tho!
*/
char message[ ] = "LA3PNA LA3PNA LA3PNA JO59BR JO59BR // SI5351 BEACON // "; // Here you put in your beacon message.
int calvalue = 14;// here you set the cal value for the TCXO
unsigned long int frequency =501000010 ; // here you set the beacon nominal frequency
long tonetime = 32000; // Here you set the continuous tone time.
struct t_mtab {
char c, pat;
} ;
struct t_mtab morsetab[] = {
{'.', 106},
{',', 115},
{'?', 76},
{'/', 41},
{'A', 6},
{'B', 17},
{'C', 21},
{'D', 9},
{'E', 2},
{'F', 20},
{'G', 11},
{'H', 16},
{'I', 4},
{'J', 30},
{'K', 13},
{'L', 18},
{'M', 7},
{'N', 5},
{'O', 15},
{'P', 22},
{'Q', 27},
{'R', 10},
{'S', 8},
{'T', 3},
{'U', 12},
{'V', 24},
{'W', 14},
{'X', 25},
{'Y', 29},
{'Z', 19},
{'1', 62},
{'2', 60},
{'3', 56},
{'4', 48},
{'5', 32},
{'6', 33},
{'7', 35},
{'8', 39},
{'9', 47},
{'0', 63}
} ;
#define N_MORSE (sizeof(morsetab)/sizeof(morsetab[0]))
#define SPEED (12)
#define DOTLEN (1200/SPEED)
#define DASHLEN (3*(1200/SPEED))
#include <si5351.h>
#include "Wire.h"
Si5351 si5351;
int LEDpin = 13 ;
void dash()
{
digitalWrite(LEDpin, HIGH) ;
si5351.output_enable(SI5351_CLK0, 1);
delay(DASHLEN);
digitalWrite(LEDpin, LOW) ;
si5351.output_enable(SI5351_CLK0, 0);
delay(DOTLEN) ;
}
void dit()
{
digitalWrite(LEDpin, HIGH) ;
si5351.output_enable(SI5351_CLK0, 1);
delay(DOTLEN);
digitalWrite(LEDpin, LOW) ;
si5351.output_enable(SI5351_CLK0, 0);
delay(DOTLEN);
}
void
send(char c)
{
int i ;
if (c == ' ') {
Serial.print(c) ;
delay(7 * DOTLEN) ;
return ;
}
for (i = 0; i < N_MORSE; i++) {
if (morsetab[i].c == c) {
unsigned char p = morsetab[i].pat ;
Serial.print(morsetab[i].c) ;
while (p != 1) {
if (p & 1)
dash() ;
else
dit() ;
p = p / 2 ;
}
delay(2 * DOTLEN) ;
return ;
}
}
/* if we drop off the end, then we send a space */
Serial.print("?") ;
}
void sendmsg(char *str)
{
while (*str)
send(*str++) ;
Serial.println("");
}
void setup() {
pinMode(LEDpin, OUTPUT) ;
Serial.begin(9600) ;
Serial.println("Si5351 beacon initiated") ;
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, calvalue);
si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_2MA);
si5351.output_enable(SI5351_CLK0, 0);
si5351.set_pll(12ULL*frequency, SI5351_PLLA);
si5351.set_freq(frequency*100ULL, SI5351_CLK0);
delay(2000);
}
void loop() {
sendmsg(message) ;
delay(1000) ;
digitalWrite(LEDpin, HIGH) ;
si5351.output_enable(SI5351_CLK0, 1);
delay(tonetime);
digitalWrite(LEDpin, LOW) ;
si5351.output_enable(SI5351_CLK0, 1);
delay(1000);
}