<p>The problem can be restated:
360 / 20 = 18 deg / sec = 1 deg / .056 sec</p>

<p>One degree is the smallest increment provided by the rotation sensors.</p>

<p>NXT-G has a timer sensor with 1/100th second resolution.</p>

<p>In pseudo-code:</p>

<pre><code>Set a motorPower variable to 10
Start a timer
Loop until rotationDegrees &gt;= 360
    If timeElapsed * 18 &gt; rotationSensorDegrees
        motorPower = motorPower - 1
    Else
        motorPower = motorPower + 1
    End If
    MoveBlock (power = motorPower)
End Loop
MoveBlock (stop)
</code></pre>

<p>Of course, use of the 8 tooth and 40 tooth gears to give a 5 to 1 reduction would give even better results.  Even the best programming will have trouble offsetting bad mechanics.</p>

CC BY-SA 3.0
2013-10-13T23:45:17.347Z
2013-10-13T23:45:17.347Z
dfrevert
<p>I'm interested in mimicking the functionality of the <a href="http://kck.st/J2CuKT" rel="nofollow noreferrer">Arqball Spin</a>, at $60 it isn't cheap so I'd like to make the most out of my Mindstorms parts.</p>

<p>I'd like to use NXT-G to program a motor to rotate 360° in 20 seconds. NXT-G can only controll the power of the motor and duration (Unlimited, Degrees, Rotations &amp; Seconds). The power of the motor can be set from 0 to 100 seemingly arbitrary values:</p>

<p><img src="https://i.sstatic.net/j3ZyS.png" alt="enter image description here"></p>

<p>I don't mind using 3rd party software to program the motor, provided it's easy to use.</p>

CC BY-SA 3.0
2012-07-24T11:15:10.603Z
Do you have access to the Rotation Sensor at all? You might be able to do some internal calibration prior to the main run?
Zhaph - Ben Duguid
CC BY-SA 3.0
2012-07-25T20:24:12.100Z
@Zhaph-BenDuguid Yes, I do, but it hasn't helped much. My motor is weak at low power (4-12-ish), it would turn at a reliable speed so I increased the power of the motor and added a small gear to power a larger one.
Ambo100
<nxt><mindstorms><programming><motor><nxt-g>
Program a full rotation of a NXT motor in X seconds
Ambo100
# Program a full rotation of a NXT motor in X seconds

(Asked by: username_0 on 2012-07-22)

I'm interested in mimicking the functionality of the [Arqball Spin](http://kck.st/J2CuKT), at $60 it isn't cheap so I'd like to make the most out of my Mindstorms parts.

I'd like to use NXT-G to program a motor to rotate 360° in 20 seconds. NXT-G can only controll the power of the motor and duration (Unlimited, Degrees, Rotations & Seconds). The power of the motor can be set from 0 to 100 seemingly arbitrary values:

![enter image description here](https://i.sstatic.net/j3ZyS.png)

I don't mind using 3rd party software to program the motor, provided it's easy to use.

**Tags:** nxt, mindstorms, programming, motor, nxt-g

> **Comments:**
> **username_1**: Do you have access to the Rotation Sensor at all? You might be able to do some internal calibration prior to the main run?  
> **username_0**: @Zhaph-BenDuguid Yes, I do, but it hasn't helped much. My motor is weak at low power (4-12-ish), it would turn at a reliable speed so I increased the power of the motor and added a small gear to power a larger one.  

---

## 1 answers

### Answer by username_2 on 2013-10-13. Score: 5 | Accepted answer

The problem can be restated:
360 / 20 = 18 deg / sec = 1 deg / .056 sec
One degree is the smallest increment provided by the rotation sensors.
NXT-G has a timer sensor with 1/100th second resolution.
In pseudo-code:
Set a motorPower variable to 10
Start a timer
Loop until rotationDegrees >= 360
    If timeElapsed * 18 > rotationSensorDegrees
        motorPower = motorPower - 1
    Else
        motorPower = motorPower + 1
    End If
    MoveBlock (power = motorPower)
End Loop
MoveBlock (stop)

Of course, use of the 8 tooth and 40 tooth gears to give a 5 to 1 reduction would give even better results.  Even the best programming will have trouble offsetting bad mechanics.


---

