I'm working on a simple arm with two rotational degrees of freedom(it only acts in 2d). The idea is to place a pen at the tip and draw simple things with it. I'm having some trouble because the program compiles well but when I execute it in the brick I immediately get "File Error!" and the program ends. Here you have the code(in NXC) it isnot the final one(I want to add mor functionalities) but I don't know why it doesn't work.
in most cases (to my experience) runtime errors occur when devide by zero
(e.g.: can THIS become zero:
/((L2 * sin2 * posY) + ((L1 + (L2 * cos2)) * posX)
or when accessing arrays on undifined ranges (array[-1], array[lenght+1] a.s.o.). Lets see what error msg you get.
Last edited by HaWe on 03 Jul 2011, 20:37, edited 1 time in total.
The compiler should complain but doesn't that you are trying to return an array of float in a function that is declared to return a float. NXC does not currently support returning array types and it does not do a very good job of telling you that you are doing something wrong when you try to do that.
It looks like you are targeting the standard firmware. I would recommend switching to the enhanced NBC/NXC firmware. If you do that then use asin and acos rather than ASin and ACos which are deprecated.
When you declare an array you either have to give it a size (float Angles[2]) or you have to initialize it at the declaration (float Angles[] = {PI, PI/2}).
If you try to write to elements 0 and 1 of an array that has zero elements in it (since you did neither of the above) then you will get a File Error abort when you run the program.