![]() |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
Quote:
|
|
#6
|
|||
|
|||
|
Quote:
|
|
#7
|
|||
|
|||
|
Quote:
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. |
|
#8
|
|||
|
|||
|
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 |
|
#9
|
|||
|
|||
|
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? |
|
#10
|
|||
|
|||
|
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. Last edited by Dean Hystad; 09-12-2012 at 05:22 PM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Distance Move MyBlock | timdavid | Programming | 34 | 07-13-2011 04:04 PM |