Hey Everyone,
Disclaimer: first post, please advise if I am failing community guidelines.
This topic has been all but beaten into the ground. I "wrote" (more like took from other posts on this topic) a simple lookup table and analogWrite to a PWM pin on my AT Mega. Then I put it through a RLC low pass filter (R=10000 ohm, L = 10mH, C = 10uF) to get a sin wave. I used parts I had laying around. When you change the size of the look up table or the delay period, you affect the frequency of the output sin wave (after the lowpass filter). That all makes sense and is clearly discussed in this thread. However when you increase the frequency, you decrease the output peak voltage. I am pretty sure that that is due to the constraints of the PWM pin, but I was hoping someone could explain it to me because I am failing to understand what constraints on the PWM pin cause this. So the question is: why does amplitude decay as frequency is increased?
const byte sig[] = {
128,143,159,174,189,202,215,226,
235,243,249,253,255,255,253,249,
243,235,226,215,202,189,174,159,
143,128,112,96,81,66,53,40,
29,20,12,6,2,0,0,2,
6,12,20,29,40,53,66,81,
96,112
};
void setup() {
pinMode(6, OUTPUT);
}
void loop(){
for(int i = 0; i<50; i++)
{
analogWrite(6,sig[i]);
delay (20);
}
}