FIRST Forums  

Go Back   FIRST Forums > General Discussions > FIRST Programs > FIRST LEGO League > The Challenge > Programming

Reply
 
Thread Tools
  #1  
Old 08-13-2012, 10:01 AM
BlueCheesyFlamingos BlueCheesyFlamingos is offline
Senior Member
 
Join Date: Sep 2008
Location: Kalamazoo, MI
Posts: 354
Default nxt-g - connector wires & variables

This may be kind of an odd question not that I don't ask plenty of those.

We had a meeting yesterday to practice some more advanced programming concepts. One of the things I noticed is the data wires are a pain. They seem to have a mind of their own when you are connecting them over long distances (over lapping each other, etc). We noticed this a lot when we had myblocks with input variables at the start of the program.

I am a developer so messy code, even in graphical format, gives me the shivers. Any tips or advice for keeping the wires neat and organized?
Reply With Quote
  #2  
Old 08-13-2012, 11:40 AM
Dean Hystad Dean Hystad is offline
Senior Member
 
Join Date: Sep 2008
Location: Minnesota
Posts: 1,700
Default Re: nxt-g - connector wires & variables

Modular code.

The NXT editor hates having lots of blocks and wires to keep track of. Use MyBlocks to clean up the clutter and make the editor happy. Try to limit yourself to no more blocks than can be displayed on the screen at one time.

You don't have to group input and output connector blocks. I move connector blocks to be close to where they are used (see attached). The editor seldom reroutes short wires.

Undo is your friend. There are a lot of things that cause the NXT editor to reroute the wires. Doing Undo once usually leaves the action you perfomed alone while undoing all the wire rerouting that you didn't want.

Don't worry about pretty wires until you think the module is done. Get the functionality first, then play with layout.
Attached Images
File Type: jpg Wait Colord.jpg (19.4 KB, 49 views)
Reply With Quote
  #3  
Old 09-10-2012, 01:31 PM
BremenBotz! BremenBotz! is offline
Member
 
Join Date: Sep 2008
Location: Bremen, IN, USA
Posts: 72
Default Re: nxt-g - connector wires & variables

Sometimes clicking the part of the block that opens/closes the terminal where the wires connect will clean up the display.

Don't think it matters for the program itself, but is easier to follow as it cleans the wiring up a little.
Reply With Quote
  #4  
Old 09-10-2012, 03:26 PM
Dean Hystad Dean Hystad is offline
Senior Member
 
Join Date: Sep 2008
Location: Minnesota
Posts: 1,700
Default Re: nxt-g - connector wires & variables

One thing you may find beneficial is enabling advanced features. Go to the directory for the profile you are using. It will be something like :

C:\Users\***\LEGO Creations\MINDSTORMS Projects\Profiles\Default

In that directory there is a file named "settings.ini". In the file there is a line:

Enable Advanced Features=FALSE

Change the "FALSE" to a "TRUE" to enable advanced features.

The only useful "Advanced Feature" I've found is enhanced editing for wiring. With advanced features turned on you can see the connection point where wires pass into/out of switches and loops. It also highlights wire segments when they are selected in the editor.
Reply With Quote
  #5  
Old 09-10-2012, 03:30 PM
BlueCheesyFlamingos BlueCheesyFlamingos is offline
Senior Member
 
Join Date: Sep 2008
Location: Kalamazoo, MI
Posts: 354
Default Re: nxt-g - connector wires & variables

Quote:
Originally Posted by Dean Hystad View Post
The only useful "Advanced Feature" I've found is enhanced editing for wiring. With advanced features turned on you can see the connection point where wires pass into/out of switches and loops. It also highlights wire segments when they are selected in the editor.
Thank you! I think this may be the help the kids need. Right now it so hard to see the connection points.
Reply With Quote
  #6  
Old 09-10-2012, 09:19 PM
LOLComets LOLComets is offline
Senior Member
 
Join Date: Apr 2009
Location: Southern California
Posts: 147
Default Re: nxt-g - connector wires & variables

Quote:
Originally Posted by Dean Hystad View Post
One thing you may find beneficial is enabling advanced features. Go to the directory for the profile you are using. It will be something like :

C:\Users\***\LEGO Creations\MINDSTORMS Projects\Profiles\Default

In that directory there is a file named "settings.ini". In the file there is a line:

Enable Advanced Features=FALSE

