Searching \ for 'making sounds (with a pic and a speaker)' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=sound
Search entire site for: 'making sounds (with a pic and a speaker)'.

Truncated match.
PICList Thread
'making sounds (with a pic and a speaker)'
1997\10\08@165825 by oortje Hanneman & Wouter van Ooijen

picon face
Im working on a 16C84 based 'laser' (actually IR) gun/target.
When it either shoots or it is hit it should make some interesting noise.
I've connected a PIC pin to a 100uF elco and a small 8 ohm LSP,
but that doesn't make much noise. Adding a BD136/BD137 makes more noise,
but not enough for my taste. Also a simple square wave makes a rather dull
sound.

Questions:
- what is an appropriate (simple) amplifier for a small speaker (or is
 the 5 volt the limit, and should I use either a higher voltage or a
 4 transistor bridge)?
- would a piezo buzzer make more noise (when driven with the same voltage)?
- does anyone have experience in generating more interesting
 sounds via 1 output bit (for instance using PWM)?

1997\10\08@172157 by William Chops Westfield

face picon face
   - what is an appropriate (simple) amplifier for a small speaker (or is
     the 5 volt the limit, and should I use either a higher voltage or a
     4 transistor bridge)?

Why do you think you need anything more than a single transistor to Ground?

   - would a piezo buzzer make more noise (when driven with the same voltage)?

Yes, put you'd have much less flexibility in the type of sound.

   - does anyone have experience in generating more interesting
     sounds via 1 output bit (for instance using PWM)?

There exists IBM PC (original) software that can use the internal speaker
(which has a single bit, single transistor to ground) for multi-tone music,
synthesized voice, and all sorts of stuff.  My understanding is that it
works by combining a PWM signal with a high frequency signal designed to
"bias" the speaker cone near the middle of its travel points (in combination
with physical inertia.)

BillW

1997\10\08@173610 by Sean Breheny

face picon face
At 09:45 PM 10/8/97 +0100, you wrote:
>Im working on a 16C84 based 'laser' (actually IR) gun/target.
>When it either shoots or it is hit it should make some interesting noise.
>I've connected a PIC pin to a 100uF elco and a small 8 ohm LSP,
>but that doesn't make much noise. Adding a BD136/BD137 makes more noise,
>but not enough for my taste. Also a simple square wave makes a rather dull
>sound.
>
>Questions:
>- what is an appropriate (simple) amplifier for a small speaker (or is
>  the 5 volt the limit, and should I use either a higher voltage or a
>  4 transistor bridge)?
>- would a piezo buzzer make more noise (when driven with the same voltage)?
>- does anyone have experience in generating more interesting
>  sounds via 1 output bit (for instance using PWM)?
>

A simple single NPN transistor with the speaker attached between the
collector and positive, the emitter to ground, and the base to a PIC output
via a resistor (around 10K, I would estimate) should drive the speaker with
around 200 to 400mW of power when you pulse the PIC pin. This may be
suitable (it is equivalent to a small radio at full volume).

You certainly could get a piezo buzzer that would be louder, but it would
probably need a transistor to drive it, the 20mA or so of PIC pin drive
probably would not be enough. The voltage is not the primary concern, it is
the current.

