From 8148d7f6ac2b00fcc5f41277ea0a01e093e1a753 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 24 Feb 2019 11:33:26 -0500 Subject: [PATCH 01/20] created for c code reading of ina219 current sensors --- afsk/ina219.h | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 afsk/ina219.h diff --git a/afsk/ina219.h b/afsk/ina219.h new file mode 100644 index 00000000..007a9b20 --- /dev/null +++ b/afsk/ina219.h @@ -0,0 +1,79 @@ +/* + * Modified from https://github.com/foglamp/foglamp-south-ina219/blob/develop/include/ina219.h + * + * FogLAMP south service plugin + * + * Copyright (c) 2018 Dianomic Systems + * + * Released under the Apache 2.0 Licence + * + * Author: Mark Riddoch + */ +#/** + * Values for the gain setting + */; +enum { + INA219_CONFIG_GAIN_40MV = 0x0000, // 40mV Range + INA219_CONFIG_GAIN_80MV = 0x0800, // 80mV Range + INA219_CONFIG_GAIN_160MV = 0x1000, // 160mV Range + INA219_CONFIG_GAIN_320MV = 0x1800, // 320mV Range +}; + +enum +{ + INA219_CONFIG_BVOLTAGERANGE_16V = 0x0000, // 0-16V Range + INA219_CONFIG_BVOLTAGERANGE_32V = 0x2000, // 0-32V Range +}; + +#define INA219_CONFIG_BADCRES_MASK 0x0780 // ADC Resulotion Mask +enum +{ + INA219_CONFIG_BADCRES_9BIT = 0x0000, // 9-bit bus res = 0..511 + INA219_CONFIG_BADCRES_10BIT = 0x0080, // 10-bit bus res = 0..1023 + INA219_CONFIG_BADCRES_11BIT = 0x0100, // 11-bit bus res = 0..2047 + INA219_CONFIG_BADCRES_12BIT = 0x0180, // 12-bit bus res = 0..4097 +}; + +#define INA219_CONFIG_SADCRES_MASK 0x0078 // Mask for shunt ADC resolution bits +enum +{ + INA219_CONFIG_SADCRES_9BIT_1S_84US = 0x00, // 1 x 9-bit shunt sample + INA219_CONFIG_SADCRES_10BIT_1S_148US = 0x08, // 1 x 10-bit shunt sample + INA219_CONFIG_SADCRES_11BIT_1S_276US = 0x10, // 1 x 11-bit shunt sample + INA219_CONFIG_SADCRES_12BIT_1S_532US = 0x18, // 1 x 12-bit shunt sample + INA219_CONFIG_SADCRES_12BIT_2S_1060US = 0x48, // 2 x 12-bit shunt samples averaged together + INA219_CONFIG_SADCRES_12BIT_4S_2130US = 0x50, // 4 x 12-bit shunt samples averaged together + INA219_CONFIG_SADCRES_12BIT_8S_4260US = 0x58, // 8 x 12-bit shunt samples averaged together + INA219_CONFIG_SADCRES_12BIT_16S_8510US = 0x60, // 16 x 12-bit shunt samples averaged together + INA219_CONFIG_SADCRES_12BIT_32S_17MS = 0x68, // 32 x 12-bit shunt samples averaged together + INA219_CONFIG_SADCRES_12BIT_64S_34MS = 0x70, // 64 x 12-bit shunt samples averaged together + INA219_CONFIG_SADCRES_12BIT_128S_69MS = 0x78, // 128 x 12-bit shunt samples averaged together +}; + +#define INA219_CONFIG_MODE_MASK 0x0007 // Operating Mode Mask +enum { + INA219_CONFIG_MODE_POWERDOWN = 0x0000, + INA219_CONFIG_MODE_SVOLT_TRIGGERED = 0x0001, + INA219_CONFIG_MODE_BVOLT_TRIGGERED = 0x0002, + INA219_CONFIG_MODE_SANDBVOLT_TRIGGERED = 0x0003, + INA219_CONFIG_MODE_ADCOFF = 0x0004, + INA219_CONFIG_MODE_SVOLT_CONTINUOUS = 0x0005, + INA219_CONFIG_MODE_BVOLT_CONTINUOUS = 0x0006, + INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS = 0x0007, +}; + +typedef enum { + CONF_16V_400MA, + CONF_32V_1A, + CONF_32V_2A +} INA219_CONFIGURATION; + +/* + * INA219 Registers + */ +#define INA219_REG_CONFIG 0x00 +#define INA219_REG_SHUNTVOLTAGE 0x01 +#define INA219_REG_BUSVOLTAGE 0x02 +#define INA219_REG_POWER 0x03 +#define INA219_REG_CURRENT 0x04 +#define INA219_REG_CALIBRATION 0x05 From b2ceca87a589b79b31957779e529691284649fb1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 24 Feb 2019 11:35:35 -0500 Subject: [PATCH 02/20] added ina219.h --- afsk/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index 0258835c..4bc69bbb 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -33,6 +33,7 @@ #include "spi/ax5043spi.h" #include #include +#include "ina219.h" // Put your callsign here #define CALLSIGN "KU2Y" @@ -76,6 +77,14 @@ int charging = 0; uint16_t config = (0x2000 | 0x1800 | 0x0180 | 0x0018 | 0x0007 ); +int x_fd; // I2C bus 0 +int x_address; // I2C address of INA219 +int x_powerMultiplier; +int x_currentDivider; +int x_calValue; +int y_fd; // I2C bus 0 +int y_address; // I2C address of INA219 + int main(void) { // sleep(20); From d3eacc952943691b3dae8297b8a8c42d465555d9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 24 Feb 2019 11:38:31 -0500 Subject: [PATCH 03/20] removed ; --- afsk/ina219.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/afsk/ina219.h b/afsk/ina219.h index 007a9b20..9200291d 100644 --- a/afsk/ina219.h +++ b/afsk/ina219.h @@ -9,9 +9,10 @@ * * Author: Mark Riddoch */ -#/** + +/** * Values for the gain setting - */; + */ enum { INA219_CONFIG_GAIN_40MV = 0x0000, // 40mV Range INA219_CONFIG_GAIN_80MV = 0x0800, // 80mV Range From e1f34d24800fc26891cf4db626ee0eeb674433a8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 24 Feb 2019 11:51:47 -0500 Subject: [PATCH 04/20] i2c open for X- and Y- --- afsk/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index 4bc69bbb..5d53b221 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -114,6 +114,24 @@ int main(void) { int arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4c); printf("Arduio write: %d \n", wiringPiI2CWrite(arduinoI2C,42)); printf("Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); + +// new INA219 current reading code + + x_calValue = 8192; + x_powerMultiplier = 1; + x_currentDivider = 20; + config = INA219_CONFIG_BVOLTAGERANGE_16V | + INA219_CONFIG_GAIN_40MV | + INA219_CONFIG_BADCRES_12BIT | + INA219_CONFIG_SADCRES_12BIT_4S_2130US | + //INA219_CONFIG_SADCRES_12BIT_1S_532US | + INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; + + x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); + printf("Opening of X- fd %d\n", x_fd); + + y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); + printf("Opening of Y- fd %d\n", y_fd); setSpiChannel(SPI_CHANNEL); setSpiSpeed(SPI_SPEED); From b1d399ef9af830aaa7eafa297eea8f8982b661ed Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 24 Feb 2019 11:54:32 -0500 Subject: [PATCH 05/20] read i2c sensors --- afsk/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index 5d53b221..14bb13aa 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -307,6 +307,21 @@ int get_tlm(int tlm[][5]) { } +// read i2c current sensors // + + wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); + wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); + double current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; + double power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; + wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); + wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); + double y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; + double y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + + printf("0x40 current %4.2f power %4.2f 0x41 current %4.2f power %4.2f \n", current, power, y_current, y_power); + // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi From 601aa8ff10a93c0c0f91a49610fdbc0b06a396cb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 24 Feb 2019 12:18:15 -0500 Subject: [PATCH 06/20] Changed 1C, 1D, 2A, and 2B telemetry values transmitted --- afsk/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 14bb13aa..876b6938 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -325,11 +325,13 @@ int get_tlm(int tlm[][5]) { // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi - tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // +X current [4] - tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // +Y current [7] - tlm[1][C] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] (actually -X current, AO-7 didn't have a Z solar panel?) + tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // X+ current [4] + tlm[1][C] = (int) (99.5 - strtof(current, NULL)/10) % 100; // X- current [10] + tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // Y+ current [7] + + tlm[2][A] = (int) (99.5 - strtof(current_y, NULL)/10) % 100; // Y- current [10] + tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel - tlm[2][A] = 99; tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENT], NULL)/10.0) % 100; // NiMH Battery current From 351ba535147678b029645cf76cc7d8c7950e7302 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 24 Feb 2019 12:21:43 -0500 Subject: [PATCH 07/20] fixed y_current --- afsk/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 876b6938..faab1a2b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -78,12 +78,11 @@ int charging = 0; uint16_t config = (0x2000 | 0x1800 | 0x0180 | 0x0018 | 0x0007 ); int x_fd; // I2C bus 0 -int x_address; // I2C address of INA219 int x_powerMultiplier; int x_currentDivider; int x_calValue; int y_fd; // I2C bus 0 -int y_address; // I2C address of INA219 + int main(void) { @@ -329,7 +328,7 @@ int get_tlm(int tlm[][5]) { tlm[1][C] = (int) (99.5 - strtof(current, NULL)/10) % 100; // X- current [10] tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // Y+ current [7] - tlm[2][A] = (int) (99.5 - strtof(current_y, NULL)/10) % 100; // Y- current [10] + tlm[2][A] = (int) (99.5 - strtof(y_current, NULL)/10) % 100; // Y- current [10] tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; From 01e557a5d0e03e30651098c4ca1f46e99494fae1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 24 Feb 2019 12:24:53 -0500 Subject: [PATCH 08/20] fixed current and y_current calculation --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index faab1a2b..66a02695 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -325,10 +325,10 @@ int get_tlm(int tlm[][5]) { tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // X+ current [4] - tlm[1][C] = (int) (99.5 - strtof(current, NULL)/10) % 100; // X- current [10] + tlm[1][C] = (int) (99.5 - current/10) % 100; // X- current [10] tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // Y+ current [7] - tlm[2][A] = (int) (99.5 - strtof(y_current, NULL)/10) % 100; // Y- current [10] + tlm[2][A] = (int) (99.5 - y_current/10) % 100; // Y- current [10] tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; From 9e53199bd3b0f1f686b7571dd4b67b8f1380207c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 10 Mar 2019 10:41:16 -0400 Subject: [PATCH 09/20] updates --- Makefile | 1 + afsk/ina219.h | 2 +- afsk/main.c | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 8c378f36..6ea66e39 100644 --- a/Makefile +++ b/Makefile @@ -83,6 +83,7 @@ radioafsk: libax5043.a radioafsk: afsk/ax25.o radioafsk: afsk/ax5043.o radioafsk: afsk/main.o +radioafsk: afsk/ina219.h gcc -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 diff --git a/afsk/ina219.h b/afsk/ina219.h index 9200291d..0a7372e3 100644 --- a/afsk/ina219.h +++ b/afsk/ina219.h @@ -72,7 +72,7 @@ typedef enum { /* * INA219 Registers */ -#define INA219_REG_CONFIG 0x00 +#define INA219_REG_CONFIG 0x00 #define INA219_REG_SHUNTVOLTAGE 0x01 #define INA219_REG_BUSVOLTAGE 0x02 #define INA219_REG_POWER 0x03 diff --git a/afsk/main.c b/afsk/main.c index 66a02695..159e05fc 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -86,7 +86,9 @@ int y_fd; // I2C bus 0 int main(void) { -// sleep(20); + setSpiChannel(SPI_CHANNEL); + setSpiSpeed(SPI_SPEED); + initializeSpi(); int tlm[7][5]; int i, j; @@ -132,10 +134,6 @@ int main(void) { y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); printf("Opening of Y- fd %d\n", y_fd); - setSpiChannel(SPI_CHANNEL); - setSpiSpeed(SPI_SPEED); - initializeSpi(); - int ret; uint8_t data[1024]; @@ -222,6 +220,8 @@ int main(void) { static void init_rf() { int ret; + printf("Initializing AX5043\n"); + ret = ax5043_init(&hax5043, XTAL_FREQ_HZ, VCO_INTERNAL); if (ret != PQWS_SUCCESS) { fprintf(stderr, From c8c2cc44f0fba4281faf178ab888b6ebe292abd6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 10 Mar 2019 10:44:13 -0400 Subject: [PATCH 10/20] Create readdata.py --- python/readdata.py | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 python/readdata.py diff --git a/python/readdata.py b/python/readdata.py new file mode 100644 index 00000000..1e2929cf --- /dev/null +++ b/python/readdata.py @@ -0,0 +1,88 @@ +SHUNT_OHMS = 0.01 +MAX_EXPECTED_AMPS = 2.5 +SHUNT_OHMS45 = 0.1 +MAX_EXPECTED_AMPS45 = 0.6 +ina40v = 0 +ina40i = 0 +ina40p = 0 +ina41v = 0 +ina41i = 0 +ina41p = 0 +ina44v = 0 +ina44i = 0 +ina44p = 0 +ina45v = 0 +ina45i = 0 +ina45p = 0 +ina4av = 0 +ina4ai = 0 +ina4ap = 0 + +FAIL = -1 + +try: + from ina219 import INA219 + from ina219 import DeviceRangeError + INA219DISABLE=-1 +except: + INA219DISABLE=1 + +while True: + time.sleep(1) + if INA219DISABLE !=1: + try: + ina40 = INA219(SHUNT_OHMS45, MAX_EXPECTED_AMPS45, 0x40) + ina40.wake(); + ina40.configure(ina40.RANGE_16V) + ina40.busnum = 0; + ina40v = ina40.voltage() + ina40i = ina40.current() + ina40p = ina40.power() + ina40.sleep(); + except: + FAIL = 1 + try: + ina41 = INA219(SHUNT_OHMS45, MAX_EXPECTED_AMPS45, 0x41) + ina41.wake(); + ina41.configure(ina41.RANGE_16V) + ina41.busnum = 1; + ina41v = ina41.voltage() + ina41i = ina41.current() + ina41p = ina41.power() + ina41.sleep(); + except: + FAIL = 1 + try: + ina44 = INA219(SHUNT_OHMS45, MAX_EXPECTED_AMPS45, 0x44) + ina44.wake(); + ina44.configure(ina44.RANGE_16V) + ina44.busnum = 1; + ina44v = ina44.voltage() + ina44i = ina44.current() + ina44p = ina44.power() + ina44.sleep(); + except: + FAIL = 1 + try: + ina45 = INA219(SHUNT_OHMS45, MAX_EXPECTED_AMPS45, 0x45) + ina45.wake(); + ina45.configure(ina45.RANGE_16V) + ina45.busnum = 1; + ina45v = ina45.voltage() + ina45i = ina45.current() + ina45p = ina45.power() + ina45.sleep(); + except: + FAIL = 1 + try: + ina4a = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS, 0x4a) + ina4a.wake(); + ina4a.configure(ina4a.RANGE_16V) + ina4a.busnum = 1; + ina4av = ina4a.voltage() + ina4ai = ina4a.current() + ina4ap = ina4a.power() + ina4a.sleep(); + except: + FAIL = 1 + print ina40v, ",", ina40i,",", ina40p,",", ina41v,",", ina41i,",", ina41p,",", ina44v,",", ina44i,",", ina44p,",", ina45v,",", ina45i,",", ina45p,",", ina4av,",", ina4ai,",", ina4ap From 8711c75523537a0ad06a13ebdc39fc90a4e0f256 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 10 Mar 2019 15:33:05 -0400 Subject: [PATCH 11/20] removed sleep and readdata tab spacing: --- afsk/main.c | 2 +- python/readdata.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 159e05fc..ba68e7c0 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -147,7 +147,7 @@ int main(void) { /* Infinite loop */ for (;;) { - sleep(2); + //sleep(2); // send X.25 packet diff --git a/python/readdata.py b/python/readdata.py index 1e2929cf..9dfadeee 100644 --- a/python/readdata.py +++ b/python/readdata.py @@ -1,3 +1,5 @@ +import time + SHUNT_OHMS = 0.01 MAX_EXPECTED_AMPS = 2.5 SHUNT_OHMS45 = 0.1 @@ -26,6 +28,7 @@ try: INA219DISABLE=-1 except: INA219DISABLE=1 +print "+X v\t+X i\t+X p\t+Y v\t+Y i\t+Y p\t+Z v\t+Z i\t+Z p\tVbatt\tibatt\tpbatt\tV5\ti5\tp5\t+X v\t+X i\t+X p\t" while True: time.sleep(1) @@ -59,7 +62,7 @@ while True: ina44.busnum = 1; ina44v = ina44.voltage() ina44i = ina44.current() - ina44p = ina44.power() + ina44p = ina44.power() ina44.sleep(); except: FAIL = 1 @@ -72,7 +75,7 @@ while True: ina45i = ina45.current() ina45p = ina45.power() ina45.sleep(); - except: + except: FAIL = 1 try: ina4a = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS, 0x4a) @@ -85,4 +88,4 @@ while True: ina4a.sleep(); except: FAIL = 1 - print ina40v, ",", ina40i,",", ina40p,",", ina41v,",", ina41i,",", ina41p,",", ina44v,",", ina44i,",", ina44p,",", ina45v,",", ina45i,",", ina45p,",", ina4av,",", ina4ai,",", ina4ap + print ina40v, "\t", ina40i,"\t", ina40p,"\t", ina41v,"\t", ina41i,"\t", ina41p,"\t", ina44v,"\t", ina44i,"\t", ina44p,"\t", ina45v,"\t", ina45i,"\t", ina45p,"\t", ina4av,"\t", ina4ai,"\t", ina4ap From 725a9c4e9bd1b8ae2f80626cd36ee73427637867 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 11 Mar 2019 07:36:25 -0400 Subject: [PATCH 12/20] added -Z --- afsk/main.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ba68e7c0..fb58bec7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -77,11 +77,12 @@ int charging = 0; uint16_t config = (0x2000 | 0x1800 | 0x0180 | 0x0018 | 0x0007 ); -int x_fd; // I2C bus 0 +int x_fd; // I2C bus 0 address 0x40 int x_powerMultiplier; int x_currentDivider; int x_calValue; -int y_fd; // I2C bus 0 +int y_fd; // I2C bus 0 address 0x41 +int z_fd; // I2C bos 0 address 0x44 int main(void) { @@ -129,11 +130,12 @@ int main(void) { INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); - printf("Opening of X- fd %d\n", x_fd); - + printf("Opening of -X fd %d\n", x_fd); y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); - printf("Opening of Y- fd %d\n", y_fd); - + printf("Opening of -Y fd %d\n", y_fd); + z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); + printf("Opening of -Z fd %d\n", z_fd); + int ret; uint8_t data[1024]; @@ -318,20 +320,27 @@ int get_tlm(int tlm[][5]) { wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); double y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; double y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); + wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); + double z_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; + double z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; - printf("0x40 current %4.2f power %4.2f 0x41 current %4.2f power %4.2f \n", current, power, y_current, y_power); + printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", + current, power, y_current, y_power, z_current, z_power); // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi - tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // X+ current [4] + tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // +X current [4] tlm[1][C] = (int) (99.5 - current/10) % 100; // X- current [10] - tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // Y+ current [7] + tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // +Y current [7] - tlm[2][A] = (int) (99.5 - y_current/10) % 100; // Y- current [10] + tlm[2][A] = (int) (99.5 - y_current/10) % 100; // -Y current [10] tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel + tlm[2][C] = (int) (99.5 - z_current/10) % 100; // -Z current (was timestamp) - tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; +// tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENT], NULL)/10.0) % 100; // NiMH Battery current tlm[3][A] = abs((int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5) % 100); From 91650f75ca70cfa2005c53e11bc95f685410ead2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 11 Mar 2019 20:29:09 -0400 Subject: [PATCH 13/20] blinking LED using WiringPi --- afsk/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index ba68e7c0..67cd8a7e 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -32,6 +32,7 @@ #include "ax25.h" #include "spi/ax5043spi.h" #include +#include #include #include "ina219.h" @@ -85,6 +86,16 @@ int y_fd; // I2C bus 0 int main(void) { + + wiringPiSetup () ; + pinMode (0, OUTPUT) ; + int blink; + for (blink = 1; blink < 10 ;blink++) + { + digitalWrite (0, HIGH) ; delay (500) ; + digitalWrite (0, LOW) ; delay (500) ; + } + digitalWrite (0, HIGH) ; setSpiChannel(SPI_CHANNEL); setSpiSpeed(SPI_SPEED); From 6bbc0ba4967118ca6e90f728246db736c1a7e9bb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 14 Mar 2019 09:53:53 -0400 Subject: [PATCH 14/20] check i2c-0 before using --- afsk/main.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 2ed75660..0ccd9936 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -139,13 +139,22 @@ int main(void) { INA219_CONFIG_SADCRES_12BIT_4S_2130US | //INA219_CONFIG_SADCRES_12BIT_1S_532US | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; - - x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); - printf("Opening of -X fd %d\n", x_fd); - y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); - printf("Opening of -Y fd %d\n", y_fd); - z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); - printf("Opening of -Z fd %d\n", z_fd); + + if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) + { + printf("ERROR: /dev/ic2-0 bus not present\n"); + x_fd = -1; + y_fd = -1; + z_fd = -1; + } else + { + x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); + printf("Opening of -X fd %d\n", x_fd); + y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); + printf("Opening of -Y fd %d\n", y_fd); + z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); + printf("Opening of -Z fd %d\n", z_fd); + } int ret; uint8_t data[1024]; @@ -320,23 +329,24 @@ int get_tlm(int tlm[][5]) { } // read i2c current sensors // - + double current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; + if (x_fd != -1) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); - double current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; - double power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; + current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; + power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); - double y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; - double y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; + y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, config); wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); - double z_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; - double z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; - + z_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; + z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + } printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", current, power, y_current, y_power, z_current, z_power); From 66132de2f53fe8416e093bff6064422a987b29c6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 14 Mar 2019 09:58:24 -0400 Subject: [PATCH 15/20] fixed i2c bus check for arduino --- afsk/main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 0ccd9936..2ceed84d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -124,9 +124,15 @@ int main(void) { printf("tempSensor: %d \n",tempSensor); - int arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4c); - printf("Arduio write: %d \n", wiringPiI2CWrite(arduinoI2C,42)); - printf("Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); + int arduinoI2C; + if ((arduinoI2C = open("/dev/i2c-0", O_RDWR)) < 0) + { + printf"ERROR: /dev/i2c-0 bus not present\n"); + } else { + arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4c); + printf("Arduio write: %d \n", wiringPiI2CWrite(arduinoI2C,42)); + printf("Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); + } // new INA219 current reading code From a0437b6a74225596fe585ee0a8e2ac83098f9687 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 14 Mar 2019 09:58:56 -0400 Subject: [PATCH 16/20] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 2ceed84d..04610dd9 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -127,7 +127,7 @@ int main(void) { int arduinoI2C; if ((arduinoI2C = open("/dev/i2c-0", O_RDWR)) < 0) { - printf"ERROR: /dev/i2c-0 bus not present\n"); + printf("ERROR: /dev/i2c-0 bus not present\n"); } else { arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4c); printf("Arduio write: %d \n", wiringPiI2CWrite(arduinoI2C,42)); From 7918b87f2a3d587f75ba3e4da7e7a66b2edc3c01 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Mar 2019 19:47:31 -0400 Subject: [PATCH 17/20] i2c reg read from arduino payload --- afsk/main.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 04610dd9..23220986 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -91,7 +91,7 @@ int main(void) { wiringPiSetup () ; pinMode (0, OUTPUT) ; int blink; - for (blink = 1; blink < 10 ;blink++) + for (blink = 1; blink < 2 ;blink++) { digitalWrite (0, HIGH) ; delay (500) ; digitalWrite (0, LOW) ; delay (500) ; @@ -130,9 +130,27 @@ int main(void) { printf("ERROR: /dev/i2c-0 bus not present\n"); } else { arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4c); - printf("Arduio write: %d \n", wiringPiI2CWrite(arduinoI2C,42)); + for (blink = 1; blink < 20 ;blink++) { + printf("Arduio write 0: %d \n", wiringPiI2CWrite(arduinoI2C,0)); + sleep(1); + printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,0)); + sleep(1); + printf("Arduio write 1: %d \n", wiringPiI2CWrite(arduinoI2C,0)); + sleep(1); printf("Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); - } + sleep(1); + printf("Arduio write 2: %d \n", wiringPiI2CWrite(arduinoI2C,1)); + sleep(1); + printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,1)); + sleep(1); + printf("Arduio write 3: %d \n", wiringPiI2CWrite(arduinoI2C,3)); + sleep(1); + printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,2)); + sleep(1); + } + } + +exit(0); // new INA219 current reading code From d9201fe6362630879322760e14dd3bb415a4cbfc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Mar 2019 20:00:42 -0400 Subject: [PATCH 18/20] changed 1000 to 999 on fgets --- afsk/main.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 23220986..08dd2852 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -130,28 +130,23 @@ int main(void) { printf("ERROR: /dev/i2c-0 bus not present\n"); } else { arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4c); - for (blink = 1; blink < 20 ;blink++) { - printf("Arduio write 0: %d \n", wiringPiI2CWrite(arduinoI2C,0)); - sleep(1); - printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,0)); - sleep(1); - printf("Arduio write 1: %d \n", wiringPiI2CWrite(arduinoI2C,0)); - sleep(1); - printf("Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); - sleep(1); - printf("Arduio write 2: %d \n", wiringPiI2CWrite(arduinoI2C,1)); - sleep(1); - printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,1)); - sleep(1); - printf("Arduio write 3: %d \n", wiringPiI2CWrite(arduinoI2C,3)); - sleep(1); - printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,2)); - sleep(1); - } + if (arduinoI2C > 0) { + // for (blink = 1; blink < 20 ;blink++) { + sleep(1); + printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,0)); + sleep(1); + printf("Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); + sleep(1); + printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,1)); + sleep(1); + printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,2)); + sleep(1); +// } + } else { + printf("Arduino payload not present\n"); + } } -exit(0); - // new INA219 current reading code x_calValue = 8192; @@ -231,7 +226,7 @@ exit(0); if (charging) { FILE* file1 = popen("/home/pi/mopower/mpcmd LED_STAT=1", "r"); - fgets(cmdbuffer, 1000, file1); + fgets(cmdbuffer, 999, file1); pclose(file1); // printf("LED state: %s\n", cmdbuffer); @@ -248,7 +243,7 @@ exit(0); } ax5043_wait_for_transmit(); FILE* file2 = popen("/home/pi/mopower/mpcmd LED_STAT=0", "r"); - fgets(cmdbuffer, 1000, file2); + fgets(cmdbuffer, 999, file2); pclose(file2); // printf("LED state: %s\n", cmdbuffer); @@ -305,7 +300,7 @@ int get_tlm(int tlm[][5]) { char cmdbuffer[1000]; FILE* file = popen("sudo python /home/pi/CubeSatSim/python/readcurrent.py 2>&1", "r"); - fgets(cmdbuffer, 1000, file); + fgets(cmdbuffer, 999, file); pclose(file); printf("I2C Sensor data: %s\n", cmdbuffer); @@ -323,7 +318,7 @@ int get_tlm(int tlm[][5]) { // Reading MoPower telemetry info file = popen("/home/pi/mopower/mpcmd show data", "r"); - fgets(cmdbuffer, 1000, file); + fgets(cmdbuffer, 999, file); pclose(file); // printf("MoPower data: %s\n", cmdbuffer); From 007fada311c53d269110dfc5cf6d0fae88a62373 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 22 Mar 2019 16:41:34 -0400 Subject: [PATCH 19/20] trying to find lockup - everything disabled --- afsk/main.c | 54 ++++++++++++++++++++++++++++------------------------- demo.sh | 11 +++++++---- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 08dd2852..33c2998b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -96,7 +96,7 @@ int main(void) { digitalWrite (0, HIGH) ; delay (500) ; digitalWrite (0, LOW) ; delay (500) ; } - digitalWrite (0, HIGH) ; +// digitalWrite (0, HIGH) ; setSpiChannel(SPI_CHANNEL); setSpiSpeed(SPI_SPEED); @@ -115,27 +115,28 @@ int main(void) { //char *filenam1e = (char*)"/dev/i2c-3"; if ((file_i2c = open("/dev/i2c-3", O_RDWR)) < 0) { - printf("ERROR: /dev/ic2-3 bus not present\n"); + fprintf(stderr,"ERROR: /dev/ic2-3 bus not present\n"); tempSensor = -1; } else { tempSensor = wiringPiI2CSetupInterface("/dev/i2c-3", 0x48); } - printf("tempSensor: %d \n",tempSensor); + fprintf(stderr,"tempSensor: %d \n",tempSensor); int arduinoI2C; if ((arduinoI2C = open("/dev/i2c-0", O_RDWR)) < 0) { - printf("ERROR: /dev/i2c-0 bus not present\n"); + fprintf(stderr,"ERROR: /dev/i2c-0 bus not present\n"); } else { arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4c); + fprintf(stderr,"arduinoI2C: %d\n", arduinoI2C); if (arduinoI2C > 0) { // for (blink = 1; blink < 20 ;blink++) { sleep(1); - printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,0)); - sleep(1); - printf("Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); + fprintf(stderr,"Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,0)); + sleep(1); + fprintf(stderr,"Arduio: %d \n", wiringPiI2CRead(arduinoI2C)); sleep(1); printf("Arduio: %d \n", wiringPiI2CReadReg16(arduinoI2C,1)); sleep(1); @@ -143,7 +144,7 @@ int main(void) { sleep(1); // } } else { - printf("Arduino payload not present\n"); + fprintf(stderr,"Arduino payload not present\n"); } } @@ -161,14 +162,14 @@ int main(void) { if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) { - printf("ERROR: /dev/ic2-0 bus not present\n"); + fprintf(stderr,"ERROR: /dev/ic2-0 bus not present\n"); x_fd = -1; y_fd = -1; z_fd = -1; } else { x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); - printf("Opening of -X fd %d\n", x_fd); + fprintf("stderr,Opening of -X fd %d\n", x_fd); y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); printf("Opening of -Y fd %d\n", y_fd); z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); @@ -188,7 +189,7 @@ int main(void) { /* Infinite loop */ for (;;) { - //sleep(2); + sleep(2); // send X.25 packet @@ -198,18 +199,18 @@ int main(void) { // AX25_PREAMBLE_LEN, // AX25_POSTAMBLE_LEN); - printf("INFO: Getting TLM Data\n"); + fprintf(stderr,"INFO: Getting TLM Data\n"); - get_tlm(tlm); + //get_tlm(tlm); - printf("INFO: Preparing X.25 packet\n"); + fprintf(stderr,"INFO: Preparing X.25 packet\n"); char str[1000]; char tlm_str[1000]; char header_str[] = "\x03\x0fhi hi "; strcpy(str, header_str); - +/* int channel; for (channel = 1; channel < 7; channel++) { // printf("%d %d %d %d \n", tlm[channel][1], tlm[channel][2], tlm[channel][3], tlm[channel][4]); @@ -220,8 +221,9 @@ int main(void) { channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); // printf("%s \n",tlm_str); strcat(str, tlm_str); - } - + } +*/ +/* char cmdbuffer[1000]; if (charging) { @@ -231,7 +233,8 @@ int main(void) { // printf("LED state: %s\n", cmdbuffer); } - printf("INFO: Transmitting X.25 packet\n"); +*/ + fprintf(stderr,"INFO: Transmitting X.25 packet\n"); memcpy(data, str, strnlen(str, 256)); ret = ax25_tx_frame(&hax25, &hax5043, data, strnlen(str, 256)); @@ -242,12 +245,13 @@ int main(void) { exit(EXIT_FAILURE); } ax5043_wait_for_transmit(); +/* FILE* file2 = popen("/home/pi/mopower/mpcmd LED_STAT=0", "r"); fgets(cmdbuffer, 999, file2); pclose(file2); // printf("LED state: %s\n", cmdbuffer); - +*/ if (ret) { fprintf(stderr, "ERROR: Failed to transmit entire AX.25 frame with error code %d\n", @@ -261,7 +265,7 @@ int main(void) { static void init_rf() { int ret; - printf("Initializing AX5043\n"); + fprintf(stderr,"Initializing AX5043\n"); ret = ax5043_init(&hax5043, XTAL_FREQ_HZ, VCO_INTERNAL); if (ret != PQWS_SUCCESS) { @@ -279,7 +283,7 @@ int lower_digit(int number) { if (number < 100) digit = number - ((int)(number/10) * 10); else - printf("ERROR: Not a digit in lower_digit!\n"); + fprintf(stderr,"ERROR: Not a digit in lower_digit!\n"); return digit; } @@ -291,7 +295,7 @@ int upper_digit(int number) { if (number < 100) digit = (int)(number/10); else - printf("ERROR: Not a digit in upper_digit!\n"); + fprintf(stderr,"ERROR: Not a digit in upper_digit!\n"); return digit; } int get_tlm(int tlm[][5]) { @@ -302,7 +306,7 @@ int get_tlm(int tlm[][5]) { FILE* file = popen("sudo python /home/pi/CubeSatSim/python/readcurrent.py 2>&1", "r"); fgets(cmdbuffer, 999, file); pclose(file); - printf("I2C Sensor data: %s\n", cmdbuffer); + fprintf(stderr,"I2C Sensor data: %s\n", cmdbuffer); char ina219[16][20]; // voltage, currents, and power from the INA219 current sensors x4a, x40, x41, x44, and x45. int i = 0; @@ -316,7 +320,7 @@ int get_tlm(int tlm[][5]) { } // Reading MoPower telemetry info - +/* file = popen("/home/pi/mopower/mpcmd show data", "r"); fgets(cmdbuffer, 999, file); pclose(file); @@ -346,7 +350,7 @@ int get_tlm(int tlm[][5]) { printf("Charging off\n"); } - +*/ // read i2c current sensors // double current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; if (x_fd != -1) { diff --git a/demo.sh b/demo.sh index 7d0274d0..ce5328df 100755 --- a/demo.sh +++ b/demo.sh @@ -1,17 +1,20 @@ #!/bin/bash +exit 0 echo -e "\nDemo of CubeSatSim sends AFSK telemetry at 440 MHz continuously\n\n" -sleep 30 +sleep 60 #echo 'sleep over' >> /home/pi/CubeSatSim/log.txt echo $(date '+%Y %b %d %H:%M') Starting Hostname $HOSTNAME >> /home/pi/CubeSatSim/log.txt -/home/pi/CubeSatSim/radioafsk >> /home/pi/CubeSatSim/log.txt +/home/pi/CubeSatSim/radioafsk >> /home/pi/CubeSatSim/log.txt #/home/pi/DigitalTxRxRPi/testafsktx >> /home/pi/CubeSatSim/log.txt -echo $(date '+%Y %b %d %H:%M') Stopping Hostname $HOSTNAME >> /home/pi/CubeSatSim/log.txt +#echo $(date '+%Y %b %d %H:%M') Stopping Hostname $HOSTNAME >> /home/pi/CubeSatSim/log.txt -/home/pi/mopower/mpcmd LED_STAT=0 +#/home/pi/mopower/mpcmd LED_STAT=0 +#sleep 30 +#/home/pi/CubeSatSim/configax From 8077763cf6802c8e16286c925c05d71ffa34da67 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 22 Mar 2019 17:39:49 -0400 Subject: [PATCH 20/20] commented out conf_tx_path since it was locking up Pi Zero W sometimes! --- afsk/ax5043.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/ax5043.c b/afsk/ax5043.c index 2beb4d66..a6ae071e 100644 --- a/afsk/ax5043.c +++ b/afsk/ax5043.c @@ -222,11 +222,12 @@ int ax5043_init(ax5043_conf_t *conf, uint32_t f_xtal, vco_mode_t vco) { } /* Setup TX only related parameters */ +/* ret = ax5043_conf_tx_path(conf); if (ret) { return ret; } - +*/ /* Set an internal copy for the ax5042_wait_for_transmit function */ __ax5043_conf = conf;