Connect with us

Piezo/Mosfet/Keyboard problem

Discussion in 'Electronic Basics' started by Peter, May 17, 2004.

Scroll to continue with content
  1. Peter

    Peter Guest

    I have a keyboard attached to a PICAXE micro on a lonnnnng cable
    (50m). I want to add a piezo to the keyboard so I can buzz it to
    indicate invalid keystrokes etc. The Pic has the ability to control
    the 3 LEDs on the keyboard so I figured it should be a simple matter
    to connect a transistor and piezo to one of the LEDs then flash the
    LED rapidly to produce the buzz in the piezo. I tried it last night,
    both with a transistor and a mosfet without any luck. Any ideas? (PS.
    I know that I could run a separate wire for the piezo but I do NOT
    want to do that.)

    Here is the LED circuit. The keyboard IC is between the LED and

    +5V -----/\/\/\----->|---- KBD IC --- GND

    So I figured I could just add a PNP transistor/P channel Mosfet before
    the IC like this, and flash the LED at around 500Hz:

    +5V -----/\/\/\----->|--.-- KBD IC --- GND
    680 |
    | +5V
    | |
    | /
    | |/
    470 |\
    \------- PIEZO ------ GND

    I tried it with a PN200 transistor. Also with a MTP2955 MOSFET without
    the gate resistor. Absolutely nothing. I know with an N channel Mosfet
    you often need a resistor from gate to ground to bleed off the gate
    charge. With the P channel I wasn't sure what was required. I tried a
    10k between gate and Source and also Gate and Drain but still nothing.
    What am I doing wrong? (I didn't have the long cable attached when
    testing, just the standard one.) I did notice strangely that when I
    put a DMM across the Piezo to check the voltage across it it did give
    a very faint hum.
  2. A piezo is essentially a capacitor that changes shape slightly when
    the voltage across it is changed. Your circuit applies 5 volts across
    it and then disconnects from it, leaving its capacitance charged to 5
    volts. After that, additional pulses do nothing ot the voltage on the
    piezo. You need some way to discharge the charge stored on the piezo
    when the transistor switches off. A resistor in parallel (perhaps
    10k) with it would be the simplest solution. However, piezo devices
    last longer if they do not see long term DC. So a more complex
    solution might work better. But you should verify that it works at
    all with the change I suggested.
  3. Peter

    Peter Guest

    Thanks for that. That would explain why I got a faint hum when I
    paralleled the piezo with the DMM.

    At $0 for the piezo (from an old musical Christmas card) I can afford
    to replace it if it gives up the ghost.

    Maybe I could just add an N channel mosfet to the circuit with the
    gate connected to the P channel drain and the drain/source connected
    between the piezo input and Gnd. That way when the P channel turns on
    the N channel turns off. When the P channel turns off the N channel
    turns on and discharges the piezo.

    PS. I still cannot work out why the P channel mosfet did not seem to
    work at all. I put a DMM across the Drain/Source and it did not change
    regardless of whether the LED was on or off. It just sat on 5v and
    stayed there I would have expected it to drop to zero when the base
    was pulled low. Do I have to do anything with it to drain off the gate
    charge, like with an N channel? eg. should I tie the gate high with a
    10k say?
  4. Should work.
    I don't think the problem was with the switch (transistor or mosfet).
    Your approach simply did not have a mechanism to discharge the voltage
    applied to the piezo after the switch turned off. The first pulse
    charged it to 5 volts and it stayed there after the switch opened, and
    was still there for all the future pulses.

    The two mosfet push pull inverter does not have this problem. But I
    doubt it sounds much different than a single transistor driving the
    parallel combination of the piezo and a resistor.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day