CCS PCM C Compiler, Version 4.106, 47914 28-4-13 16:30
Filename: c:\users\honza\documents\pic\azimut\main.lst
ROM used: 4748 words (58%)
Largest free fragment is 2048
RAM used: 19 (5%) at main() level
82 (22%) worst case
Stack: 4 locations
*
0000: MOVLW 11
0001: MOVWF 0A
0002: GOTO 1DA
0003: NOP
.................... #include "C:\Users\Honza\Documents\pic\azimut\main.h"
.................... #include <16F887.h>
.................... //////// Standard Header file for the PIC16F887 device ////////////////
.................... #device PIC16F887
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES INTRC //Internal RC Osc
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES IESO //Internal External Switch Over mode enabled
.................... #FUSES FCMEN //Fail-safe clock monitor enabled
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES BORV40 //Brownout reset at 4.0V
....................
.................... #use delay(clock=8000000)
*
01C8: MOVLW 40
01C9: MOVWF 04
01CA: BCF 03.7
01CB: MOVF 00,W
01CC: BTFSC 03.2
01CD: GOTO 1DB
01CE: MOVLW 02
01CF: MOVWF 78
01D0: CLRF 77
01D1: DECFSZ 77,F
01D2: GOTO 1D1
01D3: DECFSZ 78,F
01D4: GOTO 1D0
01D5: MOVLW 97
01D6: MOVWF 77
01D7: DECFSZ 77,F
01D8: GOTO 1D7
01D9: DECFSZ 00,F
01DA: GOTO 1CE
01DB: RETURN
....................
....................
....................
....................
....................
.................... #define PIN_SDA PIN_C4
.................... #define PIN_SCL PIN_C3
.................... #use i2c(master, sda=PIN_SDA, scl=PIN_SCL)
*
0143: MOVLW 08
0144: MOVWF 78
0145: NOP
0146: BCF 07.3
0147: BCF 20.3
0148: MOVF 20,W
0149: BSF 03.5
014A: MOVWF 07
014B: NOP
014C: BCF 03.5
014D: RLF 4E,F
014E: BCF 07.4
014F: BTFSS 03.0
0150: GOTO 157
0151: BSF 20.4
0152: MOVF 20,W
0153: BSF 03.5
0154: MOVWF 07
0155: GOTO 15B
0156: BCF 03.5
0157: BCF 20.4
0158: MOVF 20,W
0159: BSF 03.5
015A: MOVWF 07
015B: NOP
015C: BCF 03.5
015D: BSF 20.3
015E: MOVF 20,W
015F: BSF 03.5
0160: MOVWF 07
0161: BCF 03.5
0162: BTFSS 07.3
0163: GOTO 162
0164: DECFSZ 78,F
0165: GOTO 145
0166: NOP
0167: BCF 07.3
0168: BCF 20.3
0169: MOVF 20,W
016A: BSF 03.5
016B: MOVWF 07
016C: NOP
016D: BCF 03.5
016E: BSF 20.4
016F: MOVF 20,W
0170: BSF 03.5
0171: MOVWF 07
0172: NOP
0173: NOP
0174: BCF 03.5
0175: BSF 20.3
0176: MOVF 20,W
0177: BSF 03.5
0178: MOVWF 07
0179: BCF 03.5
017A: BTFSS 07.3
017B: GOTO 17A
017C: CLRF 78
017D: NOP
017E: BTFSC 07.4
017F: BSF 78.0
0180: BCF 07.3
0181: BCF 20.3
0182: MOVF 20,W
0183: BSF 03.5
0184: MOVWF 07
0185: BCF 03.5
0186: BCF 07.4
0187: BCF 20.4
0188: MOVF 20,W
0189: BSF 03.5
018A: MOVWF 07
018B: BCF 03.5
018C: RETURN
*
028D: MOVLW 08
028E: MOVWF 4F
028F: MOVF 77,W
0290: MOVWF 50
0291: BSF 20.4
0292: MOVF 20,W
0293: BSF 03.5
0294: MOVWF 07
0295: NOP
0296: BCF 03.5
0297: BSF 20.3
0298: MOVF 20,W
0299: BSF 03.5
029A: MOVWF 07
029B: BCF 03.5
029C: BTFSS 07.3
029D: GOTO 29C
029E: BTFSC 07.4
029F: BSF 03.0
02A0: BTFSS 07.4
02A1: BCF 03.0
02A2: RLF 78,F
02A3: NOP
02A4: BCF 20.3
02A5: MOVF 20,W
02A6: BSF 03.5
02A7: MOVWF 07
02A8: BCF 03.5
02A9: BCF 07.3
02AA: DECFSZ 4F,F
02AB: GOTO 291
02AC: BSF 20.4
02AD: MOVF 20,W
02AE: BSF 03.5
02AF: MOVWF 07
02B0: NOP
02B1: BCF 03.5
02B2: BCF 07.4
02B3: MOVF 50,W
02B4: BTFSC 03.2
02B5: GOTO 2BB
02B6: BCF 20.4
02B7: MOVF 20,W
02B8: BSF 03.5
02B9: MOVWF 07
02BA: BCF 03.5
02BB: NOP
02BC: BSF 20.3
02BD: MOVF 20,W
02BE: BSF 03.5
02BF: MOVWF 07
02C0: BCF 03.5
02C1: BTFSS 07.3
02C2: GOTO 2C1
02C3: NOP
02C4: BCF 07.3
02C5: BCF 20.3
02C6: MOVF 20,W
02C7: BSF 03.5
02C8: MOVWF 07
02C9: NOP
02CA: BCF 03.5
02CB: BCF 07.4
02CC: BCF 20.4
02CD: MOVF 20,W
02CE: BSF 03.5
02CF: MOVWF 07
02D0: BCF 03.5
02D1: RETURN
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD
*
00B6: BCF 20.7
00B7: MOVF 20,W
00B8: BSF 03.5
00B9: MOVWF 07
00BA: BCF 03.5
00BB: BCF 07.7
00BC: MOVLW 08
00BD: MOVWF 78
00BE: GOTO 0BF
00BF: NOP
00C0: BSF 78.7
00C1: GOTO 0D0
00C2: BCF 78.7
00C3: RRF 55,F
00C4: BTFSC 03.0
00C5: BSF 07.7
00C6: BTFSS 03.0
00C7: BCF 07.7
00C8: BSF 78.6
00C9: GOTO 0D0
00CA: BCF 78.6
00CB: DECFSZ 78,F
00CC: GOTO 0C3
00CD: GOTO 0CE
00CE: NOP
00CF: BSF 07.7
00D0: MOVLW 3F
00D1: MOVWF 04
00D2: DECFSZ 04,F
00D3: GOTO 0D2
00D4: NOP
00D5: BTFSC 78.7
00D6: GOTO 0C2
00D7: BTFSC 78.6
00D8: GOTO 0CA
00D9: RETURN
.................... #include <math.h>
.................... ////////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,2008 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ////////////////////////////////////////////////////////////////////////////
.................... //// ////
.................... //// History: ////
.................... //// * 9/20/2001 : Improvments are made to sin/cos code. ////
.................... //// The code now is small, much faster, ////
.................... //// and more accurate. ////
.................... //// * 2/21/2007 : Compiler handles & operator differently and does
.................... //// not return generic (int8 *) so type cast is done ////
.................... //// ////
.................... ////////////////////////////////////////////////////////////////////////////
....................
.................... #ifndef MATH_H
.................... #define MATH_H
....................
.................... #ifdef PI
.................... #undef PI
.................... #endif
.................... #define PI 3.1415926535897932
....................
....................
.................... #define SQRT2 1.4142135623730950
....................
.................... //float const ps[4] = {5.9304945, 21.125224, 8.9403076, 0.29730279};
.................... //float const qs[4] = {1.0000000, 15.035723, 17.764134, 2.4934718};
....................
.................... ///////////////////////////// Round Functions //////////////////////////////
....................
.................... float32 CEIL_FLOOR(float32 x, unsigned int8 n)
.................... {
.................... float32 y, res;
.................... unsigned int16 l;
.................... int1 s;
....................
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y <= 32768.0)
.................... res = (float32)(unsigned int16)y;
....................
.................... else if (y < 10000000.0)
.................... {
.................... l = (unsigned int16)(y/32768.0);
.................... y = 32768.0*(y/32768.0 - (float32)l);
.................... res = 32768.0*(float32)l;
.................... res += (float32)(unsigned int16)y;
.................... }
....................
.................... else
.................... res = y;
....................
.................... y = y - (float32)(unsigned int16)y;
....................
.................... if (s)
.................... res = -res;
....................
.................... if (y != 0)
.................... {
.................... if (s == 1 && n == 0)
.................... res -= 1.0;
....................
.................... if (s == 0 && n == 1)
.................... res += 1.0;
.................... }
.................... if (x == 0)
.................... res = 0;
....................
.................... return (res);
.................... }
....................
.................... // Overloaded Functions to take care for new Data types in PCD
.................... // Overloaded function CEIL_FLOOR() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 CEIL_FLOOR(float48 x, unsigned int8 n)
.................... {
.................... float48 y, res;
.................... unsigned int16 l;
.................... int1 s;
....................
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y <= 32768.0)
.................... res = (float48)(unsigned int16)y;
....................
.................... else if (y < 10000000.0)
.................... {
.................... l = (unsigned int16)(y/32768.0);
.................... y = 32768.0*(y/32768.0 - (float48)l);
.................... res = 32768.0*(float32)l;
.................... res += (float48)(unsigned int16)y;
.................... }
....................
.................... else
.................... res = y;
....................
.................... y = y - (float48)(unsigned int16)y;
....................
.................... if (s)
.................... res = -res;
....................
.................... if (y != 0)
.................... {
.................... if (s == 1 && n == 0)
.................... res -= 1.0;
....................
.................... if (s == 0 && n == 1)
.................... res += 1.0;
.................... }
.................... if (x == 0)
.................... res = 0;
....................
.................... return (res);
.................... }
....................
....................
.................... // Overloaded function CEIL_FLOOR() for data type - Float64
.................... float64 CEIL_FLOOR(float64 x, unsigned int8 n)
.................... {
.................... float64 y, res;
.................... unsigned int16 l;
.................... int1 s;
....................
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y <= 32768.0)
.................... res = (float64)(unsigned int16)y;
....................
.................... else if (y < 10000000.0)
.................... {
.................... l = (unsigned int16)(y/32768.0);
.................... y = 32768.0*(y/32768.0 - (float64)l);
.................... res = 32768.0*(float64)l;
.................... res += (float64)(unsigned int16)y;
.................... }
....................
.................... else
.................... res = y;
....................
.................... y = y - (float64)(unsigned int16)y;
....................
.................... if (s)
.................... res = -res;
....................
.................... if (y != 0)
.................... {
.................... if (s == 1 && n == 0)
.................... res -= 1.0;
....................
.................... if (s == 0 && n == 1)
.................... res += 1.0;
.................... }
.................... if (x == 0)
.................... res = 0;
....................
.................... return (res);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float floor(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : rounds down the number x.
.................... // Date : N/A
.................... //
.................... float32 floor(float32 x)
.................... {
.................... return CEIL_FLOOR(x, 0);
.................... }
.................... // Following 2 functions are overloaded functions of floor() for PCD
.................... // Overloaded function floor() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 floor(float48 x)
.................... {
.................... return CEIL_FLOOR(x, 0);
.................... }
....................
.................... // Overloaded function floor() for data type - Float64
.................... float64 floor(float64 x)
.................... {
.................... return CEIL_FLOOR(x, 0);
.................... }
.................... #endif
....................
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float ceil(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : rounds up the number x.
.................... // Date : N/A
.................... //
.................... float32 ceil(float32 x)
.................... {
.................... return CEIL_FLOOR(x, 1);
.................... }
.................... // Following 2 functions are overloaded functions of ceil() for PCD
.................... // Overloaded function ceil() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 ceil(float48 x)
.................... {
.................... return CEIL_FLOOR(x, 1);
.................... }
....................
.................... // Overloaded function ceil() for data type - Float64
.................... float64 ceil(float64 x)
.................... {
.................... return CEIL_FLOOR(x, 1);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float fabs(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : Computes the absolute value of floating point number x
.................... // Returns : returns the absolute value of x
.................... // Date : N/A
.................... //
.................... #define fabs abs
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float fmod(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : Computes the floating point remainder of x/y
.................... // Returns : returns the value of x= i*y, for some integer i such that, if y
.................... // is non zero, the result has the same isgn of x na dmagnitude less than the
.................... // magnitude of y. If y is zero then a domain error occurs.
.................... // Date : N/A
.................... //
....................
.................... float fmod(float32 x,float32 y)
.................... {
.................... float32 i;
.................... if (y!=0.0)
.................... {
.................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
.................... return(x-(i*y));
.................... }
.................... else
.................... {
.................... #ifdef _ERRNO
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... }
.................... }
.................... //Overloaded function for fmod() for PCD
.................... // Overloaded function fmod() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 fmod(float48 x,float48 y)
.................... {
.................... float48 i;
.................... if (y!=0.0)
.................... {
.................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
.................... return(x-(i*y));
.................... }
.................... else
.................... {
.................... #ifdef _ERRNO
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... }
.................... }
.................... // Overloaded function fmod() for data type - Float64
.................... float64 fmod(float64 x,float64 y)
.................... {
.................... float64 i;
.................... if (y!=0.0)
.................... {
.................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
.................... return(x-(i*y));
.................... }
.................... else
.................... {
.................... #ifdef _ERRNO
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... }
.................... }
.................... #endif
.................... //////////////////// Exponential and logarithmic functions ////////////////////
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float exp(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the value (e^x)
.................... // Date : N/A
.................... //
.................... #define LN2 0.6931471805599453
....................
.................... float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093,
.................... 0.0554965651, 0.240227138, 0.693147172};
....................
....................
.................... float32 exp(float32 x)
.................... {
.................... float32 y, res, r;
.................... #if defined(__PCD__)
.................... int8 data1;
.................... #endif
.................... signed int8 n;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x > 88.722838)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... n = (signed int16)(x/LN2);
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... n = -n;
.................... y = -y;
.................... }
....................
.................... res = 0.0;
.................... #if !defined(__PCD__)
.................... *((unsigned int8 *)(&res)) = n + 0x7F;
.................... #endif
....................
.................... #if defined(__PCD__) // Takes care of IEEE format for PCD
.................... data1 = n+0x7F;
.................... if(bit_test(data1,0))
.................... bit_set(*(((unsigned int8 *)(&res)+2)),7);
.................... rotate_right(&data1,1);
.................... bit_clear(data1,7);
.................... *(((unsigned int8 *)(&res)+3)) = data1;
.................... #endif
....................
.................... y = y/LN2 - (float32)n;
....................
.................... r = pe[0]*y + pe[1];
.................... r = r*y + pe[2];
.................... r = r*y + pe[3];
.................... r = r*y + pe[4];
.................... r = r*y + pe[5];
....................
.................... res = res*(1.0 + y*r);
....................
.................... if (s)
.................... res = 1.0/res;
.................... return(res);
.................... }
....................
....................
.................... //Overloaded function for exp() for PCD
.................... // Overloaded function exp() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 exp(float48 x)
.................... {
.................... float48 y, res, r;
.................... int8 data1;
.................... signed int8 n;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x > 88.722838)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... n = (signed int16)(x/LN2);
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... n = -n;
.................... y = -y;
.................... }
....................
.................... res = 0.0;
....................
.................... data1 = n+0x7F;
.................... if(bit_test(data1,0))
.................... bit_set(*(((unsigned int8 *)(&res)+4)),7);
.................... rotate_right(&data1,1);
.................... bit_clear(data1,7);
.................... *(((unsigned int8 *)(&res)+5)) = data1;
....................
.................... y = y/LN2 - (float48)n;
....................
.................... r = pe[0]*y + pe[1];
.................... r = r*y + pe[2];
.................... r = r*y + pe[3];
.................... r = r*y + pe[4];
.................... r = r*y + pe[5];
....................
.................... res = res*(1.0 + y*r);
....................
.................... if (s)
.................... res = 1.0/res;
.................... return(res);
.................... }
....................
.................... // Overloaded function exp() for data type - Float64
.................... float64 exp(float64 x)
.................... {
.................... float64 y, res, r;
.................... unsigned int16 data1, data2;
.................... unsigned int16 *p;
.................... signed int16 n;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x > 709.7827128)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... n = (signed int16)(x/LN2);
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... n = -n;
.................... y = -y;
.................... }
....................
.................... res = 0.0;
....................
.................... #if !defined(__PCD__)
.................... *((unsigned int16 *)(&res)) = n + 0x7F;
.................... #endif
.................... p= (((unsigned int16 *)(&res))+3);
.................... data1 = *p;
.................... data2 = *p;
.................... data1 = n + 0x3FF;
.................... data1 = data1 <<4;
.................... if(bit_test(data2,15))
.................... bit_set(data1,15);
.................... data2 = data2 & 0x000F;
.................... data1 ^= data2;
....................
.................... *(((unsigned int16 *)(&res)+3)) = data1;
....................
....................
.................... y = y/LN2 - (float64)n;
....................
.................... r = pe[0]*y + pe[1];
.................... r = r*y + pe[2];
.................... r = r*y + pe[3];
.................... r = r*y + pe[4];
.................... r = r*y + pe[5];
....................
.................... res = res*(1.0 + y*r);
....................
.................... if (s)
.................... res = 1.0/res;
.................... return(res);
.................... }
....................
.................... #ENDIF
....................
....................
.................... /************************************************************/
....................
.................... float32 const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
.................... float32 const ql[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float log(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the the natural log of x
.................... // Date : N/A
.................... //
.................... float32 log(float32 x)
.................... {
.................... float32 y, res, r, y2;
.................... #if defined(__PCD__)
.................... unsigned int8 data1,data2;
.................... #endif
.................... signed int8 n;
.................... #ifdef _ERRNO
.................... if(x <0)
.................... {
.................... errno=EDOM;
.................... }
.................... if(x ==0)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... y = x;
....................
.................... if (y != 1.0)
.................... {
.................... #if !defined(__PCD__)
.................... *((unsigned int8 *)(&y)) = 0x7E;
.................... #endif
....................
.................... #if defined(__PCD__) // Takes care of IEEE format
.................... data2 = *(((unsigned int8 *)(&y))+3);
.................... *(((unsigned int8 *)(&y))+3) = 0x3F;
.................... data1 = *(((unsigned int8 *)(&y))+2);
.................... bit_clear(data1,7);
.................... *(((unsigned int8 *)(&y))+2) = data1;
.................... if(bit_test(data2,7))
.................... bit_set(*(((unsigned int8 *)(&y))+3),7);
.................... #endif
....................
.................... y = (y - 1.0)/(y + 1.0);
....................
.................... y2=y*y;
....................
.................... res = pl[0]*y2 + pl[1];
.................... res = res*y2 + pl[2];
.................... res = res*y2 + pl[3];
....................
.................... r = ql[0]*y2 + ql[1];
.................... r = r*y2 + ql[2];
.................... r = r*y2 + ql[3];
....................
.................... res = y*res/r;
.................... #if !defined(__PCD__)
.................... n = *((unsigned int8 *)(&x)) - 0x7E;
.................... #endif
.................... #if defined(__PCD__)
.................... data1 = *(((unsigned int8 *)(&x)+3));
.................... rotate_left(&data1,1);
.................... data2 = *(((unsigned int8 *)(&x)+2));
.................... if(bit_test (data2,7))
.................... bit_set(data1,0);
.................... n = data1 - 0x7E;
.................... #endif
....................
.................... if (n<0)
.................... r = -(float32)-n;
.................... else
.................... r = (float32)n;
....................
.................... res += r*LN2;
.................... }
....................
.................... else
.................... res = 0.0;
....................
.................... return(res);
.................... }
....................
.................... //Overloaded function for log() for PCD
.................... // Overloaded function log() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 log(float48 x)
.................... {
.................... float48 y, res, r, y2;
.................... unsigned int8 data1,data2;
.................... signed int8 n;
.................... #ifdef _ERRNO
.................... if(x <0)
.................... {
.................... errno=EDOM;
.................... }
.................... if(x ==0)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... y = x;
....................
.................... if (y != 1.0)
.................... {
....................
.................... #if !defined(__PCD__)
.................... *((unsigned int8 *)(&y)) = 0x7E;
.................... #endif
.................... data2 = *(((unsigned int8 *)(&y))+5);
.................... *(((unsigned int8 *)(&y))+5) = 0x3F;
.................... data1 = *(((unsigned int8 *)(&y))+4);
.................... bit_clear(data1,7);
.................... *(((unsigned int8 *)(&y))+4) = data1;
....................
.................... if(bit_test(data2,7))
.................... bit_set(*(((unsigned int8 *)(&y))+4),7);
.................... y = (y - 1.0)/(y + 1.0);
....................
.................... y2=y*y;
....................
.................... res = pl[0]*y2 + pl[1];
.................... res = res*y2 + pl[2];
.................... res = res*y2 + pl[3];
....................
.................... r = ql[0]*y2 + ql[1];
.................... r = r*y2 + ql[2];
.................... r = r*y2 + ql[3];
....................
.................... res = y*res/r;
....................
.................... data1 = *(((unsigned int8 *)(&x)+5));
.................... rotate_left(&data1,1);
.................... data2 = *(((unsigned int8 *)(&x)+4));
.................... if(bit_test (data2,7))
.................... bit_set(data1,0);
....................
.................... n = data1 - 0x7E;
....................
.................... if (n<0)
.................... r = -(float48)-n;
.................... else
.................... r = (float48)n;
....................
.................... res += r*LN2;
.................... }
....................
.................... else
.................... res = 0.0;
....................
.................... return(res);
.................... }
....................
.................... // Overloaded function log() for data type - Float48
.................... #if defined(__PCD__)
.................... float32 const pl_64[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
.................... float32 const ql_64[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};
.................... #endif
.................... float64 log(float64 x)
.................... {
.................... float64 y, res, r, y2;
.................... unsigned int16 data1,data2;
.................... unsigned int16 *p;
.................... signed int16 n;
.................... #ifdef _ERRNO
.................... if(x <0)
.................... {
.................... errno=EDOM;
.................... }
.................... if(x ==0)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... y = x;
....................
.................... if (y != 1.0)
.................... {
.................... #if !defined(__PCD__)
.................... *((unsigned int8 *)(&y)) = 0x7E;
.................... #endif
.................... p= (((unsigned int16 *)(&y))+3);
.................... data1 = *p;
.................... data2 = *p;
.................... data1 = 0x3FE;
.................... data1 = data1 <<4;
.................... if(bit_test (data2,15))
.................... bit_set(data1,15);
.................... data2 = data2 & 0x000F;
.................... data1 ^=data2;
....................
.................... *p = data1;
....................
.................... y = (y - 1.0)/(y + 1.0);
....................
.................... y2=y*y;
....................
.................... res = pl_64[0]*y2 + pl_64[1];
.................... res = res*y2 + pl_64[2];
.................... res = res*y2 + pl_64[3];
....................
.................... r = ql_64[0]*y2 + ql_64[1];
.................... r = r*y2 + ql_64[2];
.................... r = r*y2 + ql_64[3];
....................
.................... res = y*res/r;
....................
.................... p= (((unsigned int16 *)(&x))+3);
.................... data1 = *p;
.................... bit_clear(data1,15);
.................... data1 = data1 >>4;
.................... n = data1 - 0x3FE;
....................
....................
.................... if (n<0)
.................... r = -(float64)-n;
.................... else
.................... r = (float64)n;
....................
.................... res += r*LN2;
.................... }
....................
.................... else
.................... res = 0.0;
....................
.................... return(res);
.................... }
.................... #endif
....................
....................
.................... #define LN10 2.3025850929940456
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float log10(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the the log base 10 of x
.................... // Date : N/A
.................... //
.................... float32 log10(float32 x)
.................... {
.................... float32 r;
....................
.................... r = log(x);
.................... r = r/LN10;
.................... return(r);
.................... }
....................
.................... //Overloaded functions for log10() for PCD
.................... // Overloaded function log10() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 log10(float48 x)
.................... {
.................... float48 r;
....................
.................... r = log(x);
.................... r = r/LN10;
.................... return(r);
.................... }
....................
.................... // Overloaded function log10() for data type - Float64
.................... float64 log10(float64 x)
.................... {
.................... float64 r;
....................
.................... r = log(x);
.................... r = r/LN10;
.................... return(r);
.................... }
.................... #endif
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float modf(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description :breaks the argument value int integral and fractional parts,
.................... // ach of which have the same sign as the argument. It stores the integral part
.................... // as a float in the object pointed to by the iptr
.................... // Returns : returns the signed fractional part of value.
.................... // Date : N/A
.................... //
....................
.................... float32 modf(float32 value,float32 *iptr)
.................... {
.................... *iptr=(value < 0.0)? ceil(value): floor(value);
.................... return(value - *iptr);
.................... }
.................... //Overloaded functions for modf() for PCD
.................... // Overloaded function modf() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 modf(float48 value,float48 *iptr)
.................... {
.................... *iptr=(value < 0.0)? ceil(value): floor(value);
.................... return(value - *iptr);
.................... }
.................... // Overloaded function modf() for data type - Float64
.................... float64 modf(float64 value,float64 *iptr)
.................... {
.................... *iptr=(value < 0.0)? ceil(value): floor(value);
.................... return(value - *iptr);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float pwr(float x,float y)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the value (x^y)
.................... // Date : N/A
.................... // Note : 0 is returned when the function will generate an imaginary number
.................... //
.................... float32 pwr(float32 x,float32 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... //Overloaded functions for pwr() for PCD
.................... // Overloaded function pwr() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 pwr(float48 x,float48 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... // Overloaded function pwr() for data type - Float64
.................... float64 pwr(float64 x,float64 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... #endif
....................
.................... //////////////////// Power functions ////////////////////
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float pow(float x,float y)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the value (x^y)
.................... // Date : N/A
.................... // Note : 0 is returned when the function will generate an imaginary number
.................... //
.................... float32 pow(float32 x,float32 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... //Overloaded functions for pow() for PCD
.................... // Overloaded function for pow() data type - Float48
.................... #if defined(__PCD__)
.................... float48 pow(float48 x,float48 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
....................
.................... // Overloaded function pow() for data type - Float64
.................... float64 pow(float64 x,float64 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float sqrt(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the square root of x
.................... // Date : N/A
.................... //
.................... float32 sqrt(float32 x)
.................... {
.................... float32 y, res;
.................... #if defined(__PCD__)
.................... unsigned int16 data1,data2;
.................... #endif
.................... BYTE *p;
....................
.................... #ifdef _ERRNO
.................... if(x < 0)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
....................
.................... if( x<=0.0)
.................... return(0.0);
....................
.................... y=x;
....................
.................... #if !defined(__PCD__)
.................... p=&y;
.................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
.................... #endif
....................
.................... #if defined(__PCD__)
.................... p = (((unsigned int8 *)(&y))+3);
.................... data1 = *(((unsigned int8 *)(&y))+3);
.................... data2 = *(((unsigned int8 *)(&y))+2);
.................... rotate_left(&data1,1);
.................... if(bit_test(data2,7))
.................... bit_set(data1,0);
.................... data1 = ((data1+127) >>1);
.................... bit_clear(data2,7);
.................... if(bit_test(data1,0))
.................... bit_set(data2,7);
.................... data1 = data1 >>1;
.................... *(((unsigned int8 *)(&y))+3) = data1;
.................... *(((unsigned int8 *)(&y))+2) = data2;
....................
.................... #endif
....................
.................... do {
.................... res=y;
.................... y+=(x/y);
....................
.................... #if !defined(__PCD__)
.................... (*p)--;
.................... #endif
....................
.................... #if defined(__PCD__)
.................... data1 = *(((unsigned int8 *)(&y))+3);
.................... data2 = *(((unsigned int8 *)(&y))+2);
.................... rotate_left(&data1,1);
.................... if(bit_test(data2,7))
.................... bit_set(data1,0);
.................... data1--;
.................... bit_clear(data2,7);
.................... if(bit_test(data1,0))
.................... bit_set(data2,7);
.................... data1 = data1 >>1;
.................... *(((unsigned int8 *)(&y))+3) = data1;
.................... *(((unsigned int8 *)(&y))+2) = data2;
....................
.................... #endif
.................... } while(res != y);
....................
.................... return(res);
.................... }
.................... //Overloaded functions for sqrt() for PCD
.................... // Overloaded function sqrt() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 sqrt(float48 x)
.................... {
.................... float48 y, res;
.................... unsigned int16 data1,data2;
.................... BYTE *p;
....................
.................... #ifdef _ERRNO
.................... if(x < 0)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
....................
.................... if( x<=0.0)
.................... return(0.0);
....................
.................... y=x;
....................
.................... #if !defined(__PCD__)
.................... p=&y;
.................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
.................... #endif
....................
.................... #if defined(__PCD__)
.................... p = (((unsigned int8 *)(&y))+5);
.................... data1 = *(((unsigned int8 *)(&y))+5);
.................... data2 = *(((unsigned int8 *)(&y))+4);
.................... rotate_left(&data1,1);
.................... if(bit_test(data2,7))
.................... bit_set(data1,0);
.................... data1 = ((data1+127) >>1);
.................... bit_clear(data2,7);
.................... if(bit_test(data1,0))
.................... bit_set(data2,7);
.................... data1 = data1 >>1;
.................... *(((unsigned int8 *)(&y))+5) = data1;
.................... *(((unsigned int8 *)(&y))+4) = data2;
....................
.................... #endif
....................
.................... do {
.................... res=y;
.................... y+=(x/y);
....................
.................... #if !defined(__PCD__)
.................... (*p)--;
.................... #endif
....................
.................... data1 = *(((unsigned int8 *)(&y))+5);
.................... data2 = *(((unsigned int8 *)(&y))+4);
.................... rotate_left(&data1,1);
.................... if(bit_test(data2,7))
.................... bit_set(data1,0);
.................... data1--;
.................... bit_clear(data2,7);
.................... if(bit_test(data1,0))
.................... bit_set(data2,7);
.................... data1 = data1 >>1;
.................... *(((unsigned int8 *)(&y))+5) = data1;
.................... *(((unsigned int8 *)(&y))+4) = data2;
....................
.................... } while(res != y);
....................
.................... return(res);
.................... }
....................
.................... // Overloaded function sqrt() for data type - Float64
.................... float64 sqrt(float64 x)
.................... {
.................... float64 y, res;
.................... unsigned int16 *p;
.................... unsigned int16 temp1,temp2;
....................
.................... #ifdef _ERRNO
.................... if(x < 0)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
....................
.................... if( x<=0.0)
.................... return(0.0);
....................
.................... y=x;
.................... p= (((unsigned int16 *)(&y))+3);
.................... temp1 = *p;
.................... temp2 = *p;
.................... bit_clear(temp1,15);
.................... temp1 = (temp1>>4)+1023;
.................... temp1 = temp1 >> 1;
.................... temp1 = (temp1<<4) & 0xFFF0;
.................... if(bit_test(temp2,15))
.................... bit_set(temp1,15);
.................... temp2 = temp2 & 0x000F;
.................... temp1 ^= temp2;
....................
.................... (*p) = temp1;
....................
.................... do {
.................... res=y;
.................... y+=(x/y);
.................... temp1 = *p;
.................... temp2 = *p;
.................... bit_clear(temp1,15);
.................... temp1 = (temp1>>4);
.................... temp1--;
.................... temp1 = (temp1<<4) & 0xFFF0;
.................... if(bit_test(temp2,15))
.................... bit_set(temp1,15);
.................... temp2 = temp2 & 0x000F;
.................... temp1 ^= temp2;
.................... (*p) = temp1;
....................
.................... } while(res != y);
....................
.................... return(res);
.................... }
.................... #endif
....................
.................... ////////////////////////////// Trig Functions //////////////////////////////
.................... #ifdef PI_DIV_BY_TWO
.................... #undef PI_DIV_BY_TWO
.................... #endif
.................... #define PI_DIV_BY_TWO 1.5707963267948966
.................... #ifdef TWOBYPI
.................... #undef TWOBYPI
.................... #define TWOBYPI 0.6366197723675813
.................... #endif
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float cos(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the cosine value of the angle x, which is in radian
.................... // Date : 9/20/2001
.................... //
.................... float32 cos(float32 x)
.................... {
.................... float32 y, t, t2 = 1.0;
.................... unsigned int8 quad, i;
.................... float32 frac;
.................... float32 p[6] = { //by the series definition for cosine
.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
.................... 0.04166666666667,
.................... -0.00138888888889,
.................... 0.00002480158730,
.................... -0.00000027557319,
.................... 0.00000000208767,
.................... //-0.00000000001147,
.................... // 0.00000000000005
.................... };
....................
.................... if (x < 0) x = -x; // absolute value of input
....................
.................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
.................... quad = quad % 4; // quadrant (0 to 3)
....................
.................... if (quad == 0 || quad == 2)
.................... t = frac * PI_DIV_BY_TWO;
.................... else if (quad == 1)
.................... t = (1-frac) * PI_DIV_BY_TWO;
.................... else // should be 3
.................... t = (frac-1) * PI_DIV_BY_TWO;
....................
.................... y = 1.0;
.................... t = t * t;
.................... for (i = 0; i <= 5; i++)
.................... {
.................... t2 = t2 * t;
.................... y = y + p[i] * t2;
.................... }
....................
.................... if (quad == 2 || quad == 1)
.................... y = -y; // correct sign
....................
.................... return (y);
.................... }
....................
....................
.................... //Overloaded functions for cos() for PCD
.................... // Overloaded function cos() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 cos(float48 x)
.................... {
.................... float48 y, t, t2 = 1.0;
.................... unsigned int8 quad, i;
.................... float48 frac;
.................... float48 p[6] = { //by the series definition for cosine
.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
.................... 0.04166666666667,
.................... -0.00138888888889,
.................... 0.00002480158730,
.................... -0.00000027557319,
.................... 0.00000000208767,
.................... //-0.00000000001147,
.................... // 0.00000000000005
.................... };
....................
.................... if (x < 0) x = -x; // absolute value of input
....................
.................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
.................... quad = quad % 4; // quadrant (0 to 3)
....................
.................... if (quad == 0 || quad == 2)
.................... t = frac * PI_DIV_BY_TWO;
.................... else if (quad == 1)
.................... t = (1-frac) * PI_DIV_BY_TWO;
.................... else // should be 3
.................... t = (frac-1) * PI_DIV_BY_TWO;
....................
.................... y = 0.999999999781;
.................... t = t * t;
.................... for (i = 0; i <= 5; i++)
.................... {
.................... t2 = t2 * t;
.................... y = y + p[i] * t2;
.................... }
....................
.................... if (quad == 2 || quad == 1)
.................... y = -y; // correct sign
....................
.................... return (y);
.................... }
....................
.................... // Overloaded function cos() for data type - Float48
.................... float64 cos(float64 x)
.................... {
.................... float64 y, t, t2 = 1.0;
.................... unsigned int8 quad, i;
.................... float64 frac;
.................... float64 p[6] = { //by the series definition for cosine
.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
.................... 0.04166666666667,
.................... -0.00138888888889,
.................... 0.00002480158730,
.................... -0.00000027557319,
.................... 0.00000000208767,
.................... //-0.00000000001147,
.................... // 0.00000000000005
.................... };
....................
.................... if (x < 0) x = -x; // absolute value of input
....................
.................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
.................... quad = quad % 4; // quadrant (0 to 3)
....................
.................... if (quad == 0 || quad == 2)
.................... t = frac * PI_DIV_BY_TWO;
.................... else if (quad == 1)
.................... t = (1-frac) * PI_DIV_BY_TWO;
.................... else // should be 3
.................... t = (frac-1) * PI_DIV_BY_TWO;
....................
.................... y = 0.999999999781;
.................... t = t * t;
.................... for (i = 0; i <= 5; i++)
.................... {
.................... t2 = t2 * t;
.................... y = y + p[i] * t2;
.................... }
....................
.................... if (quad == 2 || quad == 1)
.................... y = -y; // correct sign
....................
.................... return (y);
.................... }
....................
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float sin(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the sine value of the angle x, which is in radian
.................... // Date : 9/20/2001
.................... //
.................... float32 sin(float32 x)
.................... {
.................... return cos(x - PI_DIV_BY_TWO);
.................... }
....................
.................... //Overloaded functions for sin() for PCD
.................... // Overloaded function sin() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 sin(float48 x)
.................... {
.................... return cos(x - PI_DIV_BY_TWO);
.................... }
....................
.................... // Overloaded function sin() for data type - Float48
.................... float64 sin(float64 x)
.................... {
.................... return cos(x - PI_DIV_BY_TWO);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float tan(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the tangent value of the angle x, which is in radian
.................... // Date : 9/20/2001
.................... //
.................... float32 tan(float32 x)
.................... {
.................... float32 c, s;
....................
.................... c = cos(x);
.................... if (c == 0.0)
.................... return (1.0e+36);
....................
.................... s = sin(x);
.................... return(s/c);
.................... }
.................... //Overloaded functions for tan() for PCD
.................... // Overloaded function tan() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 tan(float48 x)
.................... {
.................... float48 c, s;
....................
.................... c = cos(x);
.................... if (c == 0.0)
.................... return (1.0e+36);
....................
.................... s = sin(x);
.................... return(s/c);
.................... }
....................
.................... // Overloaded function tan() for data type - Float48
.................... float64 tan(float64 x)
.................... {
.................... float64 c, s;
....................
.................... c = cos(x);
.................... if (c == 0.0)
.................... return (1.0e+36);
....................
.................... s = sin(x);
.................... return(s/c);
.................... }
.................... #endif
....................
.................... float32 const pas[3] = {0.49559947, -4.6145309, 5.6036290};
.................... float32 const qas[3] = {1.0000000, -5.5484666, 5.6036290};
....................
.................... float32 ASIN_COS(float32 x, unsigned int8 n)
.................... {
.................... float32 y, res, r, y2;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x <-1 || x > 1)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 0.5)
.................... {
.................... y = sqrt((1.0 - y)/2.0);
.................... n += 2;
.................... }
....................
.................... y2=y*y;
....................
.................... res = pas[0]*y2 + pas[1];
.................... res = res*y2 + pas[2];
....................
.................... r = qas[0]*y2 + qas[1];
.................... r = r*y2 + qas[2];
....................
.................... res = y*res/r;
....................
.................... if (n & 2) // |x| > 0.5
.................... res = PI_DIV_BY_TWO - 2.0*res;
.................... if (s)
.................... res = -res;
.................... if (n & 1) // take arccos
.................... res = PI_DIV_BY_TWO - res;
....................
.................... return(res);
.................... }
....................
.................... //Overloaded functions for ASIN_COS() for PCD
.................... // Overloaded function ASIN_COS() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 ASIN_COS(float48 x, unsigned int8 n)
.................... {
.................... float48 y, res, r, y2;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x <-1 || x > 1)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 0.5)
.................... {
.................... y = sqrt((1.0 - y)/2.0);
.................... n += 2;
.................... }
....................
.................... y2=y*y;
....................
.................... res = pas[0]*y2 + pas[1];
.................... res = res*y2 + pas[2];
....................
.................... r = qas[0]*y2 + qas[1];
.................... r = r*y2 + qas[2];
....................
.................... res = y*res/r;
....................
.................... if (n & 2) // |x| > 0.5
.................... res = PI_DIV_BY_TWO - 2.0*res;
.................... if (s)
.................... res = -res;
.................... if (n & 1) // take arccos
.................... res = PI_DIV_BY_TWO - res;
....................
.................... return(res);
.................... }
....................
.................... // Overloaded function ASIN_COS() for data type - Float64
.................... float64 ASIN_COS(float64 x, unsigned int8 n)
.................... {
.................... float64 y, res, r, y2;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x <-1 || x > 1)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 0.5)
.................... {
.................... y = sqrt((1.0 - y)/2.0);
.................... n += 2;
.................... }
....................
.................... y2=y*y;
....................
.................... res = pas[0]*y2 + pas[1];
.................... res = res*y2 + pas[2];
....................
.................... r = qas[0]*y2 + qas[1];
.................... r = r*y2 + qas[2];
....................
.................... res = y*res/r;
....................
.................... if (n & 2) // |x| > 0.5
.................... res = PI_DIV_BY_TWO - 2.0*res;
.................... if (s)
.................... res = -res;
.................... if (n & 1) // take arccos
.................... res = PI_DIV_BY_TWO - res;
....................
.................... return(res);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float asin(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the arcsine value of the value x.
.................... // Date : N/A
.................... //
.................... float32 asin(float32 x)
.................... {
.................... float32 r;
....................
.................... r = ASIN_COS(x, 0);
.................... return(r);
.................... }
.................... //Overloaded functions for asin() for PCD
.................... // Overloaded function asin() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 asin(float48 x)
.................... {
.................... float48 r;
....................
.................... r = ASIN_COS(x, 0);
.................... return(r);
.................... }
....................
.................... // Overloaded function asin() for data type - Float64
.................... float64 asin(float64 x)
.................... {
.................... float64 r;
....................
.................... r = ASIN_COS(x, 0);
.................... return(r);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float acos(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the arccosine value of the value x.
.................... // Date : N/A
.................... //
.................... float32 acos(float32 x)
.................... {
.................... float32 r;
....................
.................... r = ASIN_COS(x, 1);
.................... return(r);
.................... }
.................... //Overloaded functions for acos() for PCD
.................... // Overloaded function acos() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 acos(float48 x)
.................... {
.................... float48 r;
....................
.................... r = ASIN_COS(x, 1);
.................... return(r);
.................... }
....................
.................... // Overloaded function acos() for data type - Float64
.................... float64 acos(float64 x)
.................... {
.................... float64 r;
....................
.................... r = ASIN_COS(x, 1);
.................... return(r);
.................... }
.................... #endif
....................
.................... float32 const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457};
.................... float32 const qat[4] = {1.0000000, 11.368190, 28.982246, 19.818457};
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float atan(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the arctangent value of the value x.
.................... // Date : N/A
.................... //
.................... float32 atan(float32 x)
.................... {
.................... float32 y, res, r;
.................... int1 s, flag;
....................
.................... s = 0;
*
0800: BCF 58.0
.................... flag = 0;
0801: BCF 58.1
.................... y = x;
0802: MOVF 4B,W
0803: MOVWF 4F
0804: MOVF 4A,W
0805: MOVWF 4E
0806: MOVF 49,W
0807: MOVWF 4D
0808: MOVF 48,W
0809: MOVWF 4C
....................
.................... if (x < 0)
080A: MOVF 4B,W
080B: MOVWF 5C
080C: MOVF 4A,W
080D: MOVWF 5B
080E: MOVF 49,W
080F: MOVWF 5A
0810: MOVF 48,W
0811: MOVWF 59
0812: CLRF 60
0813: CLRF 5F
0814: CLRF 5E
0815: CLRF 5D
0816: BCF 0A.3
0817: CALL 4CE
0818: BSF 0A.3
0819: BTFSS 03.0
081A: GOTO 01F
.................... {
.................... s = 1;
081B: BSF 58.0
.................... y = -y;
081C: MOVF 4D,W
081D: XORLW 80
081E: MOVWF 4D
.................... }
....................
.................... if (y > 1.0)
081F: CLRF 5C
0820: CLRF 5B
0821: CLRF 5A
0822: MOVLW 7F
0823: MOVWF 59
0824: MOVF 4F,W
0825: MOVWF 60
0826: MOVF 4E,W
0827: MOVWF 5F
0828: MOVF 4D,W
0829: MOVWF 5E
082A: MOVF 4C,W
082B: MOVWF 5D
082C: BCF 0A.3
082D: CALL 4CE
082E: BSF 0A.3
082F: BTFSS 03.0
0830: GOTO 04A
.................... {
.................... y = 1.0/y;
0831: CLRF 60
0832: CLRF 5F
0833: CLRF 5E
0834: MOVLW 7F
0835: MOVWF 5D
0836: MOVF 4F,W
0837: MOVWF 64
0838: MOVF 4E,W
0839: MOVWF 63
083A: MOVF 4D,W
083B: MOVWF 62
083C: MOVF 4C,W
083D: MOVWF 61
083E: BCF 0A.3
083F: CALL 404
0840: BSF 0A.3
0841: MOVF 7A,W
0842: MOVWF 4F
0843: MOVF 79,W
0844: MOVWF 4E
0845: MOVF 78,W
0846: MOVWF 4D
0847: MOVF 77,W
0848: MOVWF 4C
.................... flag = 1;
0849: BSF 58.1
.................... }
....................
.................... res = pat[0]*y*y + pat[1];
084A: MOVLW 0A
084B: MOVWF 60
084C: MOVLW 89
084D: MOVWF 5F
084E: MOVLW 34
084F: MOVWF 5E
0850: MOVLW 7C
0851: MOVWF 5D
0852: MOVF 4F,W
0853: MOVWF 64
0854: MOVF 4E,W
0855: MOVWF 63
0856: MOVF 4D,W
0857: MOVWF 62
0858: MOVF 4C,W
0859: MOVWF 61
085A: BCF 0A.3
085B: CALL 50D
085C: BSF 0A.3
085D: MOVF 77,W
085E: MOVWF 59
085F: MOVF 78,W
0860: MOVWF 5A
0861: MOVF 79,W
0862: MOVWF 5B
0863: MOVF 7A,W
0864: MOVWF 5C
0865: MOVWF 60
0866: MOVF 5B,W
0867: MOVWF 5F
0868: MOVF 5A,W
0869: MOVWF 5E
086A: MOVF 59,W
086B: MOVWF 5D
086C: MOVF 4F,W
086D: MOVWF 64
086E: MOVF 4E,W
086F: MOVWF 63
0870: MOVF 4D,W
0871: MOVWF 62
0872: MOVF 4C,W
0873: MOVWF 61
0874: BCF 0A.3
0875: CALL 50D
0876: BSF 0A.3
0877: MOVF 77,W
0878: MOVWF 59
0879: MOVF 78,W
087A: MOVWF 5A
087B: MOVF 79,W
087C: MOVWF 5B
087D: MOVF 7A,W
087E: MOVWF 5C
087F: BCF 03.1
0880: MOVF 5C,W
0881: MOVWF 60
0882: MOVF 5B,W
0883: MOVWF 5F
0884: MOVF 5A,W
0885: MOVWF 5E
0886: MOVF 59,W
0887: MOVWF 5D
0888: MOVLW 7C
0889: MOVWF 64
088A: MOVLW 79
088B: MOVWF 63
088C: MOVLW 35
088D: MOVWF 62
088E: MOVLW 81
088F: MOVWF 61
0890: BCF 0A.3
0891: CALL 582
0892: BSF 0A.3
0893: MOVF 7A,W
0894: MOVWF 53
0895: MOVF 79,W
0896: MOVWF 52
0897: MOVF 78,W
0898: MOVWF 51
0899: MOVF 77,W
089A: MOVWF 50
.................... res = res*y*y + pat[2];
089B: MOVF 53,W
089C: MOVWF 60
089D: MOVF 52,W
089E: MOVWF 5F
089F: MOVF 51,W
08A0: MOVWF 5E
08A1: MOVF 50,W
08A2: MOVWF 5D
08A3: MOVF 4F,W
08A4: MOVWF 64
08A5: MOVF 4E,W
08A6: MOVWF 63
08A7: MOVF 4D,W
08A8: MOVWF 62
08A9: MOVF 4C,W
08AA: MOVWF 61
08AB: BCF 0A.3
08AC: CALL 50D
08AD: BSF 0A.3
08AE: MOVF 77,W
08AF: MOVWF 59
08B0: MOVF 78,W
08B1: MOVWF 5A
08B2: MOVF 79,W
08B3: MOVWF 5B
08B4: MOVF 7A,W
08B5: MOVWF 5C
08B6: MOVWF 60
08B7: MOVF 5B,W
08B8: MOVWF 5F
08B9: MOVF 5A,W
08BA: MOVWF 5E
08BB: MOVF 59,W
08BC: MOVWF 5D
08BD: MOVF 4F,W
08BE: MOVWF 64
08BF: MOVF 4E,W
08C0: MOVWF 63
08C1: MOVF 4D,W
08C2: MOVWF 62
08C3: MOVF 4C,W
08C4: MOVWF 61
08C5: BCF 0A.3
08C6: CALL 50D
08C7: BSF 0A.3
08C8: MOVF 77,W
08C9: MOVWF 59
08CA: MOVF 78,W
08CB: MOVWF 5A
08CC: MOVF 79,W
08CD: MOVWF 5B
08CE: MOVF 7A,W
08CF: MOVWF 5C
08D0: BCF 03.1
08D1: MOVF 5C,W
08D2: MOVWF 60
08D3: MOVF 5B,W
08D4: MOVWF 5F
08D5: MOVF 5A,W
08D6: MOVWF 5E
08D7: MOVF 59,W
08D8: MOVWF 5D
08D9: MOVLW 3F
08DA: MOVWF 64
08DB: MOVLW 02
08DC: MOVWF 63
08DD: MOVLW 33
08DE: MOVWF 62
08DF: MOVLW 83
08E0: MOVWF 61
08E1: BCF 0A.3
08E2: CALL 582
08E3: BSF 0A.3
08E4: MOVF 7A,W
08E5: MOVWF 53
08E6: MOVF 79,W
08E7: MOVWF 52
08E8: MOVF 78,W
08E9: MOVWF 51
08EA: MOVF 77,W
08EB: MOVWF 50
.................... res = res*y*y + pat[3];
08EC: MOVF 53,W
08ED: MOVWF 60
08EE: MOVF 52,W
08EF: MOVWF 5F
08F0: MOVF 51,W
08F1: MOVWF 5E
08F2: MOVF 50,W
08F3: MOVWF 5D
08F4: MOVF 4F,W
08F5: MOVWF 64
08F6: MOVF 4E,W
08F7: MOVWF 63
08F8: MOVF 4D,W
08F9: MOVWF 62
08FA: MOVF 4C,W
08FB: MOVWF 61
08FC: BCF 0A.3
08FD: CALL 50D
08FE: BSF 0A.3
08FF: MOVF 77,W
0900: MOVWF 59
0901: MOVF 78,W
0902: MOVWF 5A
0903: MOVF 79,W
0904: MOVWF 5B
0905: MOVF 7A,W
0906: MOVWF 5C
0907: MOVWF 60
0908: MOVF 5B,W
0909: MOVWF 5F
090A: MOVF 5A,W
090B: MOVWF 5E
090C: MOVF 59,W
090D: MOVWF 5D
090E: MOVF 4F,W
090F: MOVWF 64
0910: MOVF 4E,W
0911: MOVWF 63
0912: MOVF 4D,W
0913: MOVWF 62
0914: MOVF 4C,W
0915: MOVWF 61
0916: BCF 0A.3
0917: CALL 50D
0918: BSF 0A.3
0919: MOVF 77,W
091A: MOVWF 59
091B: MOVF 78,W
091C: MOVWF 5A
091D: MOVF 79,W
091E: MOVWF 5B
091F: MOVF 7A,W
0920: MOVWF 5C
0921: BCF 03.1
0922: MOVF 5C,W
0923: MOVWF 60
0924: MOVF 5B,W
0925: MOVWF 5F
0926: MOVF 5A,W
0927: MOVWF 5E
0928: MOVF 59,W
0929: MOVWF 5D
092A: MOVLW 33
092B: MOVWF 64
092C: MOVLW 8C
092D: MOVWF 63
092E: MOVLW 1E
092F: MOVWF 62
0930: MOVLW 83
0931: MOVWF 61
0932: BCF 0A.3
0933: CALL 582
0934: BSF 0A.3
0935: MOVF 7A,W
0936: MOVWF 53
0937: MOVF 79,W
0938: MOVWF 52
0939: MOVF 78,W
093A: MOVWF 51
093B: MOVF 77,W
093C: MOVWF 50
....................
.................... r = qat[0]*y*y + qat[1];
093D: CLRF 60
093E: CLRF 5F
093F: CLRF 5E
0940: MOVLW 7F
0941: MOVWF 5D
0942: MOVF 4F,W
0943: MOVWF 64
0944: MOVF 4E,W
0945: MOVWF 63
0946: MOVF 4D,W
0947: MOVWF 62
0948: MOVF 4C,W
0949: MOVWF 61
094A: BCF 0A.3
094B: CALL 50D
094C: BSF 0A.3
094D: MOVF 77,W
094E: MOVWF 59
094F: MOVF 78,W
0950: MOVWF 5A
0951: MOVF 79,W
0952: MOVWF 5B
0953: MOVF 7A,W
0954: MOVWF 5C
0955: MOVWF 60
0956: MOVF 5B,W
0957: MOVWF 5F
0958: MOVF 5A,W
0959: MOVWF 5E
095A: MOVF 59,W
095B: MOVWF 5D
095C: MOVF 4F,W
095D: MOVWF 64
095E: MOVF 4E,W
095F: MOVWF 63
0960: MOVF 4D,W
0961: MOVWF 62
0962: MOVF 4C,W
0963: MOVWF 61
0964: BCF 0A.3
0965: CALL 50D
0966: BSF 0A.3
0967: MOVF 77,W
0968: MOVWF 59
0969: MOVF 78,W
096A: MOVWF 5A
096B: MOVF 79,W
096C: MOVWF 5B
096D: MOVF 7A,W
096E: MOVWF 5C
096F: BCF 03.1
0970: MOVF 5C,W
0971: MOVWF 60
0972: MOVF 5B,W
0973: MOVWF 5F
0974: MOVF 5A,W
0975: MOVWF 5E
0976: MOVF 59,W
0977: MOVWF 5D
0978: MOVLW 1B
0979: MOVWF 64
097A: MOVLW E4
097B: MOVWF 63
097C: MOVLW 35
097D: MOVWF 62
097E: MOVLW 82
097F: MOVWF 61
0980: BCF 0A.3
0981: CALL 582
0982: BSF 0A.3
0983: MOVF 7A,W
0984: MOVWF 57
0985: MOVF 79,W
0986: MOVWF 56
0987: MOVF 78,W
0988: MOVWF 55
0989: MOVF 77,W
098A: MOVWF 54
.................... r = r*y*y + qat[2];
098B: MOVF 57,W
098C: MOVWF 60
098D: MOVF 56,W
098E: MOVWF 5F
098F: MOVF 55,W
0990: MOVWF 5E
0991: MOVF 54,W
0992: MOVWF 5D
0993: MOVF 4F,W
0994: MOVWF 64
0995: MOVF 4E,W
0996: MOVWF 63
0997: MOVF 4D,W
0998: MOVWF 62
0999: MOVF 4C,W
099A: MOVWF 61
099B: BCF 0A.3
099C: CALL 50D
099D: BSF 0A.3
099E: MOVF 77,W
099F: MOVWF 59
09A0: MOVF 78,W
09A1: MOVWF 5A
09A2: MOVF 79,W
09A3: MOVWF 5B
09A4: MOVF 7A,W
09A5: MOVWF 5C
09A6: MOVWF 60
09A7: MOVF 5B,W
09A8: MOVWF 5F
09A9: MOVF 5A,W
09AA: MOVWF 5E
09AB: MOVF 59,W
09AC: MOVWF 5D
09AD: MOVF 4F,W
09AE: MOVWF 64
09AF: MOVF 4E,W
09B0: MOVWF 63
09B1: MOVF 4D,W
09B2: MOVWF 62
09B3: MOVF 4C,W
09B4: MOVWF 61
09B5: BCF 0A.3
09B6: CALL 50D
09B7: BSF 0A.3
09B8: MOVF 77,W
09B9: MOVWF 59
09BA: MOVF 78,W
09BB: MOVWF 5A
09BC: MOVF 79,W
09BD: MOVWF 5B
09BE: MOVF 7A,W
09BF: MOVWF 5C
09C0: BCF 03.1
09C1: MOVF 5C,W
09C2: MOVWF 60
09C3: MOVF 5B,W
09C4: MOVWF 5F
09C5: MOVF 5A,W
09C6: MOVWF 5E
09C7: MOVF 59,W
09C8: MOVWF 5D
09C9: MOVLW A4
09CA: MOVWF 64
09CB: MOVLW DB
09CC: MOVWF 63
09CD: MOVLW 67
09CE: MOVWF 62
09CF: MOVLW 83
09D0: MOVWF 61
09D1: BCF 0A.3
09D2: CALL 582
09D3: BSF 0A.3
09D4: MOVF 7A,W
09D5: MOVWF 57
09D6: MOVF 79,W
09D7: MOVWF 56
09D8: MOVF 78,W
09D9: MOVWF 55
09DA: MOVF 77,W
09DB: MOVWF 54
.................... r = r*y*y + qat[3];
09DC: MOVF 57,W
09DD: MOVWF 60
09DE: MOVF 56,W
09DF: MOVWF 5F
09E0: MOVF 55,W
09E1: MOVWF 5E
09E2: MOVF 54,W
09E3: MOVWF 5D
09E4: MOVF 4F,W
09E5: MOVWF 64
09E6: MOVF 4E,W
09E7: MOVWF 63
09E8: MOVF 4D,W
09E9: MOVWF 62
09EA: MOVF 4C,W
09EB: MOVWF 61
09EC: BCF 0A.3
09ED: CALL 50D
09EE: BSF 0A.3
09EF: MOVF 77,W
09F0: MOVWF 59
09F1: MOVF 78,W
09F2: MOVWF 5A
09F3: MOVF 79,W
09F4: MOVWF 5B
09F5: MOVF 7A,W
09F6: MOVWF 5C
09F7: MOVWF 60
09F8: MOVF 5B,W
09F9: MOVWF 5F
09FA: MOVF 5A,W
09FB: MOVWF 5E
09FC: MOVF 59,W
09FD: MOVWF 5D
09FE: MOVF 4F,W
09FF: MOVWF 64
0A00: MOVF 4E,W
0A01: MOVWF 63
0A02: MOVF 4D,W
0A03: MOVWF 62
0A04: MOVF 4C,W
0A05: MOVWF 61
0A06: BCF 0A.3
0A07: CALL 50D
0A08: BSF 0A.3
0A09: MOVF 77,W
0A0A: MOVWF 59
0A0B: MOVF 78,W
0A0C: MOVWF 5A
0A0D: MOVF 79,W
0A0E: MOVWF 5B
0A0F: MOVF 7A,W
0A10: MOVWF 5C
0A11: BCF 03.1
0A12: MOVF 5C,W
0A13: MOVWF 60
0A14: MOVF 5B,W
0A15: MOVWF 5F
0A16: MOVF 5A,W
0A17: MOVWF 5E
0A18: MOVF 59,W
0A19: MOVWF 5D
0A1A: MOVLW 33
0A1B: MOVWF 64
0A1C: MOVLW 8C
0A1D: MOVWF 63
0A1E: MOVLW 1E
0A1F: MOVWF 62
0A20: MOVLW 83
0A21: MOVWF 61
0A22: BCF 0A.3
0A23: CALL 582
0A24: BSF 0A.3
0A25: MOVF 7A,W
0A26: MOVWF 57
0A27: MOVF 79,W
0A28: MOVWF 56
0A29: MOVF 78,W
0A2A: MOVWF 55
0A2B: MOVF 77,W
0A2C: MOVWF 54
....................
.................... res = y*res/r;
0A2D: MOVF 4F,W
0A2E: MOVWF 60
0A2F: MOVF 4E,W
0A30: MOVWF 5F
0A31: MOVF 4D,W
0A32: MOVWF 5E
0A33: MOVF 4C,W
0A34: MOVWF 5D
0A35: MOVF 53,W
0A36: MOVWF 64
0A37: MOVF 52,W
0A38: MOVWF 63
0A39: MOVF 51,W
0A3A: MOVWF 62
0A3B: MOVF 50,W
0A3C: MOVWF 61
0A3D: BCF 0A.3
0A3E: CALL 50D
0A3F: BSF 0A.3
0A40: MOVF 77,W
0A41: MOVWF 59
0A42: MOVF 78,W
0A43: MOVWF 5A
0A44: MOVF 79,W
0A45: MOVWF 5B
0A46: MOVF 7A,W
0A47: MOVWF 5C
0A48: MOVWF 60
0A49: MOVF 5B,W
0A4A: MOVWF 5F
0A4B: MOVF 5A,W
0A4C: MOVWF 5E
0A4D: MOVF 59,W
0A4E: MOVWF 5D
0A4F: MOVF 57,W
0A50: MOVWF 64
0A51: MOVF 56,W
0A52: MOVWF 63
0A53: MOVF 55,W
0A54: MOVWF 62
0A55: MOVF 54,W
0A56: MOVWF 61
0A57: BCF 0A.3
0A58: CALL 404
0A59: BSF 0A.3
0A5A: MOVF 7A,W
0A5B: MOVWF 53
0A5C: MOVF 79,W
0A5D: MOVWF 52
0A5E: MOVF 78,W
0A5F: MOVWF 51
0A60: MOVF 77,W
0A61: MOVWF 50
....................
....................
.................... if (flag) // for |x| > 1
0A62: BTFSS 58.1
0A63: GOTO 280
.................... res = PI_DIV_BY_TWO - res;
0A64: BSF 03.1
0A65: MOVLW DB
0A66: MOVWF 60
0A67: MOVLW 0F
0A68: MOVWF 5F
0A69: MOVLW 49
0A6A: MOVWF 5E
0A6B: MOVLW 7F
0A6C: MOVWF 5D
0A6D: MOVF 53,W
0A6E: MOVWF 64
0A6F: MOVF 52,W
0A70: MOVWF 63
0A71: MOVF 51,W
0A72: MOVWF 62
0A73: MOVF 50,W
0A74: MOVWF 61
0A75: BCF 0A.3
0A76: CALL 582
0A77: BSF 0A.3
0A78: MOVF 7A,W
0A79: MOVWF 53
0A7A: MOVF 79,W
0A7B: MOVWF 52
0A7C: MOVF 78,W
0A7D: MOVWF 51
0A7E: MOVF 77,W
0A7F: MOVWF 50
.................... if (s)
0A80: BTFSS 58.0
0A81: GOTO 285
.................... res = -res;
0A82: MOVF 51,W
0A83: XORLW 80
0A84: MOVWF 51
....................
.................... return(res);
0A85: MOVF 50,W
0A86: MOVWF 77
0A87: MOVF 51,W
0A88: MOVWF 78
0A89: MOVF 52,W
0A8A: MOVWF 79
0A8B: MOVF 53,W
0A8C: MOVWF 7A
.................... }
0A8D: RETURN
.................... //Overloaded functions for atan() for PCD
.................... // Overloaded function atan() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 atan(float48 x)
.................... {
.................... float48 y, res, r;
.................... int1 s, flag;
....................
.................... s = 0;
.................... flag = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 1.0)
.................... {
.................... y = 1.0/y;
.................... flag = 1;
.................... }
....................
.................... res = pat[0]*y*y + pat[1];
.................... res = res*y*y + pat[2];
.................... res = res*y*y + pat[3];
....................
.................... r = qat[0]*y*y + qat[1];
.................... r = r*y*y + qat[2];
.................... r = r*y*y + qat[3];
....................
.................... res = y*res/r;
....................
....................
.................... if (flag) // for |x| > 1
.................... res = PI_DIV_BY_TWO - res;
.................... if (s)
.................... res = -res;
....................
.................... return(res);
.................... }
....................
.................... // Overloaded function atan() for data type - Float64
.................... float64 atan(float64 x)
.................... {
.................... float64 y, res, r;
.................... int1 s, flag;
....................
.................... s = 0;
.................... flag = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 1.0)
.................... {
.................... y = 1.0/y;
.................... flag = 1;
.................... }
....................
.................... res = pat[0]*y*y + pat[1];
.................... res = res*y*y + pat[2];
.................... res = res*y*y + pat[3];
....................
.................... r = qat[0]*y*y + qat[1];
.................... r = r*y*y + qat[2];
.................... r = r*y*y + qat[3];
....................
.................... res = y*res/r;
....................
....................
.................... if (flag) // for |x| > 1
.................... res = PI_DIV_BY_TWO - res;
.................... if (s)
.................... res = -res;
....................
.................... return(res);
.................... }
.................... #endif
....................
.................... /////////////////////////////////////////////////////////////////////////////
.................... // float atan2(float y, float x)
.................... /////////////////////////////////////////////////////////////////////////////
.................... // Description :computes the principal value of arc tangent of y/x, using the
.................... // signs of both the arguments to determine the quadrant of the return value
.................... // Returns : returns the arc tangent of y/x.
.................... // Date : N/A
.................... //
....................
.................... float32 atan2(float32 y,float32 x)
.................... {
.................... float32 z;
.................... int1 sign;
.................... unsigned int8 quad;
.................... sign=0;
.................... quad=0; //quadrant
.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
.................... if(y<0.0)
.................... {
.................... sign=1;
.................... y=-y;
.................... }
.................... if(x<0.0)
.................... {
.................... x=-x;
.................... }
.................... if (x==0.0)
.................... {
.................... if(y==0.0)
.................... {
.................... #ifdef _ERRNO
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... }
.................... else
.................... {
.................... if(sign)
.................... {
.................... return (-(PI_DIV_BY_TWO));
.................... }
.................... else
.................... {
.................... return (PI_DIV_BY_TWO);
.................... }
.................... }
.................... }
.................... else
.................... {
.................... z=y/x;
.................... switch(quad)
.................... {
.................... case 1:
.................... {
.................... return atan(z);
.................... break;
.................... }
.................... case 2:
.................... {
.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
.................... return (PI-atan(z));
.................... break;
.................... }
.................... case 3:
.................... {
.................... return (atan(z)-PI);
.................... break;
.................... }
.................... case 4:
.................... {
.................... return (-atan(z));
.................... break;
.................... }
.................... }
.................... }
.................... }
....................
.................... //Overloaded functions for atan2() for PCD
.................... // Overloaded function atan2() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 atan2(float48 y,float48 x)
.................... {
.................... float48 z;
.................... int1 sign;
.................... unsigned int8 quad;
.................... sign=0;
.................... quad=0; //quadrant
.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
.................... if(y<0.0)
.................... {
.................... sign=1;
.................... y=-y;
.................... }
.................... if(x<0.0)
.................... {
.................... x=-x;
.................... }
.................... if (x==0.0)
.................... {
.................... if(y==0.0)
.................... {
.................... #ifdef _ERRNO
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... }
.................... else
.................... {
.................... if(sign)
.................... {
.................... return (-(PI_DIV_BY_TWO));
.................... }
.................... else
.................... {
.................... return (PI_DIV_BY_TWO);
.................... }
.................... }
.................... }
.................... else
.................... {
.................... z=y/x;
.................... switch(quad)
.................... {
.................... case 1:
.................... {
.................... return atan(z);
.................... break;
.................... }
.................... case 2:
.................... {
.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
.................... return (PI-atan(z));
.................... break;
.................... }
.................... case 3:
.................... {
.................... return (atan(z)-PI);
.................... break;
.................... }
.................... case 4:
.................... {
.................... return (-atan(z));
.................... break;
.................... }
.................... }
.................... }
.................... }
....................
.................... // Overloaded function atan2() for data type - Float64
.................... float64 atan2(float64 y,float64 x)
.................... {
.................... float64 z;
.................... int1 sign;
.................... unsigned int8 quad;
.................... sign=0;
.................... quad=0; //quadrant
.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
.................... if(y<0.0)
.................... {
.................... sign=1;
.................... y=-y;
.................... }
.................... if(x<0.0)
.................... {
.................... x=-x;
.................... }
.................... if (x==0.0)
.................... {
.................... if(y==0.0)
.................... {
.................... #ifdef _ERRNO
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... }
.................... else
.................... {
.................... if(sign)
.................... {
.................... return (-(PI_DIV_BY_TWO));
.................... }
.................... else
.................... {
.................... return (PI_DIV_BY_TWO);
.................... }
.................... }
.................... }
.................... else
.................... {
.................... z=y/x;
.................... switch(quad)
.................... {
.................... case 1:
.................... {
.................... return atan(z);
.................... break;
.................... }
.................... case 2:
.................... {
.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
.................... return (PI-atan(z));
.................... break;
.................... }
.................... case 3:
.................... {
.................... return (atan(z)-PI);
.................... break;
.................... }
.................... case 4:
.................... {
.................... return (-atan(z));
.................... break;
.................... }
.................... }
.................... }
.................... }
.................... #endif
....................
.................... //////////////////// Hyperbolic functions ////////////////////
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float cosh(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : Computes the hyperbolic cosine value of x
.................... // Returns : returns the hyperbolic cosine value of x
.................... // Date : N/A
.................... //
....................
.................... float32 cosh(float32 x)
.................... {
.................... return ((exp(x)+exp(-x))/2);
.................... }
.................... //Overloaded functions for cosh() for PCD
.................... // Overloaded function cosh() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 cosh(float48 x)
.................... {
.................... return ((exp(x)+exp(-x))/2);
.................... }
....................
.................... // Overloaded function cosh() for data type - Float64
.................... float64 cosh(float64 x)
.................... {
.................... return ((exp(x)+exp(-x))/2);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float sinh(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : Computes the hyperbolic sine value of x
.................... // Returns : returns the hyperbolic sine value of x
.................... // Date : N/A
.................... //
....................
.................... float32 sinh(float32 x)
.................... {
....................
.................... return ((exp(x) - exp(-x))/2);
.................... }
.................... //Overloaded functions for sinh() for PCD
.................... // Overloaded function sinh() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 sinh(float48 x)
.................... {
....................
.................... return ((exp(x) - exp(-x))/2);
.................... }
....................
.................... // Overloaded function sinh() for data type - Float48
.................... float64 sinh(float64 x)
.................... {
....................
.................... return ((exp(x) - exp(-x))/2);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float tanh(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : Computes the hyperbolic tangent value of x
.................... // Returns : returns the hyperbolic tangent value of x
.................... // Date : N/A
.................... //
....................
.................... float32 tanh(float32 x)
.................... {
.................... return(sinh(x)/cosh(x));
.................... }
.................... //Overloaded functions for tanh() for PCD
.................... // Overloaded function tanh() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 tanh(float48 x)
.................... {
.................... return(sinh(x)/cosh(x));
.................... }
....................
.................... // Overloaded function tanh() for data type - Float64
.................... float64 tanh(float64 x)
.................... {
.................... return(sinh(x)/cosh(x));
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float frexp(float x, signed int *exp)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : breaks a floating point number into a normalized fraction and an integral
.................... // power of 2. It stores the integer in the signed int object pointed to by exp.
.................... // Returns : returns the value x, such that x is a double with magnitude in the interval
.................... // [1/2,1) or zero, and value equals x times 2 raised to the power *exp.If value is zero,
.................... // both parts of the result are zero.
.................... // Date : N/A
.................... //
....................
.................... #define LOG2 .30102999566398119521
.................... float32 frexp(float32 x, signed int8 *exp)
.................... {
.................... float32 res;
.................... int1 sign = 0;
.................... if(x == 0.0)
.................... {
.................... *exp=0;
.................... return (0.0);
.................... }
.................... if(x < 0.0)
.................... {
.................... x=-x;
.................... sign=1;
.................... }
.................... if (x > 1.0)
.................... {
.................... *exp=(ceil(log10(x)/LOG2));
.................... res=x/(pow(2, *exp));
.................... if (res == 1)
.................... {
.................... *exp=*exp+1;
.................... res=.5;
.................... }
.................... }
.................... else
.................... {
.................... if(x < 0.5)
.................... {
.................... *exp=-1;
.................... res=x*2;
.................... }
.................... else
.................... {
.................... *exp=0;
.................... res=x;
.................... }
.................... }
.................... if(sign)
.................... {
.................... res=-res;
.................... }
.................... return res;
.................... }
....................
.................... //Overloaded functions for frexp() for PCD
.................... // Overloaded function frexp() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 frexp(float48 x, signed int8 *exp)
.................... {
.................... float48 res;
.................... int1 sign = 0;
.................... if(x == 0.0)
.................... {
.................... *exp=0;
.................... return (0.0);
.................... }
.................... if(x < 0.0)
.................... {
.................... x=-x;
.................... sign=1;
.................... }
.................... if (x > 1.0)
.................... {
.................... *exp=(ceil(log10(x)/LOG2));
.................... res=x/(pow(2, *exp));
.................... if (res == 1)
.................... {
.................... *exp=*exp+1;
.................... res=.5;
.................... }
.................... }
.................... else
.................... {
.................... if(x < 0.5)
.................... {
.................... *exp=-1;
.................... res=x*2;
.................... }
.................... else
.................... {
.................... *exp=0;
.................... res=x;
.................... }
.................... }
.................... if(sign)
.................... {
.................... res=-res;
.................... }
.................... return res;
.................... }
....................
.................... // Overloaded function frexp() for data type - Float64
.................... float64 frexp(float64 x, signed int8 *exp)
.................... {
.................... float64 res;
.................... int1 sign = 0;
.................... if(x == 0.0)
.................... {
.................... *exp=0;
.................... return (0.0);
.................... }
.................... if(x < 0.0)
.................... {
.................... x=-x;
.................... sign=1;
.................... }
.................... if (x > 1.0)
.................... {
.................... *exp=(ceil(log10(x)/LOG2));
.................... res=x/(pow(2, *exp));
.................... if (res == 1)
.................... {
.................... *exp=*exp+1;
.................... res=.5;
.................... }
.................... }
.................... else
.................... {
.................... if(x < 0.5)
.................... {
.................... *exp=-1;
.................... res=x*2;
.................... }
.................... else
.................... {
.................... *exp=0;
.................... res=x;
.................... }
.................... }
.................... if(sign)
.................... {
.................... res=-res;
.................... }
.................... return res;
.................... }
.................... #endif
....................
.................... //////////////////////////////////////////////////////////////////////////////
.................... // float ldexp(float x, signed int *exp)
.................... //////////////////////////////////////////////////////////////////////////////
.................... // Description : multiplies a floating point number by an integral power of 2.
.................... // Returns : returns the value of x times 2 raised to the power exp.
.................... // Date : N/A
.................... //
....................
.................... float32 ldexp(float32 value, signed int8 exp)
.................... {
.................... return (value * pow(2,exp));
.................... }
.................... //Overloaded functions for ldexp() for PCD
.................... // Overloaded function ldexp() for data type - Float48
....................
.................... #if defined(__PCD__)
.................... float48 ldexp(float48 value, signed int8 exp)
.................... {
.................... return (value * pow(2,exp));
.................... }
.................... // Overloaded function ldexp() for data type - Float64
.................... float64 ldexp(float64 value, signed int8 exp)
.................... {
.................... return (value * pow(2,exp));
.................... }
.................... #endif
....................
.................... #endif
....................
....................
.................... //Akcelerometr
.................... #define AK_W 0x38 //adresa akcelerometru zápis
.................... #define AK_R 0x39 //adresa akcelerometru ètení
.................... #define AK_XH 0x01 //osa X LSB
.................... #define AK_XL 0x02 //osa X MSB
.................... #define AK_YH 0x03 //osa Y LSB
.................... #define AK_YL 0x04 //osa Y MSB
.................... #define AK_ZH 0x05 //osa Z LSB
.................... #define AK_ZL 0x06 //osa Z MSB
....................
.................... //Magnetometr
.................... #define MAG_W 0x3C //adresa akcelerometru zápis
.................... #define MAG_R 0x3D //adresa akcelerometru ètení
.................... #define MAG_XH 0x03 //osa X LSB
.................... #define MAG_XL 0x04 //osa X MSB
.................... #define MAG_ZH 0x05 //osa Y LSB
.................... #define MAG_ZL 0x06 //osa Y MSB
.................... #define MAG_YH 0x07 //osa Z LSB
.................... #define MAG_YL 0x08 //osa Z MSB
....................
....................
....................
....................
....................
.................... //pøipojení motorù
.................... //AIN1 - pro vysku slunce
.................... #define AIN1 PIN_D0
.................... #define AIN2 PIN_D1
.................... //motor A -cerveny vodic na AOUT1
.................... //motor A -modry vodic na Aout2
....................
.................... //AIN2 - pro azimut
.................... #define BIN1 PIN_D2
.................... #define BIN2 PIN_D3
.................... //motor B - èerveny vodic na BOUT2
.................... //motor B - modrý vodic na BOUT1
....................
.................... signed int16 X, Y, Z,AX, AY, AZ;
....................
.................... void setAK (void) //nastaveni akcelerometru
.................... {
.................... i2c_start();
*
018D: BSF 20.4
018E: MOVF 20,W
018F: BSF 03.5
0190: MOVWF 07
0191: NOP
0192: BCF 03.5
0193: BSF 20.3
0194: MOVF 20,W
0195: BSF 03.5
0196: MOVWF 07
0197: NOP
0198: BCF 03.5
0199: BCF 07.4
019A: BCF 20.4
019B: MOVF 20,W
019C: BSF 03.5
019D: MOVWF 07
019E: NOP
019F: BCF 03.5
01A0: BCF 07.3
01A1: BCF 20.3
01A2: MOVF 20,W
01A3: BSF 03.5
01A4: MOVWF 07
.................... I2C_Write(AK_W);
01A5: MOVLW 38
01A6: BCF 03.5
01A7: MOVWF 4E
01A8: CALL 143
.................... I2C_write(0x2A);
01A9: MOVLW 2A
01AA: MOVWF 4E
01AB: CALL 143
.................... I2C_write(0x01); //nastaví aktivní stav
01AC: MOVLW 01
01AD: MOVWF 4E
01AE: CALL 143
....................
.................... i2c_stop();
01AF: BCF 20.4
01B0: MOVF 20,W
01B1: BSF 03.5
01B2: MOVWF 07
01B3: NOP
01B4: BCF 03.5
01B5: BSF 20.3
01B6: MOVF 20,W
01B7: BSF 03.5
01B8: MOVWF 07
01B9: BCF 03.5
01BA: BTFSS 07.3
01BB: GOTO 1BA
01BC: NOP
01BD: GOTO 1BE
01BE: NOP
01BF: BSF 20.4
01C0: MOVF 20,W
01C1: BSF 03.5
01C2: MOVWF 07
01C3: NOP
.................... }
01C4: BCF 03.5
01C5: BCF 0A.3
01C6: BSF 0A.4
01C7: GOTO 266 (RETURN)
....................
.................... void setmag (void)
.................... {
.................... i2c_start();
*
01DC: BSF 20.4
01DD: MOVF 20,W
01DE: BSF 03.5
01DF: MOVWF 07
01E0: NOP
01E1: BCF 03.5
01E2: BSF 20.3
01E3: MOVF 20,W
01E4: BSF 03.5
01E5: MOVWF 07
01E6: NOP
01E7: BCF 03.5
01E8: BCF 07.4
01E9: BCF 20.4
01EA: MOVF 20,W
01EB: BSF 03.5
01EC: MOVWF 07
01ED: NOP
01EE: BCF 03.5
01EF: BCF 07.3
01F0: BCF 20.3
01F1: MOVF 20,W
01F2: BSF 03.5
01F3: MOVWF 07
.................... I2C_Write(MAG_W); // W
01F4: MOVLW 3C
01F5: BCF 03.5
01F6: MOVWF 4E
01F7: CALL 143
.................... I2C_Write(0x00);
01F8: CLRF 4E
01F9: CALL 143
.................... I2C_Write(0x78);
01FA: MOVLW 78
01FB: MOVWF 4E
01FC: CALL 143
.................... i2c_stop();
01FD: BCF 20.4
01FE: MOVF 20,W
01FF: BSF 03.5
0200: MOVWF 07
0201: NOP
0202: BCF 03.5
0203: BSF 20.3
0204: MOVF 20,W
0205: BSF 03.5
0206: MOVWF 07
0207: BCF 03.5
0208: BTFSS 07.3
0209: GOTO 208
020A: NOP
020B: GOTO 20C
020C: NOP
020D: BSF 20.4
020E: MOVF 20,W
020F: BSF 03.5
0210: MOVWF 07
0211: NOP
.................... Delay_ms(6);
0212: MOVLW 06
0213: BCF 03.5
0214: MOVWF 40
0215: CALL 1C8
....................
.................... i2c_start();
0216: BSF 20.4
0217: MOVF 20,W
0218: BSF 03.5
0219: MOVWF 07
021A: NOP
021B: BCF 03.5
021C: BSF 20.3
021D: MOVF 20,W
021E: BSF 03.5
021F: MOVWF 07
0220: NOP
0221: BCF 03.5
0222: BCF 07.4
0223: BCF 20.4
0224: MOVF 20,W
0225: BSF 03.5
0226: MOVWF 07
0227: NOP
0228: BCF 03.5
0229: BCF 07.3
022A: BCF 20.3
022B: MOVF 20,W
022C: BSF 03.5
022D: MOVWF 07
.................... I2C_Write(MAG_W); // W
022E: MOVLW 3C
022F: BCF 03.5
0230: MOVWF 4E
0231: CALL 143
.................... I2C_Write(0x01);
0232: MOVLW 01
0233: MOVWF 4E
0234: CALL 143
.................... I2C_Write(0x00);
0235: CLRF 4E
0236: CALL 143
.................... i2c_stop();
0237: BCF 20.4
0238: MOVF 20,W
0239: BSF 03.5
023A: MOVWF 07
023B: NOP
023C: BCF 03.5
023D: BSF 20.3
023E: MOVF 20,W
023F: BSF 03.5
0240: MOVWF 07
0241: BCF 03.5
0242: BTFSS 07.3
0243: GOTO 242
0244: NOP
0245: GOTO 246
0246: NOP
0247: BSF 20.4
0248: MOVF 20,W
0249: BSF 03.5
024A: MOVWF 07
024B: NOP
....................
.................... Delay_ms(6);
024C: MOVLW 06
024D: BCF 03.5
024E: MOVWF 40
024F: CALL 1C8
....................
.................... i2c_start();
0250: BSF 20.4
0251: MOVF 20,W
0252: BSF 03.5
0253: MOVWF 07
0254: NOP
0255: BCF 03.5
0256: BSF 20.3
0257: MOVF 20,W
0258: BSF 03.5
0259: MOVWF 07
025A: NOP
025B: BCF 03.5
025C: BCF 07.4
025D: BCF 20.4
025E: MOVF 20,W
025F: BSF 03.5
0260: MOVWF 07
0261: NOP
0262: BCF 03.5
0263: BCF 07.3
0264: BCF 20.3
0265: MOVF 20,W
0266: BSF 03.5
0267: MOVWF 07
.................... I2C_Write(MAG_W); // W
0268: MOVLW 3C
0269: BCF 03.5
026A: MOVWF 4E
026B: CALL 143
.................... I2C_Write(0x02);
026C: MOVLW 02
026D: MOVWF 4E
026E: CALL 143
.................... I2C_Write(0x00);
026F: CLRF 4E
0270: CALL 143
.................... i2c_stop();
0271: BCF 20.4
0272: MOVF 20,W
0273: BSF 03.5
0274: MOVWF 07
0275: NOP
0276: BCF 03.5
0277: BSF 20.3
0278: MOVF 20,W
0279: BSF 03.5
027A: MOVWF 07
027B: BCF 03.5
027C: BTFSS 07.3
027D: GOTO 27C
027E: NOP
027F: GOTO 280
0280: NOP
0281: BSF 20.4
0282: MOVF 20,W
0283: BSF 03.5
0284: MOVWF 07
0285: NOP
.................... Delay_ms(6);
0286: MOVLW 06
0287: BCF 03.5
0288: MOVWF 40
0289: CALL 1C8
.................... }
028A: BCF 0A.3
028B: BSF 0A.4
028C: GOTO 269 (RETURN)
....................
.................... int16 akR (int8 H, int8 L) //vycitani hodnot z akcelerometru
.................... {
*
02D2: CLRF 4A
02D3: CLRF 4B
.................... unsigned int8 XL=0,XH=0;
.................... signed int16 x;
....................
.................... i2c_start();
02D4: BSF 20.4
02D5: MOVF 20,W
02D6: BSF 03.5
02D7: MOVWF 07
02D8: NOP
02D9: BCF 03.5
02DA: BSF 20.3
02DB: MOVF 20,W
02DC: BSF 03.5
02DD: MOVWF 07
02DE: NOP
02DF: BCF 03.5
02E0: BCF 07.4
02E1: BCF 20.4
02E2: MOVF 20,W
02E3: BSF 03.5
02E4: MOVWF 07
02E5: NOP
02E6: BCF 03.5
02E7: BCF 07.3
02E8: BCF 20.3
02E9: MOVF 20,W
02EA: BSF 03.5
02EB: MOVWF 07
.................... I2C_Write(AK_W);
02EC: MOVLW 38
02ED: BCF 03.5
02EE: MOVWF 4E
02EF: CALL 143
.................... I2C_write(H);
02F0: MOVF 48,W
02F1: MOVWF 4E
02F2: CALL 143
.................... i2c_start();
02F3: BSF 20.4
02F4: MOVF 20,W
02F5: BSF 03.5
02F6: MOVWF 07
02F7: NOP
02F8: BCF 03.5
02F9: BSF 20.3
02FA: MOVF 20,W
02FB: BSF 03.5
02FC: MOVWF 07
02FD: NOP
02FE: BCF 03.5
02FF: BTFSS 07.3
0300: GOTO 2FF
0301: BCF 07.4
0302: BCF 20.4
0303: MOVF 20,W
0304: BSF 03.5
0305: MOVWF 07
0306: NOP
0307: BCF 03.5
0308: BCF 07.3
0309: BCF 20.3
030A: MOVF 20,W
030B: BSF 03.5
030C: MOVWF 07
.................... I2C_Write(AK_R);
030D: MOVLW 39
030E: BCF 03.5
030F: MOVWF 4E
0310: CALL 143
.................... XH=i2c_read(0);
0311: CLRF 77
0312: CALL 28D
0313: MOVF 78,W
0314: MOVWF 4B
.................... i2c_stop();
0315: BCF 20.4
0316: MOVF 20,W
0317: BSF 03.5
0318: MOVWF 07
0319: NOP
031A: BCF 03.5
031B: BSF 20.3
031C: MOVF 20,W
031D: BSF 03.5
031E: MOVWF 07
031F: BCF 03.5
0320: BTFSS 07.3
0321: GOTO 320
0322: NOP
0323: GOTO 324
0324: NOP
0325: BSF 20.4
0326: MOVF 20,W
0327: BSF 03.5
0328: MOVWF 07
0329: NOP
....................
.................... i2c_start();
032A: BCF 03.5
032B: BSF 20.4
032C: MOVF 20,W
032D: BSF 03.5
032E: MOVWF 07
032F: NOP
0330: BCF 03.5
0331: BSF 20.3
0332: MOVF 20,W
0333: BSF 03.5
0334: MOVWF 07
0335: NOP
0336: BCF 03.5
0337: BCF 07.4
0338: BCF 20.4
0339: MOVF 20,W
033A: BSF 03.5
033B: MOVWF 07
033C: NOP
033D: BCF 03.5
033E: BCF 07.3
033F: BCF 20.3
0340: MOVF 20,W
0341: BSF 03.5
0342: MOVWF 07
.................... I2C_Write(AK_W);
0343: MOVLW 38
0344: BCF 03.5
0345: MOVWF 4E
0346: CALL 143
.................... I2C_write(L);
0347: MOVF 49,W
0348: MOVWF 4E
0349: CALL 143
.................... i2c_start();
034A: BSF 20.4
034B: MOVF 20,W
034C: BSF 03.5
034D: MOVWF 07
034E: NOP
034F: BCF 03.5
0350: BSF 20.3
0351: MOVF 20,W
0352: BSF 03.5
0353: MOVWF 07
0354: NOP
0355: BCF 03.5
0356: BTFSS 07.3
0357: GOTO 356
0358: BCF 07.4
0359: BCF 20.4
035A: MOVF 20,W
035B: BSF 03.5
035C: MOVWF 07
035D: NOP
035E: BCF 03.5
035F: BCF 07.3
0360: BCF 20.3
0361: MOVF 20,W
0362: BSF 03.5
0363: MOVWF 07
.................... I2C_Write(AK_R);
0364: MOVLW 39
0365: BCF 03.5
0366: MOVWF 4E
0367: CALL 143
.................... XL=i2c_read(0);
0368: CLRF 77
0369: CALL 28D
036A: MOVF 78,W
036B: MOVWF 4A
.................... i2c_stop();
036C: BCF 20.4
036D: MOVF 20,W
036E: BSF 03.5
036F: MOVWF 07
0370: NOP
0371: BCF 03.5
0372: BSF 20.3
0373: MOVF 20,W
0374: BSF 03.5
0375: MOVWF 07
0376: BCF 03.5
0377: BTFSS 07.3
0378: GOTO 377
0379: NOP
037A: GOTO 37B
037B: NOP
037C: BSF 20.4
037D: MOVF 20,W
037E: BSF 03.5
037F: MOVWF 07
0380: NOP
....................
.................... x = (((unsigned int16) XH << 8) + XL ); //prevod na 16bit hodnotu
0381: BCF 03.5
0382: CLRF 4F
0383: MOVF 4B,W
0384: MOVWF 4E
0385: MOVWF 4F
0386: CLRF 4E
0387: MOVF 4A,W
0388: ADDWF 4E,W
0389: MOVWF 78
038A: MOVF 4F,W
038B: MOVWF 7A
038C: BTFSC 03.0
038D: INCF 7A,F
038E: MOVF 78,W
038F: MOVWF 4C
0390: MOVF 7A,W
0391: MOVWF 4D
.................... x=x/4;
0392: MOVF 4D,W
0393: MOVWF 4F
0394: MOVF 4C,W
0395: MOVWF 4E
0396: CLRF 51
0397: MOVLW 04
0398: MOVWF 50
*
03D6: MOVF 79,W
03D7: MOVWF 4D
03D8: MOVF 78,W
03D9: MOVWF 4C
....................
.................... return x;
03DA: MOVF 4C,W
03DB: MOVWF 78
03DC: MOVF 4D,W
03DD: MOVWF 79
.................... }
03DE: RETURN
....................
.................... int16 magR (int8 H, int8 L) //vycitani hodnot z akcelerometru
.................... {
*
0E44: CLRF 4A
0E45: CLRF 4B
.................... unsigned int8 XL=0,XH=0;
.................... signed int16 x;
....................
.................... i2c_start();
0E46: BSF 20.4
0E47: MOVF 20,W
0E48: BSF 03.5
0E49: MOVWF 07
0E4A: NOP
0E4B: BCF 03.5
0E4C: BSF 20.3
0E4D: MOVF 20,W
0E4E: BSF 03.5
0E4F: MOVWF 07
0E50: NOP
0E51: BCF 03.5
0E52: BCF 07.4
0E53: BCF 20.4
0E54: MOVF 20,W
0E55: BSF 03.5
0E56: MOVWF 07
0E57: NOP
0E58: BCF 03.5
0E59: BCF 07.3
0E5A: BCF 20.3
0E5B: MOVF 20,W
0E5C: BSF 03.5
0E5D: MOVWF 07
.................... I2C_Write(MAG_W);
0E5E: MOVLW 3C
0E5F: BCF 03.5
0E60: MOVWF 4E
0E61: BCF 0A.3
0E62: CALL 143
0E63: BSF 0A.3
.................... I2C_write(H);
0E64: MOVF 48,W
0E65: MOVWF 4E
0E66: BCF 0A.3
0E67: CALL 143
0E68: BSF 0A.3
.................... i2c_start();
0E69: BSF 20.4
0E6A: MOVF 20,W
0E6B: BSF 03.5
0E6C: MOVWF 07
0E6D: NOP
0E6E: BCF 03.5
0E6F: BSF 20.3
0E70: MOVF 20,W
0E71: BSF 03.5
0E72: MOVWF 07
0E73: NOP
0E74: BCF 03.5
0E75: BTFSS 07.3
0E76: GOTO 675
0E77: BCF 07.4
0E78: BCF 20.4
0E79: MOVF 20,W
0E7A: BSF 03.5
0E7B: MOVWF 07
0E7C: NOP
0E7D: BCF 03.5
0E7E: BCF 07.3
0E7F: BCF 20.3
0E80: MOVF 20,W
0E81: BSF 03.5
0E82: MOVWF 07
.................... I2C_Write(MAG_R);
0E83: MOVLW 3D
0E84: BCF 03.5
0E85: MOVWF 4E
0E86: BCF 0A.3
0E87: CALL 143
0E88: BSF 0A.3
.................... XH=i2c_read(0);
0E89: CLRF 77
0E8A: BCF 0A.3
0E8B: CALL 28D
0E8C: BSF 0A.3
0E8D: MOVF 78,W
0E8E: MOVWF 4B
.................... i2c_stop();
0E8F: BCF 20.4
0E90: MOVF 20,W
0E91: BSF 03.5
0E92: MOVWF 07
0E93: NOP
0E94: BCF 03.5
0E95: BSF 20.3
0E96: MOVF 20,W
0E97: BSF 03.5
0E98: MOVWF 07
0E99: BCF 03.5
0E9A: BTFSS 07.3
0E9B: GOTO 69A
0E9C: NOP
0E9D: GOTO 69E
0E9E: NOP
0E9F: BSF 20.4
0EA0: MOVF 20,W
0EA1: BSF 03.5
0EA2: MOVWF 07
0EA3: NOP
....................
.................... i2c_start();
0EA4: BCF 03.5
0EA5: BSF 20.4
0EA6: MOVF 20,W
0EA7: BSF 03.5
0EA8: MOVWF 07
0EA9: NOP
0EAA: BCF 03.5
0EAB: BSF 20.3
0EAC: MOVF 20,W
0EAD: BSF 03.5
0EAE: MOVWF 07
0EAF: NOP
0EB0: BCF 03.5
0EB1: BCF 07.4
0EB2: BCF 20.4
0EB3: MOVF 20,W
0EB4: BSF 03.5
0EB5: MOVWF 07
0EB6: NOP
0EB7: BCF 03.5
0EB8: BCF 07.3
0EB9: BCF 20.3
0EBA: MOVF 20,W
0EBB: BSF 03.5
0EBC: MOVWF 07
.................... I2C_Write(MAG_W);
0EBD: MOVLW 3C
0EBE: BCF 03.5
0EBF: MOVWF 4E
0EC0: BCF 0A.3
0EC1: CALL 143
0EC2: BSF 0A.3
.................... I2C_write(L);
0EC3: MOVF 49,W
0EC4: MOVWF 4E
0EC5: BCF 0A.3
0EC6: CALL 143
0EC7: BSF 0A.3
.................... i2c_start();
0EC8: BSF 20.4
0EC9: MOVF 20,W
0ECA: BSF 03.5
0ECB: MOVWF 07
0ECC: NOP
0ECD: BCF 03.5
0ECE: BSF 20.3
0ECF: MOVF 20,W
0ED0: BSF 03.5
0ED1: MOVWF 07
0ED2: NOP
0ED3: BCF 03.5
0ED4: BTFSS 07.3
0ED5: GOTO 6D4
0ED6: BCF 07.4
0ED7: BCF 20.4
0ED8: MOVF 20,W
0ED9: BSF 03.5
0EDA: MOVWF 07
0EDB: NOP
0EDC: BCF 03.5
0EDD: BCF 07.3
0EDE: BCF 20.3
0EDF: MOVF 20,W
0EE0: BSF 03.5
0EE1: MOVWF 07
.................... I2C_Write(MAG_R);
0EE2: MOVLW 3D
0EE3: BCF 03.5
0EE4: MOVWF 4E
0EE5: BCF 0A.3
0EE6: CALL 143
0EE7: BSF 0A.3
.................... XL=i2c_read(0);
0EE8: CLRF 77
0EE9: BCF 0A.3
0EEA: CALL 28D
0EEB: BSF 0A.3
0EEC: MOVF 78,W
0EED: MOVWF 4A
.................... i2c_stop();
0EEE: BCF 20.4
0EEF: MOVF 20,W
0EF0: BSF 03.5
0EF1: MOVWF 07
0EF2: NOP
0EF3: BCF 03.5
0EF4: BSF 20.3
0EF5: MOVF 20,W
0EF6: BSF 03.5
0EF7: MOVWF 07
0EF8: BCF 03.5
0EF9: BTFSS 07.3
0EFA: GOTO 6F9
0EFB: NOP
0EFC: GOTO 6FD
0EFD: NOP
0EFE: BSF 20.4
0EFF: MOVF 20,W
0F00: BSF 03.5
0F01: MOVWF 07
0F02: NOP
....................
.................... x = (((unsigned int16) XH << 8) + XL );
0F03: BCF 03.5
0F04: CLRF 4F
0F05: MOVF 4B,W
0F06: MOVWF 4E
0F07: MOVWF 4F
0F08: CLRF 4E
0F09: MOVF 4A,W
0F0A: ADDWF 4E,W
0F0B: MOVWF 78
0F0C: MOVF 4F,W
0F0D: MOVWF 7A
0F0E: BTFSC 03.0
0F0F: INCF 7A,F
0F10: MOVF 78,W
0F11: MOVWF 4C
0F12: MOVF 7A,W
0F13: MOVWF 4D
....................
....................
.................... return x;
0F14: MOVF 4C,W
0F15: MOVWF 78
0F16: MOVF 4D,W
0F17: MOVWF 79
.................... }
0F18: RETURN
....................
.................... float vyska (void) //vypocet aktualni vysky panelu
.................... {
.................... printf("Akcelerometr5: \r\n",);
*
0B85: MOVLW 04
0B86: BSF 03.6
0B87: MOVWF 0D
0B88: MOVLW 00
0B89: MOVWF 0F
0B8A: BCF 0A.3
0B8B: BCF 03.6
0B8C: CALL 0DA
0B8D: BSF 0A.3
....................
.................... X= akR (AK_XH, AK_XL);
0B8E: MOVLW 01
0B8F: MOVWF 48
0B90: MOVLW 02
0B91: MOVWF 49
0B92: BCF 0A.3
0B93: CALL 2D2
0B94: BSF 0A.3
0B95: MOVF 79,W
0B96: MOVWF 22
0B97: MOVF 78,W
0B98: MOVWF 21
.................... Y= akR (AK_YH, AK_YL);
0B99: MOVLW 03
0B9A: MOVWF 48
0B9B: MOVLW 04
0B9C: MOVWF 49
0B9D: BCF 0A.3
0B9E: CALL 2D2
0B9F: BSF 0A.3
0BA0: MOVF 79,W
0BA1: MOVWF 24
0BA2: MOVF 78,W
0BA3: MOVWF 23
.................... Z= akR (AK_ZH, AK_ZL);
0BA4: MOVLW 05
0BA5: MOVWF 48
0BA6: MOVLW 06
0BA7: MOVWF 49
0BA8: BCF 0A.3
0BA9: CALL 2D2
0BAA: BSF 0A.3
0BAB: MOVF 79,W
0BAC: MOVWF 26
0BAD: MOVF 78,W
0BAE: MOVWF 25
....................
.................... AX=abs(X);
0BAF: MOVF 22,W
0BB0: MOVWF 7A
0BB1: MOVF 21,W
0BB2: BTFSS 22.7
0BB3: GOTO 3BD
0BB4: MOVF 21,W
0BB5: SUBLW 00
0BB6: MOVWF 77
0BB7: CLRF 7A
0BB8: MOVF 22,W
0BB9: BTFSS 03.0
0BBA: INCFSZ 22,W
0BBB: SUBWF 7A,F
0BBC: MOVF 77,W
0BBD: MOVWF 27
0BBE: MOVF 7A,W
0BBF: MOVWF 28
.................... AY=abs(Y)+250;
0BC0: MOVF 24,W
0BC1: MOVWF 7A
0BC2: MOVF 23,W
0BC3: BTFSS 24.7
0BC4: GOTO 3CE
0BC5: MOVF 23,W
0BC6: SUBLW 00
0BC7: MOVWF 77
0BC8: CLRF 7A
0BC9: MOVF 24,W
0BCA: BTFSS 03.0
0BCB: INCFSZ 24,W
0BCC: SUBWF 7A,F
0BCD: MOVF 77,W
0BCE: MOVWF 48
0BCF: MOVLW FA
0BD0: ADDWF 48,W
0BD1: MOVWF 29
0BD2: MOVF 7A,W
0BD3: MOVWF 2A
0BD4: BTFSC 03.0
0BD5: INCF 2A,F
.................... AZ=abs(Z)+250;
0BD6: MOVF 26,W
0BD7: MOVWF 7A
0BD8: MOVF 25,W
0BD9: BTFSS 26.7
0BDA: GOTO 3E4
0BDB: MOVF 25,W
0BDC: SUBLW 00
0BDD: MOVWF 77
0BDE: CLRF 7A
0BDF: MOVF 26,W
0BE0: BTFSS 03.0
0BE1: INCFSZ 26,W
0BE2: SUBWF 7A,F
0BE3: MOVF 77,W
0BE4: MOVWF 48
0BE5: MOVLW FA
0BE6: ADDWF 48,W
0BE7: MOVWF 2B
0BE8: MOVF 7A,W
0BE9: MOVWF 2C
0BEA: BTFSC 03.0
0BEB: INCF 2C,F
....................
.................... float a, b;
.................... a=(float)Y/Z;
0BEC: MOVF 24,W
0BED: MOVWF 4D
0BEE: MOVF 23,W
0BEF: MOVWF 4C
0BF0: BCF 0A.3
0BF1: CALL 3DF
0BF2: BSF 0A.3
0BF3: MOVF 77,W
0BF4: MOVWF 48
0BF5: MOVF 78,W
0BF6: MOVWF 49
0BF7: MOVF 79,W
0BF8: MOVWF 4A
0BF9: MOVF 7A,W
0BFA: MOVWF 4B
0BFB: MOVF 26,W
0BFC: MOVWF 4D
0BFD: MOVF 25,W
0BFE: MOVWF 4C
0BFF: BCF 0A.3
0C00: CALL 3DF
0C01: BSF 0A.3
0C02: MOVF 4B,W
0C03: MOVWF 60
0C04: MOVF 4A,W
0C05: MOVWF 5F
0C06: MOVF 49,W
0C07: MOVWF 5E
0C08: MOVF 48,W
0C09: MOVWF 5D
0C0A: MOVF 7A,W
0C0B: MOVWF 64
0C0C: MOVF 79,W
0C0D: MOVWF 63
0C0E: MOVF 78,W
0C0F: MOVWF 62
0C10: MOVF 77,W
0C11: MOVWF 61
0C12: BCF 0A.3
0C13: CALL 404
0C14: BSF 0A.3
0C15: MOVF 7A,W
0C16: MOVWF 43
0C17: MOVF 79,W
0C18: MOVWF 42
0C19: MOVF 78,W
0C1A: MOVWF 41
0C1B: MOVF 77,W
0C1C: MOVWF 40
.................... b=atan(a);
0C1D: MOVF 43,W
0C1E: MOVWF 4B
0C1F: MOVF 42,W
0C20: MOVWF 4A
0C21: MOVF 41,W
0C22: MOVWF 49
0C23: MOVF 40,W
0C24: MOVWF 48
0C25: CALL 000
0C26: MOVF 7A,W
0C27: MOVWF 47
0C28: MOVF 79,W
0C29: MOVWF 46
0C2A: MOVF 78,W
0C2B: MOVWF 45
0C2C: MOVF 77,W
0C2D: MOVWF 44
.................... b = (b/3.14)*180;
0C2E: MOVF 47,W
0C2F: MOVWF 60
0C30: MOVF 46,W
0C31: MOVWF 5F
0C32: MOVF 45,W
0C33: MOVWF 5E
0C34: MOVF 44,W
0C35: MOVWF 5D
0C36: MOVLW C3
0C37: MOVWF 64
0C38: MOVLW F5
0C39: MOVWF 63
0C3A: MOVLW 48
0C3B: MOVWF 62
0C3C: MOVLW 80
0C3D: MOVWF 61
0C3E: BCF 0A.3
0C3F: CALL 404
0C40: BSF 0A.3
0C41: MOVF 77,W
0C42: MOVWF 48
0C43: MOVF 78,W
0C44: MOVWF 49
0C45: MOVF 79,W
0C46: MOVWF 4A
0C47: MOVF 7A,W
0C48: MOVWF 4B
0C49: MOVWF 60
0C4A: MOVF 79,W
0C4B: MOVWF 5F
0C4C: MOVF 78,W
0C4D: MOVWF 5E
0C4E: MOVF 77,W
0C4F: MOVWF 5D
0C50: CLRF 64
0C51: CLRF 63
0C52: MOVLW 34
0C53: MOVWF 62
0C54: MOVLW 86
0C55: MOVWF 61
0C56: BCF 0A.3
0C57: CALL 50D
0C58: BSF 0A.3
0C59: MOVF 7A,W
0C5A: MOVWF 47
0C5B: MOVF 79,W
0C5C: MOVWF 46
0C5D: MOVF 78,W
0C5E: MOVWF 45
0C5F: MOVF 77,W
0C60: MOVWF 44
.................... b=abs(b);
0C61: MOVF 44,W
0C62: MOVWF 77
0C63: MOVF 45,W
0C64: MOVWF 78
0C65: MOVF 46,W
0C66: MOVWF 79
0C67: MOVF 47,W
0C68: MOVWF 7A
0C69: BCF 78.7
0C6A: MOVF 47,W
0C6B: MOVWF 47
0C6C: MOVF 46,W
0C6D: MOVWF 46
0C6E: MOVF 78,W
0C6F: MOVWF 45
0C70: MOVF 44,W
0C71: MOVWF 44
....................
.................... if(((AX>AY) || (AX>AZ))) //indikace prevraceni panelu
0C72: BTFSS 2A.7
0C73: GOTO 477
0C74: BTFSS 28.7
0C75: GOTO 494
0C76: GOTO 479
0C77: BTFSC 28.7
0C78: GOTO 483
0C79: MOVF 2A,W
0C7A: SUBWF 28,W
0C7B: BTFSS 03.0
0C7C: GOTO 483
0C7D: BTFSS 03.2
0C7E: GOTO 494
0C7F: MOVF 27,W
0C80: SUBWF 29,W
0C81: BTFSS 03.0
0C82: GOTO 494
0C83: BTFSS 2C.7
0C84: GOTO 488
0C85: BTFSS 28.7
0C86: GOTO 494
0C87: GOTO 48A
0C88: BTFSC 28.7
0C89: GOTO 4BD
0C8A: MOVF 2C,W
0C8B: SUBWF 28,W
0C8C: BTFSS 03.0
0C8D: GOTO 4BD
0C8E: BTFSS 03.2
0C8F: GOTO 494
0C90: MOVF 27,W
0C91: SUBWF 2B,W
0C92: BTFSC 03.0
0C93: GOTO 4BD
.................... {
.................... printf("Prevracený panel)\r\n", );
0C94: MOVLW 0E
0C95: BSF 03.6
0C96: MOVWF 0D
0C97: MOVLW 00
0C98: MOVWF 0F
.................... }
.................... else
*
0CBB: GOTO 551
0CBC: BCF 03.6
.................... {
.................... if(Z==0) //osetreni proti deleni 0
0CBD: MOVF 25,F
0CBE: BTFSS 03.2
0CBF: GOTO 4D8
0CC0: MOVF 26,F
0CC1: BTFSS 03.2
0CC2: GOTO 4D8
.................... {
.................... if(Y>0)
0CC3: BTFSC 24.7
0CC4: GOTO 4D3
0CC5: MOVF 24,F
0CC6: BTFSS 03.2
0CC7: GOTO 4CC
0CC8: MOVF 23,W
0CC9: SUBLW 00
0CCA: BTFSC 03.0
0CCB: GOTO 4D3
.................... {
.................... b=180;
0CCC: CLRF 47
0CCD: CLRF 46
0CCE: MOVLW 34
0CCF: MOVWF 45
0CD0: MOVLW 86
0CD1: MOVWF 44
.................... }
.................... else
0CD2: GOTO 4D7
.................... {
.................... b=0;
0CD3: CLRF 47
0CD4: CLRF 46
0CD5: CLRF 45
0CD6: CLRF 44
.................... }
.................... }
.................... else
0CD7: GOTO 550
.................... {
.................... if(Z>0)
0CD8: BTFSC 26.7
0CD9: GOTO 519
0CDA: MOVF 26,F
0CDB: BTFSS 03.2
0CDC: GOTO 4E1
0CDD: MOVF 25,W
0CDE: SUBLW 00
0CDF: BTFSC 03.0
0CE0: GOTO 519
.................... {
.................... if(Y>=0)
0CE1: BTFSC 24.7
0CE2: GOTO 4FE
.................... {
.................... b=90+b;
0CE3: BCF 03.1
0CE4: CLRF 60
0CE5: CLRF 5F
0CE6: MOVLW 34
0CE7: MOVWF 5E
0CE8: MOVLW 85
0CE9: MOVWF 5D
0CEA: MOVF 47,W
0CEB: MOVWF 64
0CEC: MOVF 46,W
0CED: MOVWF 63
0CEE: MOVF 45,W
0CEF: MOVWF 62
0CF0: MOVF 44,W
0CF1: MOVWF 61
0CF2: BCF 0A.3
0CF3: CALL 582
0CF4: BSF 0A.3
0CF5: MOVF 7A,W
0CF6: MOVWF 47
0CF7: MOVF 79,W
0CF8: MOVWF 46
0CF9: MOVF 78,W
0CFA: MOVWF 45
0CFB: MOVF 77,W
0CFC: MOVWF 44
.................... }
.................... else
0CFD: GOTO 518
.................... {
.................... b=90-b;
0CFE: BSF 03.1
0CFF: CLRF 60
0D00: CLRF 5F
0D01: MOVLW 34
0D02: MOVWF 5E
0D03: MOVLW 85
0D04: MOVWF 5D
0D05: MOVF 47,W
0D06: MOVWF 64
0D07: MOVF 46,W
0D08: MOVWF 63
0D09: MOVF 45,W
0D0A: MOVWF 62
0D0B: MOVF 44,W
0D0C: MOVWF 61
0D0D: BCF 0A.3
0D0E: CALL 582
0D0F: BSF 0A.3
0D10: MOVF 7A,W
0D11: MOVWF 47
0D12: MOVF 79,W
0D13: MOVWF 46
0D14: MOVF 78,W
0D15: MOVWF 45
0D16: MOVF 77,W
0D17: MOVWF 44
.................... }
.................... }
.................... else
0D18: GOTO 550
.................... {
.................... if(Y>=0)
0D19: BTFSC 24.7
0D1A: GOTO 536
.................... {
.................... b=180-b;
0D1B: BSF 03.1
0D1C: CLRF 60
0D1D: CLRF 5F
0D1E: MOVLW 34
0D1F: MOVWF 5E
0D20: MOVLW 86
0D21: MOVWF 5D
0D22: MOVF 47,W
0D23: MOVWF 64
0D24: MOVF 46,W
0D25: MOVWF 63
0D26: MOVF 45,W
0D27: MOVWF 62
0D28: MOVF 44,W
0D29: MOVWF 61
0D2A: BCF 0A.3
0D2B: CALL 582
0D2C: BSF 0A.3
0D2D: MOVF 7A,W
0D2E: MOVWF 47
0D2F: MOVF 79,W
0D30: MOVWF 46
0D31: MOVF 78,W
0D32: MOVWF 45
0D33: MOVF 77,W
0D34: MOVWF 44
.................... }
.................... else
0D35: GOTO 550
.................... {
.................... b=270+b;
0D36: BCF 03.1
0D37: CLRF 60
0D38: CLRF 5F
0D39: MOVLW 07
0D3A: MOVWF 5E
0D3B: MOVLW 87
0D3C: MOVWF 5D
0D3D: MOVF 47,W
0D3E: MOVWF 64
0D3F: MOVF 46,W
0D40: MOVWF 63
0D41: MOVF 45,W
0D42: MOVWF 62
0D43: MOVF 44,W
0D44: MOVWF 61
0D45: BCF 0A.3
0D46: CALL 582
0D47: BSF 0A.3
0D48: MOVF 7A,W
0D49: MOVWF 47
0D4A: MOVF 79,W
0D4B: MOVWF 46
0D4C: MOVF 78,W
0D4D: MOVWF 45
0D4E: MOVF 77,W
0D4F: MOVWF 44
0D50: BSF 03.6
.................... }
.................... }
....................
.................... }
....................
....................
....................
.................... }
.................... printf("uhel namìreny %10.2f \r\n", b);
0D51: MOVLW 22
0D52: MOVWF 0D
0D53: MOVLW 00
0D54: MOVWF 0F
0D55: MOVLW 0E
0D56: BCF 03.6
0D57: MOVWF 48
0D58: BCF 0A.3
0D59: CALL 6C3
0D5A: BSF 0A.3
0D5B: MOVLW 09
0D5C: MOVWF 04
0D5D: MOVF 47,W
0D5E: MOVWF 4B
0D5F: MOVF 46,W
0D60: MOVWF 4A
0D61: MOVF 45,W
0D62: MOVWF 49
0D63: MOVF 44,W
0D64: MOVWF 48
0D65: MOVLW 02
0D66: MOVWF 4C
0D67: GOTO 28E
0D68: MOVLW 20
0D69: MOVWF 55
0D6A: BCF 0A.3
0D6B: CALL 0B6
0D6C: BSF 0A.3
0D6D: MOVLW 0D
0D6E: MOVWF 55
0D6F: BCF 0A.3
0D70: CALL 0B6
0D71: BSF 0A.3
0D72: MOVLW 0A
0D73: MOVWF 55
0D74: BCF 0A.3
0D75: CALL 0B6
0D76: BSF 0A.3
.................... return b;
0D77: MOVF 44,W
0D78: MOVWF 77
0D79: MOVF 45,W
0D7A: MOVWF 78
0D7B: MOVF 46,W
0D7C: MOVWF 79
0D7D: MOVF 47,W
0D7E: MOVWF 7A
....................
.................... }
0D7F: RETURN
....................
.................... float azimut (void) //vypocet aktualni vysky panelu
.................... {
.................... X= magR (MAG_XH, MAG_XL);
*
1000: MOVLW 03
1001: MOVWF 48
1002: MOVLW 04
1003: MOVWF 49
1004: BCF 0A.4
1005: BSF 0A.3
1006: CALL 644
1007: BSF 0A.4
1008: BCF 0A.3
1009: MOVF 79,W
100A: MOVWF 22
100B: MOVF 78,W
100C: MOVWF 21
.................... Y= magR (MAG_YH, MAG_YL);
100D: MOVLW 07
100E: MOVWF 48
100F: MOVLW 08
1010: MOVWF 49
1011: BCF 0A.4
1012: BSF 0A.3
1013: CALL 644
1014: BSF 0A.4
1015: BCF 0A.3
1016: MOVF 79,W
1017: MOVWF 24
1018: MOVF 78,W
1019: MOVWF 23
.................... Z= magR (MAG_ZH, MAG_ZL);
101A: MOVLW 05
101B: MOVWF 48
101C: MOVLW 06
101D: MOVWF 49
101E: BCF 0A.4
101F: BSF 0A.3
1020: CALL 644
1021: BSF 0A.4
1022: BCF 0A.3
1023: MOVF 79,W
1024: MOVWF 26
1025: MOVF 78,W
1026: MOVWF 25
....................
....................
....................
....................
.................... AX=abs(X);
1027: MOVF 22,W
1028: MOVWF 7A
1029: MOVF 21,W
102A: BTFSS 22.7
102B: GOTO 035
102C: MOVF 21,W
102D: SUBLW 00
102E: MOVWF 77
102F: CLRF 7A
1030: MOVF 22,W
1031: BTFSS 03.0
1032: INCFSZ 22,W
1033: SUBWF 7A,F
1034: MOVF 77,W
1035: MOVWF 27
1036: MOVF 7A,W
1037: MOVWF 28
.................... AY=abs(Y);
1038: MOVF 24,W
1039: MOVWF 7A
103A: MOVF 23,W
103B: BTFSS 24.7
103C: GOTO 046
103D: MOVF 23,W
103E: SUBLW 00
103F: MOVWF 77
1040: CLRF 7A
1041: MOVF 24,W
1042: BTFSS 03.0
1043: INCFSZ 24,W
1044: SUBWF 7A,F
1045: MOVF 77,W
1046: MOVWF 29
1047: MOVF 7A,W
1048: MOVWF 2A
.................... AZ=abs(Z);
1049: MOVF 26,W
104A: MOVWF 7A
104B: MOVF 25,W
104C: BTFSS 26.7
104D: GOTO 057
104E: MOVF 25,W
104F: SUBLW 00
1050: MOVWF 77
1051: CLRF 7A
1052: MOVF 26,W
1053: BTFSS 03.0
1054: INCFSZ 26,W
1055: SUBWF 7A,F
1056: MOVF 77,W
1057: MOVWF 2B
1058: MOVF 7A,W
1059: MOVWF 2C
....................
.................... float a, b;
.................... a=(float)Y/X;
105A: MOVF 24,W
105B: MOVWF 4D
105C: MOVF 23,W
105D: MOVWF 4C
105E: BCF 0A.4
105F: CALL 3DF
1060: BSF 0A.4
1061: MOVF 77,W
1062: MOVWF 48
1063: MOVF 78,W
1064: MOVWF 49
1065: MOVF 79,W
1066: MOVWF 4A
1067: MOVF 7A,W
1068: MOVWF 4B
1069: MOVF 22,W
106A: MOVWF 4D
106B: MOVF 21,W
106C: MOVWF 4C
106D: BCF 0A.4
106E: CALL 3DF
106F: BSF 0A.4
1070: MOVF 4B,W
1071: MOVWF 60
1072: MOVF 4A,W
1073: MOVWF 5F
1074: MOVF 49,W
1075: MOVWF 5E
1076: MOVF 48,W
1077: MOVWF 5D
1078: MOVF 7A,W
1079: MOVWF 64
107A: MOVF 79,W
107B: MOVWF 63
107C: MOVF 78,W
107D: MOVWF 62
107E: MOVF 77,W
107F: MOVWF 61
1080: BCF 0A.4
1081: CALL 404
1082: BSF 0A.4
1083: MOVF 7A,W
1084: MOVWF 43
1085: MOVF 79,W
1086: MOVWF 42
1087: MOVF 78,W
1088: MOVWF 41
1089: MOVF 77,W
108A: MOVWF 40
.................... b=atan(a);
108B: MOVF 43,W
108C: MOVWF 4B
108D: MOVF 42,W
108E: MOVWF 4A
108F: MOVF 41,W
1090: MOVWF 49
1091: MOVF 40,W
1092: MOVWF 48
1093: BCF 0A.4
1094: BSF 0A.3
1095: CALL 000
1096: BSF 0A.4
1097: BCF 0A.3
1098: MOVF 7A,W
1099: MOVWF 47
109A: MOVF 79,W
109B: MOVWF 46
109C: MOVF 78,W
109D: MOVWF 45
109E: MOVF 77,W
109F: MOVWF 44
.................... b = (b/3.14)*180;
10A0: MOVF 47,W
10A1: MOVWF 60
10A2: MOVF 46,W
10A3: MOVWF 5F
10A4: MOVF 45,W
10A5: MOVWF 5E
10A6: MOVF 44,W
10A7: MOVWF 5D
10A8: MOVLW C3
10A9: MOVWF 64
10AA: MOVLW F5
10AB: MOVWF 63
10AC: MOVLW 48
10AD: MOVWF 62
10AE: MOVLW 80
10AF: MOVWF 61
10B0: BCF 0A.4
10B1: CALL 404
10B2: BSF 0A.4
10B3: MOVF 77,W
10B4: MOVWF 48
10B5: MOVF 78,W
10B6: MOVWF 49
10B7: MOVF 79,W
10B8: MOVWF 4A
10B9: MOVF 7A,W
10BA: MOVWF 4B
10BB: MOVWF 60
10BC: MOVF 4A,W
10BD: MOVWF 5F
10BE: MOVF 49,W
10BF: MOVWF 5E
10C0: MOVF 48,W
10C1: MOVWF 5D
10C2: CLRF 64
10C3: CLRF 63
10C4: MOVLW 34
10C5: MOVWF 62
10C6: MOVLW 86
10C7: MOVWF 61
10C8: BCF 0A.4
10C9: CALL 50D
10CA: BSF 0A.4
10CB: MOVF 7A,W
10CC: MOVWF 47
10CD: MOVF 79,W
10CE: MOVWF 46
10CF: MOVF 78,W
10D0: MOVWF 45
10D1: MOVF 77,W
10D2: MOVWF 44
.................... b=abs(b);
10D3: MOVF 44,W
10D4: MOVWF 77
10D5: MOVF 45,W
10D6: MOVWF 78
10D7: MOVF 46,W
10D8: MOVWF 79
10D9: MOVF 47,W
10DA: MOVWF 7A
10DB: BCF 78.7
10DC: MOVF 47,W
10DD: MOVWF 47
10DE: MOVF 46,W
10DF: MOVWF 46
10E0: MOVF 78,W
10E1: MOVWF 45
10E2: MOVF 44,W
10E3: MOVWF 44
....................
....................
....................
....................
.................... if(X==0) //osetreni proti deleni 0
10E4: MOVF 21,F
10E5: BTFSS 03.2
10E6: GOTO 101
10E7: MOVF 22,F
10E8: BTFSS 03.2
10E9: GOTO 101
.................... {
.................... if(Y>0)
10EA: BTFSC 24.7
10EB: GOTO 0FA
10EC: MOVF 24,F
10ED: BTFSS 03.2
10EE: GOTO 0F3
10EF: MOVF 23,W
10F0: SUBLW 00
10F1: BTFSC 03.0
10F2: GOTO 0FA
.................... {
.................... b=90;
10F3: CLRF 47
10F4: CLRF 46
10F5: MOVLW 34
10F6: MOVWF 45
10F7: MOVLW 85
10F8: MOVWF 44
.................... }
.................... else
10F9: GOTO 100
.................... {
.................... b=270;
10FA: CLRF 47
10FB: CLRF 46
10FC: MOVLW 07
10FD: MOVWF 45
10FE: MOVLW 87
10FF: MOVWF 44
.................... }
.................... }
.................... else
1100: GOTO 15E
.................... {
.................... if(X>0)
1101: BTFSC 22.7
1102: GOTO 127
1103: MOVF 22,F
1104: BTFSS 03.2
1105: GOTO 10A
1106: MOVF 21,W
1107: SUBLW 00
1108: BTFSC 03.0
1109: GOTO 127
.................... {
.................... if(Y>=0)
110A: BTFSS 24.7
.................... {
.................... b=b;
.................... }
.................... else
110B: GOTO 126
.................... {
.................... b=360-b;
110C: BSF 03.1
110D: CLRF 60
110E: CLRF 5F
110F: MOVLW 34
1110: MOVWF 5E
1111: MOVLW 87
1112: MOVWF 5D
1113: MOVF 47,W
1114: MOVWF 64
1115: MOVF 46,W
1116: MOVWF 63
1117: MOVF 45,W
1118: MOVWF 62
1119: MOVF 44,W
111A: MOVWF 61
111B: BCF 0A.4
111C: CALL 582
111D: BSF 0A.4
111E: MOVF 7A,W
111F: MOVWF 47
1120: MOVF 79,W
1121: MOVWF 46
1122: MOVF 78,W
1123: MOVWF 45
1124: MOVF 77,W
1125: MOVWF 44
.................... }
.................... }
.................... else
1126: GOTO 15E
.................... {
.................... if(Y>=0)
1127: BTFSC 24.7
1128: GOTO 144
.................... {
.................... b=180-b;
1129: BSF 03.1
112A: CLRF 60
112B: CLRF 5F
112C: MOVLW 34
112D: MOVWF 5E
112E: MOVLW 86
112F: MOVWF 5D
1130: MOVF 47,W
1131: MOVWF 64
1132: MOVF 46,W
1133: MOVWF 63
1134: MOVF 45,W
1135: MOVWF 62
1136: MOVF 44,W
1137: MOVWF 61
1138: BCF 0A.4
1139: CALL 582
113A: BSF 0A.4
113B: MOVF 7A,W
113C: MOVWF 47
113D: MOVF 79,W
113E: MOVWF 46
113F: MOVF 78,W
1140: MOVWF 45
1141: MOVF 77,W
1142: MOVWF 44
.................... }
.................... else
1143: GOTO 15E
.................... {
.................... b=180+b;
1144: BCF 03.1
1145: CLRF 60
1146: CLRF 5F
1147: MOVLW 34
1148: MOVWF 5E
1149: MOVLW 86
114A: MOVWF 5D
114B: MOVF 47,W
114C: MOVWF 64
114D: MOVF 46,W
114E: MOVWF 63
114F: MOVF 45,W
1150: MOVWF 62
1151: MOVF 44,W
1152: MOVWF 61
1153: BCF 0A.4
1154: CALL 582
1155: BSF 0A.4
1156: MOVF 7A,W
1157: MOVWF 47
1158: MOVF 79,W
1159: MOVWF 46
115A: MOVF 78,W
115B: MOVWF 45
115C: MOVF 77,W
115D: MOVWF 44
.................... }
.................... }
....................
.................... }
....................
.................... return b;
115E: MOVF 44,W
115F: MOVWF 77
1160: MOVF 45,W
1161: MOVWF 78
1162: MOVF 46,W
1163: MOVWF 79
1164: MOVF 47,W
1165: MOVWF 7A
....................
.................... }
1166: RETURN
....................
.................... void motorA (int8 H) //pro ovladani prvniho motoru nastaveni vysky
.................... {
.................... switch(H){
*
0120: MOVF 40,W
0121: XORLW 01
0122: BTFSC 03.2
0123: GOTO 128
0124: XORLW 03
0125: BTFSC 03.2
0126: GOTO 131
0127: GOTO 13A
.................... case 1: //reverzní chod
.................... output_low (AIN2);
0128: BSF 03.5
0129: BCF 08.1
012A: BCF 03.5
012B: BCF 08.1
.................... output_high (AIN1);
012C: BSF 03.5
012D: BCF 08.0
012E: BCF 03.5
012F: BSF 08.0
.................... break;
0130: GOTO 142
....................
.................... case 2: //dopøedu
.................... output_low (AIN1);
0131: BSF 03.5
0132: BCF 08.0
0133: BCF 03.5
0134: BCF 08.0
.................... output_high (AIN2);
0135: BSF 03.5
0136: BCF 08.1
0137: BCF 03.5
0138: BSF 08.1
.................... break;
0139: GOTO 142
....................
.................... default:
.................... output_low (AIN2);
013A: BSF 03.5
013B: BCF 08.1
013C: BCF 03.5
013D: BCF 08.1
.................... output_low (AIN1);
013E: BSF 03.5
013F: BCF 08.0
0140: BCF 03.5
0141: BCF 08.0
.................... }
.................... }
0142: RETURN
....................
.................... void motorB (int8 H) //pro ovladani prvniho motoru nastaveni vysky
.................... {
.................... switch(H){
*
07C5: MOVF 40,W
07C6: XORLW 01
07C7: BTFSC 03.2
07C8: GOTO 7CD
07C9: XORLW 03
07CA: BTFSC 03.2
07CB: GOTO 7D6
07CC: GOTO 7DF
.................... case 1: //reverzní chod
.................... output_low (BIN2);
07CD: BSF 03.5
07CE: BCF 08.3
07CF: BCF 03.5
07D0: BCF 08.3
.................... output_high (BIN1);
07D1: BSF 03.5
07D2: BCF 08.2
07D3: BCF 03.5
07D4: BSF 08.2
.................... break;
07D5: GOTO 7E7
....................
.................... case 2: //dopøedu
.................... output_low (BIN1);
07D6: BSF 03.5
07D7: BCF 08.2
07D8: BCF 03.5
07D9: BCF 08.2
.................... output_high (BIN2);
07DA: BSF 03.5
07DB: BCF 08.3
07DC: BCF 03.5
07DD: BSF 08.3
.................... break;
07DE: GOTO 7E7
....................
.................... default:
.................... output_low (BIN2);
07DF: BSF 03.5
07E0: BCF 08.3
07E1: BCF 03.5
07E2: BCF 08.3
.................... output_low (BIN1);
07E3: BSF 03.5
07E4: BCF 08.2
07E5: BCF 03.5
07E6: BCF 08.2
.................... }
.................... }
07E7: RETURN
....................
.................... void vyska_set (int8 H) //slouzi pro nastaveni nove vysky panelu
.................... {
.................... printf("Akcelerometr4: \r\n",);
*
0D80: MOVLW 3A
0D81: BSF 03.6
0D82: MOVWF 0D
0D83: MOVLW 00
0D84: MOVWF 0F
0D85: BCF 0A.3
0D86: BCF 03.6
0D87: CALL 0DA
0D88: BSF 0A.3
.................... float a;
.................... int16 b,c;
....................
.................... a=vyska();
0D89: CALL 385
0D8A: MOVF 7A,W
0D8B: MOVWF 3B
0D8C: MOVF 79,W
0D8D: MOVWF 3A
0D8E: MOVF 78,W
0D8F: MOVWF 39
0D90: MOVF 77,W
0D91: MOVWF 38
.................... b= (int16) a;
0D92: MOVF 3B,W
0D93: MOVWF 43
0D94: MOVF 3A,W
0D95: MOVWF 42
0D96: MOVF 39,W
0D97: MOVWF 41
0D98: MOVF 38,W
0D99: MOVWF 40
0D9A: BCF 0A.3
0D9B: CALL 726
0D9C: BSF 0A.3
0D9D: MOVF 79,W
0D9E: MOVWF 3D
0D9F: MOVF 78,W
0DA0: MOVWF 3C
....................
.................... if(b>350)
0DA1: MOVF 3D,W
0DA2: SUBLW 00
0DA3: BTFSC 03.0
0DA4: GOTO 5AF
0DA5: XORLW FF
0DA6: BTFSS 03.2
0DA7: GOTO 5AC
0DA8: MOVF 3C,W
0DA9: SUBLW 5E
0DAA: BTFSC 03.0
0DAB: GOTO 5AF
.................... {
.................... b=0;
0DAC: CLRF 3D
0DAD: CLRF 3C
.................... }
.................... else
0DAE: GOTO 5AF
.................... {
....................
.................... }
.................... c=abs(H-b);
0DAF: MOVF 3C,W
0DB0: SUBWF 37,W
0DB1: MOVWF 40
0DB2: CLRF 41
0DB3: MOVF 3D,W
0DB4: BTFSS 03.0
0DB5: INCFSZ 3D,W
0DB6: SUBWF 41,F
0DB7: MOVF 41,W
0DB8: MOVWF 3F
0DB9: MOVF 40,W
0DBA: MOVWF 3E
....................
.................... while(c>2) //maximalni odchylka uhlu, aby nebylo potreba panelem hybat
.................... {
0DBB: MOVF 3F,F
0DBC: BTFSS 03.2
0DBD: GOTO 5C2
0DBE: MOVF 3E,W
0DBF: SUBLW 02
0DC0: BTFSC 03.0
0DC1: GOTO 61E
.................... while(H!=b) //probiha dokud se uhel panelu nerovna zadanemu na cele stupne
.................... {
0DC2: MOVF 3C,W
0DC3: SUBWF 37,W
0DC4: BTFSS 03.2
0DC5: GOTO 5C9
0DC6: MOVF 3D,F
0DC7: BTFSC 03.2
0DC8: GOTO 61D
....................
.................... if(H>b)
0DC9: MOVF 3D,F
0DCA: BTFSS 03.2
0DCB: GOTO 5D6
0DCC: MOVF 37,W
0DCD: SUBWF 3C,W
0DCE: BTFSC 03.0
0DCF: GOTO 5D6
.................... {
.................... motorA(2);
0DD0: MOVLW 02
0DD1: MOVWF 40
0DD2: BCF 0A.3
0DD3: CALL 120
0DD4: BSF 0A.3
....................
.................... }
.................... else
0DD5: GOTO 5DB
.................... {
.................... motorA(1);
0DD6: MOVLW 01
0DD7: MOVWF 40
0DD8: BCF 0A.3
0DD9: CALL 120
0DDA: BSF 0A.3
.................... }
....................
.................... delay_ms (50); //cas sepnuti motoru
0DDB: MOVLW 32
0DDC: MOVWF 40
0DDD: BCF 0A.3
0DDE: CALL 1C8
0DDF: BSF 0A.3
....................
.................... motorA(3); //vypne motor
0DE0: MOVLW 03
0DE1: MOVWF 40
0DE2: BCF 0A.3
0DE3: CALL 120
0DE4: BSF 0A.3
.................... delay_ms (50); //doma na ustaleni panelu pred merenim
0DE5: MOVLW 32
0DE6: MOVWF 40
0DE7: BCF 0A.3
0DE8: CALL 1C8
0DE9: BSF 0A.3
.................... a=vyska();
0DEA: CALL 385
0DEB: MOVF 7A,W
0DEC: MOVWF 3B
0DED: MOVF 79,W
0DEE: MOVWF 3A
0DEF: MOVF 78,W
0DF0: MOVWF 39
0DF1: MOVF 77,W
0DF2: MOVWF 38
.................... b= (int16) a;
0DF3: MOVF 3B,W
0DF4: MOVWF 43
0DF5: MOVF 3A,W
0DF6: MOVWF 42
0DF7: MOVF 39,W
0DF8: MOVWF 41
0DF9: MOVF 38,W
0DFA: MOVWF 40
0DFB: BCF 0A.3
0DFC: CALL 726
0DFD: BSF 0A.3
0DFE: MOVF 79,W
0DFF: MOVWF 3D
0E00: MOVF 78,W
0E01: MOVWF 3C
....................
.................... if(b>350) //osetreni pro uhel 0. Zabezpeci ze neprejde stav z 0 na 359 kdy by se solar zacal tocit na druhou stranu
0E02: MOVF 3D,W
0E03: SUBLW 00
0E04: BTFSC 03.0
0E05: GOTO 610
0E06: XORLW FF
0E07: BTFSS 03.2
0E08: GOTO 60D
0E09: MOVF 3C,W
0E0A: SUBLW 5E
0E0B: BTFSC 03.0
0E0C: GOTO 610
.................... {
.................... b=0;
0E0D: CLRF 3D
0E0E: CLRF 3C
.................... }
.................... else
0E0F: GOTO 610
.................... {
.................... b=b;
.................... }
.................... c=abs(H-b);
0E10: MOVF 3C,W
0E11: SUBWF 37,W
0E12: MOVWF 40
0E13: CLRF 41
0E14: MOVF 3D,W
0E15: BTFSS 03.0
0E16: INCFSZ 3D,W
0E17: SUBWF 41,F
0E18: MOVF 41,W
0E19: MOVWF 3F
0E1A: MOVF 40,W
0E1B: MOVWF 3E
.................... }
0E1C: GOTO 5C2
.................... }
0E1D: GOTO 5BB
.................... motorA(3); //vypne motor
0E1E: MOVLW 03
0E1F: MOVWF 40
0E20: BCF 0A.3
0E21: CALL 120
0E22: BSF 0A.3
.................... printf("Podaøené nastavení výka: %Ld\r\n", b);
0E23: MOVLW 44
0E24: BSF 03.6
0E25: MOVWF 0D
0E26: MOVLW 00
0E27: MOVWF 0F
0E28: MOVLW 1A
0E29: BCF 03.6
0E2A: MOVWF 48
0E2B: BCF 0A.3
0E2C: CALL 6C3
0E2D: BSF 0A.3
0E2E: MOVLW 10
0E2F: MOVWF 04
0E30: MOVF 3D,W
0E31: MOVWF 41
0E32: MOVF 3C,W
0E33: MOVWF 40
0E34: BCF 0A.3
0E35: CALL 745
0E36: BSF 0A.3
0E37: MOVLW 0D
0E38: MOVWF 55
0E39: BCF 0A.3
0E3A: CALL 0B6
0E3B: BSF 0A.3
0E3C: MOVLW 0A
0E3D: MOVWF 55
0E3E: BCF 0A.3
0E3F: CALL 0B6
0E40: BSF 0A.3
.................... }
0E41: BCF 0A.3
0E42: BSF 0A.4
0E43: GOTO 281 (RETURN)
....................
.................... void azimut_set (int8 H) //slouzi pro nastaveni nove vysky panelu
.................... {
.................... float a;
.................... int16 b,c;
....................
.................... a=azimut();
*
0F19: BSF 0A.4
0F1A: BCF 0A.3
0F1B: CALL 000
0F1C: BCF 0A.4
0F1D: BSF 0A.3
0F1E: MOVF 7A,W
0F1F: MOVWF 3B
0F20: MOVF 79,W
0F21: MOVWF 3A
0F22: MOVF 78,W
0F23: MOVWF 39
0F24: MOVF 77,W
0F25: MOVWF 38
.................... b= (int16) a;
0F26: MOVF 3B,W
0F27: MOVWF 43
0F28: MOVF 3A,W
0F29: MOVWF 42
0F2A: MOVF 39,W
0F2B: MOVWF 41
0F2C: MOVF 38,W
0F2D: MOVWF 40
0F2E: BCF 0A.3
0F2F: CALL 726
0F30: BSF 0A.3
0F31: MOVF 79,W
0F32: MOVWF 3D
0F33: MOVF 78,W
0F34: MOVWF 3C
.................... //printf("auhel pro mereni: %Ld(procenta)\r\n", b);
.................... if(b>350)
0F35: MOVF 3D,W
0F36: SUBLW 00
0F37: BTFSC 03.0
0F38: GOTO 743
0F39: XORLW FF
0F3A: BTFSS 03.2
0F3B: GOTO 740
0F3C: MOVF 3C,W
0F3D: SUBLW 5E
0F3E: BTFSC 03.0
0F3F: GOTO 743
.................... {
.................... b=0;
0F40: CLRF 3D
0F41: CLRF 3C
.................... }
.................... else
0F42: GOTO 743
.................... {
....................
.................... }
.................... c=abs(H-b);
0F43: MOVF 3C,W
0F44: SUBWF 37,W
0F45: MOVWF 40
0F46: CLRF 41
0F47: MOVF 3D,W
0F48: BTFSS 03.0
0F49: INCFSZ 3D,W
0F4A: SUBWF 41,F
0F4B: MOVF 41,W
0F4C: MOVWF 3F
0F4D: MOVF 40,W
0F4E: MOVWF 3E
....................
.................... while(c>3) //maximalni odchylka uhlu, aby nebylo potreba panelem hybat
.................... {
0F4F: MOVF 3F,F
0F50: BTFSS 03.2
0F51: GOTO 756
0F52: MOVF 3E,W
0F53: SUBLW 03
0F54: BTFSC 03.0
0F55: GOTO 7B6
.................... while(H!=b) //probiha dokud se uhel panelu nerovna zadanemu na cele stupne
.................... {
0F56: MOVF 3C,W
0F57: SUBWF 37,W
0F58: BTFSS 03.2
0F59: GOTO 75D
0F5A: MOVF 3D,F
0F5B: BTFSC 03.2
0F5C: GOTO 7B5
....................
.................... if(H>b)
0F5D: MOVF 3D,F
0F5E: BTFSS 03.2
0F5F: GOTO 76A
0F60: MOVF 37,W
0F61: SUBWF 3C,W
0F62: BTFSC 03.0
0F63: GOTO 76A
.................... {
.................... motorB(2);
0F64: MOVLW 02
0F65: MOVWF 40
0F66: BCF 0A.3
0F67: CALL 7C5
0F68: BSF 0A.3
....................
.................... }
.................... else
0F69: GOTO 76F
.................... {
.................... motorB(1);
0F6A: MOVLW 01
0F6B: MOVWF 40
0F6C: BCF 0A.3
0F6D: CALL 7C5
0F6E: BSF 0A.3
.................... }
....................
.................... delay_ms (50); //cas sepnuti motoru
0F6F: MOVLW 32
0F70: MOVWF 40
0F71: BCF 0A.3
0F72: CALL 1C8
0F73: BSF 0A.3
....................
.................... motorB(3); //vypne motor
0F74: MOVLW 03
0F75: MOVWF 40
0F76: BCF 0A.3
0F77: CALL 7C5
0F78: BSF 0A.3
.................... delay_ms (50); //doma na ustaleni panelu pred merenim
0F79: MOVLW 32
0F7A: MOVWF 40
0F7B: BCF 0A.3
0F7C: CALL 1C8
0F7D: BSF 0A.3
.................... a=azimut();
0F7E: BSF 0A.4
0F7F: BCF 0A.3
0F80: CALL 000
0F81: BCF 0A.4
0F82: BSF 0A.3
0F83: MOVF 7A,W
0F84: MOVWF 3B
0F85: MOVF 79,W
0F86: MOVWF 3A
0F87: MOVF 78,W
0F88: MOVWF 39
0F89: MOVF 77,W
0F8A: MOVWF 38
.................... b= (int16) a;
0F8B: MOVF 3B,W
0F8C: MOVWF 43
0F8D: MOVF 3A,W
0F8E: MOVWF 42
0F8F: MOVF 39,W
0F90: MOVWF 41
0F91: MOVF 38,W
0F92: MOVWF 40
0F93: BCF 0A.3
0F94: CALL 726
0F95: BSF 0A.3
0F96: MOVF 79,W
0F97: MOVWF 3D
0F98: MOVF 78,W
0F99: MOVWF 3C
....................
.................... if(b>350) //osetreni pro uhel 0. Zabezpeci ze neprejde stav z 0 na 359 kdy by se solar zacal tocit na druhou stranu
0F9A: MOVF 3D,W
0F9B: SUBLW 00
0F9C: BTFSC 03.0
0F9D: GOTO 7A8
0F9E: XORLW FF
0F9F: BTFSS 03.2
0FA0: GOTO 7A5
0FA1: MOVF 3C,W
0FA2: SUBLW 5E
0FA3: BTFSC 03.0
0FA4: GOTO 7A8
.................... {
.................... b=0;
0FA5: CLRF 3D
0FA6: CLRF 3C
.................... }
.................... else
0FA7: GOTO 7A8
.................... {
.................... b=b;
.................... }
.................... c=abs(H-b);
0FA8: MOVF 3C,W
0FA9: SUBWF 37,W
0FAA: MOVWF 40
0FAB: CLRF 41
0FAC: MOVF 3D,W
0FAD: BTFSS 03.0
0FAE: INCFSZ 3D,W
0FAF: SUBWF 41,F
0FB0: MOVF 41,W
0FB1: MOVWF 3F
0FB2: MOVF 40,W
0FB3: MOVWF 3E
.................... }
0FB4: GOTO 756
.................... }
0FB5: GOTO 74F
.................... motorA(3); //vypne motor
0FB6: MOVLW 03
0FB7: MOVWF 40
0FB8: BCF 0A.3
0FB9: CALL 120
0FBA: BSF 0A.3
.................... printf("Podaøené nastavení azimut: %Ld\r\n", b);
0FBB: MOVLW 64
0FBC: BSF 03.6
0FBD: MOVWF 0D
0FBE: MOVLW 00
0FBF: MOVWF 0F
0FC0: MOVLW 1B
0FC1: BCF 03.6
0FC2: MOVWF 48
0FC3: BCF 0A.3
0FC4: CALL 6C3
0FC5: BSF 0A.3
0FC6: MOVLW 10
0FC7: MOVWF 04
0FC8: MOVF 3D,W
0FC9: MOVWF 41
0FCA: MOVF 3C,W
0FCB: MOVWF 40
0FCC: BCF 0A.3
0FCD: CALL 745
0FCE: BSF 0A.3
0FCF: MOVLW 0D
0FD0: MOVWF 55
0FD1: BCF 0A.3
0FD2: CALL 0B6
0FD3: BSF 0A.3
0FD4: MOVLW 0A
0FD5: MOVWF 55
0FD6: BCF 0A.3
0FD7: CALL 0B6
0FD8: BSF 0A.3
.................... }
0FD9: BCF 0A.3
0FDA: BSF 0A.4
0FDB: GOTO 287 (RETURN)
....................
....................
.................... void main()
.................... {
*
11DA: CLRF 04
11DB: BCF 03.7
11DC: MOVLW 1F
11DD: ANDWF 03,F
11DE: MOVLW 71
11DF: BSF 03.5
11E0: MOVWF 0F
11E1: MOVF 0F,W
11E2: BCF 03.5
11E3: BCF 20.7
11E4: MOVF 20,W
11E5: BSF 03.5
11E6: MOVWF 07
11E7: BCF 03.5
11E8: BSF 07.7
11E9: BSF 03.5
11EA: BSF 03.6
11EB: MOVF 09,W
11EC: ANDLW C0
11ED: MOVWF 09
11EE: BCF 03.6
11EF: BCF 1F.4
11F0: BCF 1F.5
11F1: MOVLW 00
11F2: BSF 03.6
11F3: MOVWF 08
11F4: BCF 03.5
11F5: CLRF 07
11F6: CLRF 08
11F7: CLRF 09
....................
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
*
11FB: BSF 03.5
11FC: BSF 03.6
11FD: MOVF 09,W
11FE: ANDLW C0
11FF: MOVWF 09
1200: BCF 03.6
1201: BCF 1F.4
1202: BCF 1F.5
1203: MOVLW 00
1204: BSF 03.6
1205: MOVWF 08
.................... setup_adc(ADC_CLOCK_DIV_2);
1206: BCF 03.5
1207: BCF 03.6
1208: BCF 1F.6
1209: BCF 1F.7
120A: BSF 03.5
120B: BCF 1F.7
120C: BCF 03.5
120D: BSF 1F.0
.................... setup_spi(SPI_SS_DISABLED);
120E: BCF 14.5
120F: BCF 20.5
1210: MOVF 20,W
1211: BSF 03.5
1212: MOVWF 07
1213: BCF 03.5
1214: BSF 20.4
1215: MOVF 20,W
1216: BSF 03.5
1217: MOVWF 07
1218: BCF 03.5
1219: BCF 20.3
121A: MOVF 20,W
121B: BSF 03.5
121C: MOVWF 07
121D: MOVLW 01
121E: BCF 03.5
121F: MOVWF 14
1220: MOVLW 00
1221: BSF 03.5
1222: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
1223: MOVF 01,W
1224: ANDLW C7
1225: IORLW 08
1226: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
1227: BCF 03.5
1228: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
1229: MOVLW 00
122A: MOVWF 78
122B: MOVWF 12
122C: MOVLW 00
122D: BSF 03.5
122E: MOVWF 12
.................... setup_ccp1(CCP_OFF);
122F: BCF 03.5
1230: BSF 20.2
1231: MOVF 20,W
1232: BSF 03.5
1233: MOVWF 07
1234: BCF 03.5
1235: CLRF 17
1236: BSF 03.5
1237: CLRF 1B
1238: CLRF 1C
1239: MOVLW 01
123A: MOVWF 1D
.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
123B: BCF 03.5
123C: BSF 03.6
123D: CLRF 07
123E: CLRF 08
123F: CLRF 09
....................
.................... setup_adc_ports(PIN_A0); //piny pro A/D RA0
1240: BSF 03.5
1241: MOVF 09,W
1242: ANDLW C0
1243: MOVWF 09
1244: BCF 03.6
1245: BCF 1F.4
1246: BCF 1F.5
1247: MOVLW 28
1248: BSF 03.6
1249: MOVWF 08
.................... setup_adc_ports(PIN_A1); //piny pro A/D RA1
124A: MOVF 09,W
124B: ANDLW C0
124C: MOVWF 09
124D: BCF 03.6
124E: BCF 1F.4
124F: BCF 1F.5
1250: MOVLW 29
1251: BSF 03.6
1252: MOVWF 08
....................
.................... printf("Akcelerometr: \r\n",);
1253: MOVLW 85
1254: BCF 03.5
1255: MOVWF 0D
1256: MOVLW 00
1257: MOVWF 0F
1258: BCF 0A.4
1259: BCF 03.6
125A: CALL 0DA
125B: BSF 0A.4
....................
.................... motorA(3);
125C: MOVLW 03
125D: MOVWF 40
125E: BCF 0A.4
125F: CALL 120
1260: BSF 0A.4
....................
.................... float a, b;
.................... unsigned int value1=10,value2=10;
1261: MOVLW 0A
1262: MOVWF 35
1263: MOVWF 36
....................
....................
.................... setAK(); //nastaveni akcelerometru
1264: BCF 0A.4
1265: GOTO 18D
1266: BSF 0A.4
.................... setmag();
1267: BCF 0A.4
1268: GOTO 1DC
1269: BSF 0A.4
.................... printf("Akcelerometr1: \r\n",);
126A: MOVLW 8E
126B: BSF 03.6
126C: MOVWF 0D
126D: MOVLW 00
126E: MOVWF 0F
126F: BCF 0A.4
1270: BCF 03.6
1271: CALL 0DA
1272: BSF 0A.4
.................... while(TRUE)
.................... {
....................
.................... printf("Akcelerometr2: \r\n",);
1273: MOVLW 98
1274: BSF 03.6
1275: MOVWF 0D
1276: MOVLW 00
1277: MOVWF 0F
1278: BCF 0A.4
1279: BCF 03.6
127A: CALL 0DA
127B: BSF 0A.4
....................
....................
....................
....................
....................
.................... /// set_adc_channel(0); //nastavi AD na kanál 0 (RA0)
.................... /// read_adc(ADC_START_ONLY); // Spustime A/D prevod
.................... // Delay_ms(1);
.................... // while(!adc_done()); // Cekame na dokonceni prevodu
.................... // value1=read_adc(); // Precteme hodnotu z prevodniku
.................... vyska_set (90);
127C: MOVLW 5A
127D: MOVWF 37
127E: BCF 0A.4
127F: BSF 0A.3
1280: GOTO 580
1281: BSF 0A.4
1282: BCF 0A.3
.................... azimut_set(0);
1283: CLRF 37
1284: BCF 0A.4
1285: BSF 0A.3
1286: GOTO 719
1287: BSF 0A.4
1288: BCF 0A.3
.................... printf("zadaný azimut %d \r\n", value1);
1289: MOVLW A2
128A: BSF 03.6
128B: MOVWF 0D
128C: MOVLW 00
128D: MOVWF 0F
128E: MOVLW 0E
128F: BCF 03.6
1290: MOVWF 48
1291: BCF 0A.4
1292: CALL 6C3
1293: BSF 0A.4
1294: MOVF 35,W
1295: MOVWF 37
1296: MOVLW 1F
1297: MOVWF 38
1298: GOTO 167
1299: MOVLW 20
129A: MOVWF 55
129B: BCF 0A.4
129C: CALL 0B6
129D: BSF 0A.4
129E: MOVLW 0D
129F: MOVWF 55
12A0: BCF 0A.4
12A1: CALL 0B6
12A2: BSF 0A.4
12A3: MOVLW 0A
12A4: MOVWF 55
12A5: BCF 0A.4
12A6: CALL 0B6
12A7: BSF 0A.4
....................
.................... // set_adc_channel(1); //nastavi AD na kanál 1 (RA1)
.................... // read_adc(ADC_START_ONLY); // Spustime A/D prevod
.................... // Delay_ms(1);
.................... // while(!adc_done()); // Cekame na dokonceni prevodu
.................... // value2=read_adc();
.................... //vyska_set (90);
....................
....................
.................... delay_ms (2000);
12A8: MOVLW 08
12A9: MOVWF 37
12AA: MOVLW FA
12AB: MOVWF 40
12AC: BCF 0A.4
12AD: CALL 1C8
12AE: BSF 0A.4
12AF: DECFSZ 37,F
12B0: GOTO 2AA
....................
....................
.................... }
12B1: GOTO 273
.................... }
12B2: SLEEP
Configuration Fuses:
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
Word 2: 3FFF NOWRT BORV40