LabVIEW

cancel
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.

Solved!
Go to solution

@constructionworker wrote:


@Henrik_Volkers wrote:

Here is my solution... without bells and whistles

 

 

 

EDIT... didn't read all the new stuff ...  missed the part for cw ccw and absolute position .. 😉

so a little addon: cw or ccw needs to be checked 😉 , the actual command needs to be build anyway 🙂

 


I tested this, but as I explained in the previous message, if -125 is sent to the motor, the motor will start from 0 and go to -125 degrees in the CCW direction, which corresponds to 235 degrees when compared to the compass logic.

No matter how many turns the motor turns, it should go to 235 degrees with compass logic.
According to the current position of the motor, the degree to which the motor should go is 235, but maybe -125 should be sent so that the motor reaches 235 degrees.
Maybe it is 235 degrees for the motor to go, but it is necessary to write 235 for the motor to turn 235 degrees.
maybe the motor should go to 235 degrees, but for the motor to go to 235 degrees, (360+235)595 should be written. It just depends on the current position of the motor (whether it has moved in CCW or CW) and the shortest path.


595 deg. is definitely not compass logic. Compasses have a range of [0-360) deg...

0 Kudos
Message 21 of 67
(1,081 Views)

wiebe@CARYA wrote:


595 deg. is definitely not compass logic. Compasses have a range of [0-360) deg...


595 degree is the value sent to the motor. But mode 360 is 195 degrees.this is compass logic.

0 Kudos
Message 22 of 67
(1,069 Views)

@Basjong53 wrote:

It's still not clear to me what you mean by the absolute position of the motor. Is this position restricted to 0-360? Or can it go beyond? 

When you start the motor and the software, the angle is 0. If you just store all the increments of my example, you know the position of the motor. Let's say you move 200 degrees, 3 times, that's 600 degrees. Is it sufficient to send 600 to the motor?

 

answer:

-The absolute position of the motor is not limited between 0-360. The motor rotates one full turn at 360 degrees. example: lap 1.0-360 lap 2=360-720 lap 3=720-1080

 

-If I send 200, the engine stays in place until I write 201. If I type 201 it goes to 201 degrees. It does not increase by 1 degree, it rises to 201 degrees. If I type 350 it goes to 350 degrees in the CW direction.

@Kevin_Price wrote:

Well, I thought for a minute I had managed to decipher what the request was, but apparently not.   Let me try to restate my present best guess:

 

It sounds like the motor controller is a little bit stupid and has a faulty method for travelling to the requested destination.  It *will* arrive at the correct absolute angle that you requested, but it may take the long way around to get there.  So you want to intervene and (sometimes) add or subtract 360 from the target position, forcing the stupid controller to take the shorter path.

    If I understand right, the controller's problem is that it uses the sign of the commanded position to determine which direction to travel.  The table below lays out what I'm supposing your controller would want to do, and how you would want to intervene to do a smarter thing.

 

Start Pos Original Cmd Pos Controller Motion Modified Cmd Pos Controller Motion
330 30 CW 60 deg 30 CW 60 deg
30 300 CW 270 deg -60 CCW 90 deg
300 -30 CCW 330 deg 330 CW 30 deg
330 240 CW 270 deg -120 CCW 90 deg
240 -60 CCW 300 deg 300 CW 60 deg
300 -180 CCW 120 deg -180 CCW 120 deg

 

If this is an incorrect understanding, please lay out a similar sequence of commanded positions to help define:

A. Which direction and how far the motor would move if you didn't modify the command

B. How you *want* the motor to move instead

C. What command position you would need to send to make the motor move the way you want

 

And please don't use examples where the motor starts from 0 position!  It becomes ambiguous whether your subsequent talk about degrees refer to a *position* or a *relative distance*.   Also, please make a special effort to be really clear about whether you are describing what DOES happen vs. what you WANT to happen.  As I read back through the thread, I often found it hard to tell b/c different msgs seemed to contradict one another.  Probably some were describing what DOES happen while others were describing what you WANT, but I'm not entirely sure which is which.

 

 

-Kevin P


