Showing results for 
Search instead for 
Did you mean: 

Algorithm that can calculate the shortest path between 0-360 degrees for an AC servo motor.

Go to solution

How does Bob's solution stand up to the "golden" VI?

(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 61 of 67

Here (bottom) is alternative code that gives the same (probably incorrect!!!) result as the code by constructionworker (top).


Arguably slightly simpler 😄




Message 62 of 67

wiebe@CARYA wrote:

This seems to give the same results as the presumably working example.


At least for the 5 values I've tested:

Motor direction.png

Thanks for your answer.

This seems to work. 🙂
I almost started banging my head against the walls.

At least according to the chart here it looks error free.

I waited for a while and was able to better describe the problem once I understood what was required. I think the bird's nest helped explain the situation better 🙂


0 Kudos
Message 63 of 67

wiebe@CARYA wrote:

@altenbach wrote:

wiebe@CARYA wrote:

At least for the 5 values I've tested:

Well, In this case it is simple to do an exhaustive analysis of all 360x360 possible inputs. For at least 1/8th of the samples, there is a difference in the "send to motor" command. I doubt any version is actually correct. 😄


Not that it helps, but I think the Current input isn't limited to 0 or 360, it can be anything...


Yes, but it can always be Q&R'd into 0..259. It is safe to say that if your version (I am not going to use the word "solution" for anything posted here! 😄 ) differs in the shown range, it is not the same.


We can easily expand the exhaustive 2D test for a much wider range of one of the inputs.

0 Kudos
Message 64 of 67

Me trying to follow this thread-




Heads up! NI is moving LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 65 of 67

Thanks everyone for your effort. Problem solved.
The exact desired algorithm is as follows.


Message 66 of 67

@constructionworker wrote:

Thanks everyone for your effort. Problem solved.
The exact desired algorithm is as follows.

A greedy loop is never the solution.


Make sure you wear safety goggles and keep your fingers out of the device when testing with actual hardware. 😄


0 Kudos
Message 67 of 67