Cordic trig assembly code for PIC18f


Results 1 to 40 of 55

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Art View Post
    Ideally, to potentially be able to do full rotation of a pixel.
    Yes, I have a matrix LED display in mind
    I wouldn't care whether or not it is equally divided into 360 degrees.
    I already have made routines that make it easy to draw to the screen.

    I can do this in C on the Sony PSP like this
    Code:
    xx = 240;
    yy = 30;
    x = xx - 240;
    y = yy - 136;
    
    theta = rotation;
    thetab = 360 - theta;
    thetab = (3.141592 / 180) * theta;
    
    xnew = cos(thetab)*x - sin(thetab)*y;
    ynew = sin(thetab)*x + cos(thetab)*y;
    
    xnew = xnew + 240;
    ynew = ynew + 136;
    Where x-240, y-136 are coordinates for the centre of the screen,
    x-240,y-30 is the arbitrary point I want to rotate (the one given is a point directly above the centre of the screen),
    rotation is the real angle 0-359 (0 can also be 360).
    xnew and ynew are the new (rotated) coordinates.
    I don't know if this works with microcontrollers even if you do use a C compiler.
    Yes, it looks like you could use the same type of math. The cordic lets you compute sin and cos in a single operation. It is very quick with this type of thing, and can perform about 2000 of these per second.

    So you would just have to solve:



    as you have in your above equation. The PIC18 cordic is a little better, and I documented it more. But if you still want to do it with your PIC16, I am here to help.

    Wikipedia talks a little bit about rotation here: http://en.wikipedia.org/wiki/Rotation_%28mathematics%29
    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 31st January 2010 at 05:20.

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