Cordic trig assembly code for PIC18f


Closed Thread
Results 1 to 40 of 55

Hybrid View

  1. #1
    Join Date
    Apr 2010
    Location
    Gavle, Sweden
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Cordic trig assembly code for PIC18f

    Hi !
    I'm trying to write a program to calculate sunrise and sunset. The pic is 18F2550 and I'm using long variables and PBPL. I've tried to use the TRIG.INC but it seems that I cant use it in PBPL, Error: DIV32. Is there a way to rewrite the program so that it will work with PBPL?
    I'm using Picbasic Pro 2.50 and MPASM 8.15.
    Bernt-Ove

  2. #2
    Join Date
    Apr 2010
    Location
    Gavle, Sweden
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Cordic trig assembly code for PIC18f

    The problem is solved. I found another version of trig.inc in post 13, and it works well for me. I have to put the word variables x,y into long variables before doing any calculations on them.

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


    Did you find this post helpful? Yes | No

    Default Re: Cordic trig assembly code for PIC18f

    Quote Originally Posted by B-O Eliasson View Post
    The problem is solved. I found another version of trig.inc in post 13, and it works well for me. I have to put the word variables x,y into long variables before doing any calculations on them.
    That's a good bare bones cordic version as long as you don't mind manipulating the radians. So you could either use that and do math to your liking, or you could use TrigL , which you can find with my tilt example here: http://www.picbasic.co.uk/forum/cont...-axis-g-sensor . If you use TrigL.inc, you would probably want to add a line to replace goto main with goto overcordic
    and at the end of the TrigL.inc add a line overcordic:

    Keep us posted, I'd love to see your project.

    Walter

  4. #4
    Join Date
    Oct 2008
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Cordic trig assembly code for PIC18f

    Hi Walter, I have been looking at this for some time now and keep coming back to this post. I am actually attempting to do a similar project to the tilt sensor project which you have built only on a single axis. I believe I am almost there now and just need a few pointers! I am looking at your code atn2. the following is the equation i require to solve: tan-1 ((zresult - calval)/SQR ((5017 - calval)^2 - (zresult - calval)^2))
    Now from reading your posts would I be right in thinking that if i do the following:

    Code:
    x=0
     y= ((zresult - calval)/SQR ((5017 - calval)^2 - (zresult - calval)^2))
    
    call atn2
    Am I right in thinking that this would convert my equation as I am not interested in the hyp or does the x vaule come into play?

  5. #5
    Join Date
    Jul 2011
    Location
    Hawaii
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: Cordic trig assembly code for PIC18f

    Hi,

    I am using your TRIG.inc in a small program. The values appear correct from (ang) = 0 to 9000, 0 to 90.00 degrees. For values, 9000 < (ang) < 18000 ,the
    values for x and y appear to switch. As an example with an (ang) value of 8900 or 89.00 degrees I receive a value back x = 29995 and y = 525. This seems correct.
    For an (ang) value of 9100 or 91.00 degrees I receive back x = -523 and y = 29995. For 91.00 degrees I would expect x = 29995 and y = -523 ?

    - Martin

Similar Threads

  1. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. 4 Chanel Dmx512 ready assembly code to PBP ?
    By syscoder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 21st March 2007, 23:55
  5. Your Suggestions: Assembly code material?
    By dw_picbasic in forum General
    Replies: 1
    Last Post: - 2nd February 2007, 17:33

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