From 55770aa37b023f507abf482dbcc8779a6aeaf766 Mon Sep 17 00:00:00 2001 From: c vw Date: Wed, 12 Jan 2022 12:07:59 +0100 Subject: [PATCH] Re-visited the "ATLAS" bits, and introduced the choice No TX/Penelope TX/Pennylane TX in radio menu for ATLAS systems. --- hpsdrsim.c | 2 +- old_protocol.c | 55 +++++++++++++++++++++++++++++++++++--------------- radio.c | 31 ++++++++-------------------- radio.h | 1 - radio_menu.c | 38 ++++++++++++++++------------------ transmitter.c | 18 ++++------------- 6 files changed, 69 insertions(+), 76 deletions(-) diff --git a/hpsdrsim.c b/hpsdrsim.c index 30abea7..496f8c2 100644 --- a/hpsdrsim.c +++ b/hpsdrsim.c @@ -954,7 +954,7 @@ void process_ep2(uint8_t *frame) case 0: case 1: chk_data((frame[1] & 0x03) >> 0, rate, "SampleRate"); - chk_data((frame[1] & 0x0C) >> 3, ref10, "Ref10MHz"); + chk_data((frame[1] & 0x0C) >> 2, ref10, "Ref10MHz"); chk_data((frame[1] & 0x10) >> 4, src122, "Source122MHz"); chk_data((frame[1] & 0x60) >> 5, PMconfig, "Penelope/Mercury config"); chk_data((frame[1] & 0x80) >> 7, MicSrc, "MicSource"); diff --git a/old_protocol.c b/old_protocol.c index da42fc0..7d98206 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -904,16 +904,6 @@ static void process_control_bytes() { penelope_software_version=control_in[3]; g_print(" Penelope Software version: %d (0x%0X)\n",penelope_software_version,penelope_software_version); } - // - // Set atlas_penelope flag to "penelope" if three conditions are met: - // a) it's a METIS device (no HERMES, ORION, etc.) - // b) penelope software version is 18 - // c) atlas_penelope flag is "unknown" - // - if (device == DEVICE_METIS && penelope_software_version == 18 && atlas_penelope == 2) { - g_print("Adjusted settings for PENELOPE\n"); - atlas_penelope=1; - } } // //DEBUG code to monitor HL2 TX-FIFO filling and @@ -1348,7 +1338,7 @@ void ozy_send_buffer() { if(metis_offset==8) { // // Every second packet is a "C0=0" packet - // Unless USB device + // Note for USB devices metis_offest is ALWAYS 8 (!) // output_buffer[C0]=0x00; output_buffer[C1]=0x00; @@ -1375,16 +1365,49 @@ void ozy_send_buffer() { if (device == DEVICE_METIS) #endif { - // atlas_mic_source is FALSE when using Janus + // + // A. Assume a mercury board is *always* present (set CONFIG_MERCURY) + // + // B. Set CONFIG_PENELOPE in either of the cases + // - a penelope or pennylane TX is selected (atlas_penelope != 0) + // - a penelope is specified as mic source (atlas_mic_source != 0) + // - the penelope is the source for the 122.88 Mhz clock (atlas_clock_source_128mhz == 0) + // - the penelope is the source for the 10 Mhz reference (atlas_clock_source_10mhz == 1) + // + // So if neither penelope nor pennylane is selected but referenced as clock or mic source, + // a pennylane is chosen implicitly (not no drive level adjustment via IQ scaling in this case!) + // and CONFIG_BOTH becomes effective. + // + output_buffer[C1] |= CONFIG_MERCURY; + + if (atlas_penelope) { + output_buffer[C1] |= CONFIG_PENELOPE; + } + if (atlas_mic_source) { output_buffer[C1] |= PENELOPE_MIC; - output_buffer[C1] |= CONFIG_BOTH; + output_buffer[C1] |= CONFIG_PENELOPE; } - if (atlas_clock_source_128mhz) - output_buffer[C1] |= MERCURY_122_88MHZ_SOURCE; - output_buffer[C1] |= ((atlas_clock_source_10mhz & 3) << 2); + if (atlas_clock_source_128mhz) { + output_buffer[C1] |= MERCURY_122_88MHZ_SOURCE; // Mercury provides 122 Mhz + } else { + output_buffer[C1] |= PENELOPE_122_88MHZ_SOURCE; // Penelope provides 122 Mhz + output_buffer[C1] |= CONFIG_PENELOPE; + } + switch (atlas_clock_source_10mhz) { + case 0: + output_buffer[C1] |= ATLAS_10MHZ_SOURCE; // ATLAS provides 10 Mhz + break; + case 1: + output_buffer[C1] |= PENELOPE_10MHZ_SOURCE; // Penelope provides 10 Mhz + output_buffer[C1] |= CONFIG_PENELOPE; + break; + case 2: + output_buffer[C1] |= MERCURY_10MHZ_SOURCE; // Mercury provides 10 MHz + break; + } } #ifdef USBOZY diff --git a/radio.c b/radio.c index 8b5961a..54972de 100644 --- a/radio.c +++ b/radio.c @@ -153,12 +153,11 @@ int PS_RX_FEEDBACK; int buffer_size=1024; // 64, 128, 256, 512, 1024, 2048 int fft_size=2048; // 1024, 2048, 4096, 8192, 16384 -int atlas_penelope=0; // 0: no penelope, 1: penelope, 2: unknown +int atlas_penelope=0; // 0: no TX, 1: Penelope TX, 2: PennyLane TX int atlas_clock_source_10mhz=0; int atlas_clock_source_128mhz=0; int atlas_config=0; int atlas_mic_source=0; -int atlas_janus=0; int classE=0; @@ -686,29 +685,15 @@ void start_radio() { protocol=radio->protocol; device=radio->device; - // init atlas_penelope flag - atlas_penelope = 0; // default: no penelope - if (protocol == ORIGINAL_PROTOCOL && device == DEVICE_METIS) { + if ((protocol == ORIGINAL_PROTOCOL && device == DEVICE_METIS) || + (protocol == NEW_PROTOCOL && device == NEW_DEVICE_ATLAS)) { // - // VK4XV (Bob) suggested - // to have some "protection" for penelope systems which - // start from a virgin props file, namely to auto-detect a penelope - // and set the atlas_penelope flag so that the IQ samples are properly - // scaled (otherwise full PA output power results). + // by default, assume there is a penelope board (no PennyLane) + // when using an ATLAS bus system, to avoid TX overdrive due to + // missing IQ scaling. // - // So my implementation works as follows: - // To guard against "false penelope detects", the atlas_penelope flag - // is initialized with 2 ("unknown"). - // - // This has no effect if a props file is already there and the flag is - // read from the props file. The value 2 "unknown" can be changed - // to either 0 or 1 in two situations: - // - P1 analyzing the control flags and finding the penelope software version - // is 18: change "unknown" to "penelope" - // - radio menu is opened and penelope checkbox is to be displayed: change - // "unknown" to "no penelope" - // - atlas_penelope=2; + atlas_penelope = 1; + atlas_mic_source = 1; } // set the default power output and max drive value drive_max=100.0; diff --git a/radio.h b/radio.h index 8cb2d54..f2893ed 100644 --- a/radio.h +++ b/radio.h @@ -134,7 +134,6 @@ extern int atlas_clock_source_10mhz; extern int atlas_clock_source_128mhz; extern int atlas_config; extern int atlas_mic_source; -extern int atlas_janus; extern int classE; diff --git a/radio_menu.c b/radio_menu.c index f7071fe..0467e64 100644 --- a/radio_menu.c +++ b/radio_menu.c @@ -409,11 +409,7 @@ static void micsource_cb(GtkWidget *widget, gpointer data) { } static void penelopetx_cb(GtkWidget *widget, gpointer data) { - atlas_penelope=atlas_penelope==1?0:1; -} - -static void janus_cb(GtkWidget *widget, gpointer data) { - atlas_janus=atlas_janus==1?0:1; + atlas_penelope=GPOINTER_TO_INT(data); } void radio_menu(GtkWidget *parent) { @@ -743,6 +739,7 @@ void radio_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),atlas_label,col,row,1,1); row++; + // Possibly "fuse" the 10Mhz Atlas buttons in one drop-down GtkWidget *ck10mhz_1=gtk_radio_button_new_with_label(NULL,"10MHz clock=Atlas"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ck10mhz_1), atlas_clock_source_10mhz==0); gtk_grid_attach(GTK_GRID(grid),ck10mhz_1,col,row,1,1); @@ -773,24 +770,23 @@ void radio_menu(GtkWidget *parent) { g_signal_connect(mic_src_b,"toggled",G_CALLBACK(micsource_cb),NULL); row++; - // - // If we arrive here and atlas_penelope is still "unknown", - // set it to "no penelope" (from now on, it may only take - // the values 0 and 1). - // - if (atlas_penelope == 2) { - atlas_penelope = 0; - } - GtkWidget *pene_tx_b=gtk_check_button_new_with_label("Penelope TX"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pene_tx_b), atlas_penelope); - gtk_grid_attach(GTK_GRID(grid),pene_tx_b,col,row,1,1); - g_signal_connect(pene_tx_b,"toggled",G_CALLBACK(penelopetx_cb),NULL); + // Possibly "fuse" the TX buttons in one drop-down + GtkWidget *penelopetx_1=gtk_radio_button_new_with_label(NULL,"No TX"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (penelopetx_1), atlas_penelope==0); + gtk_grid_attach(GTK_GRID(grid),penelopetx_1,col,row,1,1); + g_signal_connect(penelopetx_1,"toggled",G_CALLBACK(penelopetx_cb),(gpointer *)0); + row++; + + GtkWidget *penelopetx_2=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(penelopetx_1),"Penelope TX"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (penelopetx_2), atlas_penelope==1); + gtk_grid_attach(GTK_GRID(grid),penelopetx_2,col,row,1,1); + g_signal_connect(penelopetx_2,"toggled",G_CALLBACK(penelopetx_cb),(gpointer *)1); row++; - GtkWidget *janus_b=gtk_check_button_new_with_label("Janus"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (janus_b), atlas_janus); - gtk_grid_attach(GTK_GRID(grid),janus_b,col,row,1,1); - g_signal_connect(janus_b,"toggled",G_CALLBACK(janus_cb),NULL); + GtkWidget *penelopetx_3=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(penelopetx_1),"Pennylane TX"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (penelopetx_3), atlas_penelope==2); + gtk_grid_attach(GTK_GRID(grid),penelopetx_3,col,row,1,1); + g_signal_connect(penelopetx_3,"toggled",G_CALLBACK(penelopetx_cb),(gpointer *)2); row++; if(row>temp_row) temp_row=row; diff --git a/transmitter.c b/transmitter.c index 644fa99..446ccdd 100644 --- a/transmitter.c +++ b/transmitter.c @@ -1219,24 +1219,14 @@ static void full_tx_buffer(TRANSMITTER *tx) { ) && atlas_penelope == 1) { // // Note that the atlas_penelope flag can have three values, namely - // 0 "no penelope" : no scaling + // 0 "no penelope" : no scaling // 1 "penelope" : scale - // 2 "unknown" : no scaling - // - // Note "unknown" will be changed to "penelope" if P1 HPSDR packets are - // received and the penelope software version is 1.8. However, if it is a - // METIS system with a penelope software version different from 1.8, then - // the flag will remain in the "unknown" state. - // - // Note further, in the moment the radio menu is opened, "unknown" will be - // changed to "no penelope". - // - // This is so because some RedPitaya-based HPSDR servers identify as a - // METIS with penelope software version = 1.7 + // 2 "pennylane" : no scaling // // On Penelope boards, the TX drive level as reported by the P1 protocol has // no effect, and TX drive level changes are instead realized by - // scaling the TX IQ samples. + // scaling the TX IQ samples. Pennylane is a slightly updated Penelope board + // that has drive scaling just as Hermes and later. // // "The magic factor" 0.00392 is slightly less than 1/255. // -- 2.45.2