diff options
-rw-r--r-- | hardware/ihu-ttx-test/ihu-ttx-test.pro | 3 | ||||
-rw-r--r-- | software/ihu/ihu.asm | 228 | ||||
-rw-r--r-- | software/ihu/solar.inc | 4 | ||||
-rw-r--r-- | tools/solarmeter/Makefile | 66 | ||||
-rw-r--r-- | tools/solarmeter/solarmeter.c | 88 |
5 files changed, 234 insertions, 155 deletions
diff --git a/hardware/ihu-ttx-test/ihu-ttx-test.pro b/hardware/ihu-ttx-test/ihu-ttx-test.pro index d993ac7..1a5d03c 100644 --- a/hardware/ihu-ttx-test/ihu-ttx-test.pro +++ b/hardware/ihu-ttx-test/ihu-ttx-test.pro @@ -1,4 +1,4 @@ -update=Mon 28 Nov 2011 00:16:52 CET +update=Die 03 Jän 2012 22:00:55 CET version=1 last_client=pcbnew [cvpcb] @@ -77,6 +77,7 @@ PadDrlX=320 PadDimH=600 PadDimV=600 BoardThickness=630 +SgPcb45=1 TxtPcbV=800 TxtPcbH=600 TxtModV=600 diff --git a/software/ihu/ihu.asm b/software/ihu/ihu.asm index 552c213..6ccc821 100644 --- a/software/ihu/ihu.asm +++ b/software/ihu/ihu.asm @@ -197,7 +197,7 @@ int_dtmf btfsc STATUS,Z goto int_dtmf_end -;; DTMF command complete + ;; DTMF command complete movlw .1 movwf TMP @@ -360,6 +360,9 @@ uart_rx_fe ;; ------------------------------------- include "adc.inc" + + ;; ------------------------------------- + include "solar.inc" ;; ------------------------------------- ;; MAINLOOP @@ -369,60 +372,77 @@ main ;; -------------------- ;; ADC Test - ;; call adc_get_solar + call adc_get_solar + call solar_calc_power - ;; movf ADC_SOLAR_C0,w - ;; movwf TXREG - ;; movlw .1 - ;; call wait_ms + movlw .255 + movwf TXREG + movlw .1 + call wait_ms - ;; movf ADC_SOLAR_C1,w - ;; movwf TXREG - ;; movlw .1 - ;; call wait_ms + movf ADC_SOLAR_C0,w + movwf TXREG + movlw .1 + call wait_ms - ;; movf ADC_SOLAR_C2,w - ;; movwf TXREG - ;; movlw .1 - ;; call wait_ms + movf ADC_SOLAR_C1,w + movwf TXREG + movlw .1 + call wait_ms - ;; movf ADC_SOLAR_C3,w - ;; movwf TXREG - ;; movlw .1 - ;; call wait_ms + movf ADC_SOLAR_C2,w + movwf TXREG + movlw .1 + call wait_ms - ;; movf ADC_SOLAR_C4,w - ;; movwf TXREG - ;; movlw .1 - ;; call wait_ms + movf ADC_SOLAR_C3,w + movwf TXREG + movlw .1 + call wait_ms - ;; movf ADC_SOLAR_C5,w - ;; movwf TXREG - ;; movlw .1 - ;; call wait_ms + movf ADC_SOLAR_V0,w + movwf TXREG + movlw .1 + call wait_ms - ;; movf ADC_SOLAR_C6,w - ;; movwf TXREG - ;; movlw .1 - ;; call wait_ms + movf ADC_SOLAR_C4,w + movwf TXREG + movlw .1 + call wait_ms - ;; movf ADC_SOLAR_C7,w - ;; movwf TXREG - ;; movlw .1 - ;; call wait_ms + movf ADC_SOLAR_C5,w + movwf TXREG + movlw .1 + call wait_ms - ;; movf ADC_SOLAR_V,w - ;; movwf TXREG - ;; movlw .1 - ;; call wait_ms + movf ADC_SOLAR_C6,w + movwf TXREG + movlw .1 + call wait_ms - ;; movlw .255 - ;; movwf TXREG - ;; movlw .11 - ;; call wait_ms + movf ADC_SOLAR_C7,w + movwf TXREG + movlw .1 + call wait_ms - ;; clrf TMP - ;; goto main + movf ADC_SOLAR_V1,w + movwf TXREG + movlw .1 + call wait_ms + + movf SOL_POWERH,w + movwf TXREG + movlw .1 + call wait_ms + + movf SOL_POWERL,w + movwf TXREG + + movlw .8 + call wait_ms + + clrf TMP + goto main ;; -------------------- ;; DTMF Test program @@ -489,77 +509,77 @@ main ;; -------------------- ;; RTC Test program - movf TMP,f - btfsc STATUS,Z - goto main + ;; movf TMP,f + ;; btfsc STATUS,Z + ;; goto main - call rtc_get_time + ;; call rtc_get_time - swapf RTC_TOD3,w - andlw b'00001111' - call digit - movwf TXREG - movlw .1 - call wait_ms + ;; swapf RTC_TOD3,w + ;; andlw b'00001111' + ;; call digit + ;; movwf TXREG + ;; movlw .1 + ;; call wait_ms - movf RTC_TOD3,w - andlw b'00001111' - call digit - movwf TXREG - movlw .1 - call wait_ms + ;; movf RTC_TOD3,w + ;; andlw b'00001111' + ;; call digit + ;; movwf TXREG + ;; movlw .1 + ;; call wait_ms - swapf RTC_TOD2,w - andlw b'00001111' - call digit - movwf TXREG - movlw .1 - call wait_ms + ;; swapf RTC_TOD2,w + ;; andlw b'00001111' + ;; call digit + ;; movwf TXREG + ;; movlw .1 + ;; call wait_ms - movf RTC_TOD2,w - andlw b'00001111' - call digit - movwf TXREG - movlw .1 - call wait_ms + ;; movf RTC_TOD2,w + ;; andlw b'00001111' + ;; call digit + ;; movwf TXREG + ;; movlw .1 + ;; call wait_ms - swapf RTC_TOD1,w - andlw b'00001111' - call digit - movwf TXREG - movlw .1 - call wait_ms + ;; swapf RTC_TOD1,w + ;; andlw b'00001111' + ;; call digit + ;; movwf TXREG + ;; movlw .1 + ;; call wait_ms - movf RTC_TOD1,w - andlw b'00001111' - call digit - movwf TXREG - movlw .1 - call wait_ms + ;; movf RTC_TOD1,w + ;; andlw b'00001111' + ;; call digit + ;; movwf TXREG + ;; movlw .1 + ;; call wait_ms - swapf RTC_TOD0,w - andlw b'00001111' - call digit - movwf TXREG - movlw .1 - call wait_ms + ;; swapf RTC_TOD0,w + ;; andlw b'00001111' + ;; call digit + ;; movwf TXREG + ;; movlw .1 + ;; call wait_ms - movf RTC_TOD0,w - andlw b'00001111' - call digit - movwf TXREG - movlw .1 - call wait_ms + ;; movf RTC_TOD0,w + ;; andlw b'00001111' + ;; call digit + ;; movwf TXREG + ;; movlw .1 + ;; call wait_ms - movlw '\r' - movwf TXREG - movlw .1 - call wait_ms - movlw '\n' - movwf TXREG + ;; movlw '\r' + ;; movwf TXREG + ;; movlw .1 + ;; call wait_ms + ;; movlw '\n' + ;; movwf TXREG - clrf TMP - goto main + ;; clrf TMP + ;; goto main ;; -------------------- ;; Temp Test program diff --git a/software/ihu/solar.inc b/software/ihu/solar.inc index c41bcc3..484a538 100644 --- a/software/ihu/solar.inc +++ b/software/ihu/solar.inc @@ -40,6 +40,7 @@ sol_calc_power_single ;; sum up all currents -> SOL_CALC_0:2 sol_sum_current movf INDF,w + bcf STATUS,C addwf SOL_CALC_0,f btfsc STATUS,C incf SOL_CALC_1,f @@ -90,6 +91,7 @@ sol_mula_rotate ;; ------------------------------------- solar_calc_power + ;; calc power of power line 1 movlw ADC_SOLAR_C0 movwf FSR call sol_calc_power_single @@ -102,11 +104,13 @@ solar_calc_power movf SOL_CALC_5,w movwf SOL_CALC_8 + ;; calc power of power line 2 movlw ADC_SOLAR_C4 movwf FSR call sol_calc_power_single ;; add SOL_CALC_3:5 to SOL_CALC_6:8 -> SOL_CALC_6:8 + bcf STATUS,C movf SOL_CALC_3,w addwf SOL_CALC_6,f movlw .1 diff --git a/tools/solarmeter/Makefile b/tools/solarmeter/Makefile new file mode 100644 index 0000000..5c6794f --- /dev/null +++ b/tools/solarmeter/Makefile @@ -0,0 +1,66 @@ +## +## mur.sat +## +## Somewhen in the year 2012, mur.at will have a nano satellite launched +## into a low earth orbit (310 km above the surface of our planet). The +## satellite itself is a TubeSat personal satellite kit, developed and +## launched by interorbital systems. mur.sat is a joint venture of mur.at, +## ESC im Labor and realraum. +## +## Please visit the project hompage at sat.mur.at for further information. +## +## +## Copyright (C) 2011 Christian Pointner <equinox@mur.at> +## +## This file is part of mur.sat. +## +## mur.sat is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## any later version. +## +## mur.sat is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with mur.sat. If not, see <http://www.gnu.org/licenses/>. +## + +CC := gcc +CFLAGS := -g -O2 $(GST_CFLAGS) +LDFLAGS := -g -Wall -O2 $(GST_LDFLAGS) +STRIP := strip + +EXECUTABLES := solarmeter + +OBJS := solarmeter.o + +C_SRCS := $(OBJS:%.o=%.c) + +.PHONY: clean + +all: $(EXECUTABLES) + +%.d: %.c + @set -e; rm -f $@; \ + $(CC) -MM $(CFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$; echo '(re)building $@' + +ifneq ($(MAKECMDGOALS),distclean) +-include $(C_SRCS:%.c=%.d) +endif + +$(EXECUTABLES): $(OBJS) + $(CC) $(OBJS) -o $@ $(LDFLAGS) + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +clean: + rm -f *.o + rm -f *.d + rm -f *.d.* + rm -f $(EXECUTABLES) diff --git a/tools/solarmeter/solarmeter.c b/tools/solarmeter/solarmeter.c index 64bca8f..1ddca80 100644 --- a/tools/solarmeter/solarmeter.c +++ b/tools/solarmeter/solarmeter.c @@ -2,61 +2,49 @@ #include <unistd.h> #include <fcntl.h> #include <stdlib.h> +#include <stdint.h> -// data via stdin -// begin = 255 followed by 9 byte 8 mal i + 1 mal u -// u = input * 5/256 // u in V -// i = input / 2.099 // i in mA - -#define UFAC 5.0f/256.0f*5.6f/1.89f +// data via $1, output to STDOUT +// begin = 255 followed by 12 bytes 2*(4*i + 1*u) + PowerH:PowerL int main (int argc, char* argv[]) { - unsigned char tmp = 0; - unsigned char buffer[9]; - float pow; - float pow_sum; - int i; - int n=0; - unsigned char *outbuffer; - int outfile_fd = -1; - - if (argc > 1) - { - outfile_fd = open(argv[1], O_WRONLY | O_CREAT | O_APPEND, 0666); + u_int8_t tmp = 0; + u_int8_t buffer[12]; + u_int16_t power = 0; + + int infile_fd = -1; + if (argc > 1) { + infile_fd = open(argv[1], O_RDONLY); + if(infile_fd < 0) { + perror("open error"); + return 1; } + } else { + infile_fd = STDIN_FILENO; + } + + while (read(infile_fd, &tmp, 1) == 1) { + if (tmp == 255) { + if (read(infile_fd, &buffer, sizeof(buffer)) != sizeof(buffer)) { + perror("read error:"); + return 2; + } + + power = (buffer[10]<<8) + buffer[11]; + printf("%5d (", power); - while (read (STDIN_FILENO, &tmp, 1) == 1) - { - if (tmp == 255) - { - if (read (STDIN_FILENO, &buffer, 9) != 9) - { - printf ("read error\n"); - return 0; - } - printf ("%5.2fV", buffer[8] * UFAC); - pow_sum = 0.0f; - for (i = 0; i<8; i++) - { - pow = (buffer[i] / 2.099f) * (buffer[8] * UFAC); - printf (" %6.2fmW", pow); - pow_sum += pow; - if (outfile_fd > 0) - { - n = asprintf(&outbuffer, "%d %6.2f %6.2f\n", i, buffer[8]*UFAC, buffer[i]/2.099f); - write(outfile_fd, outbuffer , n); - free(outbuffer); - } - } - if (outfile_fd > 0) - write(outfile_fd, "\n" , 1); - printf (" %6.2fmW", pow_sum); - printf ("\r"); - } + int i; + for(i=0; i<10; i++) + printf("%3d ", buffer[i]); + + power = (((u_int16_t)buffer[0] + (u_int16_t)buffer[1] + (u_int16_t)buffer[2] + (u_int16_t)buffer[3]) * (u_int16_t)buffer[4]) + + (((u_int16_t)buffer[5] + (u_int16_t)buffer[6] + (u_int16_t)buffer[7] + (u_int16_t)buffer[8]) * (u_int16_t)buffer[9]); + + printf(") -> %5d\r", power); } - printf ("\n"); - if (outfile_fd > 0) - close(outfile_fd); - return 0; + } + printf("\n"); + + return 0; } |