Help please with Assembly (PBPro user)


Results 1 to 10 of 10

Threaded View

  1. #10
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    After seeing some odd behavior while rotating the accelerometer, I eventually noticed that in the formula I used, an assumption is made that rotation is ideal around the y axis. So as long as you have x rotation but not y, it works, or y rotation, but not x, it works. But if you have a combination of both, it did not give you correct values.

    Time for a new equation. The good news was, the same data sheet that showed me the "ideal" equation had an example of the equation I wanted.



    http://www.freescale.com/files/senso...ote/AN3461.pdf

    This equation required longs, and a few other adjustments. It seems to be pretty accurate, though I have not come up with an easy way to test it.
    I have included TRIGL.INC, which has a minor edit to run with pbpl.



    Here is the meat of the code:

    Code:
    solveangle:
    '**********Solve for x angle ********************************************
    if xresult < yresult + zresult then 
        dummy = 5000   'when x is smaller the following equation works best
        xlong = (dummy * xresult) /(sqr((yresult*yresult) + (zresult*zresult)))
    else  'keeps results accurate at near 0 and near 90 degree values
        dummy =30      'when x is larger the following equation works best
        xlong = (dummy * xresult*xresult) / ((yresult*yresult)+(zresult*zresult))
    endif
    y = xlong
    x = dummy 'Assign x and y values for atan2 function
    call atan2
    xangle = 9000 - y
    
    if yresult < xresult + zresult then 
        dummy = 5000  'when y is smaller the following eqauation works best
        ylong = (dummy * yresult) / (sqr((xresult*xresult) + (zresult*zresult)))
    else
        dummy =30 'when y is larger the following equation works best
        ylong = (dummy * yresult*yresult) / ((xresult*xresult)+(zresult*zresult))
    endif 
    y = ylong
    x = dummy '
    call atan2
    yangle = 9000 - y
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by ScaleRobotics; - 9th October 2010 at 17:36.
    http://www.scalerobotics.com

Similar Threads

  1. Adding PBPro code to an ASM file - how to?
    By wjsmarine in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th January 2010, 18:49
  2. Picbasic Pro Demo assembly errors
    By mikeRho in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd January 2008, 06:41
  3. Assembly Guru : Question
    By Archangel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th May 2007, 03:51
  4. from assembly to basic
    By shantanu in forum Off Topic
    Replies: 4
    Last Post: - 1st February 2007, 14:50
  5. How do you do this in Assembly
    By ice in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th May 2005, 06:47

Members who have read this thread : 0

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