how can i calculate?


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2016
    Posts
    1

    Default how can i calculate?

    hi everybody;
    sory for my bad english...
    3 days i am working but i could not....

    how to calculate on pic basic pro this formula?
    my pic 18f452

    calculate as word
    B2 as long
    B3 as long
    C2 as long
    C3 as long
    F2 as long
    A2=35,110681 ' i know picbasic not support double
    B2=35,110765
    B3=33,960657
    C3=33,961749
    F2= 3,141593


    calculate=ACOS( SİN(B2*F2/180)*SİN(C2*F2/180) + COS(B2*F2/180)*COS(C2*F2/180)*COS(C3*F2/180-B3*F2/180) ) * 6371000

    if calculate = 99,7687 then true


    can you help me?

    Thanks

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: how can i calculate?

    SIN
    returns the 8-bit sine of a value. The result is in two’s complement form (i.e. -
    127 to 127). It uses a quarter-wave lookup table to find the result. SIN starts with a
    value in binary radians, 0 to 255, as opposed to the usual 0 to 359 degrees.
    I assume that the F2/180 term below is an attempt to convert B2 (35.110765 degrees ) to radians with increased resolution
    SİN(B2*F2/180)
    it won't work
    for a start pbp sin function wants the input to be a Brad and the result will be a signed byte .
    the best you can get with pbp is :-
    all vars here are words
    B0=351 ; 35.1 deg * 10 ie degrees x 10
    B1=B0 */ 182 ; convert to brad ( B0 * 255)/360
    B1=(B1+5)/10 ; scale back to degrees x 1 ( with rounding )
    B2= sin(B1) ; sin 35.1 = 0.575 === pbp sin(25)=73
    serout2 PORTA.0,84, ["brad 35.1 =",# B1,13,10 ] ;===== 25
    serout2 PORTA.0,84, ["sin 35.1 =",# B2,13,10 ] ;==== 73
    73 ====== 73/127 ===== 0.5748

    its more likely you will get a better result from the forum if you explain what you are trying to achieve .
    along with your attempted code

    btw there is no acos function in pbp

Similar Threads

  1. How to calculate Burden Resistor ??
    By andybarrett1 in forum General
    Replies: 9
    Last Post: - 13th January 2015, 20:09
  2. Calculate checksum?
    By jgauthier in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th February 2013, 23:04
  3. Calculate how many amps a solenoid needs
    By The Master in forum Off Topic
    Replies: 20
    Last Post: - 2nd April 2008, 10:23
  4. How to calculate SCLK frequency?
    By GCollier in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th January 2006, 13:30
  5. calculate with date
    By Pedro Pinto in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th October 2005, 16:49

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts