{"id":434,"date":"2013-05-13T12:35:30","date_gmt":"2013-05-13T02:35:30","guid":{"rendered":"http:\/\/legoeng.local\/?p=434"},"modified":"2013-06-17T20:20:46","modified_gmt":"2013-06-17T10:20:46","slug":"three-troubleshooting-tips-for-nxt-g","status":"publish","type":"post","link":"http:\/\/legoeng.local\/three-troubleshooting-tips-for-nxt-g\/","title":{"rendered":"Three troubleshooting tips for NXT-G"},"content":{"rendered":"

Troubleshooting NXT-G programs can be a little challenging. There aren\u2019t any traditional debugging tools built into the environment. Here are three ways you can emulate common troubleshooting techniques when your program isn\u2019t working the way you expected.<\/p>\n

    \n
  1. Watch variables \u2013 You probably know you can monitor a sensor in the bottom left corner of the screen. If you keep the NXT connected to the computer, you\u2019ll see the value of the highlighted sensor block in real time. But what if you can\u2019t keep the robot tethered or you\u2019re trying to monitor another value? Put it on screen! Use the Number To Text Block to send data to input B of the Text Block. Use A to name the variable and C to pad the output with blank spaces. Send each value to a different line using the Display Block. If you drop this all into a MyBlock, you\u2019ll have a simple routine to watch a variable without cluttering up your program.<\/li>\n
  2. Set breakpoints \u2013 Breakpoints are really useful because they halt the program at a certain spot so you can inspect the state of your robot. When I\u2019m trying to isolate a program bug, I use the Stop Block and just move it down the line to test each step of the program. This works great when you\u2019re trying to navigate and aren\u2019t sure why your robot is going off course.<\/li>\n
  3. Set alerts \u2013 If I\u2019m not sure which branch my program is using in a switch, I\u2019ll add audio cues to my program for each branch. For instance, I wrote a program to read color codes and perform different actions depending on which color it identified using the color sensor. To confirm the color sensor was seeing the colors accurately, I made each value in my switch say the color name out loud.<\/li>\n<\/ol>\n

    \"NXT-G<\/a>
    \nUse these methods alone or together to quickly get to the root when your programs are misbehaving. You\u2019ll save a lot of guesswork by using these three simple techniques to pinpoint problems and isolate failures.<\/p>\n","protected":false},"excerpt":{"rendered":"

    Troubleshooting NXT-G programs can be a little challenging. There aren\u2019t any traditional debugging tools built into the environment. Here are three ways you can emulate common troubleshooting techniques when your program isn\u2019t working the way you expected. Watch variables \u2013 You probably know you can monitor a sensor in the bottom left corner of the […]<\/p>\n","protected":false},"author":14,"featured_media":435,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[159],"tags":[],"_links":{"self":[{"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/posts\/434"}],"collection":[{"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/comments?post=434"}],"version-history":[{"count":0,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/posts\/434\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/media\/435"}],"wp:attachment":[{"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/media?parent=434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/categories?post=434"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/tags?post=434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}