Actually, I created an example that is close to what I want to do but still has problems. What I want to add to this example is if it moves in CCW direction and if the given position command requires it to rotate in CCW direction, it should continue ie -360+-20=-380.
For example, if I move in the CCW direction and reach 10 degrees on the compass, that means going -350 to the motor. In compass logic, if I want to switch to 350 degrees again, it sends -10 instead of -370. The same is true for the CW direction. This is a problem.

 

A. Which direction and how far the motor would move if you didn't modify the command

answer:If I don't change the command, the engine stays in place.

B. How you *want* the motor to move instead

answer:The command entered should be between 0-360 degrees in the compass logic. But it doesn't matter which command goes to the motor, maybe in the 50th turn of the motor, if I say go to 10 degrees, it's okay even if 50*360+10=18010 position is sent to the motor. This is valid in CCW direction.50* -360-10=-18010.

 

C. What command position you would need to send to make the motor move the way you want

answer:I wrote in the answer above.

 

When I examine the table you have created, I think that I have not fully explained what I want to create.

I hope I can reduce the confusion a little more with the example below.

 

 

edit:the example was changed again because there was an error in the "knob" notation.

0 Kudos
Message 23 of 67
(1,055 Views)

Imagine, please, the motor being at position "10 Degrees".

You send it the command "20".

What happens?

 

Imagine the motor again at "10 Degrees"

You send it the command "-20".

What happens?

 

Please try not to use the words "compass logic". Try to not use "compass" at all". It is confusing.

0 Kudos
Message 24 of 67
(1,041 Views)

They say a problem well-defined is a problem half-solved.  We're not there yet.  Sorry, but that last explanation and example made things even *less* clear.  This is turning into the kind of thread I generally stay away from.  Good luck everyone!

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 25 of 67
(1,039 Views)

@LLindenbauer wrote:

Imagine, please, the motor being at position "10 Degrees".

You send it the command "20".

What happens?

 

Imagine the motor again at "10 Degrees"

You send it the command "-20".

What happens?

 

Please try not to use the words "compass logic". Try to not use "compass" at all". It is confusing.


-If I send the 20 command while in the 10(CW) position, the motor goes to 20 degrees in the CW direction.

- If the motor is at 10 degrees CW

If I send the -20 command, the motor goes to 0 and turn to  -20 degrees in the CCW direction.

 

The reason I couldn't tell the Compass logic was to make it a little more understandable.

 

  wrote:

They say a problem well-defined is a problem half-solved.  We're not there yet.  Sorry, but that last explanation and example made things even *less* clear.  This is turning into the kind of thread I generally stay away from.  Good luck everyone!

 

Please try not to use the words "compass logic". Try to not use "compass" at all". It is confusing.


It's an AC servo I'm using. It is not a stepper motor. I think it is confused with stepper motor. This is not a stepper motor and I am not controlling it with an incremental pulse.

 

Thank you for your effort to help.

0 Kudos
Message 26 of 67
(1,039 Views)

@constructionworker wrote:

@LLindenbauer wrote:

Imagine, please, the motor being at position "10 Degrees".

You send it the command "20".

What happens?

 

Imagine the motor again at "10 Degrees"

You send it the command "-20".

What happens?

 

Please try not to use the words "compass logic". Try to not use "compass" at all". It is confusing.


-If I send the 20 command while in the 10(CW) position, the motor goes to 20 degrees in the CW direction.

- If the motor is at 10 degrees CW

If I send the -20 command, the motor goes to 0 and turn to  -20 degrees in the CCW direction.

 

 


What do you mean by "goes to"? Please also indicate in which direction the motor is moving. For example:

 

  • If the motor is at +10 Degrees CW
  • and the command "20" is sent
  • the motor will start turning in the CW direction
  • the motor will turn for 10 degrees
  • the motor will stop at the position +20 Degrees CW

And

 

  • If the motor is at +10 Degrees CW
  • and the command "-20" is sent
  • the motor will start turning in the CCW direction
  • the motor will turn for 30 degrees
  • the motor will stop at the position -20 Degrees CW

 

If the motor is in the "10 Degrees" position and you send it the command "340", what will happen?

If the motor is in the "10 Degrees" position and you send it the command "-340", what will happen?

 

0 Kudos
Message 27 of 67
(1,013 Views)

@constructionworker wrote:
-If I send the 20 command while in the 10(CW) position, the motor goes to 20 degrees in the CW direction.
- If the motor is at 10 degrees CW

If I send the -20 command, the motor goes to 0 and turn to  -20 degrees in the CCW direction..


You are still not making any sense. CW is not a position, but a direction. It is not obvious what you mean by "in the 10(CW) position".

 

You have an overdetermined system, because you have CW/CCW and positive and negative angle definitions. How do they relate?

Is a CW(10) command the same as a CCW(-10) command?

Is CW for positive angles and CCW for negative angles?

 

In any case, my code (and probably many others here!) will give you the positive (CW) and negative (CCW) angles to move to the new position. Have you tried? Do you need an earlier LabVIEW version?

0 Kudos
Message 28 of 67
(1,009 Views)

@LLindenbauer wrote:

@constructionworker wrote:

@LLindenbauer wrote:

Imagine, please, the motor being at position "10 Degrees".

You send it the command "20".

What happens?

 

Imagine the motor again at "10 Degrees"

You send it the command "-20".

What happens?

 

Please try not to use the words "compass logic". Try to not use "compass" at all". It is confusing.


-If I send the 20 command while in the 10(CW) position, the motor goes to 20 degrees in the CW direction.

- If the motor is at 10 degrees CW

If I send the -20 command, the motor goes to 0 and turn to  -20 degrees in the CCW direction.

 

 


What do you mean by "goes to"? Please also indicate in which direction the motor is moving. For example:

 

  • If the motor is at +10 Degrees CW
  • and the command "20" is sent
  • the motor will start turning in the CW direction
  • the motor will turn for 10 degrees
  • the motor will stop at the position +20 Degrees CW

And

 

  • If the motor is at +10 Degrees CW
  • and the command "-20" is sent
  • the motor will start turning in the CCW direction
  • the motor will turn for 30 degrees
  • the motor will stop at the position -20 Degrees CW

 

If the motor is in the "10 Degrees" position and you send it the command "340", what will happen?

If the motor is in the "10 Degrees" position and you send it the command "-340", what will happen?

 


the motor moves as we listed above.

If the motor is in the "10 Degrees" position and you send it the command "340", what will happen?

answer:

  • The motor will move in the CW direction 130 and reach 140 degrees and stop.

 

If the motor is in the "10 Degrees" position and you send it the command "-340", what will happen?

answer:

  • if the motor is at 10 degrees CW
  • when position -340 is sent to the motor
  • the motor will reverse a total of 150 degrees in the CCW direction
  • and reach -140 degrees.

 

0 Kudos
Message 29 of 67
(987 Views)

@altenbach wrote:

@constructionworker wrote:
-If I send the 20 command while in the 10(CW) position, the motor goes to 20 degrees in the CW direction.
- If the motor is at 10 degrees CW

If I send the -20 command, the motor goes to 0 and turn to  -20 degrees in the CCW direction..


You are still not making any sense. CW is not a position, but a direction. It is not obvious what you mean by "in the 10(CW) position".

 

You have an overdetermined system, because you have CW/CCW and positive and negative angle definitions. How do they relate?

Is a CW(10) command the same as a CCW(-10) command?

Is CW for positive angles and CCW for negative angles?

 

In any case, my code (and probably many others here!) will give you the positive (CW) and negative (CCW) angles to move to the new position. Have you tried? Do you need an earlier LabVIEW version?


Is a CW(10) command the same as a CCW(-10) command?

-No.absolutely

Is CW for positive angles and CCW for negative angles?

Yes.absolutely.

 

In any case, my code (and probably many others here!) will give you the positive (CW) and negative (CCW) angles to move to the new position. Have you tried? Do you need an earlier LabVIEW version?

 

I tested but there is a problem.

constructionworker_0-1663786934519.png

also I can only send +/- location to the motor. I can't send CCW or CW.

 

Also, have you looked at the last example I shared? In that example, there is no problem in the 1st round in the rotations between 0 and -360(CW) or between 0 and -360(CCW).

sometimes it needs to go to the 2nd lap in order to take the shortest route to the given position in the CCW direction or CW direction.By round 2 here I mean 360+N or -360-N

0 Kudos
Message 30 of 67
(975 Views)