I have done 1 bit complex sound on a PC speaker. It seems to me that you
could do the same on a PIC. All you do is to come up with a waveform (you
could record some type of sound that you like through a computer sound card
and look at the waveform on the computer. See how often it repeats. Lets
say it repeats around every 20ms and can be adequately sampled at 8KHz.
What you can do is take a 20ms chunk of 8KHz samples and translate each
sample (0-255 8 bit value) into lets say 4 levels (0 for 0-63, 1 for
64-127, etc.). Now, write a routene for your PIC which every 1/8000 of a
second, looks at the next sample in a row and turns the output pin on for
an amount of time which corresponds to the appropriate one of the 4 levels.
This would require a timing resolution of 1/24000 of a second. This is
quite possible on a 16F84 if you do your timing via instruction timing (1
instruction = 1 microsecond at 4MHz)

Here is an example:

Original 4 samples:

0 100 200 50

Translated levels:

0 1 3 0

Timing of pin(tickmarks are 1/24000 sec, * is on, _ is off)

___*__***___
||||||||||||
#1 #2 #3 #4
sample #s^

I realize that I didn't do a great job of explaining it, but this is a
basic PWM method of doing pretty good 1 bit audio. I am able to play back
.WAV files on the PC speaker with good sound. If you want, I can provide
you with C source code which does this on a PC.

I would reccommend using a look up table to get the timing values for each
sample, unless you happen to be able to have 64 or less samples, in which
case you can place them in the EEPROM data area of the 16C/F84.

Good luck,

Sean

Sean Breheny,KA3YXM
Electrical Engineering Student

1997\10\08@183344 by Rick Dickinson

flavicon
face
At 09:45 PM 10/8/97 +0100, Floortje Hanneman & Wouter van Ooijen <spam_OUTwfTakeThisOuTspamXS4ALL.NL>
wrote:
>Im working on a 16C84 based 'laser' (actually IR) gun/target.
>When it either shoots or it is hit it should make some interesting noise.
>I've connected a PIC pin to a 100uF elco and a small 8 ohm LSP,
>but that doesn't make much noise. Adding a BD136/BD137 makes more noise,
>but not enough for my taste. Also a simple square wave makes a rather dull
>sound.
>
>Questions:
>- what is an appropriate (simple) amplifier for a small speaker (or is
>  the 5 volt the limit, and should I use either a higher voltage or a
>  4 transistor bridge)?
>- would a piezo buzzer make more noise (when driven with the same voltage)?
>- does anyone have experience in generating more interesting
>  sounds via 1 output bit (for instance using PWM)?

If you can afford an additional pin, you can get twice the voltage amplitude by
differential-driving your speaker.  Simply output 01 or 10 to the two pins to
either apply +V or -V across your speaker, giving a 2*V amplitude swing.  Using
one pin, you get only 0 to +V across the speaker.

PICs have relatively high current sink & source capabilities (I think 25mA &
20mA, respectively, for the 16C84), but 5V into an 8 ohm load can draw up to
625mA, so a simple transistor amplifier could help if you need higher volume
than is possible with differential drive.

Small speakers have a rather limited frequency response.  Most that I have seen
are best used between about 400 - 4000 Hz.

Piezo elements have higher impedance than speakers, and you should be able to
get fairly high volume out of one with even single-ended drive off of one pin,
but they have even worse frequency response than miniature speakers.  Most have
a resonant peak around 3-4 KHz.

If you have access to a signal generator, try driving a piezo element like the
one you plan to use with a 5Vp-p square wave, and tweak the frequency for
maximum volume.  Design your PIC circuit to use the same frequency.  If you
don't have a signal generator, many sources (such as DigiKey) list the resonant
frequencies of the piezo elements they sell.

If you want some more control over waveform, try using two pins, two resistors,
and an op-amp voltage follower circuit to build a simple buffered D/A converter
to drive your output device.

                                +------------+
                                |            |
                                |  |\        |
                                |  | \       |
                                +--|- \      |
                                   |   >-----+------O  Vout
           +-----------+-----------|+ /
           |           |           | /
           >           >           |/        D1 | D0 | Vout
           < 10Kohms   < 20Kohms           -----+----+-------
           >           >                      0 |  0 | 0
           |           |                      0 |  1 | V/3
           |           |                      1 |  0 | 2V/3
---------------------------------             1 |  1 | V
          D1           D0
          PIC Output Port            (where V is your supply voltage)

This will allow you to have 4 distinct voltage levels on your output, and the
op-amp will give you higher output drive capability, as well.  By careful
setting of the output levels, you can simulate triangle, sine, sawtooth, and
other waveforms, albeit with only two bits of accuracy.  However, depending on
how many output pins you have free, you could go to 3 or 4 bits by extending
this concept.  Just make sure that each resistor is twice the value of the
previous one.  For example, use a 10K on D3, a 20K on D2, 40K on D1, and 80K on
D0.  Beyond 4 bits, go to a R/2R network or a dedicated D/A chip.

Hopefully, my ASCII art circuit is sufficiently legible.... use a fixed-pitch
font such as Courier to view it.

- Rick "ASCII silly question, get a silly ANSI" Dickinson

+---------------------------------+---------------------------+
| Enterprise ArchiTechs Company   |                           |
|     Lotus Certified Notes       |  Never underestimate the  |
|  Appl. Design & Administration  |  bandwidth of a station-  |
|(818)563-1061  .....rtdKILLspamspam@spam@notesguy.com  | wagon full of tape reels. |
|   http://www.eArchiTechs.com    |                           |
+---------------------------------+---------------------------+

1997\10\09@094434 by Leon Heller
flavicon
picon face
In message <1.5.4.32.19971008204500.00366a04spamKILLspamxs4all.nl>, Floortje
Hanneman & Wouter van Ooijen <.....wfKILLspamspam.....XS4ALL.NL> writes
>Im working on a 16C84 based 'laser' (actually IR) gun/target.
>When it either shoots or it is hit it should make some interesting noise.
>I've connected a PIC pin to a 100uF elco and a small 8 ohm LSP,
>but that doesn't make much noise. Adding a BD136/BD137 makes more noise,
>but not enough for my taste. Also a simple square wave makes a rather dull
>sound.
>
>Questions:
>- what is an appropriate (simple) amplifier for a small speaker (or is
>  the 5 volt the limit, and should I use either a higher voltage or a
>  4 transistor bridge)?
>- would a piezo buzzer make more noise (when driven with the same voltage)?
>- does anyone have experience in generating more interesting
>  sounds via 1 output bit (for instance using PWM)?

With a square wave, simply sweeping the frequency (incrementing it on
every cycle) makes it much more "interesting"; some of the pedestrian
crossings near where I live use this technique, presumably to make
people walk faster. Here's a little program I wrote some time ago to try
this out.

;WRITTEN BY            LEON HELLER
;DATE                  20/7/96
;FILE NAME             WARNING.TXT
;PROCESSOR             PIC 16C84
;RESONATOR             4 MHZ XTAL
;CYCLE TIME            1 uS
;WATCHDOG              DISABLED
;CODE PROTECTION       OFF

;EQUATES


PORTB   EQU     6
PB0     EQU     0
STATUS  EQU     3

COUNT   EQU     0x0C
TEMP    EQU     0x0D

;SIMPLE PROGRAM TO GENERATE A SWEPT FREQUENCY TONE ON PB0

ORG     00

INIT    MOVLW   00              ;MAKE PORT B OUTPUTS
       TRIS    PORTB
       CLRF    PORTB

       CLRW                    ;SETS START FREQUENCY
LOOP
       CALL    CYCLE           ;GENERATE ONE CYCLE
       ADDLW   1               ;INCREMENT FREQUENCY
       GOTO    LOOP            ;KEEP GOING


CYCLE
       BSF     PORTB,PB0
       CALL    DELAY
       NOP
       NOP
       BCF     PORTB,PB0
       CALL    DELAY
       RETURN



;DELAY ROUTINE, CALLED WITH DELAY COUNT IN W

DELAY
       NOP
       NOP
       NOP
       MOVWF   COUNT
DELAY1
       NOP
       DECFSZ  COUNT,1
       GOTO    DELAY1
       GOTO    DELAY2
DELAY2
       NOP
       RETURN

       END

Leon
--
Leon Heller: EraseMEleonspam_OUTspamTakeThisOuTlfheller.demon.co.uk http://www.lfheller.demon.co.uk
Amateur Radio Callsign G1HSM    Tel: +44 (0) 118 947 1424
See http://www.lfheller.demon.co.uk/rcm.htm for details of a
low-cost reconfigurable computing module using the XC6216 FPGA

1997\10\09@152704 by Andrew Warren

face
flavicon
face
Leon Heller <PICLISTspamspam_OUTMITVMA.MIT.EDU> wrote:

> With a square wave, simply sweeping the frequency (incrementing it
> on every cycle) makes it much more "interesting"; some of the
> pedestrian crossings near where I live use this technique,
> presumably to make people walk faster.

Leon:

It's more likely that the sounders are there to inform blind
pedestrians that the traffic light is in their favor.

-Andy

=== Andrew Warren - @spam@fastfwdKILLspamspamix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1997\10\11@032051 by Leon Heller

flavicon
picon face
In message <KILLspam199710091925.OAA22250KILLspamspamdfw-ix5.ix.netcom.com>, Andrew Warren
<RemoveMEfastfwdTakeThisOuTspamIX.NETCOM.COM> writes
>Leon Heller <spamBeGonePICLISTspamBeGonespamMITVMA.MIT.EDU> wrote:
>
>> With a square wave, simply sweeping the frequency (incrementing it
>> on every cycle) makes it much more "interesting"; some of the
>> pedestrian crossings near where I live use this technique,
>> presumably to make people walk faster.
>
>Leon:
>
>It's more likely that the sounders are there to inform blind
>pedestrians that the traffic light is in their favor.
>
>-Andy

Only a few of these crossings have sounders, but this is the only one
I've come across with a swept frequency.

Leon
--
Leon Heller: TakeThisOuTleonEraseMEspamspam_OUTlfheller.demon.co.uk http://www.lfheller.demon.co.uk
Amateur Radio Callsign G1HSM    Tel: +44 (0) 118 947 1424
See http://www.lfheller.demon.co.uk/rcm.htm for details of a
low-cost reconfigurable computing module using the XC6216 FPGA

1997\10\11@101451 by paulb

flavicon
face
Floortje Hanneman & Wouter van Ooijen wrote:

> - what is an appropriate (simple) amplifier for a small speaker (or is
>   the 5 volt the limit, and should I use either a higher voltage or a
>   4 transistor bridge)?

 Isn't this the job the LM386 was designed for?

> - does anyone have experience in generating more interesting
>   sounds via 1 output bit (for instance using PWM)?

 Someone posted a two-resistor "ladder" array and stated it permitted
four levels or states.  Wrong!  Three output states for each resistor
makes nine, enough for quite detailed analogue sound output.

 Cheers,
       Paul B.

1997\10\12@103227 by myke predko

flavicon
face
Hiya,

I just sent this reply back to Paul directly when I meant to send it to the
entire list:

Paul Webster Wrote:

>  Someone posted a two-resistor "ladder" array and stated it permitted
>four levels or states.  Wrong!  Three output states for each resistor
>makes nine, enough for quite detailed analogue sound output.

Paul, could you explain how to do this with a Resistor ladder?  The Best
that I can do is n + 1 (where "n" is the Number of Resistors):

    |
 o0 |--- R0 ---+---  Output
    |          |
    |          R1
    |          |
 o1 |----------+
    |          |
    |          R2
    |          |
 o2 |----------+
    |

With this circuit, I can get:

 Vcc  ->  o0 at Vcc, o1 = o2 = High Impedance
 Gnd  ->  o0 at Gnd, o1 = o2 = High Impedance
 V1   ->  o0 at Vcc, o1 at Gnd, o2 at High Impedance,
          V1 = R1 / ( R0 + R1 )
 V2   ->  o0 at Vcc, o2 at Gnd, o1 at High Impedance,
          V2 = ( R1 + R2 ) / ( R0 + R1 + R2 )

Now, I suppose that multiple Outputs could be turned on to get parallel
resistances, but I would be concerned about this with uneven current drive
capabilities with different pins.

This method would make it very hard to calculate the actual Voltage Outputs.

There must be something I'm missing?  Or is a circuit other than a ladder used?

myke

Check out "Programming and Customizing the PIC Microcontroller" at:

http://www.myke.com

1997\10\12@111838 by oortje Hanneman & Wouter van Ooijen

picon face
Thanks for the tips. I've done some more experiments, mayby someone can
(re-) use the results.

My aim is to produce a few different sounds (at least one for shooting, one
for being hit and one for being killed) which are both loud enough to be
heard from some distance and appropriate for their function. I've finished
the electronics, now I'll start exprimenting with waveforms (using PWM).

ELECTRONICS

The most simple solution is to couple a PIC output directly to a speaker,
with or without a C. This gives a verly low volume due to the limited drive
capability of the PIC.
                     ___
                     \ /
   PIC --------------| |----- Gnd
                  Lsp -
                     ___
             ||      \ /
   PIC ------||------| |----- Gnd
           C ||   Lsp -

Direct PIC output with and without capacitive coupling: simple, but not much
volume due to PIC impedance.

The one-transistor solution has the drawback that current always flows
through the speaker in the same direction (switched DC), which in the long
run could be bad for the speaker, and limits the movement of the conus: it
can only move from the middle position to one of the extreme positions. And
when you leave the pin in the wrong (is this case: high) position for too
long quite a current will flow through the speaker, not a good idea for a
battery-powered application.
                              ___
                              \ /
                         /----| |---- Vcc
           R  ____     |/      -
   PIC ------|____|----|     Lsp
                       |>
                   npn   \
                          Gnd
or
                         +------- Vcc
                       |/
   PIC ----------------|
                       |>     ___ Lsp
                   npn   \    \ /
                          +---| |--- Gnd
                               -
single npn buffer: more volume, but not optimal (DC problem)

That's why I initially choose a npn/pnp pair, which gives a real AC of Vcc
Top-Top (effective voltage is lower: 0.5 * Vcc for a square wave,
1/2*sqrt(2) * Vcc for a sine).

              npn    / Vcc
                   |/
               +---|            ___
               |   |>\    ||    \ /
  PIC ---------+      +---||----| |--- Vcc or Gnd
               |   |</    ||     -
               +---|        C     Lsp
                   |\
              pnp    \ Gnd

complementary buffer: good volume, real AC, low impedance. Can not make use
of a Vcc > PIC-Vcc

In my application I'll have a 7-9V NiCad which is regulated down to 5V for
the PIC and the SFH506 IR receiver, so I can gain some volume by using the
NiCad directly. This requires a level shifter (3th transistor).
                        ____
                   +---|____|------+---- Vcc > Vcc-PIC
                   |             |/
                   +----------+--|           ___
         ____    |/           |  |>\    ||   \ /
  PIC --|____|---|            |     +---||---| |-+
                 |>\          |  |</    ||    -  |
              npn   \         +--|               |
                     Gnd         |\         Vcc or Gnd
                                   \ Gnd

complementary buffer with inverting level shifter to make use of a higher
Vcc than the PIC's Vcc.

Once the impedance of the driver is no longer a problem the volume is
determined by the impendance of the speaker and the voltage applied to it (
P = V*V/R ). So to get a high volume it is important to take the lowest
impedance speaker which you can get (4 ohms if possible). It is even more
important to apply the highest possible voltage. If you only have 5V it will
help to use two PIC output pins which are always each others inverse to
drive two complementary buffers. If you do not want to use two PIC pins an
extra transistor can provide the inversion. And if you want to use a Vcc >
PIC-Vcc you'll have to add two level-shifters (no need for two PIC outputs
then, the level shifters are also inverters).


              npn    / Vcc
                   |/
               +---|      ___
               |   |>\    \ /
  PIC1 --------+      +---| |-+
               |   |</     -  |
               +---|          |
                   |\         |
              pnp    \ Gnd    |
                              |
              npn    / Vcc    |
                   |/         |
               +---|          |
               |   |>\    ||  |
  PIC2 --------+      +---||--+
