<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Simple Angle Conversion in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067959#M1168445</link>
    <description>&lt;P&gt;That description was initially a comment label in LV, I went back and cleaned it up to possibly get rid of the confusion, and added a couple more examples.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jul 2020 15:19:23 GMT</pubDate>
    <dc:creator>FireFist-Redhawk</dc:creator>
    <dc:date>2020-07-16T15:19:23Z</dc:date>
    <item>
      <title>Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067946#M1168437</link>
      <description>&lt;P&gt;I cannot think this morning... what I need is super simple I feel like, but I can't figure out an easy way to implement it. Please halp.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Inputs: angles c and d:&lt;BR /&gt;current angle = c&lt;BR /&gt;desired angle = d&lt;/P&gt;
&lt;P&gt;Output: angle z that is closest angle to c but is also in the set {d, d+-360, d+-720, ...}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;examples:&lt;/P&gt;
&lt;P&gt;c=0&lt;BR /&gt;d=270&lt;BR /&gt;z=-90&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;c=765&lt;BR /&gt;d=0&lt;BR /&gt;z=720&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;c=-361&lt;/P&gt;
&lt;P&gt;d=-1&lt;/P&gt;
&lt;P&gt;z=-361&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;c=0&lt;/P&gt;
&lt;P&gt;d=3,602&lt;/P&gt;
&lt;P&gt;z=2&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:17:58 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067946#M1168437</guid>
      <dc:creator>FireFist-Redhawk</dc:creator>
      <dc:date>2020-07-16T15:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067953#M1168441</link>
      <description>&lt;P&gt;Hi Andrew,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/626824"&gt;@FireFist-Redhawk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;inputs: angles c and d:&lt;BR /&gt;current angle=c&lt;BR /&gt;desired angle = d&lt;/P&gt;
&lt;P&gt;output: angle z that is closest angle&lt;BR /&gt;examples:&lt;/P&gt;
&lt;P&gt;c=765&lt;BR /&gt;d=0&lt;BR /&gt;z=720&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please explain this example!&lt;/P&gt;
&lt;P&gt;Why should z be 720° when c=765° (=720°+45°) and d=0°???&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 14:56:29 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067953#M1168441</guid>
      <dc:creator>GerdW</dc:creator>
      <dc:date>2020-07-16T14:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067957#M1168443</link>
      <description>&lt;P&gt;Hi GerdW,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure I understand you're query. If my current angle shows 765, and I want to go to 0 (same place for me as +-360,+-720), then z is 720 because its the member of that set whose value is closest to my current angle, 765.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:13:08 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067957#M1168443</guid>
      <dc:creator>FireFist-Redhawk</dc:creator>
      <dc:date>2020-07-16T15:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067959#M1168445</link>
      <description>&lt;P&gt;That description was initially a comment label in LV, I went back and cleaned it up to possibly get rid of the confusion, and added a couple more examples.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:19:23 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067959#M1168445</guid>
      <dc:creator>FireFist-Redhawk</dc:creator>
      <dc:date>2020-07-16T15:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067961#M1168446</link>
      <description>&lt;P&gt;I think this does everything you need.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.ni.com/ni/attachments/ni/170/1168446/1/Example_VI.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea here is to find the differences and keep that difference in a shift register.&amp;nbsp; Add (or subtract) 360 until the absolute value of the difference is greater.&amp;nbsp; The previous value is therefore the closest value.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:26:17 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067961#M1168446</guid>
      <dc:creator>crossrulz</dc:creator>
      <dc:date>2020-07-16T15:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067963#M1168447</link>
      <description>&lt;P&gt;Can you explain it graphically instead?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:25:29 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067963#M1168447</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2020-07-16T15:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067968#M1168448</link>
      <description>&lt;P&gt;Hi Andrew,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please explain this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;c=0
d=3,602
z=2&lt;/LI-CODE&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;I think I get this one - decimal separator confusion. I'm used to commas instead of points…&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:32:28 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067968#M1168448</guid>
      <dc:creator>GerdW</dc:creator>
      <dc:date>2020-07-16T15:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067975#M1168452</link>
      <description>&lt;P&gt;Let's say&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e=(c-d)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and z'=(z-d)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then, you are looking for a z' in {..., -720, 360, 0, 360, 720,...} for which the difference to e is minimal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dividing e by 360 using the quotient &amp;amp; remainder VI gives a quotient which, multiplied with 360 again, is the next &lt;STRONG&gt;lower&lt;/STRONG&gt; multible of 360 to e. If the remainder is &amp;gt;180, add 360 to get the nearest value. This is z'. Add d to get z.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In LabVIEW:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cd.png" style="width: 585px;"&gt;&lt;img src="https://ip1.i.lithium.com/59a37f774cb73ebe194c4741116a48552944f6bd/68747470733a2f2f6e692e6c69746869756d2e636f6d2f74352f696d6167652f736572766572706167652f696d6167652d69642f32373034323269413342313142373633363433334538382f696d6167652d73697a652f6c617267653f763d76322670783d393939" role="button" title="cd.png" alt="cd.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;c=0
&lt;P&gt;d=3,602&lt;/P&gt;
&lt;P&gt;z=2&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;z must be in {..., d-360, d, d+360,...}, so it must be d=3,602 to be next to c....&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:54:06 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067975#M1168452</guid>
      <dc:creator>Sebastian.Weber</dc:creator>
      <dc:date>2020-07-16T15:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067978#M1168453</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/75897"&gt;@crossrulz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I think this does everything you need.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's very dangerous code because it will run forever if any of the inputs is NaN. &lt;span class="lia-unicode-emoji" title=":face_with_open_mouth:"&gt;😮&lt;/span&gt; Maybe you want to reverse some logic so it stops on FALSE instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;(I am pretty sure there is a loop-free solution ;))&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:57:56 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067978#M1168453</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2020-07-16T15:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067992#M1168460</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/7614"&gt;@altenbach&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can you explain it graphically instead?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think we all have the idea at this point but it took me a few mins to make, so may as well post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FireFist-Redhawk_0-1594918933172.png" style="width: 400px;"&gt;&lt;img src="https://ip1.i.lithium.com/f1e41cc339e667d7c33cda116d578167b40ad7cb/68747470733a2f2f6e692e6c69746869756d2e636f6d2f74352f696d6167652f736572766572706167652f696d6167652d69642f32373034323469393443463533413434364534443938442f696d6167652d73697a652f6d656469756d3f763d76322670783d343030" role="button" title="FireFist-Redhawk_0-1594918933172.png" alt="FireFist-Redhawk_0-1594918933172.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 17:08:56 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067992#M1168460</guid>
      <dc:creator>FireFist-Redhawk</dc:creator>
      <dc:date>2020-07-16T17:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067993#M1168461</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/7614"&gt;@altenbach&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;&lt;EM&gt;(I am pretty sure there is a loop-free solution ;))&lt;/EM&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is what I was looking for, a loop-free way of doing it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sebastian, thanks. Your solution works nicely. Kudos&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 17:12:02 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4067993#M1168461</guid>
      <dc:creator>FireFist-Redhawk</dc:creator>
      <dc:date>2020-07-16T17:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4068010#M1168467</link>
      <description>&lt;P&gt;Here's Sebastian's code slightly simplified... (Please validate!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;(Note that I swapped the comparison so an exact translation would use "less or equal". Not sure what's correct. If the remainder is exactly 180, both directions are equally close).&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="altenbach_0-1594921284634.png" style="width: 999px;"&gt;&lt;img src="https://ip1.i.lithium.com/3ba8c2d4ddd62abdf7eae973efac6b9bb71752c3/68747470733a2f2f6e692e6c69746869756d2e636f6d2f74352f696d6167652f736572766572706167652f696d6167652d69642f32373034323969324141343033423739453643323946332f696d6167652d73697a652f6c617267653f763d76322670783d393939" role="button" title="altenbach_0-1594921284634.png" alt="altenbach_0-1594921284634.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 17:48:47 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4068010#M1168467</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2020-07-16T17:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Angle Conversion</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4068013#M1168469</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/7614"&gt;@altenbach&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here's Sebastian's code slightly simplified... (Please validate!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;(Note that I swapped the comparison so an exact translation would use "less or equal". Not sure what's correct. If the remainder is exactly 180, both directions are equally close).&lt;/EM&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Looks like that does work, thanks altenbach!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If anyone is wondering what I'm doing, I'm building a routine for operators to perform an encoder verification test on a unit (the unit is a slip ring that has a built-in encoder). And I needed this as part of the algorithm telling the SmartMotor (another thing we make at a different facility) where to travel to next.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 18:03:08 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Simple-Angle-Conversion/m-p/4068013#M1168469</guid>
      <dc:creator>FireFist-Redhawk</dc:creator>
      <dc:date>2020-07-16T18:03:08Z</dc:date>
    </item>
  </channel>
</rss>

