From 69a406ea890cf492d5c8070470a1f5f778297b76 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 4 Jul 2022 17:00:27 -0400 Subject: [PATCH 001/147] added pwm code --- cubesatsim/cubesatsim.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index a3c82cd0..1c8e015b 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -27,6 +27,12 @@ #include #include #include +#include +#include "pico/stdlib.h" // stdlib +#include "hardware/irq.h" // interrupts +#include "hardware/pwm.h" // pwm +#include "hardware/sync.h" // wait for interrupt + // Pico GPIO pin assignments #define LPF_PIN 8 // LPF is installed @@ -84,6 +90,8 @@ #define OFF - 1 #define ON 1 +#define WAV_DATA_LENGTH 100000 + uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET; uint8_t data[1024]; uint32_t tx_channel = 0; @@ -120,20 +128,23 @@ short eeprom_word_read(int addr); void eeprom_word_write(int addr, int val); void read_payload(); void start_ina219(); - +void pwm_interrupt_handler(); +void start_pwm() ; + extern int Encode_8b10b[][256]; -int socket_open = 0; -int sock = 0; +//int socket_open = 0; +//int sock = 0; int loop_count = 0; int firstTime = ON; // 0; long start; int testCount = 0; long time_start; //char cmdbuffer[1000]; -FILE * file1; +//FILE * file1;// short int buffer[100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK -FILE *sopen(const char *program); +short int buffer[WAV_DATA_LENGTH]; +//FILE *sopen(const char *program); #define S_RATE (8000) //(48000) // (44100) @@ -223,6 +234,8 @@ int sensorValue; float Temp; float rest; +int wav_position = 0; + /* * TelemEncoding.h * From ce274040af48058e678b4e83ff9d89a569de7789 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 4 Jul 2022 17:00:39 -0400 Subject: [PATCH 002/147] added pwm code --- cubesatsim/cubesatsim.ino | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5af2ac55..10dc8038 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -28,6 +28,11 @@ #include #include #include +#include +#include "pico/stdlib.h" // stdlib +#include "hardware/irq.h" // interrupts +#include "hardware/pwm.h" // pwm +#include "hardware/sync.h" // wait for interrupt Adafruit_INA219 ina219_1_0x40; Adafruit_INA219 ina219_1_0x41(0x41); @@ -1972,3 +1977,54 @@ void start_ina219() { ina219_2_0x44.setCalibration_16V_400mA(); ina219_2_0x45.setCalibration_16V_400mA(); } + +void start_pwm() { +// based on code https://github.com/rgrosset/pico-pwm-audio +// + set_sys_clock_khz(125000, true); + gpio_set_function(AUDIO_OUT_PIN, GPIO_FUNC_PWM); + + int audio_pin_slice = pwm_gpio_to_slice_num(AUDIO_PIN); + + // Setup PWM interrupt to fire when PWM cycle is complete + pwm_clear_irq(audio_pin_slice); + pwm_set_irq_enabled(audio_pin_slice, true); + // set the handle function above + irq_set_exclusive_handler(PWM_IRQ_WRAP, pwm_interrupt_handler); + irq_set_enabled(PWM_IRQ_WRAP, true); + + // Setup PWM for audio output + pwm_config config = pwm_get_default_config(); + /* Base clock 176,000,000 Hz divide by wrap 250 then the clock divider further divides + * to set the interrupt rate. + * + * 11 KHz is fine for speech. Phone lines generally sample at 8 KHz + * + * + * So clkdiv should be as follows for given sample rate + * 8.0f for 11 KHz + * 4.0f for 22 KHz + * 2.0f for 44 KHz etc + */ + pwm_config_set_clkdiv(&config, 16.0); // 8.0f); + pwm_config_set_wrap(&config, 250); + pwm_init(audio_pin_slice, &config, true); + + pwm_set_gpio_level(AUDIO_OUT_PIN, 0); + +} + +void pwm_interrupt_handler() { +// based on code https://github.com/rgrosset/pico-pwm-audio +// + pwm_clear_irq(pwm_gpio_to_slice_num(AUDIO_OUT_PIN)); + if (wav_position < (WAV_DATA_LENGTH<<3) - 1) { + // set pwm level + // allow the pwm value to repeat for 8 cycles this is >>3 + pwm_set_gpio_level(AUDIO_OUT_PIN, WAV_DATA[wav_position>>3]); + wav_position++; + } else { + // reset to start + wav_position = 0; + } +} From 7347703071576664a2b43f494c2ada531525262c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 4 Jul 2022 17:01:48 -0400 Subject: [PATCH 003/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 1c8e015b..ebffa74b 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -90,7 +90,7 @@ #define OFF - 1 #define ON 1 -#define WAV_DATA_LENGTH 100000 +#define WAV_DATA_LENGTH 50000 uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET; uint8_t data[1024]; @@ -142,7 +142,7 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -short int buffer[100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK +//short int buffer[100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK short int buffer[WAV_DATA_LENGTH]; //FILE *sopen(const char *program); From 9c804a5f893cbbb28813648666aa86938bcd6535 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 4 Jul 2022 17:02:30 -0400 Subject: [PATCH 004/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 10dc8038..a02b1439 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -1984,7 +1984,7 @@ void start_pwm() { set_sys_clock_khz(125000, true); gpio_set_function(AUDIO_OUT_PIN, GPIO_FUNC_PWM); - int audio_pin_slice = pwm_gpio_to_slice_num(AUDIO_PIN); + int audio_pin_slice = pwm_gpio_to_slice_num(AUDIO_OUT_PIN); // Setup PWM interrupt to fire when PWM cycle is complete pwm_clear_irq(audio_pin_slice); From f67b0360262b9de5645622bdd0b3ab89130b74b7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 4 Jul 2022 17:03:18 -0400 Subject: [PATCH 005/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a02b1439..f8e4c2a3 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2021,7 +2021,7 @@ void pwm_interrupt_handler() { if (wav_position < (WAV_DATA_LENGTH<<3) - 1) { // set pwm level // allow the pwm value to repeat for 8 cycles this is >>3 - pwm_set_gpio_level(AUDIO_OUT_PIN, WAV_DATA[wav_position>>3]); + pwm_set_gpio_level(AUDIO_OUT_PIN, buffer[wav_position>>3]); wav_position++; } else { // reset to start From 077339821c4f3543de81328784e1a3366237c4ef Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 4 Jul 2022 17:05:20 -0400 Subject: [PATCH 006/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f8e4c2a3..d91efc98 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -162,6 +162,9 @@ void setup() { } +// start pwm +start_pwm(); + // configure ina219s start_ina219(); From 4bb63efd126d8f1639b41a377b91257e67e62623 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 4 Jul 2022 17:06:52 -0400 Subject: [PATCH 007/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index d91efc98..2bdb58cb 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -73,7 +73,7 @@ void setup() { Serial.println("\n\nCubeSatSim Pico v0.1 starting...\n\n"); - mode = AFSK; + mode = FSK; // AFSK; frameCnt = 1; From 28fdbbd1958cea30623d7d2b74b9dc220fa18489 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 4 Jul 2022 17:39:03 -0400 Subject: [PATCH 008/147] added * 8, and / 8 to WAV_DATA_LENGTH --- cubesatsim/cubesatsim.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index ebffa74b..668b1ced 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -90,7 +90,7 @@ #define OFF - 1 #define ON 1 -#define WAV_DATA_LENGTH 50000 +#define WAV_DATA_LENGTH (50000 * 8) uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET; uint8_t data[1024]; @@ -143,7 +143,7 @@ long time_start; //char cmdbuffer[1000]; //FILE * file1;// //short int buffer[100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK -short int buffer[WAV_DATA_LENGTH]; +short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); #define S_RATE (8000) //(48000) // (44100) From cbfc76f25c1ac71bd231344995fb650828e45fae Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 09:41:30 -0400 Subject: [PATCH 009/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 668b1ced..17e037a5 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -90,7 +90,7 @@ #define OFF - 1 #define ON 1 -#define WAV_DATA_LENGTH (50000 * 8) +//#define WAV_DATA_LENGTH (50000 * 8) uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET; uint8_t data[1024]; @@ -142,11 +142,11 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -//short int buffer[100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK -short int buffer[(WAV_DATA_LENGTH/8)]; +short int buffer[2^15]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK +//short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); -#define S_RATE (8000) //(48000) // (44100) +#define S_RATE (200) // (8000) //(48000) // (44100) #define AFSK 1 #define FSK 2 From 3ccbe7f4c849ebed1c962a824c9a1c89d79ccc7c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 09:41:49 -0400 Subject: [PATCH 010/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 2bdb58cb..645036ce 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -108,7 +108,7 @@ void setup() { Serial.println(samplePeriod); frameTime = ((float)((float)bufLen / (samples * frameCnt * bitRate))) * 1000; // frame time in ms - + Serial.println(frameTime); // printf("\n FSK Mode, %d bits per frame, %d bits per second, %d ms per frame, %d ms sample period\n", // bufLen / (samples * frameCnt), bitRate, frameTime, samplePeriod); } else if (mode == BPSK) { @@ -755,8 +755,8 @@ void get_tlm_fox() { // printf("\n\nValue of ctr after header: %d Buffer Len: %d\n\n", ctr, buffSize); /// #endif Serial.println(10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); -// for (i = 1; i <= (10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // 572 - for (i = 1; i <= ((headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // Not 10 * anymore 572 + for (i = 1; i <= (10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // 572 +// for (i = 1; i <= ((headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // Not 10 * anymore 572 { write_wave(ctr, buffer); if ((i % samples) == 0) { @@ -795,9 +795,9 @@ void write_wave(int i, short int *buffer) { if (mode == FSK) { - if ((ctr - flip_ctr) < smaller) - buffer[ctr++] = (short int)(0.1 * phase * (ctr - flip_ctr) / smaller); - else +// if ((ctr - flip_ctr) < smaller) // No wave shaping +// buffer[ctr++] = (short int)(0.1 * phase * (ctr - flip_ctr) / smaller); +// else buffer[ctr++] = (short int)(0.25 * amplitude * phase); } else From 90ed1246082996390ae9d1e5025e6373ae1f4fdc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 09:46:22 -0400 Subject: [PATCH 011/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 17e037a5..e8f86cc3 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -142,7 +142,8 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -short int buffer[2^15]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK +unsigned int buffer_size = 2^16; +short int buffer[buffer_size]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); @@ -234,7 +235,7 @@ int sensorValue; float Temp; float rest; -int wav_position = 0; +unsigned int wav_position = 0; /* * TelemEncoding.h From a84c120216f5813fd9831e79e179c97ceeae7d2e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 09:47:14 -0400 Subject: [PATCH 012/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 645036ce..7607cc44 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2021,10 +2021,11 @@ void pwm_interrupt_handler() { // based on code https://github.com/rgrosset/pico-pwm-audio // pwm_clear_irq(pwm_gpio_to_slice_num(AUDIO_OUT_PIN)); - if (wav_position < (WAV_DATA_LENGTH<<3) - 1) { +// if (wav_position < (WAV_DATA_LENGTH<<3) - 1) { + if (wav_position > (buffer_size - 1)) { // set pwm level // allow the pwm value to repeat for 8 cycles this is >>3 - pwm_set_gpio_level(AUDIO_OUT_PIN, buffer[wav_position>>3]); + pwm_set_gpio_level(AUDIO_OUT_PIN, buffer[wav_position]); wav_position++; } else { // reset to start From 3a2f4990407d0103d687b93c0bc872824c1549a1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 09:49:43 -0400 Subject: [PATCH 013/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index e8f86cc3..e49c49e3 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -142,8 +142,8 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -unsigned int buffer_size = 2^16; -short int buffer[buffer_size]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK +#define BUFFER_SIZE (2^16) +short int buffer[BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); From 2e0beb4faa8efefeea32cf57cffca7db8a85ee81 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 09:50:18 -0400 Subject: [PATCH 014/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7607cc44..01c3a53b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2022,7 +2022,7 @@ void pwm_interrupt_handler() { // pwm_clear_irq(pwm_gpio_to_slice_num(AUDIO_OUT_PIN)); // if (wav_position < (WAV_DATA_LENGTH<<3) - 1) { - if (wav_position > (buffer_size - 1)) { + if (wav_position > (BUFFER_SIZE - 1)) { // set pwm level // allow the pwm value to repeat for 8 cycles this is >>3 pwm_set_gpio_level(AUDIO_OUT_PIN, buffer[wav_position]); From 78b901d9dbea36e1ac4a520dbb2b2529ae4ce8ad Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 11:15:32 -0400 Subject: [PATCH 015/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index e49c49e3..d4710c46 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -142,8 +142,8 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -#define BUFFER_SIZE (2^16) -short int buffer[BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK +#define BUFFER_SIZE (2^15) +short int buffer[100000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); @@ -236,7 +236,10 @@ float Temp; float rest; unsigned int wav_position = 0; - +int counter = 0; +int counter_max = 420; +int amplitude = 50; //100; +int value; /* * TelemEncoding.h * From 9ce66ccfae3f2c46f9484b3d33498708fd6d6984 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 11:18:19 -0400 Subject: [PATCH 016/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index d4710c46..3a421696 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -236,10 +236,11 @@ float Temp; float rest; unsigned int wav_position = 0; -int counter = 0; -int counter_max = 420; -int amplitude = 50; //100; -int value; +int pwm_counter = 0; +int pwm_counter_max = 420; +int pwm_amplitude = 50; //100; +int pwm_value; +int pwm_rnd_bit = 1; /* * TelemEncoding.h * From 81d3344d0893868e659a8ef2fa935e9b6ef2db3b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 11:20:33 -0400 Subject: [PATCH 017/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 01c3a53b..6a6ea084 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -1984,6 +1984,8 @@ void start_ina219() { void start_pwm() { // based on code https://github.com/rgrosset/pico-pwm-audio // + pwm_value = 128 - pwm_amplitude; + set_sys_clock_khz(125000, true); gpio_set_function(AUDIO_OUT_PIN, GPIO_FUNC_PWM); @@ -2016,7 +2018,7 @@ void start_pwm() { pwm_set_gpio_level(AUDIO_OUT_PIN, 0); } - +/* void pwm_interrupt_handler() { // based on code https://github.com/rgrosset/pico-pwm-audio // @@ -2032,3 +2034,25 @@ void pwm_interrupt_handler() { wav_position = 0; } } +*/ + +void pwm_interrupt_handler() { + pwm_clear_irq(pwm_gpio_to_slice_num(AUDIO_OUT_PIN)); + pwm_counter++; + if (pwm_counter > pwm_counter_max) { + pwm_counter -= pwm_counter_max; + if (random(0,2) == 1) + pwm_rnd_bit *= (-1.0); + + if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { + pwm_value = 128 + pwm_amplitude; + Serial.print("."); + } + else { + pwm_value = 128 - pwm_amplitude; + Serial.print(" "); + } + } + pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); +// wav_position++; +} From 4f0db81306acb1036b082ac66fee7d713a33b7fb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 13:26:19 -0400 Subject: [PATCH 018/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6a6ea084..595761f3 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -766,8 +766,8 @@ void get_tlm_fox() { data = val & 1 << (bit - 1); // printf ("%d i: %d new frame %d data10[%d] = %x bit %d = %d \n", // ctr/SAMPLES, i, frames, symbol, val, bit, (data > 0) ); - Serial.print(val, HEX); // Debugging print!!! - Serial.print(" "); + Serial.print(data, BIN); // Debugging print!!! +// Serial.print(" "); if (mode == FSK) { phase = ((data != 0) * 2) - 1; // printf("Sending a %d\n", phase); @@ -785,7 +785,7 @@ void get_tlm_fox() { } // Serial.println("BB"); } - Serial.println("CC"); +// Serial.println("CC"); } Serial.println(" "); Serial.println("Returning"); @@ -2041,9 +2041,11 @@ void pwm_interrupt_handler() { pwm_counter++; if (pwm_counter > pwm_counter_max) { pwm_counter -= pwm_counter_max; - if (random(0,2) == 1) - pwm_rnd_bit *= (-1.0); - +// if (random(0,2) == 1) +// pwm_rnd_bit *= (-1.0); + + pwm_rnd = (buffer[wave_position] > 0) ? 1 : 0; + if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { pwm_value = 128 + pwm_amplitude; Serial.print("."); @@ -2054,5 +2056,7 @@ void pwm_interrupt_handler() { } } pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); -// wav_position++; + if (wav_position++ > 950) + wave_position = 0; + } From a37c79b92d0225ca2d5ed42e78a653126a7dc4f8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 13:28:20 -0400 Subject: [PATCH 019/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 595761f3..602054ce 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2044,7 +2044,7 @@ void pwm_interrupt_handler() { // if (random(0,2) == 1) // pwm_rnd_bit *= (-1.0); - pwm_rnd = (buffer[wave_position] > 0) ? 1 : 0; + pwm_rnd_bit = (buffer[wave_position] > 0) ? 1 : 0; if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { pwm_value = 128 + pwm_amplitude; From c3a88e2c16b9787b0d1abfeb8b82d1c1846d7064 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 13:29:41 -0400 Subject: [PATCH 020/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 602054ce..d2463220 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2044,7 +2044,7 @@ void pwm_interrupt_handler() { // if (random(0,2) == 1) // pwm_rnd_bit *= (-1.0); - pwm_rnd_bit = (buffer[wave_position] > 0) ? 1 : 0; + pwm_rnd_bit = (buffer[wav_position] > 0) ? 1 : 0; if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { pwm_value = 128 + pwm_amplitude; @@ -2057,6 +2057,6 @@ void pwm_interrupt_handler() { } pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); if (wav_position++ > 950) - wave_position = 0; + wav_position = 0; } From 15d568ba4e76748c9e6ca09fcf66ce1be1450d35 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 13:35:50 -0400 Subject: [PATCH 021/147] buffer[ --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index d2463220..a510f654 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -766,7 +766,7 @@ void get_tlm_fox() { data = val & 1 << (bit - 1); // printf ("%d i: %d new frame %d data10[%d] = %x bit %d = %d \n", // ctr/SAMPLES, i, frames, symbol, val, bit, (data > 0) ); - Serial.print(data, BIN); // Debugging print!!! +// Serial.print(data, BIN); // Debugging print!!! // Serial.print(" "); if (mode == FSK) { phase = ((data != 0) * 2) - 1; From 60564b4ec85addc117345f243c7795f48b3b9b8d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 13:37:34 -0400 Subject: [PATCH 022/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a510f654..4128b131 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -799,6 +799,7 @@ void write_wave(int i, short int *buffer) // buffer[ctr++] = (short int)(0.1 * phase * (ctr - flip_ctr) / smaller); // else buffer[ctr++] = (short int)(0.25 * amplitude * phase); + Serial.print(buffer[ctr - 1]); } else { From eee9f8c8b799053f7881554a90f07bb0da73df56 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 13:38:43 -0400 Subject: [PATCH 023/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4128b131..5b1b7286 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -800,6 +800,7 @@ void write_wave(int i, short int *buffer) // else buffer[ctr++] = (short int)(0.25 * amplitude * phase); Serial.print(buffer[ctr - 1]); + Serial.print(" "); } else { From c13aba2d16283ee4b4a67393b5c08f92c31356d6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 13:39:14 -0400 Subject: [PATCH 024/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 3a421696..215b91f7 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -143,7 +143,7 @@ long time_start; //char cmdbuffer[1000]; //FILE * file1;// #define BUFFER_SIZE (2^15) -short int buffer[100000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK +short int buffer[50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); From 5e71f4ade14d32369a16d3a7f6c14eb3f95b3b48 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 13:46:50 -0400 Subject: [PATCH 025/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 52 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5b1b7286..e1aad880 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -289,7 +289,7 @@ void get_tlm_ao7() { print_string(str); strcat(str, payload_str); print_string(str); - Serial.println(strlen(str)); +// Serial.println(strlen(str)); set_status(str); // } } @@ -331,11 +331,11 @@ void get_tlm_fox() { id = 7; else id = 0; // 99 in h[6] - Serial.println("About to do frame loop"); +// Serial.println("About to do frame loop"); // for (int frames = 0; frames < FRAME_CNT; frames++) for (int frames = 0; frames < frameCnt; frames++) { - Serial.println("Frame loop"); +// Serial.println("Frame loop"); if (firstTime != ON) { // delay for sample period /**/ @@ -412,25 +412,25 @@ void get_tlm_fox() { sensor[count1] = sensor_max[count1]; } } - Serial.println("Here"); +// Serial.println("Here"); } else frm_type = 0x02; // BPSK always send MAX MIN frame } - Serial.println("Continuing"); +// Serial.println("Continuing"); sensor_payload[0] = 0; // clear for next payload // if (mode == FSK) { // remove this // } memset(rs_frame, 0, sizeof(rs_frame)); memset(parities, 0, sizeof(parities)); - Serial.println("After memset"); +// Serial.println("After memset"); h[0] = (short int) ((h[0] & 0xf8) | (id & 0x07)); // 3 bits - Serial.println("After h[0]"); +// Serial.println("After h[0]"); if (uptime != 0) // if uptime is 0, leave reset count at 0 { - Serial.println("After uptime test"); +// Serial.println("After uptime test"); h[0] = (short int) ((h[0] & 0x07) | ((reset_count & 0x1f) << 3)); h[1] = (short int) ((reset_count >> 5) & 0xff); h[2] = (short int) ((h[2] & 0xf8) | ((reset_count >> 13) & 0x07)); @@ -440,7 +440,7 @@ void get_tlm_fox() { h[4] = (short int) ((uptime >> 13) & 0xff); h[5] = (short int) ((h[5] & 0xf0) | ((uptime >> 21) & 0x0f)); h[5] = (short int) ((h[5] & 0x0f) | (frm_type << 4)); - Serial.println("h[5]"); +// Serial.println("h[5]"); if (mode == BPSK) h[6] = 99; posXi = (int)(current[mapping[PLUS_X]] + 0.5) + 2048; @@ -462,9 +462,9 @@ void get_tlm_fox() { // if (payload == ON) STEMBoardFailure = 0; // read payload sensor if available - Serial.println("Before encoding"); +// Serial.println("Before encoding"); encodeA(b, 0 + head_offset, batt_a_v); - Serial.println("After encoding"); +// Serial.println("After encoding"); encodeB(b, 1 + head_offset, batt_b_v); encodeA(b, 3 + head_offset, batt_c_v); encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel @@ -472,7 +472,7 @@ void get_tlm_fox() { encodeB(b, 7 + head_offset, (int)(sensor[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel encodeA(b, 9 + head_offset, battCurr); encodeB(b, 10 + head_offset, (int)(sensor[TEMP] * 10 + 0.5)); // Temp - Serial.println("A"); +// Serial.println("A"); if (mode == FSK) { encodeA(b, 12 + head_offset, posXv); encodeB(b, 13 + head_offset, negXv); @@ -486,7 +486,7 @@ void get_tlm_fox() { encodeB(b, 25 + head_offset, negYi); encodeA(b, 27 + head_offset, posZi); encodeB(b, 28 + head_offset, negZi); - Serial.println("B"); +// Serial.println("B"); } else // BPSK { encodeA(b, 12 + head_offset, posXv); @@ -598,7 +598,7 @@ void get_tlm_fox() { encodeB(b_min, 49 + head_offset, 2048); } } - Serial.println("C"); +// Serial.println("C"); encodeA(b, 30 + head_offset, PSUVoltage); encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure @@ -613,17 +613,17 @@ void get_tlm_fox() { encodeB(b, 46 + head_offset, PSUCurrent); encodeA(b, 48 + head_offset, (int)(sensor[XS1] * 10 + 0.5) + 2048); encodeB(b, 49 + head_offset, (int)(sensor[XS2] * 10 + 0.5) + 2048); - Serial.println("D"); +// Serial.println("D"); int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; encodeA(b, 51 + head_offset, status); encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2); - Serial.println("E"); +// Serial.println("E"); if (txAntennaDeployed == 0) { txAntennaDeployed = 1; - Serial.println("TX Antenna Deployed!"); +// Serial.println("TX Antenna Deployed!"); } - Serial.println("F"); +// Serial.println("F"); if (mode == BPSK) { // wod field experiments unsigned long val = 0xffff; encodeA(b, 64 + head_offset, 0xff & val); @@ -632,7 +632,7 @@ void get_tlm_fox() { encodeA(b, 62 + head_offset, 0x01); encodeB(b, 74 + head_offset, 0xfff); } - Serial.println("Finished encoding"); +// Serial.println("Finished encoding"); short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; int ctr1 = 0; @@ -754,7 +754,7 @@ void get_tlm_fox() { /// #ifdef DEBUG_LOGGING // printf("\n\nValue of ctr after header: %d Buffer Len: %d\n\n", ctr, buffSize); /// #endif - Serial.println(10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); +// Serial.println(10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); for (i = 1; i <= (10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // 572 // for (i = 1; i <= ((headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // Not 10 * anymore 572 { @@ -787,8 +787,8 @@ void get_tlm_fox() { } // Serial.println("CC"); } - Serial.println(" "); - Serial.println("Returning"); +// Serial.println(" "); +// Serial.println("Returning"); } void write_wave(int i, short int *buffer) @@ -799,8 +799,8 @@ void write_wave(int i, short int *buffer) // buffer[ctr++] = (short int)(0.1 * phase * (ctr - flip_ctr) / smaller); // else buffer[ctr++] = (short int)(0.25 * amplitude * phase); - Serial.print(buffer[ctr - 1]); - Serial.print(" "); +// Serial.print(buffer[ctr - 1]); +// Serial.print(" "); } else { @@ -2047,6 +2047,8 @@ void pwm_interrupt_handler() { // pwm_rnd_bit *= (-1.0); pwm_rnd_bit = (buffer[wav_position] > 0) ? 1 : 0; + Serial.print(pwm_rnd_bit); + Serial.print(" "); if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { pwm_value = 128 + pwm_amplitude; @@ -2054,7 +2056,7 @@ void pwm_interrupt_handler() { } else { pwm_value = 128 - pwm_amplitude; - Serial.print(" "); + Serial.print("-"); } } pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); From af3e990429950ccf4ba41d39d13f31056726862b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 13:58:29 -0400 Subject: [PATCH 026/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index e1aad880..92338ceb 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -162,9 +162,6 @@ void setup() { } -// start pwm -start_pwm(); - // configure ina219s start_ina219(); @@ -173,6 +170,11 @@ start_ina219(); // program Transceiver board configure_radio(); + +// start pwm +start_pwm(); + + } void loop() { @@ -383,7 +385,7 @@ void get_tlm_fox() { Serial.println(" "); if (mode == FSK) { - Serial.println("Starting"); +// Serial.println("Starting"); if (loop_count % 32 == 0) { // was 8 /// was loop now loop_count Serial.println("Sending MIN frame"); frm_type = 0x03; @@ -1638,7 +1640,7 @@ void start_payload() { Serial1.begin(115200); // Pi UART faster speed - Serial.println("Starting!"); + Serial.println("Starting payload!"); blink_setup(); @@ -1986,6 +1988,8 @@ void start_ina219() { void start_pwm() { // based on code https://github.com/rgrosset/pico-pwm-audio // + Serial.println"Starting pwm!"); + pwm_value = 128 - pwm_amplitude; set_sys_clock_khz(125000, true); @@ -2052,15 +2056,16 @@ void pwm_interrupt_handler() { if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { pwm_value = 128 + pwm_amplitude; - Serial.print("."); + Serial.print("-"); } else { pwm_value = 128 - pwm_amplitude; - Serial.print("-"); + Serial.print("_"); } } pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); - if (wav_position++ > 950) + if (wav_position++ > 300) { wav_position = 0; - + Serial.println("Reset wav_position"); + } } From 5bd7b2352f186e7a9252f72c6abf7d520ce612ff Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 14:00:09 -0400 Subject: [PATCH 027/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 92338ceb..08c1fa54 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -1988,7 +1988,7 @@ void start_ina219() { void start_pwm() { // based on code https://github.com/rgrosset/pico-pwm-audio // - Serial.println"Starting pwm!"); + Serial.println("Starting pwm!"); pwm_value = 128 - pwm_amplitude; From f9fbcbf0406bb4db9514057d10216078ac231c05 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 14:03:23 -0400 Subject: [PATCH 028/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 08c1fa54..2861c517 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2063,7 +2063,9 @@ void pwm_interrupt_handler() { Serial.print("_"); } } - pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); + pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); + Serial.printl("wav_position: "); + Serial.println(wav_position); if (wav_position++ > 300) { wav_position = 0; Serial.println("Reset wav_position"); From 96bdd63a727d346cf3515fb5b351f3a71badacc5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 14:04:37 -0400 Subject: [PATCH 029/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 2861c517..65765420 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2064,7 +2064,7 @@ void pwm_interrupt_handler() { } } pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); - Serial.printl("wav_position: "); + Serial.println("wav_position: "); Serial.println(wav_position); if (wav_position++ > 300) { wav_position = 0; From 8925fd634b33e6a6ba91be06c99b38793a39b1e1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 14:08:33 -0400 Subject: [PATCH 030/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 65765420..fc3f622f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2062,12 +2062,13 @@ void pwm_interrupt_handler() { pwm_value = 128 - pwm_amplitude; Serial.print("_"); } + pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); +// Serial.println("wav_position: "); +// Serial.println(wav_position); + if (wav_position++ > 300) { + wav_position = 0; +// Serial.println("Reset wav_position"); + } } - pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); - Serial.println("wav_position: "); - Serial.println(wav_position); - if (wav_position++ > 300) { - wav_position = 0; - Serial.println("Reset wav_position"); - } + } From 39bd0ddda952dfbf36bf4bbf71df4737ea2b1a7b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 14:11:44 -0400 Subject: [PATCH 031/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fc3f622f..e8468fbc 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2051,16 +2051,16 @@ void pwm_interrupt_handler() { // pwm_rnd_bit *= (-1.0); pwm_rnd_bit = (buffer[wav_position] > 0) ? 1 : 0; - Serial.print(pwm_rnd_bit); - Serial.print(" "); +// Serial.print(pwm_rnd_bit); +// Serial.print(" "); if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { pwm_value = 128 + pwm_amplitude; - Serial.print("-"); +// Serial.print("-"); } else { pwm_value = 128 - pwm_amplitude; - Serial.print("_"); +// Serial.print("_"); } pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); // Serial.println("wav_position: "); From 5fadd62933c4143c0af7b183799fee827758a97c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 14:19:35 -0400 Subject: [PATCH 032/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index e8468fbc..224ca317 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -173,7 +173,9 @@ start_ina219(); // start pwm start_pwm(); - + + digitalWrite(MAIN_LED_BLUE, HIGH); + digitalWrite(PTT_PIN, LOW); } @@ -191,8 +193,8 @@ void loop() { else if (mode == AFSK) send_packet(); - delay(2000); - test_radio(); +// delay(2000); +// test_radio(); digitalWrite(LED_BUILTIN, LOW); @@ -790,7 +792,8 @@ void get_tlm_fox() { // Serial.println("CC"); } // Serial.println(" "); -// Serial.println("Returning"); + Serial.print("get_fox_tlm eturning with counter: "); + Serial.println(ctr); } void write_wave(int i, short int *buffer) From 0faadaadc912a243721d7010d6cff3622f75a567 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 23:34:59 -0400 Subject: [PATCH 033/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 215b91f7..3e6f1e8a 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -129,7 +129,9 @@ void eeprom_word_write(int addr, int val); void read_payload(); void start_ina219(); void pwm_interrupt_handler(); -void start_pwm() ; +void start_pwm(); +void transmit_on(); +void transmit_off(); extern int Encode_8b10b[][256]; @@ -142,8 +144,8 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -#define BUFFER_SIZE (2^15) -short int buffer[50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK +#define BUFFER_SIZE (970 * 2) +short int buffer[BUFFER_SIZE]; // 50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); From 4cdc43c671a0936f44f76fd6f10735da3c68f767 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 23:41:20 -0400 Subject: [PATCH 034/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 3e6f1e8a..eaa71ffc 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -132,7 +132,8 @@ void pwm_interrupt_handler(); void start_pwm(); void transmit_on(); void transmit_off(); - +void config_telem(); + extern int Encode_8b10b[][256]; //int socket_open = 0; From a053d5b4d4edea8789de8ad5af00a68bd69eccc8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 23:42:48 -0400 Subject: [PATCH 035/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 164 +++++++++++++++++++++----------------- 1 file changed, 90 insertions(+), 74 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 224ca317..965d0181 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -75,6 +75,84 @@ void setup() { mode = FSK; // AFSK; + config_telem(); + +// configure ina219s + start_ina219(); + +// configure STEM Payload sensors + start_payload(); + +// program Transceiver board + configure_radio(); + +// start pwm + start_pwm(); + + transmit_on(); + +} + +void loop() { + + loop_count++; + + // query INA219 sensors and Payload sensors + read_ina219(); + read_payload(); + + // encode as digits (APRS or CW mode) or binary (DUV FSK) + if ((mode == BPSK) || (mode == FSK)) + get_tlm_fox(); + else if (mode == AFSK) + send_packet(); + +// delay(2000); +// test_radio(); + + digitalWrite(LED_BUILTIN, LOW); + +// delay(3000); + sleep(3.0); + + digitalWrite(LED_BUILTIN, HIGH); + + // send telemetry + + // delay some time + +} + +void send_packet() { + +// encode telemetry + get_tlm_ao7(); + +// digitalWrite(LED_BUILTIN, LOW); + + Serial.println("Sending APRS packet!"); + transmit_on() + send_packet(_FIXPOS_STATUS); + transmit_off() + +// delay(1000); + + +// digitalWrite(LED_BUILTIN, HIGH); +} + +void transmit_on() { + digitalWrite(MAIN_LED_BLUE, HIGH); + digitalWrite(PTT_PIN, LOW); +} + +void transmit_off() { + digitalWrite(PTT_PIN, HIGH); + digitalWrite(MAIN_LED_BLUE, LOW); +} + +void config_telem() { + frameCnt = 1; Serial.println("v1 Present with UHF BPF\n"); @@ -159,74 +237,8 @@ void setup() { char sym_tab_default = 'a'; char icon[] = "Ha"; set_lat_lon_icon(lat_default, lon_default, icon); - } - -// configure ina219s -start_ina219(); - -// configure STEM Payload sensors - start_payload(); - -// program Transceiver board - configure_radio(); - -// start pwm -start_pwm(); - - digitalWrite(MAIN_LED_BLUE, HIGH); - digitalWrite(PTT_PIN, LOW); - -} - -void loop() { - - loop_count++; - - // query INA219 sensors and Payload sensors - read_ina219(); - read_payload(); - - // encode as digits (APRS or CW mode) or binary (DUV FSK) - if ((mode == BPSK) || (mode == FSK)) - get_tlm_fox(); - else if (mode == AFSK) - send_packet(); - -// delay(2000); -// test_radio(); - - digitalWrite(LED_BUILTIN, LOW); - -// delay(3000); - sleep(3.0); - - digitalWrite(LED_BUILTIN, HIGH); - - // send telemetry - - // delay some time - -} - -void send_packet() { - -// encode telemetry - get_tlm_ao7(); - -// digitalWrite(LED_BUILTIN, LOW); - - Serial.println("Sending APRS packet!"); - digitalWrite(MAIN_LED_BLUE, HIGH); - digitalWrite(PTT_PIN, LOW); - send_packet(_FIXPOS_STATUS); - digitalWrite(PTT_PIN, HIGH); - digitalWrite(MAIN_LED_BLUE, LOW); - -// delay(1000); - - -// digitalWrite(LED_BUILTIN, HIGH); + firstTime = ON; } void get_tlm_ao7() { @@ -356,8 +368,10 @@ void get_tlm_fox() { // fflush(stdout); sampleTime = (unsigned int) millis(); - } else + } else { Serial.println("first time - no sleep\n"); + firstTime = OFF; + } // if (mode == FSK) { // just moved @@ -806,6 +820,8 @@ void write_wave(int i, short int *buffer) buffer[ctr++] = (short int)(0.25 * amplitude * phase); // Serial.print(buffer[ctr - 1]); // Serial.print(" "); + if (ctr > BUFFER_SIZE) + ctr = ctr - BUFFER_SIZE; } else { @@ -2065,12 +2081,12 @@ void pwm_interrupt_handler() { pwm_value = 128 - pwm_amplitude; // Serial.print("_"); } - pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); -// Serial.println("wav_position: "); -// Serial.println(wav_position); - if (wav_position++ > 300) { - wav_position = 0; -// Serial.println("Reset wav_position"); + pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); +// Serial.println("wav_position: "); +// Serial.println(wav_position); + if (wav_position++ > BUFFER_SIZE) { // 300) { + wav_position = wav_position - BUFFER_SIZE; +// Serial.println("Reset wav_position"); } } From fa5227dd06f429d4bf62f7675a6fc7502a5d9b80 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 23:44:00 -0400 Subject: [PATCH 036/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 965d0181..19f83d6e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -131,9 +131,9 @@ void send_packet() { // digitalWrite(LED_BUILTIN, LOW); Serial.println("Sending APRS packet!"); - transmit_on() + transmit_on(); send_packet(_FIXPOS_STATUS); - transmit_off() + transmit_off(); // delay(1000); From da37f75a16f3aeb5cbb0b32ed6e3d264609c436b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 23:55:04 -0400 Subject: [PATCH 037/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 60 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 19f83d6e..6d734a6f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -73,6 +73,7 @@ void setup() { Serial.println("\n\nCubeSatSim Pico v0.1 starting...\n\n"); + sim_mode = FALSE; mode = FSK; // AFSK; config_telem(); @@ -97,8 +98,12 @@ void loop() { loop_count++; + if (sim_mode == TRUE) + generate_simualted_telem(); + else // query INA219 sensors and Payload sensors - read_ina219(); + read_ina219(); + read_payload(); // encode as digits (APRS or CW mode) or binary (DUV FSK) @@ -310,6 +315,59 @@ void get_tlm_ao7() { // } } +void generate_simulated_telem() { + + sim_mode = TRUE; + + Serial.println("Simulated telemetry mode!\n"); + + srand((unsigned int)time(0)); + + axis[0] = rnd_float(-0.2, 0.2); + if (axis[0] == 0) + axis[0] = rnd_float(-0.2, 0.2); + axis[1] = rnd_float(-0.2, 0.2); + axis[2] = (rnd_float(-0.2, 0.2) > 0) ? 1.0 : -1.0; + + angle[0] = (float) atan(axis[1] / axis[2]); + angle[1] = (float) atan(axis[2] / axis[0]); + angle[2] = (float) atan(axis[1] / axis[0]); + + volts_max[0] = rnd_float(4.5, 5.5) * (float) sin(angle[1]); + volts_max[1] = rnd_float(4.5, 5.5) * (float) cos(angle[0]); + volts_max[2] = rnd_float(4.5, 5.5) * (float) cos(angle[1] - angle[0]); + + float amps_avg = rnd_float(150, 300); + + amps_max[0] = (amps_avg + rnd_float(-25.0, 25.0)) * (float) sin(angle[1]); + amps_max[1] = (amps_avg + rnd_float(-25.0, 25.0)) * (float) cos(angle[0]); + amps_max[2] = (amps_avg + rnd_float(-25.0, 25.0)) * (float) cos(angle[1] - angle[0]); + + batt = rnd_float(3.8, 4.3); + speed = rnd_float(1.0, 2.5); + eclipse = (rnd_float(-1, +4) > 0) ? 1.0 : 0.0; + period = rnd_float(150, 300); + tempS = rnd_float(20, 55); + temp_max = rnd_float(50, 70); + temp_min = rnd_float(10, 20); + + #ifdef DEBUG_LOGGING + for (int i = 0; i < 3; i++) + printf("axis: %f angle: %f v: %f i: %f \n", axis[i], angle[i], volts_max[i], amps_max[i]); + printf("batt: %f speed: %f eclipse_time: %f eclipse: %f period: %f temp: %f max: %f min: %f\n", batt, speed, eclipse_time, eclipse, period, tempS, temp_max, temp_min); + #endif + + time_start = (long int) millis(); + + eclipse_time = (long int)(millis() / 1000.0); + if (eclipse == 0.0) + eclipse_time -= period / 2; // if starting in eclipse, shorten interval +// } + + tx_freq_hz -= tx_channel * 50000; + +} + void get_tlm_fox() { Serial.println("get_tlm_fox"); From b7e71cd13708fa483f2ccb658234568aae43576e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 23:55:24 -0400 Subject: [PATCH 038/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index eaa71ffc..b8c0380a 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -133,6 +133,7 @@ void start_pwm(); void transmit_on(); void transmit_off(); void config_telem(); +void generate_simulated_telem(); extern int Encode_8b10b[][256]; From 3f84eece376d7ece44571bfa01cabf20c028ab7c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 00:02:50 -0400 Subject: [PATCH 039/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 91 +++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 9 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6d734a6f..8bf16c18 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -73,13 +73,18 @@ void setup() { Serial.println("\n\nCubeSatSim Pico v0.1 starting...\n\n"); - sim_mode = FALSE; - mode = FSK; // AFSK; + sim_mode = FALSE; + if (sim_mode) + configure_simulated_telem(); + else + // configure ina219s + start_ina219(); + + mode = FSK; // AFSK; config_telem(); -// configure ina219s - start_ina219(); + // configure STEM Payload sensors start_payload(); @@ -317,6 +322,74 @@ void get_tlm_ao7() { void generate_simulated_telem() { + double time = ((long int)millis() - time_start) / 1000.0; + + if ((time - eclipse_time) > period) { + eclipse = (eclipse == 1) ? 0 : 1; + eclipse_time = time; + Serial.println"\n\nSwitching eclipse mode! \n\n"); + } + + double Xi = eclipse * amps_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-2, 2); + double Yi = eclipse * amps_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-2, 2); + double Zi = eclipse * amps_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-2, 2); + + double Xv = eclipse * volts_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-0.2, 0.2); + double Yv = eclipse * volts_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-0.2, 0.2); + double Zv = 2.0 * eclipse * volts_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-0.2, 0.2); + + // printf("Yi: %f Zi: %f %f %f Zv: %f \n", Yi, Zi, amps_max[2], angle[2], Zv); + + current[map[PLUS_X]] = (Xi >= 0) ? Xi : 0; + current[map[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0f) * Xi); + current[map[PLUS_Y]] = (Yi >= 0) ? Yi : 0; + current[map[MINUS_Y]] = (Yi >= 0) ? 0 : ((-1.0f) * Yi); + current[map[PLUS_Z]] = (Zi >= 0) ? Zi : 0; + current[map[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0f) * Zi); + + voltage[map[PLUS_X]] = (Xv >= 1) ? Xv : rnd_float(0.9, 1.1); + voltage[map[MINUS_X]] = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.9, 1.1); + voltage[map[PLUS_Y]] = (Yv >= 1) ? Yv : rnd_float(0.9, 1.1); + voltage[map[MINUS_Y]] = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.9, 1.1); + voltage[map[PLUS_Z]] = (Zv >= 1) ? Zv : rnd_float(0.9, 1.1); + voltage[map[MINUS_Z]] = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.9, 1.1); + + // printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]); + + tempS += (eclipse > 0) ? ((temp_max - tempS) / 50.0f) : ((temp_min - tempS) / 50.0f); + tempS += +rnd_float(-1.0, 1.0); + // IHUcpuTemp = (int)((tempS + rnd_float(-1.0, 1.0)) * 10 + 0.5); + other[IHU_TEMP] = tempS; + + voltage[map[BUS]] = rnd_float(5.0, 5.005); + current[map[BUS]] = rnd_float(158, 171); + + // float charging = current[map[PLUS_X]] + current[map[MINUS_X]] + current[map[PLUS_Y]] + current[map[MINUS_Y]] + current[map[PLUS_Z]] + current[map[MINUS_Z]]; + float charging = eclipse * (fabs(amps_max[0] * 0.707) + fabs(amps_max[1] * 0.707) + rnd_float(-4.0, 4.0)); + + current[map[BAT]] = ((current[map[BUS]] * voltage[map[BUS]]) / batt) - charging; + + // printf("charging: %f bat curr: %f bus curr: %f bat volt: %f bus volt: %f \n",charging, current[map[BAT]], current[map[BUS]], batt, voltage[map[BUS]]); + + batt -= (batt > 3.5) ? current[map[BAT]] / 30000 : current[map[BAT]] / 3000; + if (batt < 3.0) { + batt = 3.0; + SafeMode = 1; + printf("Safe Mode!\n"); + } else + SafeMode= 0; + + if (batt > 4.5) + batt = 4.5; + + voltage[map[BAT]] = batt + rnd_float(-0.01, 0.01); + + // end of simulated telemetry +} + +void config_simulated_telemetry() +{ + sim_mode = TRUE; Serial.println("Simulated telemetry mode!\n"); @@ -351,11 +424,11 @@ void generate_simulated_telem() { temp_max = rnd_float(50, 70); temp_min = rnd_float(10, 20); - #ifdef DEBUG_LOGGING - for (int i = 0; i < 3; i++) - printf("axis: %f angle: %f v: %f i: %f \n", axis[i], angle[i], volts_max[i], amps_max[i]); - printf("batt: %f speed: %f eclipse_time: %f eclipse: %f period: %f temp: %f max: %f min: %f\n", batt, speed, eclipse_time, eclipse, period, tempS, temp_max, temp_min); - #endif +// #ifdef DEBUG_LOGGING +// for (int i = 0; i < 3; i++) +// printf("axis: %f angle: %f v: %f i: %f \n", axis[i], angle[i], volts_max[i], amps_max[i]); +// printf("batt: %f speed: %f eclipse_time: %f eclipse: %f period: %f temp: %f max: %f min: %f\n", batt, speed, eclipse_time, eclipse, period, tempS, temp_max, temp_min); +// #endif time_start = (long int) millis(); From c4032acf69d8b116dd7130bae700819ad71b03c6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 00:03:22 -0400 Subject: [PATCH 040/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index b8c0380a..4a12fff6 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -133,8 +133,9 @@ void start_pwm(); void transmit_on(); void transmit_off(); void config_telem(); -void generate_simulated_telem(); - +void config_simulated_telem(); +void generate_simualted_telem(); + extern int Encode_8b10b[][256]; //int socket_open = 0; From 13950307f2e71d11448184cfb4b1252a37305c98 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 00:04:16 -0400 Subject: [PATCH 041/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 4a12fff6..553ecb01 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -114,7 +114,7 @@ void update_rs(unsigned char parity[32], unsigned char c); void write_little_endian(unsigned int word, int num_bytes, FILE *wav_file); static int init_rf(); void test_radio(); -void configure_radio(); +void config_radio(); void send_packet(); void read_ina219(); void read_sensors(); From 72bf556de5dff61422bfc6aa24fbc84992d8e41a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 00:04:21 -0400 Subject: [PATCH 042/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8bf16c18..dc712d69 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -75,7 +75,7 @@ void setup() { sim_mode = FALSE; if (sim_mode) - configure_simulated_telem(); + config_simulated_telem(); else // configure ina219s start_ina219(); @@ -90,7 +90,7 @@ void setup() { start_payload(); // program Transceiver board - configure_radio(); + config_radio(); // start pwm start_pwm(); @@ -1688,7 +1688,7 @@ void write_little_endian(unsigned int word, int num_bytes, FILE *wav_file) } } -void configure_radio() +void config_radio() { pinMode(LED_BUILTIN, OUTPUT); From ea1976ffc934345f98a9d07676f6d63554a1f1fb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 00:05:12 -0400 Subject: [PATCH 043/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index dc712d69..78fd77ee 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -327,7 +327,7 @@ void generate_simulated_telem() { if ((time - eclipse_time) > period) { eclipse = (eclipse == 1) ? 0 : 1; eclipse_time = time; - Serial.println"\n\nSwitching eclipse mode! \n\n"); + Serial.println("\n\nSwitching eclipse mode! \n\n"); } double Xi = eclipse * amps_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-2, 2); From 6c56f63b8ad2bc12922ed0632a87df1e2f0784f8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 00:07:16 -0400 Subject: [PATCH 044/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 78fd77ee..57e72b1e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -340,19 +340,19 @@ void generate_simulated_telem() { // printf("Yi: %f Zi: %f %f %f Zv: %f \n", Yi, Zi, amps_max[2], angle[2], Zv); - current[map[PLUS_X]] = (Xi >= 0) ? Xi : 0; - current[map[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0f) * Xi); - current[map[PLUS_Y]] = (Yi >= 0) ? Yi : 0; - current[map[MINUS_Y]] = (Yi >= 0) ? 0 : ((-1.0f) * Yi); - current[map[PLUS_Z]] = (Zi >= 0) ? Zi : 0; - current[map[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0f) * Zi); - - voltage[map[PLUS_X]] = (Xv >= 1) ? Xv : rnd_float(0.9, 1.1); - voltage[map[MINUS_X]] = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.9, 1.1); - voltage[map[PLUS_Y]] = (Yv >= 1) ? Yv : rnd_float(0.9, 1.1); - voltage[map[MINUS_Y]] = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.9, 1.1); - voltage[map[PLUS_Z]] = (Zv >= 1) ? Zv : rnd_float(0.9, 1.1); - voltage[map[MINUS_Z]] = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.9, 1.1); + current[mapping[PLUS_X]] = (Xi >= 0) ? Xi : 0; + current[mapping[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0f) * Xi); + current[mapping[PLUS_Y]] = (Yi >= 0) ? Yi : 0; + current[mapping[MINUS_Y]] = (Yi >= 0) ? 0 : ((-1.0f) * Yi); + current[mapping[PLUS_Z]] = (Zi >= 0) ? Zi : 0; + current[mapping[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0f) * Zi); + + voltage[mapping[PLUS_X]] = (Xv >= 1) ? Xv : rnd_float(0.9, 1.1); + voltage[mapping[MINUS_X]] = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.9, 1.1); + voltage[mapping[PLUS_Y]] = (Yv >= 1) ? Yv : rnd_float(0.9, 1.1); + voltage[mapping[MINUS_Y]] = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.9, 1.1); + voltage[mapping[PLUS_Z]] = (Zv >= 1) ? Zv : rnd_float(0.9, 1.1); + voltage[mapping[MINUS_Z]] = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.9, 1.1); // printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]); @@ -361,17 +361,17 @@ void generate_simulated_telem() { // IHUcpuTemp = (int)((tempS + rnd_float(-1.0, 1.0)) * 10 + 0.5); other[IHU_TEMP] = tempS; - voltage[map[BUS]] = rnd_float(5.0, 5.005); - current[map[BUS]] = rnd_float(158, 171); + voltage[mapping[BUS]] = rnd_float(5.0, 5.005); + current[mapping[BUS]] = rnd_float(158, 171); // float charging = current[map[PLUS_X]] + current[map[MINUS_X]] + current[map[PLUS_Y]] + current[map[MINUS_Y]] + current[map[PLUS_Z]] + current[map[MINUS_Z]]; float charging = eclipse * (fabs(amps_max[0] * 0.707) + fabs(amps_max[1] * 0.707) + rnd_float(-4.0, 4.0)); - current[map[BAT]] = ((current[map[BUS]] * voltage[map[BUS]]) / batt) - charging; + current[mapping[BAT]] = ((current[mapping[BUS]] * voltage[mapping[BUS]]) / batt) - charging; // printf("charging: %f bat curr: %f bus curr: %f bat volt: %f bus volt: %f \n",charging, current[map[BAT]], current[map[BUS]], batt, voltage[map[BUS]]); - batt -= (batt > 3.5) ? current[map[BAT]] / 30000 : current[map[BAT]] / 3000; + batt -= (batt > 3.5) ? current[mapping[BAT]] / 30000 : current[mapping[BAT]] / 3000; if (batt < 3.0) { batt = 3.0; SafeMode = 1; @@ -382,7 +382,7 @@ void generate_simulated_telem() { if (batt > 4.5) batt = 4.5; - voltage[map[BAT]] = batt + rnd_float(-0.01, 0.01); + voltage[mapping[BAT]] = batt + rnd_float(-0.01, 0.01); // end of simulated telemetry } From 81f18b4954acb7730dadd0502425d8cf9b73034a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 00:08:30 -0400 Subject: [PATCH 045/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 57e72b1e..ea7a816f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -104,7 +104,7 @@ void loop() { loop_count++; if (sim_mode == TRUE) - generate_simualted_telem(); + generate_simulated_telem(); else // query INA219 sensors and Payload sensors read_ina219(); From dfebd9cdf07f99d79036cedd3542695f609e811e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 08:31:30 -0400 Subject: [PATCH 046/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ea7a816f..a4920d8f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -100,7 +100,8 @@ void setup() { } void loop() { - + + int startSleep = millis(); loop_count++; if (sim_mode == TRUE) @@ -130,6 +131,8 @@ void loop() { // send telemetry // delay some time + Serial.print("Loop time: "); + Serial.println(millis() - startSleep); } @@ -2217,7 +2220,7 @@ void pwm_interrupt_handler() { // Serial.println(wav_position); if (wav_position++ > BUFFER_SIZE) { // 300) { wav_position = wav_position - BUFFER_SIZE; -// Serial.println("Reset wav_position"); + Serial.println("Reset wav_position"); } } From 753c3e85d78935aa63960a05d52b645dfb1e8417 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 09:59:47 -0400 Subject: [PATCH 047/147] Create cubesatsim.ino --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a4920d8f..ec6bf669 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -73,7 +73,7 @@ void setup() { Serial.println("\n\nCubeSatSim Pico v0.1 starting...\n\n"); - sim_mode = FALSE; + sim_mode = TRUE; // FALSE; if (sim_mode) config_simulated_telem(); else @@ -497,8 +497,8 @@ void get_tlm_fox() { sleep(0.1); // 25); // 0.5); // 25); // sleep((unsigned int)sleepTime); /**/ - Serial.print("Sleep period: "); - Serial.println(millis() - startSleep); +// Serial.print("Sleep period: "); +// Serial.println(millis() - startSleep); // fflush(stdout); sampleTime = (unsigned int) millis(); From c9b20108210392d68cd7f4511083e1ca96b85ecb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:07:47 -0400 Subject: [PATCH 048/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ec6bf669..a4920d8f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -73,7 +73,7 @@ void setup() { Serial.println("\n\nCubeSatSim Pico v0.1 starting...\n\n"); - sim_mode = TRUE; // FALSE; + sim_mode = FALSE; if (sim_mode) config_simulated_telem(); else @@ -497,8 +497,8 @@ void get_tlm_fox() { sleep(0.1); // 25); // 0.5); // 25); // sleep((unsigned int)sleepTime); /**/ -// Serial.print("Sleep period: "); -// Serial.println(millis() - startSleep); + Serial.print("Sleep period: "); + Serial.println(millis() - startSleep); // fflush(stdout); sampleTime = (unsigned int) millis(); From d3963bef3811f23bb84f53740844f1d45bdaa527 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:11:36 -0400 Subject: [PATCH 049/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a4920d8f..5466ad38 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -73,7 +73,7 @@ void setup() { Serial.println("\n\nCubeSatSim Pico v0.1 starting...\n\n"); - sim_mode = FALSE; + sim_mode = TRUE; // FALSE; if (sim_mode) config_simulated_telem(); else From b6d15f269baf2275e592451b2202f47c60f305f7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:14:49 -0400 Subject: [PATCH 050/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5466ad38..fafa8f76 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -390,7 +390,7 @@ void generate_simulated_telem() { // end of simulated telemetry } -void config_simulated_telemetry() +void config_simulated_telem() { sim_mode = TRUE; @@ -497,8 +497,8 @@ void get_tlm_fox() { sleep(0.1); // 25); // 0.5); // 25); // sleep((unsigned int)sleepTime); /**/ - Serial.print("Sleep period: "); - Serial.println(millis() - startSleep); +// Serial.print("Sleep period: "); +// Serial.println(millis() - startSleep); // fflush(stdout); sampleTime = (unsigned int) millis(); From aec31adcdad19ccab9fc60c2a87a42fb122fada5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:17:42 -0400 Subject: [PATCH 051/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fafa8f76..318c6aec 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -73,7 +73,7 @@ void setup() { Serial.println("\n\nCubeSatSim Pico v0.1 starting...\n\n"); - sim_mode = TRUE; // FALSE; + sim_mode = FALSE; if (sim_mode) config_simulated_telem(); else From ed9f5e98fc1b8daeb414e4330bc4272f5a96240e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:19:14 -0400 Subject: [PATCH 052/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 553ecb01..2f58df4f 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -147,7 +147,7 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -#define BUFFER_SIZE (970 * 2) +#define BUFFER_SIZE (970) // * 2) short int buffer[BUFFER_SIZE]; // 50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); From 0489fc587f01ac7780c45b0fd407e26bf3867635 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:21:14 -0400 Subject: [PATCH 053/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 318c6aec..cd8d0893 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2209,11 +2209,11 @@ void pwm_interrupt_handler() { if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { pwm_value = 128 + pwm_amplitude; -// Serial.print("-"); + Serial.print("-"); } else { pwm_value = 128 - pwm_amplitude; -// Serial.print("_"); + Serial.print("_"); } pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); // Serial.println("wav_position: "); From 718a358ba943b9be3aa46dc9af0dde921a53f46b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:29:30 -0400 Subject: [PATCH 054/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index cd8d0893..25d4b4df 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2170,7 +2170,7 @@ void start_pwm() { * 4.0f for 22 KHz * 2.0f for 44 KHz etc */ - pwm_config_set_clkdiv(&config, 16.0); // 8.0f); + pwm_config_set_clkdiv(&config, 8.0); //16.0); // 8.0f); was 16 for some reason pwm_config_set_wrap(&config, 250); pwm_init(audio_pin_slice, &config, true); From acdcef1f3436b1dfab9e0ba0d40dd0877f2fbbcd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:35:06 -0400 Subject: [PATCH 055/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 25d4b4df..7845a7e5 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2171,7 +2171,7 @@ void start_pwm() { * 2.0f for 44 KHz etc */ pwm_config_set_clkdiv(&config, 8.0); //16.0); // 8.0f); was 16 for some reason - pwm_config_set_wrap(&config, 250); + pwm_config_set_wrap(&config, 178); // 250); pwm_init(audio_pin_slice, &config, true); pwm_set_gpio_level(AUDIO_OUT_PIN, 0); From d4c620358e2c9c6f4b3c27171f0a9e2d12a8728d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:47:44 -0400 Subject: [PATCH 056/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7845a7e5..5cc0ef3b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -49,7 +49,7 @@ void setup() { Serial.begin(9600); - delay(12000); +// delay(12000); #ifndef ARDUINO_ARCH_RP2040 Serial.println("This code is written for the Raspberry Pi Pico hardware."); From e597bfbe11df81767bdce473298881637c167f1a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 10:51:11 -0400 Subject: [PATCH 057/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5cc0ef3b..f8fdb99b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2170,7 +2170,7 @@ void start_pwm() { * 4.0f for 22 KHz * 2.0f for 44 KHz etc */ - pwm_config_set_clkdiv(&config, 8.0); //16.0); // 8.0f); was 16 for some reason + pwm_config_set_clkdiv(&config, 4.0); // 8.0); //16.0); // 8.0f); was 16 for some reason pwm_config_set_wrap(&config, 178); // 250); pwm_init(audio_pin_slice, &config, true); From d0806870f1838fcedb2a6a8b5151e7f2e90e9317 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 11:00:57 -0400 Subject: [PATCH 058/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f8fdb99b..2e2de5ed 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -87,7 +87,7 @@ void setup() { // configure STEM Payload sensors - start_payload(); +// start_payload(); // program Transceiver board config_radio(); @@ -108,9 +108,10 @@ void loop() { generate_simulated_telem(); else // query INA219 sensors and Payload sensors - read_ina219(); +// read_ina219(); + ; - read_payload(); +// read_payload(); // encode as digits (APRS or CW mode) or binary (DUV FSK) if ((mode == BPSK) || (mode == FSK)) @@ -1708,7 +1709,7 @@ void config_radio() mySerial.begin(9600); for (int i = 0; i < 5; i++) { - delay(500); + sleep(0.5); // delay(500); // Serial1.println("AT+DMOSETGROUP=0,434.9100,434.9100,1,2,1,1\r"); mySerial.println("AT+DMOSETGROUP=0,434.9000,434.9000,1,2,1,1\r"); } @@ -1721,7 +1722,7 @@ void test_radio() digitalWrite(MAIN_LED_BLUE, HIGH); digitalWrite(PTT_PIN, LOW); - delay(3000); + sleep(3.0); // delay(3000); digitalWrite(PTT_PIN, HIGH); digitalWrite(MAIN_LED_BLUE, LOW); } @@ -1798,14 +1799,14 @@ Serial1.begin(115200); // Pi UART faster speed blink_setup(); blink(500); - delay(250); + sleep(0.25); // delay(250); blink(500); - delay(250); + sleep(0.25); // delay(250); led_set(greenLED, HIGH); - delay(250); + sleep(0.25); // delay(250); led_set(greenLED, LOW); led_set(blueLED, HIGH); - delay(250); + sleep(0.25); // delay(250); led_set(blueLED, LOW); if (bme.begin(0x76)) { @@ -2078,7 +2079,7 @@ void blink(int length) digitalWrite(25, LOW); // set the built-in LED ON #endif - delay(length); // wait for a lenth of time + sleep(length/1000.0); // delay(length); // wait for a lenth of time #if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) digitalWrite(PC13, HIGH); // turn the LED off by making the voltage LOW From ca55863402d938b3a67460b124f6343b53ab30e7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 11:01:33 -0400 Subject: [PATCH 059/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 2e2de5ed..5a1b6e6b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2171,7 +2171,7 @@ void start_pwm() { * 4.0f for 22 KHz * 2.0f for 44 KHz etc */ - pwm_config_set_clkdiv(&config, 4.0); // 8.0); //16.0); // 8.0f); was 16 for some reason + pwm_config_set_clkdiv(&config, 8.0); //16.0); // 8.0f); was 16 for some reason pwm_config_set_wrap(&config, 178); // 250); pwm_init(audio_pin_slice, &config, true); From 876046830416fc57df952da692f1ee47d608a389 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 11:05:58 -0400 Subject: [PATCH 060/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5a1b6e6b..6f97fed9 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -446,7 +446,7 @@ void config_simulated_telem() } void get_tlm_fox() { - Serial.println("get_tlm_fox"); +// Serial.println("get_tlm_fox"); int i; long int sync = syncWord; @@ -521,8 +521,8 @@ void get_tlm_fox() { if (current[count1] > current_max[count1]) current_max[count1] = current[count1]; // printf("Vmin %4.2f Vmax %4.2f Imin %4.2f Imax %4.2f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); - Serial.print(voltage_min[count1]); - Serial.print(" "); +// Serial.print(voltage_min[count1]); +// Serial.print(" "); } Serial.println(" "); for (int count1 = 0; count1 < 3; count1++) { @@ -530,10 +530,10 @@ void get_tlm_fox() { other_min[count1] = other[count1]; if (other[count1] > other_max[count1]) other_max[count1] = other[count1]; - Serial.print(other_min[count1]); - Serial.print(" "); +// Serial.print(other_min[count1]); +// Serial.print(" "); } - Serial.println(" "); +// Serial.println(" "); if (mode == FSK) { // Serial.println("Starting"); @@ -941,8 +941,8 @@ void get_tlm_fox() { // Serial.println("CC"); } // Serial.println(" "); - Serial.print("get_fox_tlm eturning with counter: "); - Serial.println(ctr); +// Serial.print("get_fox_tlm eturning with counter: "); +// Serial.println(ctr); } void write_wave(int i, short int *buffer) @@ -2221,7 +2221,7 @@ void pwm_interrupt_handler() { // Serial.println(wav_position); if (wav_position++ > BUFFER_SIZE) { // 300) { wav_position = wav_position - BUFFER_SIZE; - Serial.println("Reset wav_position"); + Serial.print("R"); } } From fc72148b6b6d25a5d7b4777fcd2d2952f010aa47 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 11:24:31 -0400 Subject: [PATCH 061/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 2f58df4f..ae57e502 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -243,7 +243,7 @@ float rest; unsigned int wav_position = 0; int pwm_counter = 0; int pwm_counter_max = 420; -int pwm_amplitude = 50; //100; +int pwm_amplitude = 100; //50 //100; int pwm_value; int pwm_rnd_bit = 1; /* From 30b8cc15de6d7231f940b17699652388da551c18 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 11:29:05 -0400 Subject: [PATCH 062/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index ae57e502..b16de22c 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -243,7 +243,7 @@ float rest; unsigned int wav_position = 0; int pwm_counter = 0; int pwm_counter_max = 420; -int pwm_amplitude = 100; //50 //100; +int pwm_amplitude = 10; //50 //100; int pwm_value; int pwm_rnd_bit = 1; /* From cd2449e970debf01b15d4bc10a1a11e733aa67e3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 11:30:57 -0400 Subject: [PATCH 063/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index b16de22c..53212950 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -243,7 +243,7 @@ float rest; unsigned int wav_position = 0; int pwm_counter = 0; int pwm_counter_max = 420; -int pwm_amplitude = 10; //50 //100; +int pwm_amplitude = 5; //50 //100; int pwm_value; int pwm_rnd_bit = 1; /* From 9147e0955baf9e41eda3d3024bf591506cbd8486 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 11:36:16 -0400 Subject: [PATCH 064/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 53212950..89098599 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -243,7 +243,7 @@ float rest; unsigned int wav_position = 0; int pwm_counter = 0; int pwm_counter_max = 420; -int pwm_amplitude = 5; //50 //100; +int pwm_amplitude = 50; //50 //100; int pwm_value; int pwm_rnd_bit = 1; /* From d3fd37703a6e160f3cd3cc5489784868c6c36e34 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 11:39:13 -0400 Subject: [PATCH 065/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6f97fed9..63b8329a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2210,18 +2210,18 @@ void pwm_interrupt_handler() { if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { pwm_value = 128 + pwm_amplitude; - Serial.print("-"); +// Serial.print("-"); } else { pwm_value = 128 - pwm_amplitude; - Serial.print("_"); +// Serial.print("_"); } pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); // Serial.println("wav_position: "); // Serial.println(wav_position); if (wav_position++ > BUFFER_SIZE) { // 300) { wav_position = wav_position - BUFFER_SIZE; - Serial.print("R"); +// Serial.print("R"); } } From 59998eeffe02a5233a62957663cf61397e38a3fa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:22:11 -0400 Subject: [PATCH 066/147] added setup1 and loop1 --- cubesatsim/cubesatsim.ino | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 63b8329a..83eabdd0 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -93,7 +93,8 @@ void setup() { config_radio(); // start pwm - start_pwm(); +// start_pwm(); + transmit_on(); @@ -2226,3 +2227,37 @@ void pwm_interrupt_handler() { } } + +void setup1() { + + pinMode(AUDIO_OUT_PIN, OUTPUT); +} + +void loop1() { + + if (pwm_counter > pwm_counter_max) { + pwm_counter -= pwm_counter_max; + + pwm_rnd_bit = (buffer[wav_position] > 0) ? HIGH: LOW; + digitalWrite(AUDIO_OUT_PIN, pwm_rnd_bit); +/* + pwm_rnd_bit = (buffer[wav_position] > 0) ? 1 : 0; + + if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { + pwm_value = 128 + pwm_amplitude; +// Serial.print("-"); + } + else { + pwm_value = 128 - pwm_amplitude; +// Serial.print("_"); + } + pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); +// Serial.println("wav_position: "); +// Serial.println(wav_position); +*/ + if (wav_position++ > BUFFER_SIZE) { // 300) { + wav_position = wav_position - BUFFER_SIZE; +// Serial.print("R"); + } + delay(5); +} From 74b5af0e6afb24e3529b7aaf06e119ad5a9bc619 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:23:31 -0400 Subject: [PATCH 067/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 83eabdd0..4b596f15 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2235,8 +2235,8 @@ void setup1() { void loop1() { - if (pwm_counter > pwm_counter_max) { - pwm_counter -= pwm_counter_max; +// if (pwm_counter > pwm_counter_max) { +// pwm_counter -= pwm_counter_max; pwm_rnd_bit = (buffer[wav_position] > 0) ? HIGH: LOW; digitalWrite(AUDIO_OUT_PIN, pwm_rnd_bit); From 71b9642c64e898cdfafacef2bc43941937493172 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:24:54 -0400 Subject: [PATCH 068/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4b596f15..7f5d6fbc 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2230,7 +2230,8 @@ void pwm_interrupt_handler() { void setup1() { - pinMode(AUDIO_OUT_PIN, OUTPUT); + pinMode(AUDIO_OUT_PIN, OUTPUT); + Serial.println("Setup1"); } void loop1() { From c33acdcfcb5eba30986d133ee2cf40ff5b2a987d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:29:17 -0400 Subject: [PATCH 069/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7f5d6fbc..20feedcc 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -50,6 +50,7 @@ void setup() { Serial.begin(9600); // delay(12000); + sleep(10.0); #ifndef ARDUINO_ARCH_RP2040 Serial.println("This code is written for the Raspberry Pi Pico hardware."); @@ -2229,6 +2230,8 @@ void pwm_interrupt_handler() { } void setup1() { + Serial.begin(9600); + sleep(10.0); pinMode(AUDIO_OUT_PIN, OUTPUT); Serial.println("Setup1"); From d92a1070a3e95ca2a14c744f45428af326574c2d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:32:58 -0400 Subject: [PATCH 070/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 20feedcc..4937ae06 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2243,19 +2243,20 @@ void loop1() { // pwm_counter -= pwm_counter_max; pwm_rnd_bit = (buffer[wav_position] > 0) ? HIGH: LOW; + digitalWrite(AUDIO_OUT_PIN, pwm_rnd_bit); -/* - pwm_rnd_bit = (buffer[wav_position] > 0) ? 1 : 0; - if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { - pwm_value = 128 + pwm_amplitude; -// Serial.print("-"); +// pwm_rnd_bit = (buffer[wav_position] > 0) ? 1 : 0; + + if (pwm_rnd_bit == 1) { +// pwm_value = 128 + pwm_amplitude; + Serial.print("-"); } else { - pwm_value = 128 - pwm_amplitude; -// Serial.print("_"); +// pwm_value = 128 - pwm_amplitude; + Serial.print("_"); } - pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); +// pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); // Serial.println("wav_position: "); // Serial.println(wav_position); */ From a6a70aa398642189b62fc12f3ea436b3b5049a68 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:34:33 -0400 Subject: [PATCH 071/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4937ae06..0905c512 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2259,7 +2259,7 @@ void loop1() { // pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); // Serial.println("wav_position: "); // Serial.println(wav_position); -*/ + if (wav_position++ > BUFFER_SIZE) { // 300) { wav_position = wav_position - BUFFER_SIZE; // Serial.print("R"); From e534ba8310f0d0b483a98a2bd7db55d69181dc2c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:39:44 -0400 Subject: [PATCH 072/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 0905c512..0aba6297 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2235,6 +2235,16 @@ void setup1() { pinMode(AUDIO_OUT_PIN, OUTPUT); Serial.println("Setup1"); + + digitalWrite(AUDIO_OUT_PIN, HIGH); + delay(500); + digitalWrite(AUDIO_OUT_PIN, LOW); + delay(500); + digitalWrite(AUDIO_OUT_PIN, HIGH); + delay(500); + digitalWrite(AUDIO_OUT_PIN, LOW); + delay(500); + } void loop1() { @@ -2264,5 +2274,5 @@ void loop1() { wav_position = wav_position - BUFFER_SIZE; // Serial.print("R"); } - delay(5); + delay(50); } From 65c36dfbcd2256bb19ee807de5c871483c93aaf7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:41:46 -0400 Subject: [PATCH 073/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 0aba6297..150b4742 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -134,7 +134,7 @@ void loop() { // send telemetry // delay some time - Serial.print("Loop time: "); + Serial.print("\nLoop time: "); Serial.println(millis() - startSleep); } From 914bd1a1b32e9188b9623d9e8bef945d787c5732 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:52:58 -0400 Subject: [PATCH 074/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 150b4742..fb042a3c 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -95,7 +95,19 @@ void setup() { // start pwm // start_pwm(); + + pinMode(AUDIO_OUT_PIN, OUTPUT); + Serial.println("Setup0"); + digitalWrite(AUDIO_OUT_PIN, HIGH); + delay(500); + digitalWrite(AUDIO_OUT_PIN, LOW); + delay(500); + digitalWrite(AUDIO_OUT_PIN, HIGH); + delay(500); + digitalWrite(AUDIO_OUT_PIN, LOW); + delay(500); + transmit_on(); From 84e5b56c1990bbab9f95d3dae919ba876b9eab11 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:55:29 -0400 Subject: [PATCH 075/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fb042a3c..a6cfd526 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -46,6 +46,16 @@ Adafruit_INA219 ina219_2_0x45(0x45); char payload_str[100]; void setup() { + +// set all Pico GPIO pins to input + for (int i = 6; i < 29; i++) { + pinMode(i, INPUT); + } + pinMode(LED_BUILTIN, OUTPUT); // Set LED pin to output + pinMode(MAIN_LED_GREEN, OUTPUT); // Set LED pin to output + pinMode(MAIN_LED_BLUE, OUTPUT); // Set LED pin to output + digitalWrite(MAIN_LED_GREEN, HIGH); + digitalWrite(MAIN_LED_BLUE, LOW); Serial.begin(9600); @@ -56,15 +66,7 @@ void setup() { Serial.println("This code is written for the Raspberry Pi Pico hardware."); #endif -// set all Pico GPIO pins to input - for (int i = 6; i < 29; i++) { - pinMode(i, INPUT); - } - pinMode(LED_BUILTIN, OUTPUT); // Set LED pin to output - pinMode(MAIN_LED_GREEN, OUTPUT); // Set LED pin to output - pinMode(MAIN_LED_BLUE, OUTPUT); // Set LED pin to output - digitalWrite(MAIN_LED_GREEN, HIGH); - digitalWrite(MAIN_LED_BLUE, LOW); + // detect Pi Zero using 3.3V @@ -96,6 +98,7 @@ void setup() { // start pwm // start_pwm(); +/* pinMode(AUDIO_OUT_PIN, OUTPUT); Serial.println("Setup0"); @@ -107,7 +110,7 @@ void setup() { delay(500); digitalWrite(AUDIO_OUT_PIN, LOW); delay(500); - +*/ transmit_on(); @@ -2286,5 +2289,5 @@ void loop1() { wav_position = wav_position - BUFFER_SIZE; // Serial.print("R"); } - delay(50); + delay(5); } From 5333a55a4e548ebd31bbab432d3fc0b27cb7dbb5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:59:33 -0400 Subject: [PATCH 076/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a6cfd526..3ffbdd2f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2272,15 +2272,14 @@ void loop1() { digitalWrite(AUDIO_OUT_PIN, pwm_rnd_bit); // pwm_rnd_bit = (buffer[wav_position] > 0) ? 1 : 0; - +/* if (pwm_rnd_bit == 1) { -// pwm_value = 128 + pwm_amplitude; Serial.print("-"); } else { -// pwm_value = 128 - pwm_amplitude; Serial.print("_"); } +*/ // pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); // Serial.println("wav_position: "); // Serial.println(wav_position); From 81d278aff04f89bcd0e689e13474fafe7d916d32 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 14:07:58 -0400 Subject: [PATCH 077/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 3ffbdd2f..8510dd52 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2288,5 +2288,5 @@ void loop1() { wav_position = wav_position - BUFFER_SIZE; // Serial.print("R"); } - delay(5); + delay(1); //5); } From c01c243811086c5e0ea3c85eeb00b28c7287d197 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 14:11:16 -0400 Subject: [PATCH 078/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8510dd52..962606eb 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2247,18 +2247,21 @@ void pwm_interrupt_handler() { void setup1() { Serial.begin(9600); sleep(10.0); + + if (mode == FSK) { + + pinMode(AUDIO_OUT_PIN, OUTPUT); + Serial.println("Setup1"); - pinMode(AUDIO_OUT_PIN, OUTPUT); - Serial.println("Setup1"); - - digitalWrite(AUDIO_OUT_PIN, HIGH); - delay(500); - digitalWrite(AUDIO_OUT_PIN, LOW); - delay(500); - digitalWrite(AUDIO_OUT_PIN, HIGH); - delay(500); - digitalWrite(AUDIO_OUT_PIN, LOW); - delay(500); +// digitalWrite(AUDIO_OUT_PIN, HIGH); +// delay(500); +// digitalWrite(AUDIO_OUT_PIN, LOW); +// delay(500); +// digitalWrite(AUDIO_OUT_PIN, HIGH); +// delay(500); +// digitalWrite(AUDIO_OUT_PIN, LOW); +// delay(500); + } } @@ -2267,6 +2270,7 @@ void loop1() { // if (pwm_counter > pwm_counter_max) { // pwm_counter -= pwm_counter_max; + if (mode == FSK) { pwm_rnd_bit = (buffer[wav_position] > 0) ? HIGH: LOW; digitalWrite(AUDIO_OUT_PIN, pwm_rnd_bit); @@ -2288,5 +2292,6 @@ void loop1() { wav_position = wav_position - BUFFER_SIZE; // Serial.print("R"); } - delay(1); //5); + } + delay(5); //1); } From 69360d824d93289381b09b6632ba77cf2ce0a6e8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 14:14:26 -0400 Subject: [PATCH 079/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 962606eb..ea009f63 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -83,7 +83,7 @@ void setup() { // configure ina219s start_ina219(); - mode = FSK; // AFSK; + mode = AFSK; FSK; // AFSK; config_telem(); @@ -2248,7 +2248,8 @@ void setup1() { Serial.begin(9600); sleep(10.0); - if (mode == FSK) { + if (mode == FSK) + { pinMode(AUDIO_OUT_PIN, OUTPUT); Serial.println("Setup1"); @@ -2270,7 +2271,8 @@ void loop1() { // if (pwm_counter > pwm_counter_max) { // pwm_counter -= pwm_counter_max; - if (mode == FSK) { + if (mode == FSK) + { pwm_rnd_bit = (buffer[wav_position] > 0) ? HIGH: LOW; digitalWrite(AUDIO_OUT_PIN, pwm_rnd_bit); From e19522736573425561086b1dad013528187af686 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 14:20:28 -0400 Subject: [PATCH 080/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ea009f63..b7e2608c 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -55,7 +55,9 @@ void setup() { pinMode(MAIN_LED_GREEN, OUTPUT); // Set LED pin to output pinMode(MAIN_LED_BLUE, OUTPUT); // Set LED pin to output digitalWrite(MAIN_LED_GREEN, HIGH); - digitalWrite(MAIN_LED_BLUE, LOW); + digitalWrite(MAIN_LED_BLUE, LOW); + + mode = FSK; // AFSK; Serial.begin(9600); @@ -81,9 +83,7 @@ void setup() { config_simulated_telem(); else // configure ina219s - start_ina219(); - - mode = AFSK; FSK; // AFSK; + start_ina219(); config_telem(); From 36b86c8c81b2f30bd199767f49da79968f28abc4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 15:00:22 -0400 Subject: [PATCH 081/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index b7e2608c..16efaeae 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2295,5 +2295,5 @@ void loop1() { // Serial.print("R"); } } - delay(5); //1); + delay(2); //5 1); } From c12afd7cfb50bf13ac161e21d015c63baf9585ed Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 15:03:29 -0400 Subject: [PATCH 082/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 16efaeae..cacff13f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2252,7 +2252,7 @@ void setup1() { { pinMode(AUDIO_OUT_PIN, OUTPUT); - Serial.println("Setup1"); + Serial.println("Setup1 for FSK mode"); // digitalWrite(AUDIO_OUT_PIN, HIGH); // delay(500); @@ -2295,5 +2295,5 @@ void loop1() { // Serial.print("R"); } } - delay(2); //5 1); + delay(5); //2 1); } From 751d050446c497716e45d2ac477b676fbbbc3d63 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 07:54:12 -0400 Subject: [PATCH 083/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index cacff13f..1d86b40b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -522,7 +522,7 @@ void get_tlm_fox() { sampleTime = (unsigned int) millis(); } else { Serial.println("first time - no sleep\n"); - firstTime = OFF; +// firstTime = OFF; } // if (mode == FSK) From 7956a84ea19a9bf17ae504b0f245f9ebecbbdac8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 07:56:26 -0400 Subject: [PATCH 084/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 1d86b40b..2c65e8e4 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -972,8 +972,10 @@ void write_wave(int i, short int *buffer) buffer[ctr++] = (short int)(0.25 * amplitude * phase); // Serial.print(buffer[ctr - 1]); // Serial.print(" "); - if (ctr > BUFFER_SIZE) + if (ctr > BUFFER_SIZE) { ctr = ctr - BUFFER_SIZE; + Serial.println("r"); + } } else { @@ -2238,7 +2240,7 @@ void pwm_interrupt_handler() { // Serial.println(wav_position); if (wav_position++ > BUFFER_SIZE) { // 300) { wav_position = wav_position - BUFFER_SIZE; -// Serial.print("R"); + Serial.print("R"); } } From dd46116e20c587f01f487d6b7693be5701107ce6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 07:58:44 -0400 Subject: [PATCH 085/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 2c65e8e4..9302c959 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2240,7 +2240,7 @@ void pwm_interrupt_handler() { // Serial.println(wav_position); if (wav_position++ > BUFFER_SIZE) { // 300) { wav_position = wav_position - BUFFER_SIZE; - Serial.print("R"); +// Serial.print("R"); } } @@ -2294,7 +2294,7 @@ void loop1() { if (wav_position++ > BUFFER_SIZE) { // 300) { wav_position = wav_position - BUFFER_SIZE; -// Serial.print("R"); + Serial.print("R"); } } delay(5); //2 1); From 87059e60de4f85845fd0835a18e81ed80c0f8a01 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 08:01:17 -0400 Subject: [PATCH 086/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9302c959..5a1d3540 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -974,7 +974,9 @@ void write_wave(int i, short int *buffer) // Serial.print(" "); if (ctr > BUFFER_SIZE) { ctr = ctr - BUFFER_SIZE; - Serial.println("r"); + Serial.print("r"); + Serial.print(" "); + Serial.println(millis()); } } else @@ -2295,7 +2297,8 @@ void loop1() { if (wav_position++ > BUFFER_SIZE) { // 300) { wav_position = wav_position - BUFFER_SIZE; Serial.print("R"); - } + Serial.print(" "); + Serial.println(millis()); } } delay(5); //2 1); } From 4fa1d860a01518e332af9919e603f08fd31aad30 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 08:02:42 -0400 Subject: [PATCH 087/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5a1d3540..6f8fab65 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -113,7 +113,10 @@ void setup() { */ transmit_on(); - + + Serial.print("s"); + Serial.print(" "); + Serial.println(millis()); } void loop() { @@ -2267,7 +2270,10 @@ void setup1() { // digitalWrite(AUDIO_OUT_PIN, LOW); // delay(500); } - + + Serial.print("S"); + Serial.print(" "); + Serial.println(millis()); } void loop1() { From 4a40a95e785f6647a2b95cc3c39ff14ed892197d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 08:06:49 -0400 Subject: [PATCH 088/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 89098599..66218317 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -246,6 +246,8 @@ int pwm_counter_max = 420; int pwm_amplitude = 50; //50 //100; int pwm_value; int pwm_rnd_bit = 1; + +int ready = FALSE; /* * TelemEncoding.h * From 0bcbfa20698179cdcd3a6de92cc567395e450ba7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 08:08:28 -0400 Subject: [PATCH 089/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6f8fab65..ef7b178a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -113,10 +113,12 @@ void setup() { */ transmit_on(); - - Serial.print("s"); - Serial.print(" "); - Serial.println(millis()); + + ready = TRUE; // flag for core1 to start looping + + Serial.print("s"); + Serial.print(" "); + Serial.println(millis()); } void loop() { @@ -2253,7 +2255,7 @@ void pwm_interrupt_handler() { void setup1() { Serial.begin(9600); - sleep(10.0); +// sleep(10.0); if (mode == FSK) { @@ -2271,9 +2273,12 @@ void setup1() { // delay(500); } - Serial.print("S"); - Serial.print(" "); - Serial.println(millis()); + while(!ready) // wait for core0 to start + sleep(0.1); + + Serial.print("S"); + Serial.print(" "); + Serial.println(millis()); } void loop1() { From a48fe4681509668908f15268c6406b61dc3c5a51 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 08:10:08 -0400 Subject: [PATCH 090/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ef7b178a..ca4087e4 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2255,7 +2255,7 @@ void pwm_interrupt_handler() { void setup1() { Serial.begin(9600); -// sleep(10.0); + sleep(10.0); if (mode == FSK) { From 457eccb4a652e6611aec56bcad1e283c469bedec Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 08:11:57 -0400 Subject: [PATCH 091/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 66218317..83b6924b 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -147,7 +147,7 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -#define BUFFER_SIZE (970) // * 2) +#define BUFFER_SIZE (970 * 2) // * 2) short int buffer[BUFFER_SIZE]; // 50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); From 0064b8abb2a23d2a88f14e2b8c1a0b0e5189b3fd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 08:58:56 -0400 Subject: [PATCH 092/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 83b6924b..52e050eb 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -147,7 +147,7 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -#define BUFFER_SIZE (970 * 2) // * 2) +#define BUFFER_SIZE 1940 // (970 * 2) // * 2) short int buffer[BUFFER_SIZE]; // 50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); From f6588a38f3f99f86b2bd543ddadbe2eff3c4112a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:02:36 -0400 Subject: [PATCH 093/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 52e050eb..8f4ec3cb 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -147,7 +147,7 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -#define BUFFER_SIZE 1940 // (970 * 2) // * 2) +#define BUFFER_SIZE 970 // 1940 // (970 * 2) // * 2) short int buffer[BUFFER_SIZE]; // 50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); From 985b7ce0fdbb5c55f79b18ba66d50ef13f31dee7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:03:56 -0400 Subject: [PATCH 094/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ca4087e4..820149c7 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -147,7 +147,7 @@ void loop() { digitalWrite(LED_BUILTIN, LOW); // delay(3000); - sleep(3.0); + sleep(2.9); // 3.0); digitalWrite(LED_BUILTIN, HIGH); @@ -527,7 +527,7 @@ void get_tlm_fox() { sampleTime = (unsigned int) millis(); } else { Serial.println("first time - no sleep\n"); -// firstTime = OFF; + firstTime = OFF; } // if (mode == FSK) From dff107b8092965366b6708485a93a5e169493daa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:06:28 -0400 Subject: [PATCH 095/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 820149c7..07b3d465 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -147,7 +147,7 @@ void loop() { digitalWrite(LED_BUILTIN, LOW); // delay(3000); - sleep(2.9); // 3.0); + sleep(2.845); // 3.0); digitalWrite(LED_BUILTIN, HIGH); From 2ebdcd7dc1ff3d3c534770aec490131ee3d2f990 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:15:23 -0400 Subject: [PATCH 096/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 07b3d465..bce15716 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -246,7 +246,7 @@ void config_telem() { //samplePeriod = 2200; // reduce dut to python and sensor querying delays sleepTime = 2.2f; - frameTime = ((float)((float)bufLen / (samples * frameCnt * bitRate))) * 1000; // frame time in ms + frameTime = ((float)((float)bufLen / (samples * frameCnt * bitRate))) * 1000; // frame time in ms // printf("\n BPSK Mode, bufLen: %d, %d bits per frame, %d bits per second, %d ms per frame %d ms sample period\n", // bufLen, bufLen / (samples * frameCnt), bitRate, frameTime, samplePeriod); @@ -513,11 +513,18 @@ void get_tlm_fox() { // delay for sample period /**/ // while ((millis() - sampleTime) < (unsigned int)samplePeriod) - int startSleep = millis(); + int startSleep = millis(); + if ((millis() - sampleTime) < ((unsigned int)sampleTime - 250)) // was 250 100 500 for FSK + sleep(2.0); // 0.5); // 25); // initial period + while ((millis() - sampleTime) < ((unsigned int)sampleTime - 250)) // was 250 100 + sleep(0.1); // 25); // 0.5); // 25); + +/* if ((millis() - sampleTime) < ((unsigned int)frameTime - 250)) // was 250 100 500 for FSK sleep(2.0); // 0.5); // 25); // initial period while ((millis() - sampleTime) < ((unsigned int)frameTime - 250)) // was 250 100 sleep(0.1); // 25); // 0.5); // 25); +*/ // sleep((unsigned int)sleepTime); /**/ // Serial.print("Sleep period: "); From 74b1d36d7a17c1e3fd69eafcc376d14485b347af Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:17:33 -0400 Subject: [PATCH 097/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index bce15716..3f52812f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -514,9 +514,9 @@ void get_tlm_fox() { /**/ // while ((millis() - sampleTime) < (unsigned int)samplePeriod) int startSleep = millis(); - if ((millis() - sampleTime) < ((unsigned int)sampleTime - 250)) // was 250 100 500 for FSK + if ((millis() - sampleTime) < ((unsigned int)samplePeriod - 250)) // was 250 100 500 for FSK sleep(2.0); // 0.5); // 25); // initial period - while ((millis() - sampleTime) < ((unsigned int)sampleTime - 250)) // was 250 100 + while ((millis() - sampleTime) < ((unsigned int)samplePeriod - 250)) // was 250 100 sleep(0.1); // 25); // 0.5); // 25); /* From 194e77a3d036c965b11957d3081a9658b60b8942 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:19:21 -0400 Subject: [PATCH 098/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 3f52812f..698fada0 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -514,8 +514,8 @@ void get_tlm_fox() { /**/ // while ((millis() - sampleTime) < (unsigned int)samplePeriod) int startSleep = millis(); - if ((millis() - sampleTime) < ((unsigned int)samplePeriod - 250)) // was 250 100 500 for FSK - sleep(2.0); // 0.5); // 25); // initial period +// if ((millis() - sampleTime) < ((unsigned int)samplePeriod - 750)) // was 250 100 500 for FSK +// sleep(2.0); // 0.5); // 25); // initial period while ((millis() - sampleTime) < ((unsigned int)samplePeriod - 250)) // was 250 100 sleep(0.1); // 25); // 0.5); // 25); From 066633e7c18d241280f7a24e09d472378e4e24a9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:21:24 -0400 Subject: [PATCH 099/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 698fada0..6ccb91ce 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -534,7 +534,7 @@ void get_tlm_fox() { sampleTime = (unsigned int) millis(); } else { Serial.println("first time - no sleep\n"); - firstTime = OFF; +// firstTime = OFF; } // if (mode == FSK) From f6d0dd855ea4cdc607ef20ca27fa05bd61e8ebba Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:29:29 -0400 Subject: [PATCH 100/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6ccb91ce..b7646370 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -143,14 +143,17 @@ void loop() { // delay(2000); // test_radio(); - - digitalWrite(LED_BUILTIN, LOW); - -// delay(3000); - sleep(2.845); // 3.0); - - digitalWrite(LED_BUILTIN, HIGH); - + + if (mode == FSK) { + digitalWrite(LED_BUILTIN, LOW); + digitalWrite(MAIN_LED_BLUE, LOW); + + // delay(3000); + sleep(0.5); // 2.845); // 3.0); + + digitalWrite(LED_BUILTIN, HIGH); + digitalWrite(MAIN_LED_BLUE, HIGH); + } // send telemetry // delay some time @@ -533,7 +536,7 @@ void get_tlm_fox() { sampleTime = (unsigned int) millis(); } else { - Serial.println("first time - no sleep\n"); + Serial.println("first time - no sleep"); // firstTime = OFF; } @@ -553,7 +556,7 @@ void get_tlm_fox() { // Serial.print(voltage_min[count1]); // Serial.print(" "); } - Serial.println(" "); +// Serial.println(" "); for (int count1 = 0; count1 < 3; count1++) { if (other[count1] < other_min[count1]) other_min[count1] = other[count1]; From f7d5c55649bfaadaa3bc43755a5e7ff6697e3ff0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:32:54 -0400 Subject: [PATCH 101/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index b7646370..10db0ac5 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -536,7 +536,8 @@ void get_tlm_fox() { sampleTime = (unsigned int) millis(); } else { - Serial.println("first time - no sleep"); + Serial.println("first time - short sleep"); + sleep(3.0); // firstTime = OFF; } From d700eaeea7d548ce43bf6978582947f3e3b32dae Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:37:10 -0400 Subject: [PATCH 102/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 10db0ac5..fdd842b9 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -136,10 +136,14 @@ void loop() { // read_payload(); // encode as digits (APRS or CW mode) or binary (DUV FSK) - if ((mode == BPSK) || (mode == FSK)) - get_tlm_fox(); + if ((mode == BPSK) || (mode == FSK)) { + get_tlm_fox(); + while ((millis() - sampleTime) < ((unsigned int)samplePeriod - 250)) // was 250 100 + sleep(0.1); // 25); // 0.5); // 25); + sampleTime = (unsigned int) millis(); + } else if (mode == AFSK) - send_packet(); + send_packet(); // delay(2000); // test_radio(); @@ -537,7 +541,7 @@ void get_tlm_fox() { sampleTime = (unsigned int) millis(); } else { Serial.println("first time - short sleep"); - sleep(3.0); + // sleep(3.0); // firstTime = OFF; } From 87e9afbec3feedd3d64749d38d220ed0bf463a02 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:39:38 -0400 Subject: [PATCH 103/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fdd842b9..3a200111 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -138,7 +138,7 @@ void loop() { // encode as digits (APRS or CW mode) or binary (DUV FSK) if ((mode == BPSK) || (mode == FSK)) { get_tlm_fox(); - while ((millis() - sampleTime) < ((unsigned int)samplePeriod - 250)) // was 250 100 + while ((millis() - sampleTime) < ((unsigned int)samplePeriod)) // - 250)) // was 250 100 sleep(0.1); // 25); // 0.5); // 25); sampleTime = (unsigned int) millis(); } From 9675ffe73d43c9feedd888a02f1c56e6a8b9a1c7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:41:40 -0400 Subject: [PATCH 104/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 8f4ec3cb..52e050eb 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -147,7 +147,7 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -#define BUFFER_SIZE 970 // 1940 // (970 * 2) // * 2) +#define BUFFER_SIZE 1940 // (970 * 2) // * 2) short int buffer[BUFFER_SIZE]; // 50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); From a76fe27f26a8f5545b19abcbede43465149b9755 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:43:04 -0400 Subject: [PATCH 105/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 52e050eb..054c45db 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -147,7 +147,7 @@ int testCount = 0; long time_start; //char cmdbuffer[1000]; //FILE * file1;// -#define BUFFER_SIZE 1940 // (970 * 2) // * 2) +#define BUFFER_SIZE 970 // (970 * 2) // * 2) short int buffer[BUFFER_SIZE]; // 50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); From bd7837960e60219cc01575c9a3dc1fe073619ab7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:45:58 -0400 Subject: [PATCH 106/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 3a200111..f630d108 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -57,7 +57,7 @@ void setup() { digitalWrite(MAIN_LED_GREEN, HIGH); digitalWrite(MAIN_LED_BLUE, LOW); - mode = FSK; // AFSK; + mode = AFSK; // FSK; // AFSK; Serial.begin(9600); From cfb2600ce274d3327545afa0ba7c55f3fc4068bc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:49:22 -0400 Subject: [PATCH 107/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f630d108..bff2796a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -112,7 +112,6 @@ void setup() { delay(500); */ - transmit_on(); ready = TRUE; // flag for core1 to start looping @@ -1754,6 +1753,9 @@ void config_radio() // Serial1.println("AT+DMOSETGROUP=0,434.9100,434.9100,1,2,1,1\r"); mySerial.println("AT+DMOSETGROUP=0,434.9000,434.9000,1,2,1,1\r"); } + + if (mode == AFSK) + transmit_on(); } void test_radio() From 98fa3fcf7b93f65efb9a8c89a61a8e6764ee91f4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:51:25 -0400 Subject: [PATCH 108/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index bff2796a..dd529423 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -135,15 +135,17 @@ void loop() { // read_payload(); // encode as digits (APRS or CW mode) or binary (DUV FSK) - if ((mode == BPSK) || (mode == FSK)) { + if ((mode == BPSK) || (mode == FSK)) + { get_tlm_fox(); - while ((millis() - sampleTime) < ((unsigned int)samplePeriod)) // - 250)) // was 250 100 - sleep(0.1); // 25); // 0.5); // 25); - sampleTime = (unsigned int) millis(); } else if (mode == AFSK) send_packet(); + while ((millis() - sampleTime) < ((unsigned int)samplePeriod)) // - 250)) // was 250 100 + sleep(0.1); // 25); // 0.5); // 25); + sampleTime = (unsigned int) millis(); + // delay(2000); // test_radio(); From 52fa1ac016eaeff21d5986716fa99c95b1721272 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:53:33 -0400 Subject: [PATCH 109/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index dd529423..ed88e874 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -281,6 +281,8 @@ void config_telem() { char sym_tab_default = 'a'; char icon[] = "Ha"; set_lat_lon_icon(lat_default, lon_default, icon); + + samplePeriod = 5000; } firstTime = ON; } From 0ce7a8cd680b2ed13d98dc768e8fea672d329f76 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:58:01 -0400 Subject: [PATCH 110/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ed88e874..e317de5f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -90,34 +90,18 @@ void setup() { // configure STEM Payload sensors -// start_payload(); + start_payload(); // program Transceiver board - config_radio(); - -// start pwm -// start_pwm(); - -/* - pinMode(AUDIO_OUT_PIN, OUTPUT); - Serial.println("Setup0"); - - digitalWrite(AUDIO_OUT_PIN, HIGH); - delay(500); - digitalWrite(AUDIO_OUT_PIN, LOW); - delay(500); - digitalWrite(AUDIO_OUT_PIN, HIGH); - delay(500); - digitalWrite(AUDIO_OUT_PIN, LOW); - delay(500); -*/ + config_radio(); + sampleTime = (unsigned int) millis(); ready = TRUE; // flag for core1 to start looping Serial.print("s"); Serial.print(" "); - Serial.println(millis()); + Serial.println(millis()); } void loop() { @@ -129,10 +113,9 @@ void loop() { generate_simulated_telem(); else // query INA219 sensors and Payload sensors -// read_ina219(); - ; + read_ina219(); -// read_payload(); + read_payload(); // encode as digits (APRS or CW mode) or binary (DUV FSK) if ((mode == BPSK) || (mode == FSK)) @@ -142,9 +125,9 @@ void loop() { else if (mode == AFSK) send_packet(); - while ((millis() - sampleTime) < ((unsigned int)samplePeriod)) // - 250)) // was 250 100 - sleep(0.1); // 25); // 0.5); // 25); - sampleTime = (unsigned int) millis(); + while ((millis() - sampleTime) < ((unsigned int)samplePeriod)) // - 250)) // was 250 100 + sleep(0.1); // 25); // 0.5); // 25); + sampleTime = (unsigned int) millis(); // delay(2000); // test_radio(); @@ -1760,6 +1743,8 @@ void config_radio() if (mode == AFSK) transmit_on(); +// start pwm +// start_pwm(); } void test_radio() From 3fa0d28df29a4bf9b81b21d757348e1c440ddf14 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 09:59:22 -0400 Subject: [PATCH 111/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index e317de5f..9d5f0a01 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -57,7 +57,7 @@ void setup() { digitalWrite(MAIN_LED_GREEN, HIGH); digitalWrite(MAIN_LED_BLUE, LOW); - mode = AFSK; // FSK; // AFSK; + mode = FSK; // AFSK; Serial.begin(9600); From 691bb7b927505f044523f27ef5ed2479d4c96c8e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 10:01:53 -0400 Subject: [PATCH 112/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9d5f0a01..69bcbd57 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -502,34 +502,6 @@ void get_tlm_fox() { // for (int frames = 0; frames < FRAME_CNT; frames++) for (int frames = 0; frames < frameCnt; frames++) { // Serial.println("Frame loop"); - if (firstTime != ON) { - // delay for sample period -/**/ -// while ((millis() - sampleTime) < (unsigned int)samplePeriod) - int startSleep = millis(); -// if ((millis() - sampleTime) < ((unsigned int)samplePeriod - 750)) // was 250 100 500 for FSK -// sleep(2.0); // 0.5); // 25); // initial period - while ((millis() - sampleTime) < ((unsigned int)samplePeriod - 250)) // was 250 100 - sleep(0.1); // 25); // 0.5); // 25); - -/* - if ((millis() - sampleTime) < ((unsigned int)frameTime - 250)) // was 250 100 500 for FSK - sleep(2.0); // 0.5); // 25); // initial period - while ((millis() - sampleTime) < ((unsigned int)frameTime - 250)) // was 250 100 - sleep(0.1); // 25); // 0.5); // 25); -*/ -// sleep((unsigned int)sleepTime); -/**/ -// Serial.print("Sleep period: "); -// Serial.println(millis() - startSleep); -// fflush(stdout); - - sampleTime = (unsigned int) millis(); - } else { - Serial.println("first time - short sleep"); - // sleep(3.0); -// firstTime = OFF; - } // if (mode == FSK) { // just moved From c00c9962e0dae0ce4d37ea56d5fa86bde120336e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 10:04:10 -0400 Subject: [PATCH 113/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 69bcbd57..9295d707 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -1713,7 +1713,7 @@ void config_radio() mySerial.println("AT+DMOSETGROUP=0,434.9000,434.9000,1,2,1,1\r"); } - if (mode == AFSK) + if (mode == FSK) transmit_on(); // start pwm // start_pwm(); From 586cfde67744db49a3b5aa63fb2715edacb1bafa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 10:20:54 -0400 Subject: [PATCH 114/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 054c45db..0a8bd1d4 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -37,7 +37,7 @@ // Pico GPIO pin assignments #define LPF_PIN 8 // LPF is installed #define PI_3V3_PIN 9 // 3.3V supply used to detect Pi Zero -#define PB_PIN 10 // Main board PB pushbutton pin +#define MAIN_PB_PIN 10 // Main board PB pushbutton pin #define TXC_PIN 11 // Transceiver Board is present #define SWTX_PIN 14 // SR_FRS_05W Transmit Pico software serial port #define SQUELCH 15 // SR_FRS_05W Squelch out From b4e74be169ef6e07ca55ac7f61d1ca6d1074267f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 10:52:57 -0400 Subject: [PATCH 115/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9295d707..8a9d23a3 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -56,6 +56,8 @@ void setup() { pinMode(MAIN_LED_BLUE, OUTPUT); // Set LED pin to output digitalWrite(MAIN_LED_GREEN, HIGH); digitalWrite(MAIN_LED_BLUE, LOW); + + pinMode(MAIN_PB_PIN, INPUT_PULLUP); // Read Main Board push button mode = FSK; // AFSK; @@ -1009,13 +1011,7 @@ float toAprsFormat(float input) { return(output); } -void sleep(float time) { - unsigned long time_ms = (unsigned long)(time * 1000.0); - unsigned long startSleep = millis(); - while ((millis() - startSleep) < time_ms) - delay(100); -} /* * TelemEncoding.c @@ -2289,5 +2285,34 @@ void loop1() { Serial.print(" "); Serial.println(millis()); } } - delay(5); //2 1); + delay(5); //2 1); + +// check pushbutton + pb_value = digitalRead(MAIN_PB_PIN); + if (pb_value == PRESSED) { + if (pb_state == RELEASED) { + pb_press_start = millis(); + } else { // still held + if ((millis() - pb_press_start) > 1000) { + blink(); + } + + } else if (pb_state == HELD) { + // pushbutton is released + Serial.print("New mode is: "); + Serial.println(mode_count); + pb_state = RELEASED; + } } + +void sleep(float time) { + + unsigned long time_ms = (unsigned long)(time * 1000.0); + unsigned long startSleep = millis(); + while ((millis() - startSleep) < time_ms) { + + delay(100); + + } +} + From abcc984760962503eaf16d4e11325ab8d79a2ad4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 10:53:04 -0400 Subject: [PATCH 116/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 0a8bd1d4..90349dfe 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -248,6 +248,15 @@ int pwm_value; int pwm_rnd_bit = 1; int ready = FALSE; + +#define PRESSED 0 +#define HELD 0 +#define RELEASED 1 +int pb_state = RELEASED; +int mode_count = 0; +unsigned long pb_press_start; + + /* * TelemEncoding.h * From 9aeee9439856c1e8ba46b7c95e8d0bea5cf22baf Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 10:53:45 -0400 Subject: [PATCH 117/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8a9d23a3..ef848f7f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2294,7 +2294,7 @@ void loop1() { pb_press_start = millis(); } else { // still held if ((millis() - pb_press_start) > 1000) { - blink(); + blink(150); } } else if (pb_state == HELD) { From e97187e4e92fd4c514445191ddcded431860c462 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 10:54:56 -0400 Subject: [PATCH 118/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ef848f7f..6de0e3ac 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2288,7 +2288,7 @@ void loop1() { delay(5); //2 1); // check pushbutton - pb_value = digitalRead(MAIN_PB_PIN); + int pb_value = digitalRead(MAIN_PB_PIN); if (pb_value == PRESSED) { if (pb_state == RELEASED) { pb_press_start = millis(); From 5e7a5cbad70a40493738356e9b2683570f06afa0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 10:56:23 -0400 Subject: [PATCH 119/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6de0e3ac..886f9676 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2288,7 +2288,8 @@ void loop1() { delay(5); //2 1); // check pushbutton - int pb_value = digitalRead(MAIN_PB_PIN); + int pb_value; + pb_value = digitalRead(MAIN_PB_PIN); if (pb_value == PRESSED) { if (pb_state == RELEASED) { pb_press_start = millis(); From 472cab8f5a9ab4fdd333d3b8ba13d7baeccc0f35 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:04:14 -0400 Subject: [PATCH 120/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 152 ++++++++++++++++++++++++++++++++++---- 1 file changed, 137 insertions(+), 15 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 886f9676..920725b4 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2290,21 +2290,9 @@ void loop1() { // check pushbutton int pb_value; pb_value = digitalRead(MAIN_PB_PIN); - if (pb_value == PRESSED) { - if (pb_state == RELEASED) { - pb_press_start = millis(); - } else { // still held - if ((millis() - pb_press_start) > 1000) { - blink(150); - } - - } else if (pb_state == HELD) { - // pushbutton is released - Serial.print("New mode is: "); - Serial.println(mode_count); - pb_state = RELEASED; - } -} + if (pb_value == PRESSED) + process_pushbutton(); +} void sleep(float time) { @@ -2317,3 +2305,137 @@ void sleep(float time) { } } +void process_pushbutton() { + + int release = FALSE; + + sleep(1.0); + pb_value = digitalRead(MAIN_PB_PIN); + if (pb_value == RELEASED) { + Serial.println("PB: Reboot!"); + release = TRUE; + sleep(10.0); + } + digitalWrite(MAIN_PB_PIN, LOW); + sleep(0.1); + digitalWrite(MAIN_PB_PIN, HIGH); +/* + GPIO.output(powerPin, 0); # blink once + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(1.5) + if (GPIO.input(26) and (release == False)): + print("switch to AFSK") + f = open("/home/pi/CubeSatSim/.mode", "w") + f.write("a") + f.close() + os.system("sudo systemctl restart cubesatsim") + release = True; + if (release == False): + GPIO.output(powerPin, 0); # blink twice + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1); + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(1.5) + if (GPIO.input(26) and (release == False)): + print("switch to FSK") + f = open("/home/pi/CubeSatSim/.mode", "w") + f.write("f") + f.close() + os.system("sudo systemctl restart cubesatsim") + release = True; + if (release == False): + GPIO.output(powerPin, 0); # blink three times + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1); + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1) + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(1.5) + if (GPIO.input(26) and (release == False)): + print("switch to BPSK") + f = open("/home/pi/CubeSatSim/.mode", "w") + f.write("b") + f.close() + os.system("sudo systemctl restart cubesatsim") + release = True; + if (release == False): + GPIO.output(powerPin, 0); # blink four times + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1); + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1) + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1) + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(1.5) + if (GPIO.input(26) and (release == False)): + print("switch to SSTV") + f = open("/home/pi/CubeSatSim/.mode", "w") + f.write("s") + f.close() + os.system("sudo systemctl restart cubesatsim") + release = True; + if (release == False): + GPIO.output(powerPin, 0); # blink five times + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1); + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1) + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1) + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(0.1) + GPIO.output(powerPin, 0); + time.sleep(0.1); + GPIO.output(powerPin, 1); + time.sleep(1.5) + if (GPIO.input(26) and (release == False)): + print("switch to CW") + f = open("/home/pi/CubeSatSim/.mode", "w") + f.write("m") + f.close() + os.system("sudo systemctl restart cubesatsim") + release = True; + if (release == False): + print("sudo shutdown -h now") + GPIO.setwarnings(False) + GPIO.setup(powerPin, GPIO.OUT) + GPIO.output(powerPin, 0); # blink slowly to indicate shutdown + time.sleep(0.5); + GPIO.output(powerPin, 1); + time.sleep(0.5); + GPIO.output(powerPin, 0); + time.sleep(0.5); + GPIO.output(powerPin, 1); + time.sleep(0.5); + GPIO.output(powerPin, 0); + subprocess.call(['shutdown', '-h', 'now'], shell=False) + if (txPin != 0): + GPIO.setwarnings(False) + GPIO.output(txPin, 0) + +*/ +} From 33ee9dd87119d91715f870127cea30da760e00f7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:04:47 -0400 Subject: [PATCH 121/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 90349dfe..cd791f0c 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -135,6 +135,7 @@ void transmit_off(); void config_telem(); void config_simulated_telem(); void generate_simualted_telem(); +void process_pushbutton(); extern int Encode_8b10b[][256]; From fe67a8ded8cf39cf437fcb3f486eaaed61d006b7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:05:34 -0400 Subject: [PATCH 122/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 920725b4..861f1d9b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2310,7 +2310,7 @@ void process_pushbutton() { int release = FALSE; sleep(1.0); - pb_value = digitalRead(MAIN_PB_PIN); + int pb_value = digitalRead(MAIN_PB_PIN); if (pb_value == RELEASED) { Serial.println("PB: Reboot!"); release = TRUE; From aa7155847e3e5bbe379860d718ed6f8e61d09031 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:15:50 -0400 Subject: [PATCH 123/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index cd791f0c..63ff6657 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -136,6 +136,7 @@ void config_telem(); void config_simulated_telem(); void generate_simualted_telem(); void process_pushbutton(); +void blinkTimes(int blinks); extern int Encode_8b10b[][256]; From e907ecd72c3261f808a943d6a9f18d0c10404c44 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:21:53 -0400 Subject: [PATCH 124/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 82 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 861f1d9b..fdd81007 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2310,15 +2310,79 @@ void process_pushbutton() { int release = FALSE; sleep(1.0); + int pb_value = digitalRead(MAIN_PB_PIN); if (pb_value == RELEASED) { Serial.println("PB: Reboot!"); release = TRUE; - sleep(10.0); } - digitalWrite(MAIN_PB_PIN, LOW); - sleep(0.1); - digitalWrite(MAIN_PB_PIN, HIGH); + + blinkTimes(1); + sleep(1.5); + + pb_value = digitalRead(MAIN_PB_PIN); + if ((pb_value == RELEASED) && (release == FALSE)) { + Serial.println("PB: Switch to AFSK"); + release = TRUE; + + if (release == FALSE) { + blinkTimes(2); + sleep(1.5); + } + + pb_value = digitalRead(MAIN_PB_PIN); + if ((pb_value == RELEASED) && (release == FALSE)) { + Serial.println("PB: Switch to FSK"); + release = TRUE; + + if (release == FALSE) { + blinkTimes(3); + sleep(1.5); + } + + pb_value = digitalRead(MAIN_PB_PIN); + if ((pb_value == RELEASED) && (release == FALSE)) { + Serial.println("PB: Switch to BPSK"); + release = TRUE; + + if (release == FALSE) { + digitalWrite(MAIN_PB_PIN, LOW); + blinkTimes(4); + sleep(1.5); + } + + pb_value = digitalRead(MAIN_PB_PIN); + if ((pb_value == RELEASED) && (release == FALSE)) { + Serial.println("PB: Switch to SSTV"); + release = TRUE; + + if (release == FALSE) { + digitalWrite(MAIN_PB_PIN, LOW); + blinkTimes(5); + sleep(1.5); + } + + pb_value = digitalRead(MAIN_PB_PIN); + if ((pb_value == RELEASED) && (release == FALSE)) { + Serial.println("PB: Switch to CW"); + release = TRUE; + + if (release == FALSE) { + Serial.println("PB: Shutdown!"); + digitalWrite(MAIN_PB_PIN, LOW); + sleep(0.5); + digitalWrite(MAIN_PB_PIN, HIGH); + sleep(0.5); + digitalWrite(MAIN_PB_PIN, LOW); + sleep(0.5); + digitalWrite(MAIN_PB_PIN, HIGH); + sleep(0.5); + digitalWrite(MAIN_PB_PIN, LOW); + sleep(0.5); + digitalWrite(MAIN_PB_PIN, HIGH); + sleep(0.5); + + } /* GPIO.output(powerPin, 0); # blink once time.sleep(0.1); @@ -2439,3 +2503,13 @@ void process_pushbutton() { */ } + +void blinkTimes(int blinks) { + for (int i = 0; i < blinks; i++) { + digitalWrite(MAIN_PB_PIN, LOW); + sleep(0.1); + digitalWrite(MAIN_PB_PIN, HIGH); + sleep(0.1); + } +} +} From c20ea6526f26ec371488935aef4ef5a41b54e99f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:24:14 -0400 Subject: [PATCH 125/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fdd81007..fc89258b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2324,7 +2324,8 @@ void process_pushbutton() { if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to AFSK"); release = TRUE; - + } + if (release == FALSE) { blinkTimes(2); sleep(1.5); @@ -2334,7 +2335,8 @@ void process_pushbutton() { if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to FSK"); release = TRUE; - + } + if (release == FALSE) { blinkTimes(3); sleep(1.5); @@ -2344,7 +2346,8 @@ void process_pushbutton() { if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to BPSK"); release = TRUE; - + } + if (release == FALSE) { digitalWrite(MAIN_PB_PIN, LOW); blinkTimes(4); @@ -2355,7 +2358,8 @@ void process_pushbutton() { if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to SSTV"); release = TRUE; - + } + if (release == FALSE) { digitalWrite(MAIN_PB_PIN, LOW); blinkTimes(5); @@ -2366,7 +2370,8 @@ void process_pushbutton() { if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to CW"); release = TRUE; - + } + if (release == FALSE) { Serial.println("PB: Shutdown!"); digitalWrite(MAIN_PB_PIN, LOW); @@ -2512,4 +2517,4 @@ void blinkTimes(int blinks) { sleep(0.1); } } -} + From 37a6596518d97a581619547347a15d2c5b8a7bac Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:28:35 -0400 Subject: [PATCH 126/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fc89258b..3c78ba4a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2290,6 +2290,8 @@ void loop1() { // check pushbutton int pb_value; pb_value = digitalRead(MAIN_PB_PIN); + Serial.print("PB: "); + Serial.println(pb_value); if (pb_value == PRESSED) process_pushbutton(); } From 0062dc623bb2a2223af021326acaf2a2443578b1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:39:21 -0400 Subject: [PATCH 127/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 3c78ba4a..a2059a8c 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2290,8 +2290,8 @@ void loop1() { // check pushbutton int pb_value; pb_value = digitalRead(MAIN_PB_PIN); - Serial.print("PB: "); - Serial.println(pb_value); +// Serial.print("PB: "); +// Serial.println(pb_value); if (pb_value == PRESSED) process_pushbutton(); } @@ -2376,17 +2376,17 @@ void process_pushbutton() { if (release == FALSE) { Serial.println("PB: Shutdown!"); - digitalWrite(MAIN_PB_PIN, LOW); + digitalWrite(MAIN_LED_GREEN, LOW); sleep(0.5); - digitalWrite(MAIN_PB_PIN, HIGH); + digitalWrite(MAIN_LED_GREEN, HIGH); sleep(0.5); - digitalWrite(MAIN_PB_PIN, LOW); + digitalWrite(MAIN_LED_GREEN, LOW); sleep(0.5); - digitalWrite(MAIN_PB_PIN, HIGH); + digitalWrite(MAIN_LED_GREEN, HIGH); sleep(0.5); - digitalWrite(MAIN_PB_PIN, LOW); + digitalWrite(MAIN_LED_GREEN, LOW); sleep(0.5); - digitalWrite(MAIN_PB_PIN, HIGH); + digitalWrite(MAIN_LED_GREEN, HIGH); sleep(0.5); } @@ -2513,9 +2513,9 @@ void process_pushbutton() { void blinkTimes(int blinks) { for (int i = 0; i < blinks; i++) { - digitalWrite(MAIN_PB_PIN, LOW); + digitalWrite(MAIN_LED_GREEN, LOW); sleep(0.1); - digitalWrite(MAIN_PB_PIN, HIGH); + digitalWrite(MAIN_LED_GREEN, HIGH); sleep(0.1); } } From 3e64bd5d3214a0b5798ca3be5c1316c155953fdc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:45:24 -0400 Subject: [PATCH 128/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a2059a8c..22f0b014 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2389,7 +2389,8 @@ void process_pushbutton() { digitalWrite(MAIN_LED_GREEN, HIGH); sleep(0.5); - } + } + sleep(2.0); /* GPIO.output(powerPin, 0); # blink once time.sleep(0.1); From 322383e206dacc575708fea6488b7f9b90a3964f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 11:50:12 -0400 Subject: [PATCH 129/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 -- 1 file changed, 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 22f0b014..98eb0826 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2351,7 +2351,6 @@ void process_pushbutton() { } if (release == FALSE) { - digitalWrite(MAIN_PB_PIN, LOW); blinkTimes(4); sleep(1.5); } @@ -2363,7 +2362,6 @@ void process_pushbutton() { } if (release == FALSE) { - digitalWrite(MAIN_PB_PIN, LOW); blinkTimes(5); sleep(1.5); } From b113f7dae30fe5e943d6f4ca62db163336e3bc4d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 13:53:41 -0400 Subject: [PATCH 130/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 76 ++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 13 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 98eb0826..db1ce1dc 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -46,18 +46,6 @@ Adafruit_INA219 ina219_2_0x45(0x45); char payload_str[100]; void setup() { - -// set all Pico GPIO pins to input - for (int i = 6; i < 29; i++) { - pinMode(i, INPUT); - } - pinMode(LED_BUILTIN, OUTPUT); // Set LED pin to output - pinMode(MAIN_LED_GREEN, OUTPUT); // Set LED pin to output - pinMode(MAIN_LED_BLUE, OUTPUT); // Set LED pin to output - digitalWrite(MAIN_LED_GREEN, HIGH); - digitalWrite(MAIN_LED_BLUE, LOW); - - pinMode(MAIN_PB_PIN, INPUT_PULLUP); // Read Main Board push button mode = FSK; // AFSK; @@ -2110,7 +2098,12 @@ void led_set(int ledPin, bool state) } void start_ina219() { - + // check if Pi is present by 3.3V voltage + pinMode(PI_3V3_PIN, INPUT); + Serial.print("Pi 3.3V: "); + Serial.println(digitalRead(PI_3V3_PIN); + + // Supply power to the Main board INA219s pinMode(MAIN_INA219, OUTPUT); digitalWrite(MAIN_INA219, HIGH); @@ -2519,3 +2512,60 @@ void blinkTimes(int blinks) { } } +void blink_pin(int pin, int duration) { + + digitalWrite(pin, HIGH); + sleep((float)duration / 1000.00); + digitalWrite(pin, LOW); + +} + +void config_gpio() { + + // set all Pico GPIO pins to input + for (int i = 6; i < 29; i++) { + pinMode(i, INPUT); + } + + // set LEDs and blink once + pinMode(LED_BUILTIN, OUTPUT); // Set LED pin to output + pinMode(MAIN_LED_GREEN, OUTPUT); // Set Main Green LED pin to output + blink(MAIN_LED_GREEN, 150); + pinMode(MAIN_LED_BLUE, OUTPUT); // Set Main Blue LED pin to output + blink(MAIN_LED_BLUE, 150); + pinMode(STEM_LED_GREEN, OUTPUT); // Set STEM Green LED pin to output + blink(STEM_LED_GREEN, 150); + pinMode(STEM_LED_BLUE, OUTPUT); // Set STEM Blue LED pin to output + blink(STEM_LED_BLUE, 150); + + // set input pins and read + pinMode(MAIN_PB_PIN, INPUT_PULLUP); // Read Main Board push button + pinMode(TXC_PIN, INPUT_PULLUP); // Read TXC to see if present + pinMode(LPF_PIN, INPUT_PULLUP); // Read LPF to see if present + pinMode(SQUELCH, INPUT); // Squelch from TXC + + if (digitalRead(LPF_PIN) == FALSE) + Serial.println("LPF present"); + else + Serial.println("LPF not present"); + + if (digitalRead(TXC_PIN) == FALSE) + Serial.println("TXC present"); + else + Serial.println("TXC not present"); + + Serial.print("Squelch: "); + Serial.println(digitalRead(SQUELCH)); + + + Serial.print("Pi 3.3V: "); + Serial.println(digitalRead(PI_3V3_PIN)); + + // set anlog inputs and read + Serial.print("Diode voltage (temperature): "); + Serial.println(analogRead(TEMPERATURE)); + + Serial.print("Audio In: "); + Serial.println(analogRead(AUDIO_IN_PIN)); + +} From 8c4ba4ef0e7a8f048aaa5a98c2f95d3321bff5cb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 13:53:46 -0400 Subject: [PATCH 131/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 63ff6657..0db9fedc 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -137,6 +137,8 @@ void config_simulated_telem(); void generate_simualted_telem(); void process_pushbutton(); void blinkTimes(int blinks); +void blink_pin(int pin, int duration); +void config_gpio(); extern int Encode_8b10b[][256]; From c8308dd3b2de4cf17b30194550fbcfe224a60a5b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 13:55:39 -0400 Subject: [PATCH 132/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index db1ce1dc..5204326d 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2101,7 +2101,7 @@ void start_ina219() { // check if Pi is present by 3.3V voltage pinMode(PI_3V3_PIN, INPUT); Serial.print("Pi 3.3V: "); - Serial.println(digitalRead(PI_3V3_PIN); + Serial.println(digitalRead(PI_3V3_PIN)); // Supply power to the Main board INA219s pinMode(MAIN_INA219, OUTPUT); From 8864b3ba5389b52c7cf2fca87d014e1ded69ff08 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 13:56:54 -0400 Subject: [PATCH 133/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5204326d..c59c6970 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2530,13 +2530,13 @@ void config_gpio() { // set LEDs and blink once pinMode(LED_BUILTIN, OUTPUT); // Set LED pin to output pinMode(MAIN_LED_GREEN, OUTPUT); // Set Main Green LED pin to output - blink(MAIN_LED_GREEN, 150); + blink_pin(MAIN_LED_GREEN, 150); pinMode(MAIN_LED_BLUE, OUTPUT); // Set Main Blue LED pin to output - blink(MAIN_LED_BLUE, 150); + blink_pin(MAIN_LED_BLUE, 150); pinMode(STEM_LED_GREEN, OUTPUT); // Set STEM Green LED pin to output - blink(STEM_LED_GREEN, 150); + blink_pin(STEM_LED_GREEN, 150); pinMode(STEM_LED_BLUE, OUTPUT); // Set STEM Blue LED pin to output - blink(STEM_LED_BLUE, 150); + blink_pin(STEM_LED_BLUE, 150); // set input pins and read pinMode(MAIN_PB_PIN, INPUT_PULLUP); // Read Main Board push button From 87ff13889ad3a415bb80636df6d32219bda0524b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 13:57:53 -0400 Subject: [PATCH 134/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c59c6970..88ac9ab2 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2563,7 +2563,7 @@ void config_gpio() { // set anlog inputs and read Serial.print("Diode voltage (temperature): "); - Serial.println(analogRead(TEMPERATURE)); + Serial.println(analogRead(TEMPERATURE_PIN)); Serial.print("Audio In: "); Serial.println(analogRead(AUDIO_IN_PIN)); From 155ce744a5ffbf8417b0394737bdb1f519aa4a2d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:00:18 -0400 Subject: [PATCH 135/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 88ac9ab2..86705c24 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -46,6 +46,8 @@ Adafruit_INA219 ina219_2_0x45(0x45); char payload_str[100]; void setup() { + + config_gpio() mode = FSK; // AFSK; @@ -58,12 +60,8 @@ void setup() { Serial.println("This code is written for the Raspberry Pi Pico hardware."); #endif - - // detect Pi Zero using 3.3V - // if Pi is present, run Payload OK software - // otherwise, run CubeSatSim Pico code Serial.println("\n\nCubeSatSim Pico v0.1 starting...\n\n"); @@ -76,9 +74,7 @@ void setup() { start_ina219(); config_telem(); - - - + // configure STEM Payload sensors start_payload(); From ecadeceb335e8d50d81f13e23143efc010bc19b9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:00:56 -0400 Subject: [PATCH 136/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 86705c24..f5524810 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -47,7 +47,7 @@ char payload_str[100]; void setup() { - config_gpio() + config_gpio(); mode = FSK; // AFSK; From f5a2f5d291ec39ea0a25b54b0be9eac41653733c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:08:01 -0400 Subject: [PATCH 137/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f5524810..7deed45c 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -47,14 +47,14 @@ char payload_str[100]; void setup() { + Serial.begin(9600); + config_gpio(); mode = FSK; // AFSK; - Serial.begin(9600); - // delay(12000); - sleep(10.0); +// sleep(3.0); #ifndef ARDUINO_ARCH_RP2040 Serial.println("This code is written for the Raspberry Pi Pico hardware."); @@ -2218,9 +2218,9 @@ void pwm_interrupt_handler() { void setup1() { Serial.begin(9600); - sleep(10.0); +// sleep(10.0); - if (mode == FSK) +// if (mode == FSK) { pinMode(AUDIO_OUT_PIN, OUTPUT); From 7194a26056bb5c5285ba96c177450195ddae942f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:10:55 -0400 Subject: [PATCH 138/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7deed45c..1e4620e9 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -54,7 +54,7 @@ void setup() { mode = FSK; // AFSK; // delay(12000); -// sleep(3.0); + sleep(5.0); #ifndef ARDUINO_ARCH_RP2040 Serial.println("This code is written for the Raspberry Pi Pico hardware."); @@ -2218,7 +2218,7 @@ void pwm_interrupt_handler() { void setup1() { Serial.begin(9600); -// sleep(10.0); + sleep(5.0); // if (mode == FSK) { From 0c7dd3d14a558800495b6116bfeafd63697b2a88 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:12:44 -0400 Subject: [PATCH 139/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 1e4620e9..858e15bd 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -48,14 +48,13 @@ char payload_str[100]; void setup() { Serial.begin(9600); + + sleep(5.0); config_gpio(); mode = FSK; // AFSK; -// delay(12000); - sleep(5.0); - #ifndef ARDUINO_ARCH_RP2040 Serial.println("This code is written for the Raspberry Pi Pico hardware."); #endif From d31292f8e0fedfa74b15265623c0948f0f9968be Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:24:37 -0400 Subject: [PATCH 140/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 858e15bd..5955f0bb 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2521,6 +2521,8 @@ void config_gpio() { for (int i = 6; i < 29; i++) { pinMode(i, INPUT); } + // set audio out to TXC board + pinMode(AUDIO_OUT_PIN, OUTPUT); // set LEDs and blink once pinMode(LED_BUILTIN, OUTPUT); // Set LED pin to output From f92249980e8b6fe373c0105fe0623a0694228130 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:26:59 -0400 Subject: [PATCH 141/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 0db9fedc..c0c46cef 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -189,7 +189,8 @@ long int uptime = 0; char call[5]; char sim_yes[10]; -int bitRate, mode, bufLen, rsFrames, payloads, rsFrameLen, dataLen, headerLen, syncBits, syncWord, parityLen, samples, frameCnt, samplePeriod; +int mode = FSK; +int bitRate, bufLen, rsFrames, payloads, rsFrameLen, dataLen, headerLen, syncBits, syncWord, parityLen, samples, frameCnt, samplePeriod; float sleepTime; unsigned int sampleTime = 0; int frames_sent = 0; From d522b4eab52c0369568979abfa67a3a0f7f9e05b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:28:25 -0400 Subject: [PATCH 142/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5955f0bb..fc289ba1 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -53,7 +53,7 @@ void setup() { config_gpio(); - mode = FSK; // AFSK; +// mode = FSK; // AFSK; #ifndef ARDUINO_ARCH_RP2040 Serial.println("This code is written for the Raspberry Pi Pico hardware."); @@ -2314,6 +2314,8 @@ void process_pushbutton() { if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to AFSK"); release = TRUE; + mode = AFSK; + setup(); } if (release == FALSE) { @@ -2325,6 +2327,8 @@ void process_pushbutton() { if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to FSK"); release = TRUE; + mode = FSK; + setup(); } if (release == FALSE) { From cad96d3d63d6bf557cb7e7618e89ccbc686d1145 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:32:07 -0400 Subject: [PATCH 143/147] Update cubesatsim.h --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index c0c46cef..6e7bdaa0 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -190,6 +190,7 @@ char call[5]; char sim_yes[10]; int mode = FSK; +int new_mode = FSK; int bitRate, bufLen, rsFrames, payloads, rsFrameLen, dataLen, headerLen, syncBits, syncWord, parityLen, samples, frameCnt, samplePeriod; float sleepTime; unsigned int sampleTime = 0; From 2a720fd4dfac2a895638484df01adf86d6fe16ae Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:34:42 -0400 Subject: [PATCH 144/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fc289ba1..be35ac7e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -128,7 +128,9 @@ void loop() { digitalWrite(MAIN_LED_BLUE, HIGH); } // send telemetry - + + mode = new_mode; // change modes if button pressed + // delay some time Serial.print("\nLoop time: "); Serial.println(millis() - startSleep); @@ -2314,7 +2316,7 @@ void process_pushbutton() { if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to AFSK"); release = TRUE; - mode = AFSK; + new_mode = AFSK; setup(); } @@ -2327,7 +2329,7 @@ void process_pushbutton() { if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to FSK"); release = TRUE; - mode = FSK; + new_mode = FSK; setup(); } From c9b18218ff97f4831bcea69f8d4055727a62f715 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:37:45 -0400 Subject: [PATCH 145/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index be35ac7e..cbc96131 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -128,9 +128,11 @@ void loop() { digitalWrite(MAIN_LED_BLUE, HIGH); } // send telemetry - - mode = new_mode; // change modes if button pressed - + if (mode != new_mode) { + mode = new_mode; // change modes if button pressed + config_telem(); + config_radio(); + } // delay some time Serial.print("\nLoop time: "); Serial.println(millis() - startSleep); From 477e4c205587160ac60b6c44418987375a53992d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:41:46 -0400 Subject: [PATCH 146/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index cbc96131..5c4bc07f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -128,12 +128,14 @@ void loop() { digitalWrite(MAIN_LED_BLUE, HIGH); } // send telemetry +/* if (mode != new_mode) { mode = new_mode; // change modes if button pressed config_telem(); config_radio(); - } - // delay some time + } +*/ + // Calculate loop time Serial.print("\nLoop time: "); Serial.println(millis() - startSleep); @@ -2535,7 +2537,8 @@ void config_gpio() { // set LEDs and blink once pinMode(LED_BUILTIN, OUTPUT); // Set LED pin to output pinMode(MAIN_LED_GREEN, OUTPUT); // Set Main Green LED pin to output - blink_pin(MAIN_LED_GREEN, 150); + blink_pin(MAIN_LED_GREEN, 150); + digitalWrite(MAIN_LED_GREEN, HIGH); // Leave Green LED on pinMode(MAIN_LED_BLUE, OUTPUT); // Set Main Blue LED pin to output blink_pin(MAIN_LED_BLUE, 150); pinMode(STEM_LED_GREEN, OUTPUT); // Set STEM Green LED pin to output From b0e5fc4669ba27d32d362fc252e62de2d9d4612c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 7 Jul 2022 14:44:15 -0400 Subject: [PATCH 147/147] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5c4bc07f..65c81929 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -128,13 +128,13 @@ void loop() { digitalWrite(MAIN_LED_BLUE, HIGH); } // send telemetry -/* + if (mode != new_mode) { mode = new_mode; // change modes if button pressed config_telem(); config_radio(); } -*/ + // Calculate loop time Serial.print("\nLoop time: "); Serial.println(millis() - startSleep); @@ -2321,7 +2321,7 @@ void process_pushbutton() { Serial.println("PB: Switch to AFSK"); release = TRUE; new_mode = AFSK; - setup(); +// setup(); } if (release == FALSE) { @@ -2334,7 +2334,7 @@ void process_pushbutton() { Serial.println("PB: Switch to FSK"); release = TRUE; new_mode = FSK; - setup(); +// setup(); } if (release == FALSE) {