Change the "FALSE" to a "TRUE" to enable advanced features.

The only useful "Advanced Feature" I've found is enhanced editing for wiring. With advanced features turned on you can see the connection point where wires pass into/out of switches and loops. It also highlights wire segments when they are selected in the editor.
Great tip. Dragging wires appears to work better; and seeing wires going through LOOP and SWITCH blocks helps a lot. Thank you.
Reply With Quote
  #7  
Old 09-11-2012, 12:15 PM
Rbbbbb Rbbbbb is offline
Junior Member
 
Join Date: May 2012
Location: Greenville, SC
Posts: 21
Default Re: nxt-g - connector wires & variables

Quote:
Originally Posted by BremenBotz! View Post
Sometimes clicking the part of the block that opens/closes the terminal where the wires connect will clean up the display.

Don't think it matters for the program itself, but is easier to follow as it cleans the wiring up a little.
Thank you, BremenBotz! I had been showing the kids various other ways of refreshing the wiring, such as grabbing the sequence beam and extending it, which works occasionally. This is much better. I've just tried a dozen different pieces of code with complicated wiring, and clicking that place refreshed all of them correctly.

Mindstorms documentation refers to that magical place as the "tab area." From now on, my team will refer to it as the "Bremen-spot," and we'll call it good coding practice to clean up our wiring every now and then.
Reply With Quote
  #8  
Old 09-11-2012, 09:04 PM
GWhizNonKid GWhizNonKid is offline
Senior Member
 
Join Date: Sep 2008
Location: Connecticut
Posts: 191
Default Re: nxt-g - connector wires & variables

Dean is correct about the advanced features being enabled. I would only add that there is a systems.ini file for each of the profiles that you have set for your editor program. If you create a new profile, there is a very good chance that the value will be false for the profile. At least, so far, every one I've made has been that way.
__________________
Bill Bourn
Coach, FLL#37
Mentor, FRC#2170 Titanium Tomahawks
Reply With Quote
  #9  
Old 09-12-2012, 11:26 AM
Dave Parker Dave Parker is offline
Senior Member
 
Join Date: Aug 2009
Location: Loomis, CA
Posts: 174
Default Re: nxt-g - connector wires & variables

Personally I am a fan of variables. If a data item has to travel more than a couple of blocks, store it in a variable then read it out later. It adds more blocks, but the wires end up much shorter and easier to manage, and you get the added benefit of naming the data items, which adds some documentation.

Even the struggle of having to come up with names for the variables (which kids seem quite bad at) is ultimately a good thing. Makes you think: what does this particular data represent exactly, anyway?
Reply With Quote
  #10  
Old 09-12-2012, 12:28 PM
Dean Hystad Dean Hystad is offline
Senior Member
 
Join Date: Sep 2008
Location: Minnesota
Posts: 1,700
Default Re: nxt-g - connector wires & variables

Watching the boys struggle with wires reminded me of some more practices I've found useful.

Wire from Sink to Source. I've noticed that NXT-G often does a better job routing when you start the connection at the input plug and wire backwards (to the left) to the output plug.

Take advantage of MyBlock's flexible data plug positioning. Multiple data plugs in MyBlocks don't have a fixed order like they do in the standard programming blocks. When you contract and expand the data plugs for a MyBlock connected data plugs move to the top. I use this in the attached file "Ultrasonic Demo" to clean up the wiring of the blocks inside the loop. NXT-G hates crossing wires and will come up with crazy routes in an attempt to prevent them from occurring.

Use the "crowbar" trick to expand loops and switches. When passing wires in and out of loops or switches it is nice to have a little extra room. I insert a Motor block and expand the data plugs. The loop or switch expands to show all the data plugs. Next I place a short comment inside the loop or switch block. When I collapse or delete the added Motor block the comment prevents the outer block from collapsing. I now have lots of room for wires. See attached file "Ultrasonic Demo". The loop was expanded using a motor block (which was later removed) and pinned open with the comment "Pin".

That reminds me. Each "choice" in a switch block needs to supply values to all wires exiting the block. The compiler should refuse to download programs where this doesn't happen.
Attached Images
File Type: jpg Ultrasonic demod.jpg (21.1 KB, 11 views)

Last edited by Dean Hystad; 09-12-2012 at 05:22 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Distance Move MyBlock timdavid Programming 34 07-13-2011 04:04 PM


All times are GMT -4. The time now is 07:44 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.