Shop OBEX P1 Docs P2 Docs Learn Events
was wondering — Parallax Forums

was wondering

MatspikeMatspike Posts: 2
edited 2006-02-22 14:21 in BASIC Stamp
eeh, this is probably a lame question , im no whiz when it comes to programming or electronics, but i do enjoy playing around with my basic stamp microcontroller.

i have the lowest difficultie lvl starter kit and im far from understanding everything that goes on in there.

My question is basically this, my starter kit came with a piezoelectric speaker, but im pretty much a nightperson and my housemate is not, so i was wondering if there is anyway that i could replace the piezoelectric speaker with a set of headphones, and if so, how would i go about doing that?

anyways thats all i wanted to know.
so ... thanks
mattias

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-02-15 07:38
    Well, it depends on the resistance in the headphones.

    The piezoelectric speaker [noparse][[/noparse]rather than a simple 4ohm or 8ohm speaker] was provided because it is a safe 'no brainer' audio output.

    At 4ohms or 8ohms, you really risk damaging the Basic Stamp without using a transitor circuit to drive them.

    It is simply Ohm's Law E=IXR;
    5volts = Amps x 8 ohms comes out to 5/8ths amps [noparse][[/noparse]that is about 625millamps].

    The BasicStamp can only saftely drive less than 30millamps. 20millamps is safer.

    4 ohms is worse as the amps doubles to 1.250 Amps.

    Of course, you could just add a length of wire to the piezoelectric and make you own headphone with a coat hanger. You could possilbly add a volume control too.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • MatspikeMatspike Posts: 2
    edited 2006-02-15 10:47
    thanks for that [noparse]:)[/noparse] i dont quite understand everything you just said [noparse]:)[/noparse]
    but i think i get the idea, so i wont attempt to hook up my stamp module to my high voltage amp just yet :P
    i just wrote my first program today, by that i mean a program that didnt come out of the book, and i was just hoping to have someone look at it and make sure im not frying my processor.
    its basically two buttons, a potentiometer and the lil speaker.
    the potentiometer scans its position between 3 ranges like 1 to 100 and 100 to 200 and 200 to 300
    depending on its position the frequency duration or pause between the sounds can be modified by pressing the button that adds and pressing the button that substracts values. those creating a sort of machine that will let you tune a beat etc, anyways here is my code.

    ·' {$STAMP BS2}
    ·' {$PBASIC 2.5}
    ·dur VAR Word
    ·freq VAR Word
    ·paus VAR Word
    ·optionnr VAR Word
    · freq = 500
    · paus = 50
    · dur = 50

    · DO
    · HIGH 7
    · RCTIME 7, 1, optionnr

    · IF (optionnr < 100) THEN

    · IF (IN11 = 1) THEN
    · freq = freq + 100
    · ENDIF

    · IF (IN10 = 1) THEN
    · freq = freq - 10
    · ENDIF

    · FREQOUT 15, dur, freq
    · PAUSE paus
    · DEBUG CLS, "Frequency = ", DEC5 freq
    · ENDIF

    · IF (optionnr > 100) THEN
    · IF (optionnr < 200) THEN

    · IF (IN11 = 1) THEN
    · dur = dur + 10
    · ENDIF

    · IF (IN10 = 1) THEN
    · dur = dur - 10
    · ENDIF

    ··· FREQOUT 15, dur, freq
    · PAUSE paus
    · DEBUG CLS, "Duration = ", DEC5 dur
    · ENDIF
    · ENDIF

    · IF (optionnr > 200) THEN
    · IF (optionnr < 300) THEN

    · IF (IN11 = 1) THEN
    · paus = paus + 10
    · ENDIF

    · IF (IN10 = 1) THEN
    · paus = paus - 10
    · ENDIF

    ··· FREQOUT 15, dur, freq
    · PAUSE paus
    · DEBUG CLS, "Pause = ", DEC5 paus
    · ENDIF
    · ENDIF

    · LOOP
    · END

    so ya, pls lemme know if this is the propper way to be doing things, or any suggestions would also be nice [noparse]:)[/noparse]
    anyways thanks [noparse]:)[/noparse]
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-02-22 14:21
    You will have to run the output through an audio amplifier first, if you check out the published schematics for the professional development board on Parallax's website, you'll see a circuit for using a LM386 suitible for driving a pair of headphones.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
Sign In or Register to comment.