Hi All,
Is there some odd limit to the amount of floating point stuff you can do in a program?? The reason I ask is that I have been working on the following program which I couldn't get to work and have been slowly stripping out code to see what the problem is. It runs fine when I take the marked section out but won't work with it in - even though I have modified it so that the section os code doesn't do anything other than crunch some floating point numbers???
Can anyone help me out?
#include "mbed.h"
#include "AX12.h"
struct LegAngles {
float Femer;
float Tibia;
};
LegAngles GetAngles(int X, int Y) {
/* IF I TAKE THIS BOLD SECTION OUT THE PROGRAM RUNS OK... */
float Hypotenuse, S, C, Area, Opposite, Alpha, Beta, Gamma, Adj = Y, Opp = X;
Hypotenuse = (X*X)+(Y*Y);
Hypotenuse = sqrt(Hypotenuse);
C = Hypotenuse;
S = (100 + 100 + C)/2; // Calculate the semi-perimeter
Area = S*(S-100)*(S-100)*(S-C);
Area = sqrt(Area);
Opposite = (2*Area)/Hypotenuse;
Alpha = Opposite / 100;
Alpha = asin(Alpha);
Beta = Opposite / 100;
Beta = asin(Beta);
Gamma = Opp/Adj;
Gamma = atan(Gamma);
LegAngles Angle;
Angle.Femer = X + 150;
Angle.Tibia = Y;
return Angle;
}
int main() {
AX12 myax12_Hip (p9, p10, 1), myax12_Knee (p9, p10, 2);
Timer t;
int x, y;
LegAngles Answer;
t.start();
while(1) {
if(t.read()>4)
t.reset();
if(t.read()<=2){
x = (50 * t.read()) - 50;
y = 180;
}
else{
x = (50 * (4 - t.read())) - 50;
y = 200;
}
Answer = GetAngles(x,y);
myax12_Hip.SetGoal(Answer.Femer);
myax12_Knee.SetGoal(Answer.Tibia);
}
}
Hi All,
Is there some odd limit to the amount of floating point stuff you can do in a program?? The reason I ask is that I have been working on the following program which I couldn't get to work and have been slowly stripping out code to see what the problem is. It runs fine when I take the marked section out but won't work with it in - even though I have modified it so that the section os code doesn't do anything other than crunch some floating point numbers???
Can anyone help me out?
#include "mbed.h"
#include "AX12.h"
struct LegAngles {
float Femer;
float Tibia;
};
LegAngles GetAngles(int X, int Y) {
/* IF I TAKE THIS BOLD SECTION OUT THE PROGRAM RUNS OK... */
float Hypotenuse, S, C, Area, Opposite, Alpha, Beta, Gamma, Adj = Y, Opp = X;
Hypotenuse = (X*X)+(Y*Y);
Hypotenuse = sqrt(Hypotenuse);
C = Hypotenuse;
S = (100 + 100 + C)/2; // Calculate the semi-perimeter
Area = S*(S-100)*(S-100)*(S-C);
Area = sqrt(Area);
Opposite = (2*Area)/Hypotenuse;
Alpha = Opposite / 100;
Alpha = asin(Alpha);
Beta = Opposite / 100;
Beta = asin(Beta);
Gamma = Opp/Adj;
Gamma = atan(Gamma);
LegAngles Angle;
Angle.Femer = X + 150;
Angle.Tibia = Y;
return Angle;
}
int main() {
AX12 myax12_Hip (p9, p10, 1), myax12_Knee (p9, p10, 2);
Timer t;
int x, y;
LegAngles Answer;
t.start();
while(1) {
if(t.read()>4)
t.reset();
if(t.read()<=2){
x = (50 * t.read()) - 50;
y = 180;
}
else{
x = (50 * (4 - t.read())) - 50;
y = 200;
}
Answer = GetAngles(x,y);
myax12_Hip.SetGoal(Answer.Femer);
myax12_Knee.SetGoal(Answer.Tibia);
}
}