From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

About High Throughput Arctan Function in Labview FPGA

Solved!
Go to solution

Hello everyone, 

As far as I know the phase range of arctan should be (-pi/2, pi/2). But the High throughput arctan function in LabVIEW FPGA  seems to make the output phase to be (-pi,pi). I really don't understand why they define it like this and this conflicts with my project requirement. 

 

b.JPG

 

And also, I attached my project screenshot. I thought my design is right but it seems to have some problems. The signal comes into each AI is sine wave. The frequency is 25MHZ, and the AI sample rate is 100MHZ, so that means the AI can sample 4 points in each sine wave period. If you are familiar with signal processing, it is called IQ sampling. So the sampled points are I, Q, -I, -Q. What I want to calculate is calculate arctan (I/Q), and arctan (-I/Q) and ignore the arctan (Q/-I) or arctan (-Q/I). In order to achieve this, I do something to the input valid port of Arctan function. I wire a boolean value to the shift register to make it change between true and false, and the wire it to the input valid port of arctan. So this means it do calculates every two cycles and it should achieve my goal. 

a.JPG

 

But actually, the result is not what I expected. So is there anything wrong with my programming? 

 

I really hope I can get answers from you and thank you so much for that. 

0 Kudos
Message 1 of 3
(3,478 Views)
Solution
Accepted by topic author zyb1003

The mathematical ATN takes one Real input value and returns as you say a value in the range -Pi/2, +Pi/2. However you have two inputs resp. X and Y and you have to consider this as a Complex number so the ATN is not only calculated using the ratio Y/X but also 'looks' at the sign of X. In other words think about your input as the X and Y coordinates of a point in the complex plan and ATN is the angle (argument) of that point with respect to the origine. For positive X values you get an angle in the range -Pi/2, +Pi/2, for negative X values you get the mirrored ranged across the vertical Y axis.

 

In core LabVIEW it's the difference in behavior between ATN and ATN2 in the trigonometric palette. Check the Help for more details,

 

Your Input Valid ping-pong is almost correct. However as far as I see it will be true for the first two iterations since you are forcing it to be true the very first time (First Call?)

 

If you calculate the ATN for pairs +Q, +I resp, -Q, -I you would not see the difference is you used the simple ATN since the ratio would be the same in both cases. The function you are using is therefore the right one and will return values that alternates with Pi, but it assumes that you are actually calculating the right dataset. Apart from the duplicate 'input valid' at the beginning I don't see how you synchronize you toggling to the incoming data.

Message 2 of 3
(3,434 Views)

Hi, thanks for replying so soon!

For the reason that I need to implement arctan in single cycle time loop, I must use the high throughput math function, and atan2 is the only choice. So is there any way to make the output to be in the range (-pi/2, pi/2) ??  Let's say if I use the absolute function to make x always be positive, then x is unsigned data, and y is still the signed data, I think the calculation might have problem. 

And second, yes, what I designed for the input valid ping pong is wrong, it shouldn't have the first time call function. It should be like the following screenshot:

 

c.JPG

 

And you say you don't know my synchronization of toggling to the incoming data? So the first cycle input valid is false, because only I is delivered. And the second cycle, input valid is true, Q delivers to X, and the feedback node delivers I, the calculation begins. Then the third cycle, the input valid turns to be false, arctan (Q/-I) isn't calculated. The fourth cycle calculate the arctan (-I/-Q) as the first cycle. 

 

 

0 Kudos
Message 3 of 3
(3,422 Views)