## Setting custom frequency for nxt motor

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.

### Setting custom frequency for nxt motor

Hey!
Recenetly i got intrested in astrophotography. This is why im trying to motorize my telescope with Mindstorms.
I'm searching for a way to control the rotational frequency of my nxt motors, but I can't find any NXT-G block that would allow me to directly control the rotational frequency.
So what im asking is wether there is a practical way to directly set the frequency of a motor through NXT-G with the frequency on the order of magnitude of 10^-3 hz. Is this possible at all with NXT-g or do i Have to use soemthing like nxc? Or maybe even the hardware isnt accurate enough for these types of slow movements?
d0on

Posts: 3
Joined: 11 Jul 2013, 07:10

### Re: Setting custom frequency for nxt motor

Not an expert, but I doubt if that is possible.

I was looking into this some time ago with the intention of getting a decent moon shot, and the only way I could think of was to use very high gearing and run the motor at variable power.

My present setup uses a Lego chain wrapped round a 100mm diameter base, driven by a worm gear on the motor using a gearwheel as idler.

Diameter of the chain is approximately 103 mm so the circumference is 103 x pi = 324mm, which gives 108 teeth (54 links) so the gear ratio is 108:1.

One rotation of the motor moves the chain by 1 tooth, so a complete revolution of the base requires 108*360=38,880 degrees of motor rotation.

Each degree the motor turns is the equivalent of 1/108 of a degree of camera movement.

I was considering the addition of a gear to the axle on the worm gear and driving that with another worm gear on the motor.

Using a 40-tooth gear, each revolution of the motor would move the new gear by one tooth, giving an overall gear ratio of 40 x 108 = 4320:1, which I hoped would be in the right area.

Of course, this could be adjusted by varying the size of the new gear or the rotating base, introducing additional, conventional gear trains or even a third worm drive!

I intended to monitor the actual rotation of the motor and adjust the power to keep the movement on target.

Sadly, I could not fathom out how to derive the correct panning and tilting speeds to keep the Moon centered, since it's path is continually changing; might be simpler if you are only shooting the stars.

Look forward to hearing how you get on.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
h-g-t

Posts: 531
Joined: 07 Jan 2011, 08:59
Location: Albania

### Re: Setting custom frequency for nxt motor

Tanks for the reply. So it seams I have to do a mechanical approach ,but even then how do I get the motor to turn at ie. 0.56 hz?
What do you mean by "run the motor at variable power"?
If I make any advancements ill post about it. However i doubt it would be very intresting since im only trying to motorize one axis of my equitorial mount.
d0on

Posts: 3
Joined: 11 Jul 2013, 07:10

### Re: Setting custom frequency for nxt motor

what do you mean by 0.56 Hz?

Hz is no proper rotation speed measurement , rotation speed is measured by degrees (or turns) per second or per minute or per hour...

e.g., VERY ROUGHLY,
under a power=100 PWM the NXT motor rotates (when idle) at a rate of about 100 degrees per 100 ms = 1000 degrees/s = 2.7778 turns /s.
under a power=56 PWM the NXT motor rotates (when idle) at a rate of about 56 degrees per 100 ms = 560 degrees/s = 1.556 turns /s.
under a power=20 PWM the NXT motor rotates (when idle) at a rate of about 20 degrees per 100 ms = 200 degrees/s = 0.56 turns /s.

but thats very, very roughly!

doc-helmut

Posts: 2336
Joined: 29 Sep 2010, 14:25

### Re: Setting custom frequency for nxt motor

There's no need for gears, this one uses string wrapped round the base and axle -

http://dativ.at/gigabot/

The only way I know to control the speed precisely is to have a loop with 'wait' and a 'motor' elements.

The motor turns 1 degree each time but the wait period is adjusted to give a longer/ shorter gap between movements.

The weight of the telescope and camera might be sufficient to damp out any vibration due to the individual pulses.

