View unanswered posts | View active topics It is currently Thu Aug 21, 2014 12:28 pm






Reply to topic  [ 8 posts ] 
Best Programming Language for Lego Mindstorms, Hands Down 
Author Message
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 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
Profile
Expert
User avatar

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
Post 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]


Thu Nov 15, 2007 12:24 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
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.


Thu Nov 15, 2007 12:38 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
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
Profile
Expert
User avatar

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
Post 
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).


Thu Nov 15, 2007 12:49 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
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.


Thu Nov 15, 2007 8:41 pm
Profile
Rookie

Joined: Thu Jun 06, 2013 2:12 am
Posts: 1
Post 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
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post 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
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.