Example Code

How to achieve 360 degree display using arctangent by case structure?

Code and Documents

Attachment

Introduction

I want to convert some sine and cosine values into a position that I can use for my sensor. How can I do this? I am not sure what functions I should use and how I can go about setting this up.

Steps to Complete

There are a couple of ways that we can convert sine and cosine values into positional data. Initially we start with the idea that tan(x)=[sin(x)/cos(x)]. This can be converted into atan(y). However, the atan(y) only gives an indication somewhere between -90 to 90 degree. One method is simply to use the atan2 function to translate for 360 Degrees. Another method is to use a case structure. The attached VI shows both of these methods being used to give an angle over 360 Degrees.

360Arctan.JPG

Andrew McLennan
Applications Engineer
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors