cos causing file error

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
forgottenromeo
Posts: 5
Joined: 04 Oct 2010, 15:25

cos causing file error

Post by forgottenromeo »

I am trying to use the tachometer in the motors for odometry, yet when I use cos or Cos (as i have tried them both) I get a file error message on the nxt lcd screen. I already have the enhanced firmware checked on the compiler options, any suggestions on how to fix this or work around it will be appreciated.

code

Code: Select all

sub wander()
{
   int WANDER = (Random(2000)-500);
    int WANDERR= (Random(2000)- 500);
    int count =(Random(500));
    while(count >0){
    OnFwdReg(OUT_C, WANDER/10, OUT_REGMODE_SPEED);
    OnFwdReg(OUT_A, WANDERR/10, OUT_REGMODE_SPEED);
    count--;}

}

void travel();
void updateX(int x, int y, int h);
void updateY();



task main()
{

    while(1)
    {
        wander();
        travel();
    }

}


void travel()
{
    float heading[3] = {0,0,0};
    float position[3] = {0,0,0};
    float buffer[3] = {0,0,0};

   
   float left,right, dr, dl, dt,h,i,j,x,y;
   

   
   left += MotorBlockTachoCount(OUT_C);
   right += GetOutput(OUT_A, BlockTachoCount);
   
   i = right * 0.01745;
   j = left * 0.01745;
   
   dr = i * 18;
   dl = j * 18;
   
   h = position[2] + ((dr - dl)/107);
   position[2] = h;

   dt = (dr + dl)/2;
   
   x = cos(60);
   

   


   NumOut(10,LCD_LINE1, i);
   NumOut(10,LCD_LINE2, j);
   NumOut(10,LCD_LINE3, left);
   NumOut(10,LCD_LINE4, right);
   NumOut(10,LCD_LINE5, h);
   NumOut(10,LCD_LINE6,position[2]);
   

}




Compiler options
compileroptions.jpg
compileroptions.jpg (37.75 KiB) Viewed 9477 times
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: cos causing file error

Post by afanofosc »

When you get the file error message is there any sort of numeric code shown as well? If not, that would indicate to me that you don't have the latest NXT 2.0 compatible version of the enhanced NBC/NXC firmware installed on your NXT. Also, the compiler options screenshot indicates that you do not have the latest version of BricxCC installed. I recommend updating to the recently released version of BricxCC (i.e., not just the test release zip). The version is 3.3.8.8.

http://sourceforge.net/projects/bricxcc/files/bricxcc/

I need to update the BricxCC page, it looks like, so that it lists the features of the new release.

You can get the latest version of the enhanced NBC/NXC firmware via a link on the BricxCC page. Here's the direct link:

http://bricxcc.sourceforge.net/lms_arm_nbcnxc.zip

With the latest version of BricxCC you can also enable an "automatic firmware version" option on the NBC/NXC tab in the Preferences dialog. This will override the "default" options for the firmware version based on what it detects that you have installed on your NXT. If you try to run a program that requires the enhanced firmware on the standard firmware then you will get File Error messages. That seems the most likely cause for the error you are getting.

You should also note that cos is a function that takes an input value expressed in radians rather than degrees. To calculate the cosine of 60 degrees you should use cosd rather than cos. Or you could convert 60 into radians before calling cos.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
forgottenromeo
Posts: 5
Joined: 04 Oct 2010, 15:25

Re: cos causing file error

Post by forgottenromeo »

I'm not sure if this can be answered here or needs to be added somewhere else, but the new bricxcc and firmware fixed the file error problem, the only problem i have now is that occasionally bricxcc will report "unidentified decleration cos" or similar and not compile, but after restarting bricxcc it compiles again.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: cos causing file error

Post by afanofosc »

It will report the error you mention (to my knowledge) only if the default settings are configured for the standard NXT firmware. I recommend checking "Enhanced firmware", "NXT 2.0 compatible firmware", and "Automatic firmware version". Oh, and "internal compiler".
options.jpg
options.jpg (39.92 KiB) Viewed 9445 times
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
forgottenromeo
Posts: 5
Joined: 04 Oct 2010, 15:25

Re: cos causing file error

Post by forgottenromeo »

Thank you for the help.
Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests