jremington:
Print out the character strings that atof() is supposed to translate. That will tell you if the message components are correctly separated.
I modified the code as follow :
void Get_Infos() {
char msg_from_server[255]; // for incoming serial2 data
if (Serial2.available() > 0) { // only if data are received
Serial2.readBytes(msg_from_server, 255); // read the incoming bytes
Split_Message_Into_Floats(",",msg_from_server); //Get the Angle and angle_velocity in float
}
}
void Split_Message_Into_Floats (char* delimiter, char* char_string) { //delimiter is a "," the packetBuffer is the message
char* pch; // strtok needs a pointer
Serial.println(char_string); // strtok gives an adresss
Sensor_Values[0] = atof(pch);
Angle_Velocity = Sensor_Values[0]/10.0f;
//Serial.print(Angle_Velocity);
pch = strtok(NULL, ",");
Sensor_Values[1] = atof(pch);
Angle = Sensor_Values[1]*2.5;
//Serial.print(","); Serial.println(Angle);
}
aarg:
Also, a graph is not a good way to troubleshoot the output. Please show, or at least look at, the text output from the Teensy.
Here is the ouput on serial.
-177.917480,-12.991696
-158.355713,-13.149083
-140.167236,-13.287436
-107.971191,-13.609150
-89.843750,-13.696679
-69.244385,-13.764761
-49.346924,-13.812531
-49.346924,-13.850307
-29.022217,-13.877883
-8.697510,-13.885115
49.377441,-13.765173
67.840576,-13.695092
67.840576,-13.615859
86.486816,-13.527390
104.888916,-13.420498
122.528076,-13.295707
175.506592,-12.497647
189.788818,-12.304927
216.674805,-11.652788
254.364014,-10.920572
254.364014,-10.657847
267.456055,-10.388858
281.066895,-10.106810
294.982910,-9.811305
309.234619,-9.502039
348.876953,-7.840627
365.020752,-7.478646
382.171631,-7.100412
382.171631,-6.714011
400.177002,-6.319023
418.121338,-5.906490
434.967041,-5.477011
434.967041,-5.039572
444.458008,-4.597856
449.981689,-4.149108
449.981689,-3.698078
451.110840,-0.968014
448.547363,-0.520530
448.547363,-0.074803
447.082520,0.369716
422.149658,5.180186
422.149658,5.593442
412.902832,6.001635
403.350830,6.399997
357.086182,8.645551
325.317383,9.632271
305.175781,9.933918
305.175781,10.225179
281.707764,10.504398
255.035400,10.758261
225.769043,10.983896
225.769043,11.194666
194.671631,11.389666
162.445068,11.552810
162.445068,11.699677
129.943848,11.830141
96.313477,11.927416
63.262939,11.991262
-91.552734,11.863274
-91.552734,11.755928
-119.262695,11.634845
-145.538330,11.486912
-170.410156,11.313575
-239.929199,10.213023
-286.193848,9.659416
-310.302734,9.347814
-310.302734,9.024496
-335.388184,8.688984
-361.206055,8.328390
-387.268066,7.942253
-387.268066,7.543505
-498.535156,4.814594
-498.535156,4.307966
-514.801025,3.793749
-528.564453,3.265073
-555.267334,1.069680
-555.267334,0.510341
-558.593750,-0.050064
-563.812256,-1.743849
-564.147949,-2.308895
-554.504395,-2.868687
-541.198730,-3.416414
-527.709961,-3.950165
-527.709961,-4.476608
-514.648438,-4.995961
-482.666016,-6.466759
-467.498779,-6.937914
-450.714111,-7.392600
-431.182861,-7.828651
-431.182861,-8.254478
-352.539062,-10.158957
-331.726074,-10.493287
-284.423828,-11.092727
-284.423828,-11.368382
-259.185791,-11.631125
-213.714600,-12.083783
-194.396973,-12.278048
-194.396973,-12.462451
-136.047363,-12.926250
-116.455078,-13.041845
-62.133789,-13.433024
-42.633057,-13.474243
-23.498535,-13.496108
-4.943848,-13.492844
12.603760,-13.477809
77.972412,-13.193492
93.292236,-13.097007
93.292236,-12.992968
151.062012,-12.315221
165.893555,-12.146855
181.182861,-11.963614
181.182861,-11.772927
195.098877,-11.575487
207.733154,-11.364989
218.963623,-11.142789
218.963623,-10.915214
247.009277,-9.935641
256.835937,-9.676406
267.761230,-9.407076
277.801514,-9.127555
77.801514,-8.843314
17.291260,-7.320757
31.481934,-6.991875
46.527100,-6.648734
77.868652,-5.185981
88.885498,-4.800414
16.656494,-3.178992
32.281494,-1.898893
39.208984,-1.464490
45.800781,-1.023794
45.800781,-0.580275
50.744629,-0.134759
55.871582,0.315315
61.181641,0.770125
61.181641,1.227103
66.064453,3.989355
61.975098,4.445732
49.218750,5.340709
21.051025,7.480355
08.508301,7.883787
08.508301,8.280520
93.859863,8.669507
14.392090,10.409517
14.392090,10.709482
86.926270,10.995399
56.011963,11.251834
22.991943,11.476045
22.991943,11.683516
8.583984,12.419048
8.583984,12.451183
4.648438,12.466322
18.463135,12.447938
18.463135,12.413027
49.468994,12.362655
78.399658,12.282382
156.555176,11.756620
179.992676,11.572702
179.992676,11.377268
203.033447,11.170525
225.555420,10.941231
247.924805,10.689746
247.924805,10.427350
340.087891,8.869318
363.739014,8.504921
466.339111,5.495108
480.072021,5.013073
492.645264,4.518406
As you can see, it's then only positive.
I did noticed that the first 0 is absent :
6.622314,1.794966
6.530762,1.783915
6.530762,1.772920
6.225586,1.762089
5.126953,1.711056
4.455566,1.701875
4.455566,1.693038
1.190186,1.644143
0.427246,1.639010
0.427246,1.634264
.075195,1.609905
.197266,1.607748
.288818,1.605700
.624512,1.596583
.624512,1.594925
.624512,1.593269
.922607,1.583013
.800537,1.580605
.800537,1.578138
.739502,1.575642
.800537,1.573149
.800537,1.570689
.892090,1.568276
.953125,1.565942
.197266,1.554853
.197266,1.552806
.380371,1.550852
.777100,1.538247
.563477,1.536687
.563477,1.535021
.770020,1.521737
.739502,1.519276
.739502,1.516802
.617432,1.514269
.617432,1.511678
.464844,1.509012
.159668,1.506120
.159668,1.503079
2.014160,1.471305
2.014160,1.465126
2.166748,1.418928
Tell me if you need more data.