From 19ebdd58d0d834b0d89706a71a2b19e4170521b6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 15:11:29 -0400 Subject: [PATCH 01/12] added clockgen_present --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 3c5e94ab..c54fe30c 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -376,6 +376,7 @@ bool voltage_read = false; bool ina219_started = false; bool camera_detected = false; bool rotate_flag = true; +bool clockgen_present = false; int led_builtin_pin; From 9bdc0e24c3743245504aad7a87e8a9af8df14047 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 15:22:15 -0400 Subject: [PATCH 02/12] only set clock if clockgen_present --- cubesatsim/cubesatsim.ino | 68 +++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 09360c32..9d2d704a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -549,7 +549,7 @@ void transmit_on() { ret = clockgen.enableOutputs(true); Serial.println("Enable clock outputs!"); } -*/ +*/ if (clockgen_present) { if (clockgen.enableOutputs(true)) { start_clockgen(); if (mode == BPSK) @@ -561,6 +561,7 @@ void transmit_on() { } else { Serial.println("Enable clock outputs"); } + } } else if (mode == CW) { // Serial.println("Transmit on!"); @@ -589,7 +590,7 @@ void transmit_off() { Serial.println("Disable clock outputs!"); } // clockgen.enableOutputs(false) -*/ +*/ if (clockgen_present) { if (clockgen.enableOutputs(false)) { start_clockgen(); clockgen.enableOutputs(false); @@ -597,6 +598,7 @@ void transmit_off() { } else { Serial.println("Disable clock outputs"); } + } } else if (mode == SSTV) @@ -2222,7 +2224,8 @@ void config_radio() if (sr_frs_present) digitalWrite(PD_PIN, HIGH); // Enable SR_FRS else { - start_clockgen(); + start_clockgen(); + if (clockgen_present) { if (clockgen.setClockFSK(frequency_offset)) { start_clockgen(); clockgen.setClockFSK(frequency_offset); @@ -2233,7 +2236,8 @@ void config_radio() digitalWrite(PD_PIN, LOW); // disable SR_FRS clockgen.enableOutputs(false); digitalWrite(BPSK_CONTROL_B, LOW); - digitalWrite(BPSK_CONTROL_A, LOW); + digitalWrite(BPSK_CONTROL_A, LOW); + } } @@ -2246,7 +2250,7 @@ void config_radio() Serial.println("Config clock for BPSK"); } */ - + if (clockgen_present) { if (clockgen.setClockBPSK(frequency_offset)) { start_clockgen(); clockgen.setClockBPSK(frequency_offset); @@ -2254,6 +2258,7 @@ void config_radio() } else { Serial.println("Config clock for BPSK"); } + } transmit_on(); } else if (mode == FSK) {// || (mode == SSTV)) @@ -2264,14 +2269,15 @@ void config_radio() ret = clockgen.setClockFSK(); Serial.println("Config clock for FSK"); } -*/ +*/ if (clockgen_present) { if (clockgen.setClockFSK(frequency_offset)) { start_clockgen(); clockgen.setClockFSK(frequency_offset); Serial.println("Config clock for FSK"); } else { Serial.println("Config clock for FSK"); - } + } + } transmit_on(); } @@ -4098,14 +4104,19 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise digitalWrite(AUDIO_OUT_PIN, LOW); } else { + // Serial.println("No sr_frs present!"); unsigned long start = micros(); -// clockgen.enableOutputs(true); - clockgen.enableOutputOnly(0); - digitalWrite(BPSK_CONTROL_A, HIGH); +// clockgen.enableOutputs(true); + if (clockgen_present) { + clockgen.enableOutputOnly(0); + digitalWrite(BPSK_CONTROL_A, HIGH); + } while((micros() - start) < duration_us) { } - digitalWrite(BPSK_CONTROL_A, LOW); - clockgen.enableOutputs(false); + if (clockgen_present) + digitalWrite(BPSK_CONTROL_A, LOW); + clockgen.enableOutputs(false); + } } // if (!wifi) @@ -4134,18 +4145,22 @@ void transmit_callsign(char *callsign) { print_string(id); if (!sr_frs_present) { - start_clockgen(); + start_clockgen(); + if (clockgen.setClockFSK(frequency_offset)) { start_clockgen(); - clockgen.setClockFSK(frequency_offset); + if (clockgen_present) + clockgen.setClockFSK(frequency_offset); Serial.println("Config clock for CW without SR_FRS!"); } else { Serial.println("Config clock for CW without SR_FRS"); } - digitalWrite(PD_PIN, LOW); // disable SR_FRS - clockgen.enableOutputs(false); - digitalWrite(BPSK_CONTROL_B, LOW); - digitalWrite(BPSK_CONTROL_A, LOW); + digitalWrite(PD_PIN, LOW); // disable SR_FRS + if (clockgen_present) { + clockgen.enableOutputs(false); + digitalWrite(BPSK_CONTROL_B, LOW); + digitalWrite(BPSK_CONTROL_A, LOW); + } } /* if (reset_count == 0) { @@ -5020,6 +5035,7 @@ void write_mode(int save_mode) { } void start_clockgen() { + clockgen_present = false; Wire1.setSDA(2); Wire1.setSCL(3); @@ -5036,18 +5052,22 @@ void start_clockgen() { Serial.println("No Si5351 detected on bus 2 ... Check your wiring or I2C ADDR!"); clockgen.begin(&Wire); // go back to Wire so that it doesn't lock up with no clockgen return; - } else + } else { Serial.println("Si5351 detected on bus 2"); + clockgen_present = true; + } - } else + } else { Serial.println("Si5351 detected on bus 1"); + clockgen_present = true; + } - - Serial.println("Starting clockgen frequency 434.9 MHz"); + if (clockgen_present) { + Serial.println("Starting clockgen frequency 434.9 MHz"); // clockgen.setClockFSK(); // default to FSK - clockgen.enableOutputs(false); - + clockgen.enableOutputs(false); + } } void get_input() { From 6310a36d3b9937f6c0fb094bc50a9c40ade49d1b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 15:29:55 -0400 Subject: [PATCH 03/12] missing { --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9d2d704a..73618d78 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4113,7 +4113,7 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise digitalWrite(BPSK_CONTROL_A, HIGH); } while((micros() - start) < duration_us) { } - if (clockgen_present) + if (clockgen_present) { digitalWrite(BPSK_CONTROL_A, LOW); clockgen.enableOutputs(false); } From 1a97c7a26314f8e46bd3604cae1e8b8707cbba00 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 18:35:06 -0400 Subject: [PATCH 04/12] add another clockgen_present --- cubesatsim/cubesatsim.ino | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 73618d78..6624a171 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4147,14 +4147,16 @@ void transmit_callsign(char *callsign) { if (!sr_frs_present) { start_clockgen(); - if (clockgen.setClockFSK(frequency_offset)) { - start_clockgen(); - if (clockgen_present) - clockgen.setClockFSK(frequency_offset); - Serial.println("Config clock for CW without SR_FRS!"); - } else { - Serial.println("Config clock for CW without SR_FRS"); - } + if (clockgen_present) { + if (clockgen.setClockFSK(frequency_offset)) { + start_clockgen(); + if (clockgen_present) + clockgen.setClockFSK(frequency_offset); + Serial.println("Config clock for CW without SR_FRS!"); + } else { + Serial.println("Config clock for CW without SR_FRS"); + } + } digitalWrite(PD_PIN, LOW); // disable SR_FRS if (clockgen_present) { clockgen.enableOutputs(false); From 46d27d401b019ef7cdd67fd6104f506ed70dd279 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 18:40:39 -0400 Subject: [PATCH 05/12] print before and after clockgen start --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6624a171..71c1785a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4145,8 +4145,9 @@ void transmit_callsign(char *callsign) { print_string(id); if (!sr_frs_present) { + Serial.println("before start"); start_clockgen(); - + Serial.println("after start"); if (clockgen_present) { if (clockgen.setClockFSK(frequency_offset)) { start_clockgen(); From a341cf1f494f5b148e2a5a738e73993971d1f067 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 18:44:10 -0400 Subject: [PATCH 06/12] remove clockgen start in cw id --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 71c1785a..f13945dd 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4145,9 +4145,9 @@ void transmit_callsign(char *callsign) { print_string(id); if (!sr_frs_present) { - Serial.println("before start"); - start_clockgen(); - Serial.println("after start"); +// Serial.println("before start"); +// start_clockgen(); +// Serial.println("after start"); if (clockgen_present) { if (clockgen.setClockFSK(frequency_offset)) { start_clockgen(); From a54c2d47a2b01476adb5a5dc59507831eb517350 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 18:47:12 -0400 Subject: [PATCH 07/12] add blink at start --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f13945dd..bdd5ad64 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -125,6 +125,8 @@ void setup() { config_gpio(); + blink(50) + get_input(); start_clockgen(); From 940ff31847d99dd619d93d7b6c32faab1cb3bb97 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 18:47:58 -0400 Subject: [PATCH 08/12] missing ; --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index bdd5ad64..355ea917 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -125,7 +125,7 @@ void setup() { config_gpio(); - blink(50) + blink(50); get_input(); From d0d842f2d821ed311a62e0c2ec6d1772dd6e314d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 18:52:13 -0400 Subject: [PATCH 09/12] move blink to very start --- cubesatsim/cubesatsim.ino | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 355ea917..74ad13f0 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -91,6 +91,21 @@ void setup() { Serial.begin(115200); +/**/ + if (check_for_wifi()) { + wifi = true; + led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W + pinMode(LED_BUILTIN, OUTPUT); +// configure_wifi(); + } else { + led_builtin_pin = 25; // manually set GPIO 25 for Pico board +// pinMode(25, OUTPUT); + pinMode(led_builtin_pin, OUTPUT); + } +/**/ + + blink(50); + delay(10000); LittleFS.begin(); @@ -108,25 +123,10 @@ void setup() { // otherwise, run CubeSatSim Pico code - Serial.println("CubeSatSim Pico v0.41 starting...\n"); - -/**/ - if (check_for_wifi()) { - wifi = true; - led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W - pinMode(LED_BUILTIN, OUTPUT); -// configure_wifi(); - } else { - led_builtin_pin = 25; // manually set GPIO 25 for Pico board -// pinMode(25, OUTPUT); - pinMode(led_builtin_pin, OUTPUT); - } -/**/ + Serial.println("CubeSatSim Pico v0.41 starting...\n"); config_gpio(); - blink(50); - get_input(); start_clockgen(); From a95ecff80dc86c98ac77fd4ecdb2fc7ef028f20a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 18:55:57 -0400 Subject: [PATCH 10/12] remove prints in check for wifi --- cubesatsim/cubesatsim.ino | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 74ad13f0..ac51d919 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -129,6 +129,12 @@ void setup() { get_input(); + if (wifi) + Serial.println("\nPico W detected!\n"); + else + Serial.println("\nPico detected!\n"); + + start_clockgen(); EEPROM.begin(512); @@ -3960,11 +3966,11 @@ bool check_for_wifi() { // if (result < 0x100) { if (result < 0x10) { - Serial.println("\nPico W detected!\n"); +// Serial.println("\nPico W detected!\n"); return(true); } else { - Serial.println("\nPico detected!\n"); +// Serial.println("\nPico detected!\n"); return(false); } } From 5cb8a10439bfeb757f7501b94a16a82d511e320f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 18:59:32 -0400 Subject: [PATCH 11/12] move config_gpio earlier --- cubesatsim/cubesatsim.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ac51d919..3fb5a67e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -90,7 +90,8 @@ void setup() { set_sys_clock_khz(133000, true); Serial.begin(115200); - + + config_gpio(); /**/ if (check_for_wifi()) { wifi = true; @@ -125,7 +126,7 @@ void setup() { Serial.println("CubeSatSim Pico v0.41 starting...\n"); - config_gpio(); +//// config_gpio(); get_input(); @@ -3734,6 +3735,7 @@ void config_gpio() { Serial.println(digitalRead(PI_3V3_PIN)); if (digitalRead(PI_3V3_PIN) == HIGH) { // { + delay(10000); Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code."); start_payload(); while(true) { From 51825357a40a617ea455dc72328feaf5d3491d14 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 14 Apr 2023 19:32:41 -0400 Subject: [PATCH 12/12] removed +Bat --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 3fb5a67e..118d447e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2386,7 +2386,7 @@ void read_ina219() loadvoltage = busvoltage + (shuntvoltage / 1000); if ((debug_mode) || (voltage_read)) { - Serial.print("+Bat (1 0x44) Voltage: "); + Serial.print("Bat (1 0x44) Voltage: "); Serial.print(loadvoltage); Serial.print("V Current: "); Serial.print(current_mA);