Download filezillafor windows
Although the previous program does what it should do and produces a note of
varying frequency, it isn’t exactly pleasing to the ear. What’s required is a form
of  envelope  shaper  in  order  to  give  the  note  a  more  mellow  sound.  This  is
achieved by taking advantage of a well known method of charging a  capacitor
and allowing it’s voltage to decay naturally. While the capacitor is fully charged,
the  note  is  at  full  volume  but  as  the  capacitor  discharges,  the  note’s  volume
will decrease until it is silent. This
will form a rather pleasant chime effect.
In order to accomplish this we require a few changes to our previous program
and circuit, but the interrupt driven note generator (with minor changes) is still
at  the  heart  of  the  process.  The  circuit  to  produce  a  chime  effect  from  pin
PORTB.0 is shown below.
   The circuit above also shows the approximate wave shapes produced on each
pin and the listing below shows the program needed to create the chime effect.
' Program PLAY_CHIME.BAS
' Produce two Chimes from PORTB.0 using a TMR1 interrupt
'   
Device= 18F452 ' Use a PIC18F452 device XTAL= 20 ' With a 20MHz crystal/resonator                                DimNOTE_COUNTER asWordSYSTEM   ' Determines when the pin is toggled                   DimNOTE asWordSYSTEM   ' Determines the pitch of the note                        DimTIMER1asTMR1L.Word ' Combine TMR1L/TMR1H as a 16-bit word SymbolTRIGGER = PORTB.4          ON_INTERRUPTGotoNOTE_INT ' Point interrupts to our interrupt handler Delayms400   ' Wait for PICmicro to stabilise ALL_DIGITAL= True ' Set PORTA and PORTE to digital GotoOVER_INTERRUPT ' Jump over the interrupt handler   R1
220W
    R2
100kW
    R3
100kW
        C1
4.7uF/10V
RB0 RB4   18F452
PICmicro
Output toAmplifier