Jump to content
Chris4321

Unable to use fxATan2 block

Recommended Posts

Hello, 

I need to use fxATan2 block to decode the angle value. I need an efficient way to do this so I am using fixed-point blocks. The issue is that I am not able to extract the angle value using fixed point arc tan block. I was not a problem decoding angle value from normal atan block. 

I have attached a simulation file. Please check and advise me what changes are needed to be done.

 

Note: I have tried converting the sin/cos to per unit as recommended in help. With both fx1.16 & fx1.32 based data types but nothing worked.

 

If there is another efficient way to do this then please recommend as atan is itself quite inefficient.

fxATan2_test.vsm

Share this post


Link to post
Share on other sites

image.png.46a17866e277533d5476193f178b54e2.png

Atan2(sin(θ), cos(θ)) uniquely determines angle throughout a full 2pi rotation.
A single arctan(sin(θ)/cos(θ)) is ambiguous since negative valued sin(θ)/positive cos(θ) has the same value as positive sin(θ)/negative cos(θ)
Additionally, using atan2 in fixed point is computationally faster and more precise than dividing sin/cos and then doing arctan().
The result angle of fxAtan2 ranges from 0 to 1, atan2 ranges from  -π to π

In the plot above we use 1 Hz sin and cos.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...