0
\$\begingroup\$

I have a circuit with an Arduino controlling a 2-channel, normal-off, opto-isolated relay board, 5V input signals, turning relay ON when the Arduino digital pin is set LOW. The relays are controlled independently by 2 digital output pins of the Arduino.

One relay controls a 12VDC magnetic lock, the other a 220VAC stroboscope.

Into this equation, I want to add an Adafruit Audio FX Sound Board (Headphone Out jack version). Each of the 2 Arduino pins should trigger playing a sound on the FX board in addition to activating the relays. The FX board works like this: connect one of the 11 output pins to GND (I will be using only 2 of them) to trigger the sound associated with that pin. So the board is supposed to be used by attaching momentary push-buttons to those output pins. Adafruit says this:

When the # pin is connected to GND for more than about 50 milliseconds it will trigger! There is a 100K pull up resistor on each one, so you do not need any extra resistors or pullups.

Ok, so they have 100K pull-ups. I don't see them in the schematics or the fab print of the FX board, so they must be using the internal pull-ups of the microcontroller.

This is a basic schematic of how I assume one of those pullups look like:

schematic

simulate this circuit – Schematic created using CircuitLab

I suppose I could use another 2-channel relay board, but that would be too much for this purpose.

I suspect the more elegant solution would be to use a NPN transistor, as seen here. Is this the best option? Should the GND of the Arduino share the GND of the FX board? Could 5V on the base control 5V at the collector? What values shoud the 2 resistors for the NPN be?

\$\endgroup\$
  • 1
    \$\begingroup\$ why not just use 1 kohm and go ahead?. to use NPN,say BC817, 100 ohms of base resistor and 10k of pull up is okay \$\endgroup\$ – Umar Jul 16 '15 at 12:09
  • \$\begingroup\$ @Umar What do you mean "just use 1 kohm and go ahead"? You mean ditch the transistor alltogether? \$\endgroup\$ – binar Jul 16 '15 at 12:26
  • 1
    \$\begingroup\$ I'm not sure I understand where the problem is. Just connect the FX board to the Arduino pin and when you set the pin to output a zero, the device will trigger. Could you give a schematic of what you are trying to connect up. \$\endgroup\$ – Tom Carpenter Jul 16 '15 at 12:33
  • 1
    \$\begingroup\$ @talereader Just because the board has a built in pullup doesn't mean you can't drive it high, as long as they're both operating at the same logic voltage level. \$\endgroup\$ – Nick Johnson Jul 16 '15 at 13:03
  • 1
    \$\begingroup\$ @talereader That's right. The input to the IC is high impedance as long as the voltage on it is between the rails, and driving the input high has the same effect as not driving it - the voltage across the pullup resistor is ~0. \$\endgroup\$ – Nick Johnson Jul 16 '15 at 13:14
1
\$\begingroup\$

Pullups on input pins like this exist as a convenience - for instance, so they can be connected to buttons as you suggest in your question - but they don't prevent you from being able to drive them high or low just like any other input pin. As long as your logic levels are the same, you can connect your Arduino's output pin to the input pin on the sound trigger board, and drive it as a regular GPIO pin just fine.

\$\endgroup\$
  • \$\begingroup\$ Yes, I thought that because the pins are pulled HIGH by the FX board's MCU (something I didn't have any control of), I can't use them as regular inputs. Thanks for clearing it up. \$\endgroup\$ – binar Jul 16 '15 at 14:54
1
\$\begingroup\$

This is most easily done if two conditions exist:

1) Your Arduino board runs from 5V (instead of 3.3V)

2) You have extra output pins on the Arduino board that aren't being used.

If both of these conditions exist, simply connect the grounds of both boards to the same point and then connect each input pin of the FX board to the Arduino. These output pins are set HI when not active (during initialisation).

The only difference is that now you will activate 2 pins when you want to do one of your effects: set the pin driving either the door lock or strobe HI, then set the pin connected to the FX board LO. Return the pins back to the non-active state when finished.

There is a possible advantage to doing things this way: each of the outputs can have different active time. In other words, let's say that the FX board will repeat the sound over and over again so long as the input is held active. Maybe it does, maybe it doesn't. But let's assume that it operates this way.

But: you need the strobe to be active for several minutes - far longer than the sound.

Because the outputs are separated, you can set the pulse duration for each output independently.


[Edit]

Based on your comment, I see that you want to have the same pin on the Arduino control both your effect (door lock, strobe) as well as the sound effect.

That's also easy but requires one extra transistor per FX input. The reason for the extra transistors is that your relay card is active HI but your FX card is active LO. The transistor provides logic inversion.

You can use either bipolar NPN transistors or N-channel MOSFETs. The MOSFETs are nice in that they don't require base resistors but they may cost a few pennies more than a bog-standard NPN transistor.

If using NPN transistors such as 2N4401 or 2N2222, connect Emitter to ground, connect Collector to the FX input pin, connect the Arduino output pin to both your relay card and to one side of a 10k resistor. The other side of the 10k resistor connects to the transistor Base.

If using a N-channel MOSFET such as the 2N7000, connect Source to ground, Drain to the FX input pin, Gate to the same Arduino pin that is driving the relay card.

In either case, when the Arduino pin goes HI to turn on the relay, the corresponding transistor turns ON and pulls the FX input pin LO to trigger the sound effect.

Easy as pie!

\$\endgroup\$
  • \$\begingroup\$ Hi, thanks for the input. Yes, Arduino board is 5V level. The FX board is also using 5V. BUT, no, I don't have spare pins on the Arduino, all are used (LCD, input buttons, LEDs, buzzer, etc). So I'm stuck with those 2 already activating the relays when outputing a LOW. The one for the lock is held LOW for 3 seconds, the other for 10 seconds. The FX board has configurable triggering, so I'll use it in the version when connecting the input pin to GND for at least 50ms will play the sound once and stop, no matter if the pin is still LOW or not. \$\endgroup\$ – binar Jul 16 '15 at 12:56
  • \$\begingroup\$ So no need to separate the sound triggering from the relays triggering. \$\endgroup\$ – binar Jul 16 '15 at 12:57
  • \$\begingroup\$ @talereader Okay, so why not just connect the output pin to both the relay board and the sound board? \$\endgroup\$ – Nick Johnson Jul 16 '15 at 13:00
  • \$\begingroup\$ Ok, so as I understand, I can give the FX pin a HIGH (in the OFF / not playing state) even if it has an internal pullup, and even if it's coming from a different board (Arduino board is powered separately), just because it's the same logic level? \$\endgroup\$ – binar Jul 16 '15 at 13:13
  • \$\begingroup\$ In the schematic posted in the question, let's call the upper pin of the switch FX_IN (the one going to 5V when the switch is open) and FX_GND the one going to GND. The upper part of the schematic is in the MCU, and I only have access to FX_IN and FX_GND as pins on the FX board. So you say a 5V coming from an external source (Arduino) applied to the FX_IN pin (also getting 5V from the FX board) would be ok? \$\endgroup\$ – binar Jul 16 '15 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.