(inverse       |   |</    ||
 of PIC1)      +---|
                   |\
              pnp    \ Gnd

dual complementary buffer (bridge) doubles the voltage compared to a single
bridge.

MECHANICS

One non-electric measure which is quite important: provide a good housing
for the speaker. A speaker without any housing is just causing local air
movement (from the front of the conus to the back and v-v). Ideally a
speaker should be mounted in an infinite, non-flexible plate. If you don't
have that a box will do.

1997\10\12@123846 by Marc 'Nepomuk' Heuler

flavicon
face
Hi Floortje (Floortje Hanneman & Wouter van Ooijen), in <RemoveME1.5.4.32.19971008204500.00366a04spamTakeThisOuTxs4all.nl> on Oct 8 you wrote:

> - what is an appropriate (simple) amplifier for a small speaker (or is
>   the 5 volt the limit, and should I use either a higher voltage or a
>   4 transistor bridge)?

You should use an LM386 amplifier:

- DIP-8 package

- gain of 20-200

- needs almost no external components (for gain=20)

- drives 8ohm 250mW speakers

- only a +5V supply required

- cheap

1997\10\12@161758 by William Chops Westfield

face picon face
There are a whole new set of audio amplifiers aimed a miniaturized
appliacnces (cell phones, cd players, etc.)  They do away with output caps
AND double the power that would normally be available from a low voltage
supply by driving opposites sides of the speaker from mutually inverted
simple amplifiers (similar to the hack used to drive LCDs directly from
logic.)  National Semi in particular has been agresively sending out samples
of their "BOOMER" audio amps like the LM4860/4861...

BillW

1997\10\13@040015 by Leon Heller

flavicon
picon face
In message <CMM.0.90.2.876687404.billwEraseMEspam.....puli.cisco.com>, William Chops
Westfield <EraseMEbillwspamCISCO.COM> writes
>There are a whole new set of audio amplifiers aimed a miniaturized
>appliacnces (cell phones, cd players, etc.)  They do away with output caps
>AND double the power that would normally be available from a low voltage
>supply by driving opposites sides of the speaker from mutually inverted
>simple amplifiers (similar to the hack used to drive LCDs directly from
>logic.)  National Semi in particular has been agresively sending out samples
>of their "BOOMER" audio amps like the LM4860/4861...
>
>BillW

I like the Philips TDA7052, which uses this arrangement, and needs *no*
external components.

Leon
--
Leon Heller: RemoveMEleonEraseMEspamEraseMElfheller.demon.co.uk http://www.lfheller.demon.co.uk
Amateur Radio Callsign G1HSM    Tel: +44 (0) 118 947 1424
See http://www.lfheller.demon.co.uk/rcm.htm for details of a
low-cost reconfigurable computing module using the XC6216 FPGA

1997\10\13@073246 by Paul Kolesnikoff

flavicon
face
Myke,

Here's two more,

 V3   ->  o0 at Gnd, o1 at Vcc, o2 at High Impedance,
 V4   ->  o0 at Gnd, o2 at Vcc, o1 at High Impedance,

