CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Generate audio signals with PIC and PWM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
globalsys



Joined: 17 Apr 2007
Posts: 22
Location: france

View user's profile Send private message

Generate audio signals with PIC and PWM
PostPosted: Tue Dec 09, 2008 10:35 am     Reply with quote

Hello everyone!
I want to know if somebody has already tried to generate audio signals with a PIC using the PWM output?
Because I'm looking for an easy and small way to make a speech synthesizer, and why not using a PIC...

Thanks

Bruno
yerpa



Joined: 19 Feb 2004
Posts: 58
Location: Wisconsin

View user's profile Send private message Visit poster's website

PostPosted: Tue Dec 09, 2008 12:32 pm     Reply with quote

Here's a project with source code, using PCH 3.249. Enjoy!

http://www.reprolabs.com/fraktal_synth_1.htm
globalsys



Joined: 17 Apr 2007
Posts: 22
Location: france

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 3:19 am     Reply with quote

Thanks Yerpa for your link, but I'm trying to make a vocal synthesis, I would like to have an idea of vocal signals generate by a PIC.
I'm going to have a look to the code an try to integrate vocal signals.
Thanks

Bruno
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 11:26 am     Reply with quote

Look up ADPCM (Adaptive Differential Pulse Code Modulation). It is a very efficient means to encode voice with less memory than storing each sample value, and it is still easy enough to decode that it doesn't stress a PIC too much.

Beyond that, you have to pick a PWM frequency that is easy to filter from the audio. Let's say you want the equivalent of an 8-bit D/A. That requires a PWM period that is at least 256 Fosc periods. For a 4 MHz crystal, that means the PWM frequency must be less than 15,625 Hz. This is getting awfully close to the audio range, and might require exotic filtering to remove it. If you raised the clock rate to 8 MHz, then you could use a PWM frequency of about 30 kHz, which is easy to filter out.
_________________
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
Guest








PostPosted: Fri Dec 12, 2008 6:45 am     Reply with quote

Thanks for your inputs, my audio can be limited from 300hz to 3kHz, my audio interface is not for HiFi.
I'm going to try the ADPCM with a DSPic. The results showed on the microship website looks good Cool
Ttelmah
Guest







PostPosted: Fri Dec 12, 2008 10:10 am     Reply with quote

The key though is that you do need very good filtering.
Remember that a single stage filter, only 'rolls off' at 6dB/octave. You do need to get good attenuation at your sampling frequency.
I have used CVDSM, in the past to do this type of work, and to get really acceptable audio, was using 5pole active filtration...

Best Wishes
globalsys



Joined: 17 Apr 2007
Posts: 22
Location: france

View user's profile Send private message

PostPosted: Wed Dec 17, 2008 3:52 am     Reply with quote

Hi Ttelmah, i don't know CVDSM, on my project i'm using an active filter ( already used to another audio signals).

I found this website : http://www.romanblack.com/picsound.htm

On this web site there is a software able to convert wav files to bit stream.
But i don't know how integrate the file generated on my PIC software.
The software generate ASM, MikroC, and bin files, but i don't know how to turn this BIN file on a const on my software...
globalsys



Joined: 17 Apr 2007
Posts: 22
Location: france

View user's profile Send private message

PostPosted: Wed Dec 17, 2008 11:17 am     Reply with quote

Hello,
This afternoon I insert the data generated by the "Romanblack" software on my the ROM memory of my PIC18F4520 but the result is very bad Sad
I was expecting something more understandable.
On this forum there is few users who try to do the same as me but nobody says if the result is good.
Thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group