Page 1 of 1

Please help...

Posted: 30 Mar 2011, 08:53
by zykro
Hello friends, somebody can help my with LEGO mindstorms nxt 2.0? i have a color sorter and programm in LEGO MINDSTORM soft... but i need make this program in brix... i dont know how i can save starting motor angle and then tur it in position, what i need... i can sand to e-mail program .rbt file, sombody can help make it in BRICX?

Re: Please help...

Posted: 30 Mar 2011, 19:23
by muntoo
You want to convert this NXT-G "code" to NXC?
[NXC is a programming language, and BricxCC is an IDE.]

A few things:
  • Why do you want to do this?
  • There's no "easy way" to do it; you'd have to learn* NXC. (Which isn't that hard.)
  • Please make the title more descriptive.
A little sample on how to do the things you described in your post:

Code: Select all

// Declare motor position variable and set it to 0
long motorPos = 0;

// Get the current motor position in degrees, and store it in motorPos
// OUT_A means Motor A
motorPos = MotorRotationCount(OUT_A);

// Move Motor A forward by 360 degrees, and with 75% power
RotateMotor(OUT_A, 75, 360);
*Hmmm... Maybe Visual NXC is a good idea. :)

Re: Please help...

Posted: 30 Mar 2011, 19:49
by zykro
yes, i want convert this project to BricxCC (.nxc) code

Re: Please help...

Posted: 01 Apr 2011, 04:23
by muntoo
As I asked earlier, "why?" Just on whim (hooray! :) ), or because you were required to? Or do you want to learn NXC? If so, there are far better ways to do that than try to translate programs from one language to another. If you translate, you won't be using any of the so-called good practices that come with a programming language.
A trivial example (there are far better ones):
In NBC, we don't have any while loops, so one may do this:

Code: Select all

mywhileloop:
// ...
jmp mywhileloop;
A direct translation into NXC (ignoring asm{};) would be:

Code: Select all

mywhileloop:
// ...
goto mywhileloop;
But it'd have been better to simply do this:

Code: Select all

while(1)
{
    // ...
}
Also, do you have any prior experience with NXC, or other programming languages?

Re: Please help...

Posted: 01 Apr 2011, 09:15
by zykro
i need this programm in BRICX, because i write work about two robots, one robot is programmed in bricxx but othet in LEGO software... i want other robot programm get in BRICX code... i need it very much... :(

Re: Please help...

Posted: 03 Apr 2011, 03:07
by muntoo
zykro wrote:i need this programm in BRICX, because i write work about two robots, one robot is programmed in bricxx but othet in LEGO software... i want other robot programm get in BRICX code... i need it very much... :(
It doesn't matter which language each robot is in*; they're all compiled into the same bytecode** ".rxe" files, although the compiled NXC code ones tend to be much smaller and faster.

If you post the other NXC code, and explain your objectives (what the robot should do), we might be able to help you better. Be sure to post the NXC code in

Code: Select all

...[/code ] tags (without the extra space before the "]", or attach it in a .zip file.

*Unless, of course, you're using special NBC/NXC EF only features, which I doubt you are in NXT-G.
**They run on a VM, so it should be "bytecode", not "machine code", right?