Skip to content

Commit 544b4f8

Browse files
committed
Initial addition of JT4 to library
1 parent 75827c9 commit 544b4f8

File tree

4 files changed

+82
-10
lines changed

4 files changed

+82
-10
lines changed

JTEncode.cpp

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ JTEncode::JTEncode(void)
4747
* Ensure that you pass a uint8_t array of size JT65_SYMBOL_COUNT to the method.
4848
*
4949
*/
50-
5150
void JTEncode::jt65_encode(char * message, uint8_t * symbols)
5251
{
5352
// Ensure that the message text conforms to standards
@@ -88,7 +87,6 @@ void JTEncode::jt65_encode(char * message, uint8_t * symbols)
8887
* Ensure that you pass a uint8_t array of size JT9_SYMBOL_COUNT to the method.
8988
*
9089
*/
91-
9290
void JTEncode::jt9_encode(char * message, uint8_t * symbols)
9391
{
9492
// Ensure that the message text conforms to standards
@@ -123,6 +121,44 @@ void JTEncode::jt9_encode(char * message, uint8_t * symbols)
123121
jt9_merge_sync_vector(a, symbols);
124122
}
125123

124+
/*
125+
* jt9_encode(char * message, uint8_t * symbols)
126+
*
127+
* Takes an arbitrary message of up to 13 allowable characters and returns
128+
* a channel symbol table.
129+
*
130+
* message - Plaintext Type 6 message.
131+
* symbols - Array of channel symbols to transmit retunred by the method.
132+
* Ensure that you pass a uint8_t array of size JT9_SYMBOL_COUNT to the method.
133+
*
134+
*/
135+
void JTEncode::jt4_encode(char * message, uint8_t * symbols)
136+
{
137+
// Ensure that the message text conforms to standards
138+
// --------------------------------------------------
139+
jt_message_prep(message);
140+
141+
// Bit packing
142+
// -----------
143+
uint8_t c[13];
144+
jt9_bit_packing(message, c);
145+
146+
// Convolutional Encoding
147+
// ---------------------
148+
uint8_t s[JT4_SYMBOL_COUNT];
149+
convolve(c, s, 13, JT4_BIT_COUNT);
150+
151+
// Interleaving
152+
// ------------
153+
jt9_interleave(s);
154+
memmove(s + 1, s, JT4_BIT_COUNT);
155+
s[0] = 0; // Append a 0 bit to start of sequence
156+
157+
// Merge with sync vector
158+
// ----------------------
159+
jt4_merge_sync_vector(s, symbols);
160+
}
161+
126162
/*
127163
* wspr_encode(char * call, char * loc, uint8_t dbm, uint8_t * symbols)
128164
*
@@ -135,7 +171,6 @@ void JTEncode::jt9_encode(char * message, uint8_t * symbols)
135171
* Ensure that you pass a uint8_t array of size WSPR_SYMBOL_COUNT to the method.
136172
*
137173
*/
138-
139174
void JTEncode::wspr_encode(char * call, char * loc, uint8_t dbm, uint8_t * symbols)
140175
{
141176
// Ensure that the message text conforms to standards
@@ -655,6 +690,27 @@ void JTEncode::jt9_merge_sync_vector(uint8_t * g, uint8_t * symbols)
655690
}
656691
}
657692

693+
void JTEncode::jt4_merge_sync_vector(uint8_t * g, uint8_t * symbols)
694+
{
695+
uint8_t i;
696+
const uint8_t sync_vector[JT4_SYMBOL_COUNT] =
697+
{0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0,
698+
0, 0, 0, 0, 1, 1, 0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,1 ,1,
699+
0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0,
700+
1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0,
701+
0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0,
702+
1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1,
703+
1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1,
704+
0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1,
705+
1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1,
706+
0, 1, 1, 1, 1, 0, 1, 0, 1};
707+
708+
for(i = 0; i < JT4_SYMBOL_COUNT; i++)
709+
{
710+
symbols[i] = sync_vector[i] + (2 * g[i]);
711+
}
712+
}
713+
658714
void JTEncode::wspr_merge_sync_vector(uint8_t * g, uint8_t * symbols)
659715
{
660716
uint8_t i;

JTEncode.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828

2929
#define JT65_SYMBOL_COUNT 126
3030
#define JT9_SYMBOL_COUNT 85
31+
#define JT4_SYMBOL_COUNT 207
3132
#define WSPR_SYMBOL_COUNT 162
3233

3334
#define JT65_ENCODE_COUNT 63
3435
#define JT9_ENCODE_COUNT 69
3536

3637
#define JT9_BIT_COUNT 206
38+
#define JT4_BIT_COUNT 206
3739
#define WSPR_BIT_COUNT 162
3840

3941
class JTEncode
@@ -42,6 +44,7 @@ class JTEncode
4244
JTEncode(void);
4345
void jt65_encode(char *, uint8_t *);
4446
void jt9_encode(char *, uint8_t *);
47+
void jt4_encode(char *, uint8_t *);
4548
void wspr_encode(char *, char *, uint8_t, uint8_t *);
4649
private:
4750
uint8_t jt_code(char);
@@ -59,6 +62,7 @@ class JTEncode
5962
void jt_gray_code(uint8_t *, uint8_t);
6063
void jt65_merge_sync_vector(uint8_t *, uint8_t *);
6164
void jt9_merge_sync_vector(uint8_t *, uint8_t *);
65+
void jt4_merge_sync_vector(uint8_t *, uint8_t *);
6266
void wspr_merge_sync_vector(uint8_t *, uint8_t *);
6367
void convolve(uint8_t *, uint8_t *, uint8_t, uint8_t);
6468
void rs_encode(uint8_t *, uint8_t *);

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ During transmit, the proper class method is chosen based on the desired mode, th
7070
break;
7171
}
7272