If the resistors are wired as shown here, you can parallel them to get
more voltages. Obviously, you must choose your resistors wisely to get
unique voltages.

    |
 o0 |--- R0 ---+---  Output
    |          |
    |          |
    |          |
 o1 |----R1----+
    |          |
    |          |
    |          |
 o2 |----R2----+
    |

I am enjoying your book.
Nice Job!
Paul



Date:    Sun, 12 Oct 1997 10:27:40 -0400
From:    myke predko <RemoveMEmykespam_OUTspamKILLspamPASSPORT.CA>
Subject: Re: making sounds (with a pic and a speaker)

Hiya,

I just sent this reply back to Paul directly when I meant to send it to
the
entire list:

Paul Webster Wrote:

>  Someone posted a two-resistor "ladder" array and stated it permitted
>four levels or states.  Wrong!  Three output states for each resistor
>makes nine, enough for quite detailed analogue sound output.

Paul, could you explain how to do this with a Resistor ladder?  The Best
that I can do is n + 1 (where "n" is the Number of Resistors):

    |
 o0 |--- R0 ---+---  Output
    |          |
    |          R1
    |          |
 o1 |----------+
    |          |
    |          R2
    |          |
 o2 |----------+
    |

With this circuit, I can get:

 Vcc  ->  o0 at Vcc, o1 = o2 = High Impedance
 Gnd  ->  o0 at Gnd, o1 = o2 = High Impedance
 V1   ->  o0 at Vcc, o1 at Gnd, o2 at High Impedance,
          V1 = R1 / ( R0 + R1 )
 V2   ->  o0 at Vcc, o2 at Gnd, o1 at High Impedance,
          V2 = ( R1 + R2 ) / ( R0 + R1 + R2 )

