Shop OBEX P1 Docs P2 Docs Learn Events
Reading the SIN tables — Parallax Forums

Reading the SIN tables

HarpritHarprit Posts: 539
edited 2009-11-24 01:14 in Propeller 1
I have a value in degrees. How do I read the SIN of this value
from the SIN tables in SPIN.

Harprit

Comments

  • tronsnavytronsnavy Posts: 70
    edited 2009-11-20 23:54
    Not sure if this is what you are looking for, but attached program converts a "degrees" value (and range), to coordinates (X,Y) value, using the sin table.· Understand that this DOES NOT USE FLOTING POINT (FP) MATH.· It uses INTERGER MATH.· Thus, your return value is an integer value.· If you want "FLOATING FOINT" output, then let me know.· I can modify the program to use FP.· Modify the CON (constant) values (degree and range) (in the constant block) to get coordinate value.· You should be able to get an idea from my source code (to help you understand the sin table).· If not, please reply.· Once you start the program, you will need to start "PST" (and “enable” (before 2 seconds) ) to see the results.
  • HarpritHarprit Posts: 539
    edited 2009-11-21 01:11
    This is for my book for beginners
    I need to show them how to read a value from the Log, SIN tables etc.
    If I can read a memory location, I think I can do the rest.
    I don't have a clue as to how one reads a memory location
    I may be missing something.
    But I do want to do it in SPIN, no PASM

    Harprit
  • jazzedjazzed Posts: 11,803
    edited 2009-11-21 02:37
    Harprit said...
    This is for my book for beginners
    I need to show them how to read a value from the Log, SIN tables etc.
    If I can read a memory location, I think I can do the rest.
    I don't have a clue as to how one reads a memory location
    I may be missing something.
    But I do want to do it in SPIN, no PASM

    Harprit
    Fascinating ....

    You can read any memory location with something like ... result := word[noparse][[/noparse]$E000]
    The fine example tronsnavy posted is written entirely in SPIN ... surely you can translate that.
  • KyeKye Posts: 2,200
    edited 2009-11-21 03:02
    Try this out. I think it works fine.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • HarpritHarprit Posts: 539
    edited 2009-11-21 19:27
    Thanks guys, that was extremely helpful.
    A great big thanks to all.

    I can demonstrate what I want in integer math now.
    It remarkable how much easier thing are with some expert guidance
    Now to convert it to a floating point result.

    Regards
    HSS
  • KyeKye Posts: 2,200
    edited 2009-11-22 00:25
    That's what a community is for.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • tronsnavytronsnavy Posts: 70
    edited 2009-11-22 01:43
    HSS,
    Here is an example of using FP math to manipulate the sin table.· If you wish to display a FP value on PST, you must convert any FP value to a string.· Pay close attention to the "attached" objects (to see how the "objects" manipulate the sin table).· I simply modified the program that I sent you earlier (using "objects" from OBX)·.· Did not get a chance to add comments, but I'm sure you can figure it out.· Remember, the "Propeller Object Exchange" is your best friend.· No need to reinvent the wheel.· Good luck.
    Best Regards,
    Bob
  • cessnapilotcessnapilot Posts: 182
    edited 2009-11-22 19:36
    You can avoid floating point with http://obex.parallax.com/objects/501/ This is the first Fixed-Point object at OBEX. It is faster than FloatMath, does trigonometry without extra COGs, hase the fastes ROM table reader routine ever.

    Cheers,

    Istvan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Intentionally Left Blank

    Post Edited (cessnapilot) : 11/22/2009 7:41:39 PM GMT
  • tronsnavytronsnavy Posts: 70
    edited 2009-11-23 13:41


    Istvan,
    Nice Object.· Got a chance to look at it last night.· I will certainly use it, from this point forward, for all future ·Math functions.· Have a good one.
    By the way, I think oral hygiene is over rated.· What say you? icon11.gif

  • cessnapilotcessnapilot Posts: 182
    edited 2009-11-23 23:49
    Bob,

    Those are propeller related (chopped) bugs and 100% bio, at least. Oral hygiene is important, that's why we need orally administered alcohol after the flight.

    Cheers,

    Istvan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Intentionally Left Blank
  • tronsnavytronsnavy Posts: 70
    edited 2009-11-24 01:14
    Istvan,
    Washing "chopped-up" bugs down with alcohol (A high protein treat)... That's got to increase the "halitosis" effect.· A man after my own heart.· Cheers right back at ya. icon9.gif
    Bob
Sign In or Register to comment.