From 4b39f2243d63e14569bc2c904c0e120ed60be92f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 21 Dec 2011 19:46:59 +0000 Subject: solar power calculations git-svn-id: https://svn.spreadspace.org/mur.sat@228 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- software/ihu/adc.inc | 3 +- software/ihu/ihu.asm | 27 ++++++--- software/ihu/solar.inc | 145 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 8 deletions(-) create mode 100644 software/ihu/solar.inc (limited to 'software') diff --git a/software/ihu/adc.inc b/software/ihu/adc.inc index 846f979..6d58dd2 100644 --- a/software/ihu/adc.inc +++ b/software/ihu/adc.inc @@ -170,6 +170,7 @@ adc_get_solar_v btfsc ADCON0,GO goto adc_get_solar_v movf ADRESH,w - movwf ADC_SOLAR_V + movwf ADC_SOLAR_V0 + movwf ADC_SOLAR_V1 return \ No newline at end of file diff --git a/software/ihu/ihu.asm b/software/ihu/ihu.asm index 264452b..552c213 100644 --- a/software/ihu/ihu.asm +++ b/software/ihu/ihu.asm @@ -108,13 +108,26 @@ ADC_SOLAR_C0 EQU H'0050' ADC_SOLAR_C1 EQU H'0051' ADC_SOLAR_C2 EQU H'0052' ADC_SOLAR_C3 EQU H'0053' -ADC_SOLAR_C4 EQU H'0054' -ADC_SOLAR_C5 EQU H'0055' -ADC_SOLAR_C6 EQU H'0056' -ADC_SOLAR_C7 EQU H'0057' -ADC_SOLAR_C8 EQU H'0058' -ADC_SOLAR_C9 EQU H'0059' -ADC_SOLAR_V EQU H'005A' +ADC_SOLAR_V0 EQU H'0054' +ADC_SOLAR_C4 EQU H'0055' +ADC_SOLAR_C5 EQU H'0056' +ADC_SOLAR_C6 EQU H'0057' +ADC_SOLAR_C7 EQU H'0058' +ADC_SOLAR_V1 EQU H'0059' +SOL_POWERL EQU H'005A' +SOL_POWERH EQU H'005B' + +SOL_CALC_0 EQU H'005C' +SOL_CALC_1 EQU H'005D' +SOL_CALC_2 EQU H'005E' +SOL_CALC_3 EQU H'005F' +SOL_CALC_4 EQU H'0060' +SOL_CALC_5 EQU H'0061' +SOL_CALC_6 EQU H'0062' +SOL_CALC_7 EQU H'0063' +SOL_CALC_8 EQU H'0064' +SOL_CALC_9 EQU H'0065' +SOL_CALC_CNT EQU H'0066' ;; variables ;; page 2 only diff --git a/software/ihu/solar.inc b/software/ihu/solar.inc new file mode 100644 index 0000000..c41bcc3 --- /dev/null +++ b/software/ihu/solar.inc @@ -0,0 +1,145 @@ + ;; + ;; 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 + ;; + ;; 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 . + ;; + ;; ------------------------------------- + ;; DEFINES + ;; constants +sol_calc_power_single + clrf SOL_CALC_0 + clrf SOL_CALC_1 + clrf SOL_CALC_2 + movlw .4 + movwf SOL_CALC_CNT + + ;; sum up all currents -> SOL_CALC_0:2 +sol_sum_current + movf INDF,w + addwf SOL_CALC_0,f + btfsc STATUS,C + incf SOL_CALC_1,f + incf FSR,f + decfsz SOL_CALC_CNT,f + goto sol_sum_current + + movf INDF,w + movwf SOL_CALC_9 + clrf SOL_CALC_3 + clrf SOL_CALC_4 + clrf SOL_CALC_5 + + ;; multiply SOL_CALC_0:2 with SOL_CALC_9 -> SOL_CALC_3:5 + movlw .8 + movwf SOL_CALC_CNT +sol_mula_vc + btfss SOL_CALC_9,0 + goto sol_mula_rotate + + movf SOL_CALC_0,w + addwf SOL_CALC_3,f + movlw .1 + btfss STATUS,C + addwf SOL_CALC_4,f + btfsc STATUS,C + incf SOL_CALC_5,f + + movf SOL_CALC_1,w + addwf SOL_CALC_4,f + btfsc STATUS,C + incf SOL_CALC_5,f + + movf SOL_CALC_2,w + addwf SOL_CALC_5,f + +sol_mula_rotate + rrf SOL_CALC_9,f + bcf STATUS,C + rlf SOL_CALC_0,f + rlf SOL_CALC_1,f + rlf SOL_CALC_2,f + + decfsz SOL_CALC_CNT,f + goto sol_mula_vc + + return + + ;; ------------------------------------- +solar_calc_power + movlw ADC_SOLAR_C0 + movwf FSR + call sol_calc_power_single + + ;; move SOL_CALC_3:5 -> SOL_CALC_6:8 + movf SOL_CALC_3,w + movwf SOL_CALC_6 + movf SOL_CALC_4,w + movwf SOL_CALC_7 + movf SOL_CALC_5,w + movwf SOL_CALC_8 + + 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 + movf SOL_CALC_3,w + addwf SOL_CALC_6,f + movlw .1 + btfss STATUS,C + addwf SOL_CALC_7,f + btfsc STATUS,C + incf SOL_CALC_8,f + + movf SOL_CALC_4,w + addwf SOL_CALC_7,f + btfsc STATUS,C + incf SOL_CALC_8,f + + movf SOL_CALC_5,w + addwf SOL_CALC_8,f + + ;; SOL_CALC_6:8 << 1 -> SOL_CALC_6:8 + rlf SOL_CALC_6,f + rlf SOL_CALC_7,f + rlf SOL_CALC_8,f + + ;; if(SOL_CALC_6 & 0x80) SOL_CALC_7:8+=1 + movlw .1 + btfsc SOL_CALC_6,7 + addwf SOL_CALC_7,f + btfsc STATUS,C + incf SOL_CALC_8,f + + ;; SOL_CALC_7 -> SOL_POWERL, SOL_CALC_8 -> SOL_POWERH + movf SOL_CALC_7,w + movwf SOL_POWERL + movf SOL_CALC_8,w + movwf SOL_POWERH + + return + ;; ------------------------------------- -- cgit v1.2.3