Now, I suppose that multiple Outputs could be turned on to get parallel
resistances, but I would be concerned about this with uneven current
drive
capabilities with different pins.

This method would make it very hard to calculate the actual Voltage
Outputs.

There must be something I'm missing?  Or is a circuit other than a
ladder used?

myke

Check out "Programming and Customizing the PIC Microcontroller" at:

http://www.myke.com

------------------------------

1997\10\13@081439 by paulb

flavicon
face
Myke Predko wrote:

> Hiya,

 G'day!

> I just sent this reply back to Paul directly when I meant to send it
> to the entire list:

 No worries, I caught both, will forward to the list only.

>> Three output states for each resistor makes nine, enough for quite
>> detailed analogue sound output.

> Paul, could you explain how to do this with a Resistor ladder?  The
> Best that I can do is n + 1 (where "n" is the Number of Resistors):

 * diagram of rather assymetric circuit bearing *
 *    negligible resemblance to R-2R ladder!    *

 Your circuit is a little confused.  Let me propose again the use of
two outputs, each with a resistor to a common output point (coupled to
the LM386 by a capacitor) which is the centre point of an equal voltage
divider between Vcc and ground.  I specify that the resistors from the
PIC outputs are related in a 3 to 1 ratio, and the values in the voltage
divider are each equal to the lesser value of the other.

              Vcc
               |
    |          R
    |          |   DC Block
 o1 |----R-----+------||--- Output
    |          |
    |          |
 o2 |----3R----+-- "common point"
    |          |
    |          R
               |
              Gnd

 If neither PIC output is enabled, the common voltage is ¸Vcc.  If the
output coupled to the lesser resistor is enabled in either direction, it
delivers a voltage bias of Vcc/6 to the common point in that direction,
while the other output produces a third of this bias in whichever
direction.  Calling this lesser bias increment "i" and referring this
to ¸Vcc, the effects of the two outputs are:

           o1
      Gnd O/C Vcc       Nine states in total, four positive
  Gnd -4i  -i +2i     and four negative increments relative  
o2 O/C -3i  0  +3i     to the zero point.  If you REALLY want
  Vcc -2i  +i +4i     twenty-seven states, use a third output.

 Even a four bit (81 state) system would fit really nicely packed in
a byte using the SWAPF instruction to extract first the port, then the
TRIS value, and a lookup table might of course be used to read such
values from a "phase" or syllable table.

 Something tells me an "R-3R" ladder would also be usable for this
task.  For the moment though, stock resistor values are sufficiently
accurate.

> Now, I suppose that multiple Outputs could be turned on to get
> parallel resistances, but I would be concerned about this with uneven
> current drive capabilities with different pins.

 I wouldn't!  The PIC "Maximum Current Sunk" by an output pin being
quoted as 20mA (though this is actually a maximum safe rating rather
than a claimed drive ability) at 5V suggests an output impedance of 250
ohms.  Since the input impedance of the LM386 is about 250k, the "R"
above should be picked in the order of 270k (giving 3R a convenient
value of 820k) and the current drive capability of the PIC pins is
trivial.

> This method would make it very hard to calculate the actual Voltage
> Outputs.

 That's what scientific calculators or PCs are for!

 Cheers,
       Paul B.

1997\10\14@101407 by myke predko

flavicon
face
Hi Paul,

>Here's two more,
>
>  V3   ->  o0 at Gnd, o1 at Vcc, o2 at High Impedance,
>  V4   ->  o0 at Gnd, o2 at Vcc, o1 at High Impedance,
>
>If the resistors are wired as shown here, you can parallel them to get
>more voltages. Obviously, you must choose your resistors wisely to get
>unique voltages.

That was the point I was trying to make (and I guess I didn't articulate it
well enough).

>I am enjoying your book.
>Nice Job!

Thanx!

myke

Check out "Programming and Customizing the PIC Microcontroller" at:

http://www.myke.com

1997\10\14@115523 by Chuck Adams

flavicon
face
Myke,

Haven't gotten much into your book yet.

Interesting note, I was in CA and was on the way to San Jose airport
on way back to DFW.  I stopped at Computer Literacy and bought Dave
Benson's book.  :-)  Had it read and rewritten by the time I landed.

Sent him a note about it too.  :-)  So I have four chapters written
on mine.  I did two books a long time ago on the Motorola 6800 and
6809 and have been off doing supercomputers since.

ciao dude,


I'll let you know if I have any comments on your book.

Chuck Adams  K5FO CP-60 RemoveMEadamsTakeThisOuTspamspamsgi.com
http://reality.sgi.com/adams/index.html

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...