# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

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

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

Bill

(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.
Message 61 of 67
(801 Views)

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

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
(799 Views)

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

wiebe@CARYA wrote:

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

At least for the 5 values I've tested:

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 🙂

Message 63 of 67
(794 Views)

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

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.

Message 64 of 67
(793 Views)

Message 65 of 67
(772 Views)

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

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

Message 66 of 67
(759 Views)

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

@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. 😄

Message 67 of 67
(730 Views)