Problem is that friction may prevent any movement until a sufficient tension is built up, then it will move suddenly. ball bearings are advised.

You might find all this simpler in NXC, rather than NXT-G.

It looks more complex, but I converted my program in one day. Just looked for equivalent commands in the NXC library.

Of course, you can have a motor running at a constant speed and use a CVT gearbox controlled by the NXT.

These have been built in Lego (just google Lego variable gearbox) but a metal one might be more precise.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
h-g-t

Posts: 531
Joined: 07 Jan 2011, 08:59
Location: Albania

### Re: Setting custom frequency for nxt motor

You've probably seen this already but I thought I would post it anyway.

Allows you to predict the paths of celestial objects - I was never able to work out how to incorporate it into a Lego program!

http://www.astro.com/swisseph/
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
h-g-t

Posts: 531
Joined: 07 Jan 2011, 08:59
Location: Albania

### Re: Setting custom frequency for nxt motor

and I still need to know
what do you mean by 0.56 Hz?
Hz is no proper rotation speed measurement , rotation speed is measured by degrees (or turns) per second or per minute or per hour...
regards,
HaWe
±≠≈αγδεωΔΦΣ∫√∅∞
NXC CHESS for NXT: http://www.mindstormsforum.de/viewtopic.php?f=70&t=6790
indispensable for NXC + EV3-C: easy + trouble-free network & remote control for rs485, Xbee, BT, USB!

doc-helmut

Posts: 2336
Joined: 29 Sep 2010, 14:25

### Re: Setting custom frequency for nxt motor

Maybe they dont use hz this way in english but in my country they use hz for rotational frequency aswell. Basicaly Hz means 1/sec so 1 Hz means one rotation per second. Its the reciprocal value of the rotational period.
d0on

Posts: 3
Joined: 11 Jul 2013, 07:10

### Re: Setting custom frequency for nxt motor

well, I'm actually from Germany but AFAIK 1/s is a commom unit for us, too.

anyway, then it's probably this what you need and what I already mentioned:
under a power=20 PWM the NXT motor rotates (when idle) at a rate of about 20 degrees per 100 ms = 200 degrees/s = 0.56 turns /s.

But you'll have to monitor the rotation speed by monitoring the current loop time in an endless loop and a wait state of maybe 1000 ms, calculate the current speed of the motor, and adjust the speed if needed.

And I'd take NXC instead of NXT-G if I were you.
regards,
HaWe
±≠≈αγδεωΔΦΣ∫√∅∞
NXC CHESS for NXT: http://www.mindstormsforum.de/viewtopic.php?f=70&t=6790
indispensable for NXC + EV3-C: easy + trouble-free network & remote control for rs485, Xbee, BT, USB!

doc-helmut

Posts: 2336
Joined: 29 Sep 2010, 14:25

### Re: Setting custom frequency for nxt motor

Some useful info on Lego motors here -

http://www.philohome.com/motors/motorcomp.htm

http://www.philohome.com/nxtmotor/nxtmotor.htm

You can also use other motors and drive them with relays (http://www.techno-stuff.com/relay.htm) or one of these -

http://www.mindsensors.com/index.php?mo ... AGE_id=140

The advantage of these is that you can use geared/ more powerful motors, including mains powered -

http://www.ebay.co.uk/sch/i.html?_trksi ... &_from=R40.

You can also run your NXT off the mains - http://www.philohome.com/nxtsupply/nxtsupply.htm

If your program is quite simple, you can also pick up the original Mindstorms bricks very cheaply, and the first models had sockets for an external power supply/ charger so can be run off the mains.

For really precise movements, you can add an I2C interface to the NXT, which allows you to run stepper motors -

http://www.tau.ac.il/~stoledo/lego/Stepper/

http://www.ebay.co.uk/sch/i.html?_odkw= ... r&_sacat=0
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
h-g-t

Posts: 531
Joined: 07 Jan 2011, 08:59
Location: Albania

Next