73-
Once the channel symbols have been generate, it is a simple matter of transmitting them in sequence, each of the correct amount of time:
73+
Once the channel symbols have been generated, it is a simple matter of transmitting them in sequence, each the correct amount of time:
7474

7575
// Now transmit the channel symbols
7676
for(i = 0; i < symbol_count; i++)

examples/Si5351JTDemo/Si5351JTDemo.ino

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,27 @@
4545
// Mode defines
4646
#define JT9_TONE_SPACING 174 // ~1.74 Hz
4747
#define JT65_TONE_SPACING 269 // ~2.69 Hz
48+
#define JT4_TONE_SPACING 437 // ~4.37 Hz
4849
#define WSPR_TONE_SPACING 146 // ~1.46 Hz
4950

50-
#define JT9_CTC 9000 // CTC value for JT9-1
51-
#define JT65_CTC 5812 // CTC value for JT65A
52-
#define WSPR_CTC 10672 // CTC value for WSPR
51+
#define JT9_CTC 9000 // CTC value for JT9-1
52+
#define JT65_CTC 5812 // CTC value for JT65A
53+
#define JT4_CTC 3578 // CTC value for JT4
54+
#define WSPR_CTC 10672 // CTC value for WSPR
5355

5456
#define JT9_DEFAULT_FREQ 14078600UL
5557
#define JT65_DEFAULT_FREQ 14077500UL
58+
#define JT4_DEFAULT_FREQ 14077500UL
5659
#define WSPR_DEFAULT_FREQ 14097100UL
5760

58-
#define DEFAULT_MODE MODE_JT65
61+
#define DEFAULT_MODE MODE_JT4
5962

6063
// Hardware defines
6164
#define BUTTON 12
6265
#define LED_PIN 13
6366

6467
// Enumerations
65-
enum mode {MODE_JT9, MODE_JT65, MODE_WSPR};
68+
enum mode {MODE_JT9, MODE_JT65, MODE_JT4, MODE_WSPR};
6669

6770
// Class instantiation
6871
Si5351 si5351;
@@ -107,6 +110,9 @@ void encode()
107110
case MODE_JT65:
108111
jtencode.jt65_encode(message, tx_buffer);
109112
break;
113+
case MODE_JT4:
114+
jtencode.jt4_encode(message, tx_buffer);
115+
break;
110116
case MODE_WSPR:
111117
jtencode.wspr_encode(call, loc, dbm, tx_buffer);
112118
break;
@@ -157,6 +163,12 @@ void setup()
157163
symbol_count = JT65_SYMBOL_COUNT; // From the library defines
158164
tone_spacing = JT65_TONE_SPACING;
159165
break;
166+
case MODE_JT4:
167+
freq = JT4_DEFAULT_FREQ;
168+
ctc = JT4_CTC;
169+
symbol_count = JT4_SYMBOL_COUNT; // From the library defines
170+
tone_spacing = JT4_TONE_SPACING;
171+
break;
160172
case MODE_WSPR:
161173
freq = WSPR_DEFAULT_FREQ;
162174
ctc = WSPR_CTC;
@@ -168,7 +180,7 @@ void setup()
168180
// Initialize the Si5351
169181
// Change the 2nd parameter in init if using a ref osc other
170182
// than 25 MHz
171-
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0);
183+
si5351.init(SI5351_VARIANT_A3, SI5351_CRYSTAL_LOAD_8PF, 0);
172184

173185
// Set CLK0 output
174186
si5351.set_correction(0);

0 commit comments

Comments
 (0)