How do I name my inputs on MyBlocks? Help with crowbars? PDF Print E-mail
Tuesday, 05 October 2010 21:32




I attended your recent advanced programming class and I’m well on my way to mastering NXT and trying to teach my team at the same time some of the advanced navigational tools.  I’ve run into two frustrating issues that I hope you can provide guidance on.  I was using 1.0 at the workshop and we’ve upgraded to 2.0 and that’s we’re I’ve started having problems. 

1.        For variables in myblocks I can’t seem to get the Myblock to have the variable names when its created just the name to the block its linked to inside the my block.  I’ve tried both using just an read briefcase with the created variable and leaving that outside the selected blocks and using a combination of read and write blocks and grabbing  the write blocks inside the Myblock.  In either case when the my block pops up it does not have the desired variable names, but the first default name of where the briefcase is wired into inside the Myblock.  I know we did this at the workshop and I’ve done it in 1.0, but now in 2.0 I’m having trouble.

2.       When we went to build the back to wall program with the two loops inside of the counting loop we had a VERY difficult time adding the second beam inside the loop and dropping blocks on it.  Seemed to work better in 1.0 and was frustrating to burn up valuable student time messing with it.  Since then  I’ve played with it more at home and had to first drag the first inner loop to the right to stretch the main loop to the right then expand the crowbar on the move block to stretch the main loop down and then was able add the parallel beam and finally the second loop.  Is there a better way? 





1. This one stumped me for a while when I made the same jump.  With 2.0 or 2.1, you literally just change the label on the attached data stub inside of the MyBlock.  When you first make the change and save the MyBlock the change won't propagate correctly to the parent program so delete the MyBlock from the parent and re-add it after you have changed the input and output variable names.

2. You do need to crowbar the loop open.  Typically I add disposable move or switch and move blocks to the right of the stuff I'm keeping.  So in this case, you drag the first loop (left-motor-sensor) inside the 1-count loop.  I then would add a move block after the left-motor-sensor loop.  Fully expand the data ports on the move block.  Now drag in your second (right-motor-sensor) loop.  Then using the shift key, drag the beam down to connect up the right-motor-sensor loop and make it active.  Finally just delete your crowbar.  If I need a really big crowbar I will put in a switch, and then put the move block inside the switch, and then expand the data ports on the myblock which will in-turn expand the switch.

Additionally you want to make sure that your longest execution path (in terms of visible length in the editor) is the top path of the multiple threads inside the loop. Build it first, then crowbar, then add execution path below it, then delete crowbar.

Hope this helps.



Copyright © 2018 All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.