Author |
Message |
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 616
|
 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
|
Thu Nov 15, 2007 10:51 am |
|
 |
elemes
Expert
Joined: Fri Nov 09, 2007 4:51 am Posts: 121 Location: Hungary, Europe
|
 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).
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]
|
Thu Nov 15, 2007 12:24 pm |
|
 |
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 616
|
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.
|
Thu Nov 15, 2007 12:38 pm |
|
 |
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 616
|
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.
|
Thu Nov 15, 2007 12:47 pm |
|
 |
elemes
Expert
Joined: Fri Nov 09, 2007 4:51 am Posts: 121 Location: Hungary, Europe
|
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).
|
Thu Nov 15, 2007 12:49 pm |
|
 |
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 616
|
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.
|
Thu Nov 15, 2007 8:41 pm |
|
 |
irenas1
Rookie
Joined: Thu Jun 06, 2013 2:12 am Posts: 1
|
 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
|
Thu Jun 06, 2013 2:17 am |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: Best Programming Language for Lego Mindstorms, Hands Dow
dat necropost
_________________A.K.A. inxt-generation Self-proclaimed genius, and future world dominator. My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor Bow down to Nikola Tesla, King of the Geek Gods.
|
Thu Jun 06, 2013 9:23 am |
|
|