You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just an information:
you can issue a pair of sinus-cosinus signals very easily without any complex math and look up table.
Try that:
// Digital sinus generator for Arduino Due.
int8_t x ;
int8_t y ;
void setup() {
//pinMode(5,OUTPUT);
//pinMode(6,OUTPUT);
y= 114; // put less to change amplitude but not less than 64, else it will deteriorate the sine quality
// 114 gives 2v PP and 0.70V RMS which is 10dB
//Serial.begin (115200); // to test show on serial
}
void loop() {
x += (y / 4);
y -= (x / 4); // Divisor value: according to table below:
//printf ("%i %i \n", x , y ); // to test show on serial
delayMicroseconds(2); // Delay value according to table below:
analogWrite(DAC1, y + 127);
}
/*
Frequ divisor delay divisor delay
3 Khz 8 0 n/a n/a
2 Khz 8 4 n/a n/a
1 Khz 8 13 16 4 (0,945 Khz), 3(1.054 KHz) right value would have been between.
500Hz 8 33 16 13
250Hz 8 71 16 30
125Hz 8 149 16 68
63Hz 8 299 16 140
32Hz 8 599 16 282
Frequ divisor delay divisor delay divisor delay
50 Hz 8 378 16 179 32 76
5Khz 4 2 (fastest run at a round frequency)
*/
This is a simple demonstration example using delays and 8 bit integer math just to show how fast this unorthodox sine generation can be.
Getting 50Hz in a PLL should be easy to be done by using 16bit values and PLLing the divisor and replacing the delay with a periodic processing.
Why does these two lines issue a sinus without trigonometry?
Pure magic?
Not really:
x += (y / 4); //is in a loop the expression of: "x is the integral of y"
y -= (x / 4); //is in a loop the expression of: "-y is the integral of x"
The only solution of this pair of equations is x=cos (y) and -y=sin(x)
The text was updated successfully, but these errors were encountered:
Just an information:
you can issue a pair of sinus-cosinus signals very easily without any complex math and look up table.
Try that:
This is a simple demonstration example using delays and 8 bit integer math just to show how fast this unorthodox sine generation can be.
Getting 50Hz in a PLL should be easy to be done by using 16bit values and PLLing the divisor and replacing the delay with a periodic processing.
Why does these two lines issue a sinus without trigonometry?
Pure magic?
Not really:
x += (y / 4); //is in a loop the expression of: "x is the integral of y"
y -= (x / 4); //is in a loop the expression of: "-y is the integral of x"
The only solution of this pair of equations is x=cos (y) and -y=sin(x)
The text was updated successfully, but these errors were encountered: