From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

XM43

Member

09-21-2022 02:11 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

If you do not mind me asking, which motor and drive system are you using?

09-21-2022 02:17 PM - edited 09-21-2022 02:18 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

@XM43 wrote:

If you do not mind me asking, which motor and drive system are you using?

Delta asda-a2 AC servo motor.

I use with internal parameter and PR mode.

altenbach

Knight of NI

09-21-2022 02:21 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

@constructionworker wrote:

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

-No.absolutely

So yes? I.e. implicit, a +10 is a CW and a -10 is CCW.

In my example code, you enter the "go to position" and it will go from the current position to the new absolute position. Right after the value has been changed, the "move!" indicator tells what the remaining relative movement should be (positive or negative, whatever is shorter).

I think we are going in circles!

GerdW

Knight of NI

09-21-2022 02:28 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

Hi worker,

@constructionworker wrote: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.

Why does the motor move 130 degrees when you command to go 340 degrees?

Why does the motor move 150 degrees when you command 340?

Where do these numbers come from?

In the other message you basically stated "absolute position" commands when the motor goes to +-20 degrees...

You really need to explain this problem much better!

altenbach

Knight of NI

09-21-2022 02:32 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

@constructionworker wrote:

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

You need to be more specific (link?) because the code posted here (your last example) is just plain silly, with code such as the following. The comparison makes no difference: There is no wait in the loop! Why? The diagram is maximized to the screen, very annoying to stare at 90% whitespace! Why?

Also explain what a "round" and "lap" is, etc. What exactly are you entering and in what order. What do you see and what do you expect to see instead. Step-by-step!!!

09-21-2022 02:41 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

@GerdW wrote:

Hi worker,

@constructionworker wrote: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.

Why does the motor move 130 degrees when you command to go 340 degrees?

Why does the motor move 150 degrees when you command 340?

Where do these numbers come from?

In the other message you basically stated "absolute position" commands when the motor goes to +-20 degrees...

You really need to explain this problem much better!

Believe me, I started to write the more numbers incorrectly because of dealing with numbers. I'm very very sorry.

correction:

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 330 and reach 340 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 350 degrees in the CCW direction
- and reach -340 degrees.

altenbach

Knight of NI

09-21-2022 02:50 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

@constructionworker wrote:

- and reach -340 degrees.

There are no negative degrees in your position indicator.

09-21-2022 03:08 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

@altenbach wrote:

@constructionworker wrote:

- and reach -340 degrees.
There are no negative degrees in your position indicator.

Yes, because I will be constantly entering positive values between 0-360 from the numerical control.

However, the values that will go to the motor can be negative or positive. A value should be sent to the motor by calculating the shortest path to reach the degree entered from the "numerical control" according to the current degree of the motor. This can be + or - degrees.

Bob_Schor

Knight of NI

09-21-2022 03:58 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

You are confounding "position" and what I will call "pseudo-velocity". Position, as you have defined it with your circular disk label 360, 10, 20, ... 340, 350 (going clockwise) are the __only__ possible "positions" (well, there's an ambiguity, as Position 0 = Position 360 -- another way to define "Position" is "Angle clockwise from straight up mod 360", so one complete clockwise revolution = 360° = 0° (because 360 mod 360 = 0). Let's define "Rotate CW from X by Y" as (X + Y) mod 360, and "Rotate CCW from X by Y" as (X - Y) mod 360. So if you start at 10 and rotate CCW by 50, you get to (10 - 50) mod 360 = 320. __You can (by definition) never get to a negative position__ because Position is always 0 .. 360.

So take any two positions, A and B. Start at A and make a single Rotation (of some amount) to get to B. If you are going Clockwise, you need to move by Ycw such that B = A + Ycw, or Ycw = (B - A) mod 360, and if CCW, B = A - Yccw, or Yccw = (A - B) mod 360. Choose the direction that has the smaller value (they'll both be non-negative, of course).

Example -- you are at 15, and want to go to 50. Ycw = (50 - 15) mod 360 = 35. Yccw = (15 - 50) mod 360 = 325. Go CW (because 35 < 325). [Notice that Ycw + Yccw will always be 0 mod 360].

Another example -- you are at 15, and want to go to 350. Ycw = (350 - 15) mod 360 = 335. Yccw = (15 - 350) mod 360 = 25. Go CCW (because 25 < 335).

Bob Schor

billko

Proven Zealot

09-21-2022 04:46 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

@Bob_Schor wrote:

You are confounding "position" and what I will call "pseudo-velocity". Position, as you have defined it with your circular disk label 360, 10, 20, ... 340, 350 (going clockwise) are the

onlypossible "positions" (well, there's an ambiguity, as Position 0 = Position 360 -- another way to define "Position" is "Angle clockwise from straight up mod 360", so one complete clockwise revolution = 360° = 0° (because 360 mod 360 = 0). Let's define "Rotate CW from X by Y" as (X + Y) mod 360, and "Rotate CCW from X by Y" as (X - Y) mod 360. So if you start at 10 and rotate CCW by 50, you get to (10 - 50) mod 360 = 320.You can (by definition) never get to a negative positionbecause Position is always 0 .. 360.

So take any two positions, A and B. Start at A and make a single Rotation (of some amount) to get to B. If you are going Clockwise, you need to move by Ycw such that B = A + Ycw, or Ycw = (B - A) mod 360, and if CCW, B = A - Yccw, or Yccw = (A - B) mod 360. Choose the direction that has the smaller value (they'll both be non-negative, of course).

Example -- you are at 15, and want to go to 50. Ycw = (50 - 15) mod 360 = 35. Yccw = (15 - 50) mod 360 = 325. Go CW (because 35 < 325). [Notice that Ycw + Yccw will always be 0 mod 360].

Another example -- you are at 15, and want to go to 350. Ycw = (350 - 15) mod 360 = 335. Yccw = (15 - 350) mod 360 = 25. Go CCW (because 25 < 335).

Bob Schor

Ugh. This was my first thought from post 1, but I couldn't believe that was what this was all about.

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.

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