NXC float

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
roboteer
Posts: 12
Joined: 12 Aug 2011, 04:00

NXC float

Post by roboteer »

Hi,
I ran the following simple code and the NXT 2.0 brick just hangs. I keep hearing some ticks but nothing else happens. I upgraded the firmware to 1.31 to make sure but that did not help. Does anyone have any ideas? I assume that float variables are supported in NXT 2.0. Here is the code snippet that causes the problem.

#define Kproportional 6

task main(){
int error = 0;
float proportional = 0;

proportional = Kproportional * error;
}

Thanks for the help. 8-)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC float

Post by mattallen37 »

It runs just fine for me. I am using version 1.32 of John's EFW.

Try this so you can actually see the result:

Code: Select all

#define Kproportional 6

task main(){
  int error = 0;
  float proportional = 0;

  proportional = Kproportional * error;
  NumOut(0, LCD_LINE1, proportional);
  while(true);
}
Although with an error of 0, the result should be 0 (6*0=0).
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: NXC float

Post by mcsummation »

roboteer, I had a similar problem with float when I first started using NXC. However, I can't remember what the problem turned out to be. It was something really simple though. (I suffer from CRS = Can't Remember Stuff. :( )
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC float

Post by mattallen37 »

Oh, make sure you have your FW related compiler settings set according to your NXT FW version.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: NXC float

Post by mcsummation »

What version of the compiler and BricxCC are you using?
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: NXC float

Post by nxtboyiii »

And you have the latest enhanced firmware?
Thanks, and have a nice day,
nxtboy III

programnxt.com
roboteer
Posts: 12
Joined: 12 Aug 2011, 04:00

Re: NXC float

Post by roboteer »

Yup, I got it working. I had a very old version of the firmware installed. By the way, it matters how the color sensor is physically installed. I installed it on the back of the robot and my program now drives it backwards around the track. In case anyone wanted to know.

Thanks for all the help.
Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests