calculation problem


Closed Thread
Results 1 to 3 of 3
  1. #1
    nicolelawsc's Avatar
    nicolelawsc Guest

    Default calculation problem

    hi all,
    my project now is dealing with some calculation.The main purpose is i want to get average value of Xs and Ys .
    The problem i faced now is when i compile it,there was error "unable to fix the variable "
    the formula are:
    tan thetai= (yi – ys)/(xi- xs) i=1,2,3


    below was the code i wrote:

    X1 var word
    Y1 var word
    X2 var word
    Y2 var word
    X3 var word
    Y3 var word
    Xs var word
    Ys var word
    Xs1 var word
    Xs2 var word
    Xs3 var word
    Ys1 var word
    Ys2 var word
    Ys3 var word



    theta1 var word
    theta2 var word
    theta3 var word

    sin_value1 var word
    cos_value1 var word
    tan_value1 var word

    sin_value2 var word
    cos_value2 var word
    tan_value2 var word

    sin_value3 var word
    cos_value3 var word
    tan_value3 var word

    temp1 var word
    temp2 var word
    temp3 var word
    temp4 var word
    temp5 var word
    temp6 var word
    temp7 var word
    temp8 var word
    temp9 var word
    temp10 var word
    temp11 var word
    temp12 var word
    temp13 var word
    temp14 var word
    temp15 var word
    temp16 var word
    temp17 var word
    temp18 var word
    temp19 var word
    temp20 var word
    temp21 var word
    temp22 var word
    temp23 var word
    temp24 var word
    temp25 var word
    temp26 var word
    tempA var word
    tempB var word
    tempC var word

    let X1 = 0000
    let Y1 = 0000
    let X2 = 0000
    let Y2 = 6000
    let X3 = 6000
    let Y3 = 6000




    sin_value1 = sin theta1
    cos_value1 = cos theta1
    tan_value1 = sin_value1/cos_value1


    sin_value2 = sin theta2
    cos_value2 = cos theta2
    tan_value2 = sin_value2/cos_value2


    sin_value3 = sin theta3
    cos_value3 = cos theta3
    tan_value3 = sin_value3/cos_value3




    temp1 = Y2-Y1
    temp2 = X1*tan_value1
    temp3 = X2*tan_value2
    temp4 = tan_value1 - tan_value2
    temp5 = temp2 - temp3
    temp6 = temp1 + temp5
    Xs1 = temp6 / temp4

    temp7 = Xs1 -X1
    temp8 = temp7 * tan_value1
    Ys1 = Y1 + temp8


    temp9 = Y3-Y2
    temp10 = X2*tan_value2
    temp11 = X3*tan_value3
    temp12 = tan_value2 - tan_value3
    temp13 = temp10 - temp11
    temp14 = temp9 + temp13
    Xs2 = temp14 / temp12

    temp15 = Xs2 -X2
    temp16 = temp15 * tan_value2
    Ys2 = Y2 + temp16


    temp17 = Y3-Y1
    temp18 = X1*tan_value1
    temp19 = X3*tan_value3
    temp20 = tan_value1 - tan_value3
    temp21 = temp18 - temp19
    temp22 = temp17 + temp21
    Xs3 = temp22 / temp20

    temp23 = Xs3 -X1
    temp24 = temp23 * tan_value1
    Ys3 = Y1 + temp24

    temp25 = Xs1+Xs2+Xs3
    temp26 = Ys1 + Ys2 + Ys3
    Xs = temp25/3
    Ys = temp26/3

    end



    thanks a lot

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Are you sure the error was not “ERROR: Unable to fit variable” instead of “fix the variable”? If it was “fit”, then you are most certainly using a PIC without enough RAM for all 110 bytes that you are requesting.

    Your code as is compiles fine using a 16F628 (224 bytes of RAM) as the target device but NOT with the 16F84A (68 bytes of RAM) as the target device. In the latter, I get the unable to fit error noted above. Check the data sheet for your PIC to see how much RAM is available. Please let us know.

    Good Luck,

    Paul Borgmeier
    Salt Lake City, Utah
    USA

  3. #3
    nicolelawsc's Avatar
    nicolelawsc Guest


    Did you find this post helpful? Yes | No

    Default

    thank you very much paul. Before this i use 16F84A (68 bytes of RAM) as the target device, and now change it to 16F877A and it can compile sucessfully..
    thanks again.

Similar Threads

  1. Calculation Problem - value goes to zero after 65
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 12th March 2010, 06:10
  2. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 20:52
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 09:12
  4. Microcode Studio 18f2455 problem?????
    By volkan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st May 2007, 22:04
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 23:59

Members who have read this thread : 1

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