summaryrefslogtreecommitdiff
path: root/software/ihu/solar.inc
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2011-12-21 19:46:59 +0000
committerChristian Pointner <equinox@mur.at>2011-12-21 19:46:59 +0000
commit4b39f2243d63e14569bc2c904c0e120ed60be92f (patch)
tree1120c9049376f5963d444ff95afee8e872444cd4 /software/ihu/solar.inc
parentfixed header info (2011 vs. 2012) (diff)
solar power calculations
git-svn-id: https://svn.spreadspace.org/mur.sat@228 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/ihu/solar.inc')
-rw-r--r--software/ihu/solar.inc145
1 files changed, 145 insertions, 0 deletions
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 <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/>.
+ ;;
+ ;; -------------------------------------
+ ;; 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
+ ;; -------------------------------------