Page 1 of 1

NXC float

Posted: 19 Mar 2012, 19:44
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-)

Re: NXC float

Posted: 19 Mar 2012, 20:03
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).

Re: NXC float

Posted: 19 Mar 2012, 20:42
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. :( )

Re: NXC float

Posted: 19 Mar 2012, 21:10
by mattallen37
Oh, make sure you have your FW related compiler settings set according to your NXT FW version.

Re: NXC float

Posted: 19 Mar 2012, 21:38
by mcsummation
What version of the compiler and BricxCC are you using?

Re: NXC float

Posted: 21 Mar 2012, 02:59
by nxtboyiii
And you have the latest enhanced firmware?

Re: NXC float

Posted: 22 Mar 2012, 17:21
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.