Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

About 5Hz-20KHz audio generator of mr. rb

Status
Not open for further replies.

dosatelite

New Member
I was trying to code PIC pwm to generate audio sines, as did Mr. RB. But my maths cant find his results. He didnt publish code. After reading the article, I got: Taudio(min) = samples * Tpwm(min). From the article, he says for 20Khz he used 20 samples to form the sine, so the Tpwm(min) =1/20KHz * 1/20 = 1/400,000 s.=2.5us. So far, so good. The problem is how to get the duty cycle, which he said spans 5-95%, requiring a Tpwm always greater than Tdcycle, obviously. So, using the pwm formulas of the PIC, we have: Tpwm = (Ptper-1)/Fosc/4, so: Tpwm = (95-1)/40MHz/4= 9,4us required to allow that duty cycle spam. This is much greater than the 2.5us required to 20KHz out, so for me it seems impossible to assembly a 20khz audio with 20 samples with that amplitude spam. For that I would have to use a much faster clock. Any ideas where is my error or the trick he used?

This is the article: https://www.romanblack.com/onesec/SineDDS.htm
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top