Ich will diese Funktion
Code:
r=(double)(richtung_temp); //in Radiant*1000
        r=r/1000; //in Radiant

        
        sin_x =(long)(128*sin(r));
durch diese ersetzen:

Code:
richtung_temp=(richtung_temp*2)/35; // von Radiant*1000 in Grad, zB 3141*2/35= 179, 1° Fehler ist egal

        sin_x =sinus(richtung_temp);
Code:
#include <sincos.h>
#include <avr/pgmspace.h> 

static const short sinusdaten[92] PROGMEM = 
{0,2,4,7,9,11,13,16,18,20,22,24,27,29,31
,33,35,37,40,42,44,46,48,50,52,54,56,58
,60,62,64,66,68,70,72,73,75,77,79,81,82
,84,86,87,89,91,92,94,95,97,98,99,101
,102,104,105,106,107,109,110,111,112,113
,114,115,116,117,118,119,119,120,121,122
,122,123,124,124,125,125,126,126,126,127
,127,127,128,128,128,128,128,128};

short sinus(short winkel)
{
short result=0;
if (winkel>360) winkel=winkel-360;
if (winkel<360) winkel=winkel+360;

if (winkel<=90) result = (short)(pgm_read_word(&sinusdaten[winkel]));
if ((winkel>90)&&(winkel<=180)) result = (short)(pgm_read_word(&sinusdaten[180-winkel]));
if ((winkel>180)&&(winkel<=270)) result = -(short)(pgm_read_word(&sinusdaten[winkel-180]));
if (winkel>270) result = -(short)(pgm_read_word(&sinusdaten[360-winkel]));

return (result);

short cosinus(short winkel)
{
short result=0;
if (winkel>360) winkel=360;

if (winkel<=90) result = (short)(pgm_read_word(&sinusdaten[90-winkel]));
if ((winkel>90)&&(winkel<=180)) result = -(short)(pgm_read_word(&sinusdaten[winkel-90]));
if ((winkel>180)&&(winkel<=270)) result = -(short)(pgm_read_word(&sinusdaten[270-winkel]));
if (winkel>270) result = (short)(pgm_read_word(&sinusdaten[winkel-270]));

return (result);
}
sin_x soll also immer den Sinuswert*128 entsprechen.

1. Grund ist Umstellung meiner Fahrfunktionen auf Grad ( also drehe 20° nach links) da ich mich mit Radiant noch nie anfreunden konnte.
2. Grund: die Eigenbau Berechnung läuft viel schneller als Fließkomma, die Genauigkeit ist ausreichend.

Problem: funktioniert nicht, die nachfolgende Positionsberechnung errechnet mehrere Meter Fahrweg anstatt nur cm.
Wenn man wieder die normale Sinus/Cosinus Berechnung nimmt rechnet es richtig, also liegt es nur an dieser Funktion

Ist die Tabelle falsch angelegt?