-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 4/26/2012 9:31 AM, Gabriel Willen wrote:
> But I'm not grasping the sign lookup table.  I have read a half a
> dozen articles on it.  In sure I will figure out, I always do but I
> figured maybe you could help.
> 

I'm still learning LinuxCNC, but I can help with sine look-up tables.

The basic concept is very simple...you create a table in RAM where the
address represents "degrees" (or where you are on the circle) and at
each address you place the sine of that "degree" value.  That way you
can do the complex sine calculations ahead of time and perform a sine
calculation using an indexed memory read.

Using a full circle for your look-up table is wasteful, however, so
typically some folding is done to increase the resolution or reduce
the memory required.  That's where it begins to get a bit more confusing.

Folding around the X and Y coordinates is easy.  You can simply invert
the address and/or the output and use 90 degrees of sine table to
represent 360 degrees of output.

It is also possible to fold around the 45 degree axis, but this
requires a bit more math.

So, if you have a 256 entry table representing a full circle, then
your angle is represented as an 8-bit value with a step resolution of
360 / 256, or apx. 1.4 degrees per binary unit.

If you fold around the x axis, you can create a sine table with twice
as much resolution because it only has to represent 180 degrees (apx.
.7 degrees per binary unit), and your angle value is now nine bits.

To use the folded table, you use the lower 8-bits of your angle to
look up a value from your table.  If the MSB of your angle value is
zero, the angle is between zero and 180 degrees, so you're done.  If
the MSB of your angle is one, you need to transform the value you read
by 180 degrees.  For a sine look-up, that means you invert the output
value you read from your table (90 degrees = +1.0, 180 degrees = -1.0).

Folding around the Y axis is similar.  Your 8 bit look-up table now
represents 90 degrees, and your angle value grows to 10 bits.  The MSB
still represents the 0/180 degree transform (invert the data read from
the table), and bit 9 now represents a 90 degree transform.  Thinking
about 0 to 180 degrees, to transform 90-180 degrees to the 0-90 degree
range, you have to subtract 90 from your desired angle.  Or in other
words, the sine value for 91 degrees is the same as the value for 89
degrees.  In binary land, the easy way to do this is to simply invert
the index value based on bit 9.

So, to sum up, with a 90 degree look-up table, you get the following:

// Calculate index for look-up table
if Angle[msb-1] = 1
  sine_index = not Angle[msb-2 downto 0]
else
  sine_index = Angle[msb-2 downto 0]
fi

// Look up our sine value
Value = Sine_Table[sine_index]

// Calculate output value
if Angle[msb] = 1
  Output = 0 - Value
else
  Output = Value
fi

- -- 
Charles Steinkuehler
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+ZY28ACgkQLywbqEHdNFyloQCdFbhQkx2NNKDuFAbaeiD4bCGG
gWUAn3NUFIjqYd38vmDdunEqwsPRlOvy
=Fu31
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to