ROBOTC.net forumshttp://www.robotc.net/forums/ Best Programming Language for Lego Mindstorms, Hands Downhttp://www.robotc.net/forums/viewtopic.php?f=1&t=297 Page 1 of 1

 Author: Dick Swan [ Thu Nov 15, 2007 10:51 am ] Post subject: Best Programming Language for Lego Mindstorms, Hands Down A very nice article on ROBOTC from the Wired magazine web site at http://blog.wired.com/geekdad/2007/11/the-best-progra.html. Chris Anderson of Wired has been using his NXT to control his UAV — Unmanned Aerial Vehicle — and has tried many of the different NXT programming environments. For more on his airplane, see the videos at http://diydrones.com/video/video/show?id=705844:Video:43

Author:  elemes [ Thu Nov 15, 2007 12:24 pm ]
Post subject:  Re: Best Programming Language for Lego Mindstorms, Hands Dow

Can I quote the article

" -100 is > than -90. Is this true in all languages? "

No it is not of course.

I have spent some time troubleshoot a program and found the following loop executed only once (instead of 500 as I have expected).

 Code:   for( i = 0; i < 500; i++ ) {      rotation[ i ] = nMotorEncoder[ motorA ];      wait1Msec( 1 );   }

There *was* a flaw in my program but not here. and when I found it I was a bit surprised by the compiler behavior.
[/code]

Author:  Dick Swan [ Thu Nov 15, 2007 12:38 pm ]
Post subject:

 Quote:-100 is > than -90. Is this true in all languages?

I think it turned out that Chris was referring to ROBOTC's control of motors where positive numbers are forward direction and negative numbers are reverse. So of course a power level of -100 is faster (larger) than -90.

 Author: Dick Swan [ Thu Nov 15, 2007 12:47 pm ] Post subject: It would be a serious bug if the following loop only executed once. for( i = 0; i < 500; i++ ) { rotation[ i ] = nMotorEncoder[ motorA ]; wait1Msec( 1 ); } I can think of a couple of scenarios that would cause this. For exanple, if the declaration was int rotation[1]; int i; You would find that 'i' was overwritten by the assignment to 'rotation[i]' when 'i' is 1. If ROBOTC's array bounds checking was enabled this would be caught at run time. Send me a compilable code snippet (at dickswan@sbcglobal.net) that illustrates only once through the loop and I will confirm and fix ROBOTC internal error if one exists.

Author:  elemes [ Thu Nov 15, 2007 12:49 pm ]
Post subject:

 Dick Swan wrote:I think it turned out that Chris was referring to ROBOTC's control of motors

That's OK then.

My flaw (in the aboce example) was to declare i as a byte. I did not think RobotC follows the good old days of C when there was no type checking.

Here (I assume) the compiler casted the 500 to byte format. 500 is 0x1F4, chunking to 8 bits 0xF4 which is the binary representative of minus twelve (however, if the reasoning above is right, it is still interesting why the body of the "for" loop was executed even once. when, during troubleshooting, I replaced it with a "while" loop, it exited without executing the body).

Author:  Dick Swan [ Thu Nov 15, 2007 8:41 pm ]
Post subject:

 Quote:My flaw (in the above example) was to declare i as a byte. I did not think RobotC follows the good old days of C when there was no type checking.

This is not an "error" that is caught by any of the following commercial compilers -- Microsoft Visual Studio C++, IAR Embedded Workshop for ARM, MPLAB C18 compiler for Microchip or Renesas H8/300 -- that I just tried.

Unfortunately, this is valid C (and C++) syntax and semantics so type checking won't help. In C/C++ expressions are "promoted" to "int" precision during calculation.

IAR's C compiler and MS C++ (but not their C) compiler are the only two that generated warning messages for "i = 500;" where "i" is a char.

 Author: irenas1 [ Thu Jun 06, 2013 2:17 am ] Post subject: Re: Best Programming Language for Lego Mindstorms, Hands Dow There are some of the best Programming Language to learn like java, C++, PHP, visual basic. It's descriptions are available online.http://www.ranker.com/list/best-programming-language-to-learn/mark

 Author: NeXT-Generation [ Thu Jun 06, 2013 9:23 am ] Post subject: Re: Best Programming Language for Lego Mindstorms, Hands Dow dat necropost

 Page 1 of 1 All times are UTC - 5 hours [ DST ] Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/