Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sine/cos encoder to digital

Status
Not open for further replies.
It is not easy to use a LUT for tan(x).
Right. Actually it's atan(y/x), respectively atan2(x,y). A reasonable implementation uses a half quadrant LUT (0 .. 45 degree) and applies the identity
atan(y/x) = sgn(y)*pi/2 - atan(x/y)
 

A reasonable implementation uses a half quadrant LUT (0 .. 45 degree) and ...

Actually, the formal expansion for atan(x) is:

atan(x)= x -x*x*x/3 +x*x*x*x*x/5 -x*x*x*x*x*x*x/7 +....

This series expansion converges slowly (to get 4 decimal accuracy, you will need perhaps 50 terms ...)

But more importantly, the expansion is valid only for x >=1; (for x=1, the left hand side is pi/4 or 45 deg).

For x>1, you will be forced to use the identity you cite.

In the present case, we need the atan2(x,y) function which in turn calls the atan(x) function after fixing the quadrant.
 

Hello!

That's why we have atan2() function. It's already handling the atan() discontinuities.

I know, but in any case, you're going to end up with very large values when approaching from
the discontinuities when you calculate the ratio. That's why in all the encoders I know, the 45
degrees quadrants approach I was mentioning is used. By this method, you only get numbers
between -1 and +1 (-π/4 ~ π/4 on the other axis), which is very handy when using fixed point
arithmetic or even integers.


Take a look at the original set of data.

That is incorrect.

Just see the plot of tan(x) vs x:

View attachment 156682

(we cannot plot ±∞ and the graph is cropped).

It is not easy to use a LUT for tan(x).

I disagree, what I said is perfectly correct. You may consider reading my post
before claiming I'm wrong.
I was talking of tan, taken in shifted quadrants (from -π/4 to π/4, see my post
above), in which case you have only tan values between -1 and 1. You can then use
the symmetry to reduce further to 1/8 of a circle (0, π/4).
In this case, it's extremely easy to use a LUT, which gives you values that can be
used in fixed point or integer.
The symmetry around π/4 allows to use tan((π/2) -x) to find the angle in the
interval [π/4, π/2], and then the other symmetries for x and y are just a matter of sign.

Now, for the easy / not easy issue, that's really a matter of taste / ability.
What I meant is that this lookup table is not more difficult to make than any other LUT.

Dora.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top