Gerd Schmidt hat auf seiner Seite (der Link in meinem letztem Beitrag) eine schöne Sinustabelle gemacht.
Habe ich auch schon mal eine gemacht, extra klein für den Attiny:
Code:
/**********************************************************************
int8_t sinus( uint8_t x)
Sinus Berechnung
y=127*sin(2*pi/256*x)
x:0..255
y:-127..+127
23.5.2006 stochri
**********************************************************************/
int8_t sinwerte[17]={0, 12, 25, 37, 49, 60, 71, 81, 90, 98, 106, 112, 117, 122, 125, 126, 127 };
int8_t sinus( uint8_t x)
{
int8_t wert;
x=x>>2;
if(x>48)
{
x=64-x;
wert=-sinwerte[x];
}
else if(x>32)
{
x=x-32;
wert=-sinwerte[x];
}
else if(x>16)
{
x=32-x;
wert=sinwerte[x];
}
else
{
wert=sinwerte[x];
}
return wert;
}
Lesezeichen