PIC16F684 Capabilities

Thread Starter

DHEN

Joined Dec 7, 2009
9
New to the Pic16f684! can it in any way generate sounds to output through a speaker in any way?

Thanks for your help?
 

mik3

Joined Feb 4, 2008
4,843
It has not an analog output and thus it is not able to generate sound in an analog manner. However, it is possible to use a PWM output and filter it to produce an analog signal which when amplified will be able to produce sound via a speaker. The PWM duty cycle variation will be according to the required sound to be produced.
 

beenthere

Joined Apr 20, 2004
15,819
The converted values correspond to loudness. Use the value of the conversions in the file to set the percentage of pulse width. You have to be able to separate the right and left channels values, as well as determine the length of the converted values. The .wav file format should have that information in it. Trimming the words to 8 bits may make life easier.
 
Last edited:

THE_RB

Joined Feb 11, 2008
5,438
Have a look at this page, it allows you to playback sound with just one digital output pin on a PIC;
http://www.romanblack.com/picsound.htm

There is also free windows software on that page to convert wave files to the 1bit sound format.

The main problem is getting a decent length of sound playback, in most cases you need external memory. There is a low cost PCB here that will store 1 megabit of sound and play it in up to 255 separate sounds (controlled by serial);
http://www.talkbotbrain.com/
 

Thread Starter

DHEN

Joined Dec 7, 2009
9
This is Great, Jest what i am looking for. What i don't understand is how to use the Algorithm. how is it entered into the code?
 

THE_RB

Joined Feb 11, 2008
5,438
The 1-bit playback is extremely simple. You just send the sound data byte to the PIC pin, 1 bit at a time, and when the 8 bits are sent you just start sending the next byte.

The 1bit format stores the sound with MSB first so so send the sound out using a left shift, something like this;

Rich (BB code):
  MOVF databyte,w
  MOVWF PORTB    

  RLF PORTB,f   ;   this RLF sends out 1 sound bit
And the sound will be output from the PIC pin for bit7.
 
Top