I could really use some help getting oriented on a project that is intended to be used as part of a Christmas / White Elephant gift tomorrow.

The idea behind my project is essentially that when a wire is cut, music plays from one of these “singing card” programmable speaker module. The one I have uses a 4V lithium battery cell.

I already have the programmable speaker module configured to immediately play music as soon as its power switch is moved to the “on” position.

In exploring possible ways to go about this, I realized that what I am effectively doing is building a tripwire circuit.

The examples I found were very simple, involving an NPN transistor (2n2222), 10KΩ resistor, battery, and DC Piezo speaker.

In my case, there’s no piezo - I’m trying to handle the entire load that would otherwise be running through the on/off switch.

With my initial attempt, I wired +4V from the switch to the transistor’s collector and then separated the collector from the base with a resistor. I connected the emitter to the pin that, when the switch is engaged, would send 4V through and power the module.

Initially, all I got with the “Tripwire” disconnected was rapid clicking from the module’s speaker as it cycled on and off. I reduced the resistor to 1KΩ and then 510Ω to get longer runtime, but it was still restarting. I jumped down to 22Ω and that stopped the restarting while introducing a new concern: that resistor quickly climbed up past 100C while the “tripwire” was connected. Without the tripwire, the I don’t want to start a fire, nor do I want the battery to die while this all sits in a box.

Someone suggested that what I actually needed was a MOSFET, so I ordered a hobby kit with various FETs that would get here in time and am now running into a new issue - I can’t get the MOSFETs I have to turn fully on and let current through.

I have the resistor connected between Gate and Drain, +4V going to drain, and the load from the module on Source.

With an RFP30N06LE, I get about 2V output to Source. With an IRF840N, I’m only getting 0.9V.

In my photos, the orange wire is +4V, brown connectors the the circuit that ultimately powers the module, and blue is the “tripwire” that pulls down to GND.

I’ve attached a couple of the diagrams I have been referencing, as well as one I quickly drew outlining my particular application.

I’m starting to feel like this circuit design isn’t actually applicable in this context and that what I am going to end up needing is something far more complex that involves parts I don’t have on hand. At the same time, I’m worried that I’m about to give up when I’m only a small adjustment away from success.

EDIT / Update:

So far, I have been trying to place the load (full speaker module) after the emitter or source, depending on component used - mostly a limitation of trying to set up the circuit to bypass the on/off switch.

I shifted my attention to just the speaker itself. The good news is that I had success with both NPN and MOSFET, however the audio quality gets so degraded that this approach is not viable.

Update 2: Went back to the NPN Transistor, found a sweet spot at 330Ω where the speaker module does not reset. Resistor seems to stabilize at 40C. Probably going to roll with this and see what happens, try to plug in batteries just before delivery so I can avoid the situation where the battery has died before the right time.

  • Agent641@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    5 hours ago

    Forgive me if I’ve misunderstood the application, but could the tripwire not just complete a circuit by its removal? As in, a spring-loaded switch, it’s contacts separated by an insulator, the insulator is yanked out by the tripwire?

  • raspberriesareyummy@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    15 hours ago

    I was never excellent at analogue electronics but your very first diagram looks perfectly fine, with the tripwire connecting the transistor base to ground. Preferably with a large resistor to avoid draining the battery quickly. A grounded base should effectively close the collector-emitter path.

    • Romkslrqusz@lemmy.zipOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      15 hours ago

      That’s where I think I’m having the biggest issue. I’ve been experimenting with different resistors, 20Ω is the only value so far that doesn’t result in the module power cycling the resistor starts to cook, I think it is rated for 1/8W and I could go with a higher wattage rating but I don’t want to drain the 300mAh battery too fast

      • raspberriesareyummy@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        6 hours ago

        I couldn’t imagine the transistor flipping when it’s base is actually grounded. Did you try an NPN transistor? I am not familiar with FETs, maybe they behave weirdly here?

  • litchralee@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    15 hours ago

    I’m going to try to answer your situation, but although time appears to be of the essence, I need to first understand exactly what you’ve already tried. So bear with me for a moment.

    The examples I found were very simple, involving an NPN transistor (2n2222), 10KΩ resistor, battery, and DC Piezo speaker.

    With my initial attempt, I wired +4V from the switch to the transistor’s collector and then separated the collector from the base with a resistor. I connected the emitter to the pin that, when the switch is engaged, would send 4V through and power the module.

    Does this diagram correctly describe what you tried as a first attempt?

    schematic diagram of attempt 1

    Someone suggested that what I actually needed was a MOSFET …

    I have the resistor connected between Gate and Drain, +4V going to drain, and the load from the module on Source.

    With an RFP30N06LE, I get about 2V output to Source. With an IRF840N, I’m only getting 0.9V.

    Do these diagrams match your circuits with each MOSFET?

    schematic diagram of attempt 2

    schematic diagram of attempt 3

    What I am not able to understand, in your last photo with the MOSFET, is where the blue wire is going.

    • Romkslrqusz@lemmy.zipOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      15 hours ago

      Appreciate your response / effort! The first diagram that comes up in my post is one I drew of what I’ve been implementing, you can sub the NPN Transistor for a MOSFET to cover attempts with that component type. Base to Gate, Drain to Collector, Source to emitter.

      For all three of your diagrams, SW2 exists on the module PCB but it is being bypassed by my circuit. I have the resistor / drain / collector wired to “1” on SW2, “2” is the load of the rest of the Module (in my diagram, “2W Speaker and some ICs”)

      The blue wire is my “Tripwire” / pulldown to GND. In the last picture, I haven’t even bothered attaching it to pull down the signal from Gate because I had been experimenting with different MOSFETs and finding they weren’t turning on all the way / letting any more than 2V through, which is not enough to power the speaker module.

    • litchralee@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      1
      ·
      edit-2
      15 hours ago

      In any case, pending your reply, I would suggest the following circuit for reliable operation. This will require a P-channel MOSFET, which is different from the two MOSFETs you tried earlier, which are all N-channel. This will also use two resistors. I am making an assumption that your speaker module simply requires two wires at feed it 4 volts, and does not care whether we add a switching circuit to either wire, the positive or negative wire.

      suggested circuit 1

      This type of circuit would be described as an inverting, low-side MOSFET switching circuit. The inverting part means that when the MOSFET is fed a lower voltage, that causes the transistor to become active, whereas a non-inverting circuit would require feeding the MOSFET with a higher voltage to make the transistor become active.

      Low-side switching refers to the fact that the load (ie the speaker module) is permanently attached to the higher voltage (the high-side) and we are manipulating the low-side. Not all electronic loads can be used with low-side switching, but this is the easiest mode to implement using a single MOSFET transistor. As a general rule, to do low-side switching always requires a P-channel MOSFET. WARNING: a P-channel MOSFET has its drain/source reversed from how an N-channel MOSFET is usually wired up. Observe the schematic very carefully.

      As for why we cannot do high-side switching (which would use an N-channel MOSFET), it is because a typical N-channel MOSFET requires that the gate be a few volts higher than the source. But consider that when the transistor turns on, the drain and source become almost-similar voltages. So if the drain is attached to 4 volts, and as the transistor becomes active, the source rises to something like 3.95 volts, then what gate do we use to keep the transistor active? If we give 4v to the drain, then the gate-to-source voltage is a mere 0.05 volts, which is insufficient to keep the transistor on. We would need an external source to provide more gate voltage, relative to the source pin. If we tried such a high-side switching circuit anyway, it would quickly oscillate: the transistor tries to turn on, then turns itself off, then back on, and so forth. Or it would sit comfortably at some half-way gate voltage, where the transistor is barely-on, barely-off. This is not useful as a switching circuit.

      The way that my suggested circuit works is as follows: when the tripwire (marked as SW3) is in place, then R4 and R2 will form a voltage divider. Given that the battery supplies 4v, we can show that the voltage at the MOSFET’s gate will be 91% of 4v, or 3.64 volts. This should be just enough to prevent the P-channel MOSFET from becoming active. Note: a P-channel MOSFET becomes active when there is a low gate-to-drain voltage, with 0v causing the transistor to become active. In this way, with the trip-wire, the transistor will not allow current to pass through the speaker.

      When the tripwire is pulled out, this breaks the connection to R4. That leaves the gate connected to only R2, which is connected to the negative side of the battery. Thus, any charge in the gate will seep away through R2, meaning that the voltage across R2 will equalize at 0v. This means the gate-to-drain voltage will be 0v, which means the MOSFET will activate. And that allows current to power the speaker module.

      Note: one end of the tripwire (labeled #1 in the diagram) will still have 4v on it. If the tripwire is cleanly detached from the whole circuit, using your loop-of-wire and nails idea, then there is no problem. But if the tripwire is still hanging onto the 4v side of the circuit, then be careful that the tripwire doesn’t make contact with another part of this circuit. The R4 resistor will still be there, so there won’t be a short circuit or anything bad like that. But if that tripwire reconnects to the gate, then the transistor will deactivate again, stopping the music.

      I wish you good luck in this endeavor!

      • jeinzi@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        14 hours ago

        Props for the detailled answer, but this all sounds completely backwards.

        Low-side switching should in general use an N-Channel FET. And with your voltage divider, the gate will be at 9% of the supply voltage, not 91%, which means the FET will always be conducting. It will also never fully turn on, because that would mean the Gate-Source voltage would drop to near 0, which would turn it off again - it will instead settle somewhere near the GS threshold voltage from Drain (and Gate) to Source. Moreover, PMOS devices are not controlled by the Gate-Drain voltage, but with the Gate-Source voltage, just like NMOS devices.

        My counter proposal:

        Edit: Note that this is an N-Channel FET

        Edit 2: Changed image, I initially placed the resistor and the tripwire the wrong way around.

        • Romkslrqusz@lemmy.zipOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          12 hours ago

          I don’t think it’s possible place the full module between 4V and Drain (or collector for NPN), so I shifted my focus to just the speaker without all the ICs.

          The good news is that it works with both an NPN or a MOSFET - the bad news is that it totally degrades the quality of the audio to a point where the thing I am trying to play is unintelligible.

      • Romkslrqusz@lemmy.zipOP
        link
        fedilink
        English
        arrow-up
        1
        ·
        14 hours ago

        With how I’ve been going about this, technically, the load of U2 / Speaker Module would be on the Drain side of Q3 PMOS rather than the source side - and that’s the key difference between what I’m doing and the Piezo speaker tripwire circuits.

        Could this be the reason I’m not seeing success?

        • jeinzi@discuss.tchncs.de
          link
          fedilink
          English
          arrow-up
          2
          ·
          14 hours ago

          With a PMOS device used for simple on/off switching, placing the load between drain and ground would be correct. With an NMOS FET, the load should be between drain and VCC.

          In general: NMOS source to GND, PMOS source to VCC.

  • Console_Modder@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    15 hours ago

    Any possibility that you have some small solid state relays sitting around? Power to the coil can be the tripwire, so when that is cut and the relay closes the NC contacts it turns on the speaker

    • Romkslrqusz@lemmy.zipOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      15 hours ago

      Nope! Mostly do computer repair / SMD rework, I’ve also tweaked some existing circuits to do what I want so this is probably my first foray into really tinkering and building something.

      • Console_Modder@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        2
        ·
        12 hours ago

        Alright. Well, I tried but I have really used transistors or MOSFETs since college. Those diagrams you had looked like they made sense to me, so the only thing I could think of is the transistors are expecting a different voltage from what the batteries are providing. But, it looks like some other people have responded that are much more familiar with transistors, good luck! I hope you get this working in time