Added azimuth calculation

pull/16/merge
Bob Larkin 2 years ago
parent be2182b23d
commit 1a2ba41e1b
  1. 13
      examples/FT8Receive/FT8Receive.ino
  2. 7
      examples/FT8Receive/decode_ft8R.ino
  3. 22
      examples/FT8Receive/locatorR.ino

@ -1,6 +1,7 @@
// FT8Receive.ino 13 Oct 2022 Bob Larkin, W7PUA // FT8Receive.ino 13 Oct 2022 Bob Larkin, W7PUA
// Simple command-line reception of WSJT FT8 signals for // Simple command-line reception of WSJT FT8 signals for
// amateur radio. // amateur radio.
// Added azimuth calculation. Bob 14 Nov 2022
/* /*
* Huge thanks to Charley Hill, W5BAA, for his Pocket FT8 work, much of which * Huge thanks to Charley Hill, W5BAA, for his Pocket FT8 work, much of which
@ -120,7 +121,9 @@ int master_decoded;
#define FT8_RCV_IDLE 0 #define FT8_RCV_IDLE 0
#define FT8_RCV_DATA_COLLECT 1 #define FT8_RCV_DATA_COLLECT 1
#define FT8_RCV_FIND_POWERS 2 #define FT8_RCV_FIND_POWERS 2
#define FT8_RCV_DECODE 3 #define FT8_RCV_READY_DECODE 3
#define FT8_RCV_DECODE 4
int rcvFT8State = FT8_RCV_IDLE; int rcvFT8State = FT8_RCV_IDLE;
int master_offset, offset_step; int master_offset, offset_step;
int Target_Flag = 0; int Target_Flag = 0;
@ -304,13 +307,16 @@ void loop(void) {
Serial.print("Extract Power, fft count = "); Serial.println( demod1.getFFTCount() ); Serial.print("Extract Power, fft count = "); Serial.println( demod1.getFFTCount() );
#endif #endif
extract_power(master_offset); // Do FFT and log powers extract_power(master_offset); // Do FFT and log powers
rcvFT8State = FT8_RCV_DATA_COLLECT; if(demod1.getFFTCount() >= 184)
rcvFT8State = FT8_RCV_READY_DECODE;
else
rcvFT8State = FT8_RCV_DATA_COLLECT;
#ifdef DEBUG1 #ifdef DEBUG1
Serial.println("Power array updated"); Serial.println("Power array updated");
#endif #endif
} }
if(rcvFT8State!=FT8_RCV_IDLE && demod1.getFFTCount() >= 184) if(rcvFT8State==FT8_RCV_READY_DECODE )
{ {
rcvFT8State = FT8_RCV_DECODE; rcvFT8State = FT8_RCV_DECODE;
#ifdef DEBUG1 #ifdef DEBUG1
@ -318,6 +324,7 @@ void loop(void) {
#endif #endif
tu = micros(); tu = micros();
num_decoded_msg = ft8_decode(); num_decoded_msg = ft8_decode();
printFT8Received();
rcvFT8State = FT8_RCV_IDLE; rcvFT8State = FT8_RCV_IDLE;
master_decoded = num_decoded_msg; master_decoded = num_decoded_msg;
#ifdef DEBUG1 #ifdef DEBUG1

@ -57,6 +57,7 @@ typedef struct
int sync_score; int sync_score;
int snr; int snr;
int distance; int distance;
float32_t azimuth; // Added Nov 2022
} Decode; } Decode;
Decode new_decoded[20]; Decode new_decoded[20];
@ -222,6 +223,7 @@ int ft8_decode(void) {
{ {
distance = Target_Distancef(Target_Locator); distance = Target_Distancef(Target_Locator);
new_decoded[num_decoded].distance = (int)(0.5f + distance); new_decoded[num_decoded].distance = (int)(0.5f + distance);
new_decoded[num_decoded].azimuth = Target_Azimuthf(Target_Locator);
} }
else else
{ {
@ -233,7 +235,7 @@ int ft8_decode(void) {
} // End, duplicate not found } // End, duplicate not found
} //End of big decode loop } //End of big decode loop
noiseMeasured = false; // Global flag for Process_DSP_R noiseMeasured = false; // Global flag for Process_DSP_R
printFT8Received(); //printFT8Received(); // Move to main INO
return num_decoded; return num_decoded;
} }
@ -254,7 +256,8 @@ void printFT8Received(void) {
Serial.print(" snr="); Serial.print(new_decoded[kk].snr); Serial.print(" snr="); Serial.print(new_decoded[kk].snr);
if(new_decoded[kk].distance > 0) if(new_decoded[kk].distance > 0)
{ {
Serial.print(" km="); Serial.println(new_decoded[kk].distance); Serial.print(" km="); Serial.print(new_decoded[kk].distance);
Serial.print(" az="); Serial.println(new_decoded[kk].azimuth, 1);
} }
else else
Serial.println(""); Serial.println("");

@ -6,6 +6,7 @@
// locatorR.ino Bob Larkin 12 Nov 2022 // locatorR.ino Bob Larkin 12 Nov 2022
// Built from the K. Goba double precision files. // Built from the K. Goba double precision files.
// Data types float precision, funtion unchanged, names have added 'f' // Data types float precision, funtion unchanged, names have added 'f'
// Added azimuth calculations Bob 14 Nov 2022
const float32_t EARTH_RAD = 6371.0f; //radius in km const float32_t EARTH_RAD = 6371.0f; //radius in km
float32_t Latitude, Longitude; float32_t Latitude, Longitude;
@ -21,11 +22,28 @@ float32_t Target_Distancef(char target[]) {
process_locator(target); process_locator(target);
Target_Latitude = Latitude; Target_Latitude = Latitude;
Target_Longitude = Longitude; Target_Longitude = Longitude;
targetDistance = distancef((float32_t)Station_Latitude, (float32_t)Station_Longitude, targetDistance = distancef(Station_Latitude, Station_Longitude,
(float32_t)Target_Latitude, (float32_t)Target_Longitude); Target_Latitude, Target_Longitude);
return targetDistance; return targetDistance;
} }
// Azimuth added 14 Nov 2022 - This duplicates some of the calculations in distance
// but the number of targets this is run on is small, so won't restructure.
float32_t Target_Azimuthf(char target[]) {
float32_t targetAz;
float d2r = 0.017453292f;
process_locator(target);
Target_Latitude = Latitude;
Target_Longitude = Longitude;
float32_t y = sinf(d2r*(Target_Longitude - Station_Longitude)) * cosf(Target_Latitude*d2r);
float32_t x = cosf(Station_Latitude*d2r) * sinf(Target_Latitude*d2r) -
sinf(Station_Latitude*d2r) * cosf(Target_Latitude*d2r) * cosf(d2r*(Target_Longitude - Station_Longitude));
targetAz = 57.2957795f*atan2f(y, x);
if(targetAz<0.0f)
targetAz += 360.0f;
return targetAz;
}
void process_locator(char locator[]) { void process_locator(char locator[]) {
uint8_t A1, A2, N1, N2; uint8_t A1, A2, N1, N2;
uint8_t A1_value, A2_value, N1_value, N2_value; uint8_t A1_value, A2_value, N1_value, N2_value;

Loading…
Cancel
Save