Skip to content

Sophie pano by pfeiffer.

AotPR part 3 - Programming

OK, we've built Frankenstein's Panohead, how do we tell it what to do? Obvious - drag some icons around on a grey grid!

LEGO Mindstorms NXT is mostly programmed using the Windows and Mac app of the same name, using a visual programming language called NXT-G* - you simply drag around different blocks and connect them up, then download that program to the NXT brick via USB or Bluetooth.


fig I: program interface

You drag different types of block such as Move, Wait, Switch, Loop etc. from the list on the left onto the grid in a line. In the advanced section there are all kinds of extra blocks available.


fig II: the complete program for the mk0 panobot

As you can see, it's currently just a long series of actions all after the other, with no logic or alternative actions involved. In brief, it rotates 60? and fires the shutter, repeats that 6 times, then returns to the starting point, tilts up, fires the shutter and returns to the start position again.

Section one


fig III: section one

The repeating loop. This is slightly more complex than it needs to be because rather than using plain Move blocks for the rotation of the head I've used Motor blocks which allow you to ramp up the motor to speed rather than it jerking suddenly into full gear.
The first three blocks bring the head up to speed, do most of the movement at a constant speed and then slow down towards the end of the 60?.
The forth block waits for a couple of seconds for the vibrations to die down.
The fifth, sixth and seventh blocks move the third motor forwards, pause and return, to fire the shutter.
These blocks are all included in a Loop block which is set to loop six times. Both Loop and Wait blocks can use a set time/number of loops, or wait for specific conditions such as a touch sensor being pressed.


fig IV: Move block


fig V: Motor block

Looking carefully at the details for the two movement blocks we can see that there are a few extra options in the Motor block such as the Ramp Up action to slowly accelerate up to speed.

Section two:


fig VI: section two

Motor A (controlling the rotation of the head) goes backwards to it's starting position. The third Motor block doesn't force anything to wait for it, so the blocks controlling motor B (pitch) start moving before the head has returned to position.

Section three:


fig VI: section three

The obligatory Wait block for vibrations to dissipate.
Shutter release.
Return to horizontal.

General Notes

I did this first using Move blocks and no Motor blocks. There were roughly half as many blocks involved, but the movement of the head was extremely jerky with LOTS of vibration building up. The NXT-G language seems to be surprisingly powerful given how easy it is to use - there are all sorts of extras such as complex logic and messages between bricks via Bluetooth.

For more on programming NXT-G:

http://www.bnxt.com/tutorial/default.aspx
http://www.ni.com/swf/lv_lego/us/lego_lv_demo.swf

Coming Next

Combining LEGO pieces with aluminium profile.
Building something powerful enough to lift a camera.
Firing the shutter.

Ian

P.S. The Mindstorms application runs on Windows and on PPC Macs - it's not yet a Universal Binary (although that's said to be due soon). On an Intel mac running under Rosetta it is horrendously slow - I actually run it on Windows via Parallels on a MBP.

*NXT-G: as in 'next generation'. Ouch.

»

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Awesome, Ian! Can I come and play?

This is very cool stuff... I wait anticipatingly for the next installment.

Patrick Cheatham
--
CheathamLane | spinControl:VR
Berkeley, California
VR Photography
QuickTime & Web Development

»