Please help...

Discussion specific to projects ideas and support.
Post Reply
zykro
Posts: 3
Joined: 30 Mar 2011, 08:41

Please help...

Post 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?
Attachments
Capture.jpg
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Please help...

Post 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. :)
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
zykro
Posts: 3
Joined: 30 Mar 2011, 08:41

Re: Please help...

Post by zykro »

yes, i want convert this project to BricxCC (.nxc) code
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Please help...

Post 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?
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
zykro
Posts: 3
Joined: 30 Mar 2011, 08:41

Re: Please help...

Post 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... :(
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Please help...

Post 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?
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests