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

08-27-2014 03:46 AM

Options

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

Hi,

I am looking for a formula to calculate the Stepper Motor Angle from the Stepper Motor Counter. The Stepper Motor has 1.8 Degree/200 Steps Resolution. As it rotates more than 200 Steps, I want the Angle to reset to 0 and start calculating again from 0 to 360 Degrees. As I am a beginner I am confused to use some sort of While or For Loop. Any suggestions?

Solved! Go to Solution.

08-27-2014 03:53 AM

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

Hi rkamat,

use this:

x := StepCount MOD 200 angle := x*1.8

MOD is the modulo function (aka Quotient and Remainder)…

Best regards,

GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO

GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO

08-27-2014 04:19 AM

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

Thanks GerdW. That worked. I had one more question. I have a For loop which rotates the Stepper Motor 1 Step at a time whithin this loop. But I want the Loop Count to be dependent on the Angle Variable within this For loop. I tried creating a constant linking the Stepper Motor Angle and giving it a value of 90 so that the loop runs only till the Stepper Motor Angle within the loop is 90 Degrees. But it seems to run 90 times. Any suggestions?

- Tags:
- GerdW

Solution

Accepted by topic author rkamat

08-27-2014 04:21 AM

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

Hi rkamat,

FOR loops are used when you know the iteration count before starting the loop.

When iteration count depends on a condition you should use a WHILE loop instead…

Best regards,

GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO

GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO

08-27-2014 04:23 AM

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

Thank You!