0

I want to control a relay with both Arduino and DAQ. Arduino is used as an embedded device for the control, while the DAQ is hooked up with a computer and performs the control with a user interface. Here is below a schematic of the circuit wiring for the control: enter image description here

The two signal pins of the relay are connected with the digital pins of Arduino and DAQ. For some reasons, when Arduino comes into play, the control via DAQ cannot be achieved. If only Arduino or DAQ is connected to the relay, there is no problems with the control.

My plan here is, mstly, to let Arduino to instruct some tasks. In some special cases, I want to have the control with DAQ. Anyone can debug my circuit above? Thanks!

1
  • 1
    Are the control lines active low or active high? In other words, from the Arduino do you digitalWrite(portnum, HIGH) or LOW? You might be able to solve this with a pair of diodes.
    – Jim Mack
    Commented Jun 28, 2019 at 23:03

1 Answer 1

1

I guess, that you drive the digital pin of the Arduino directly with digitalWrite() for HIGH and LOW and that the DAQ does the same (I didn't researched this).

In that case your circuit is dangerous for the devices. As long, as they both output the same, everything is ok. But take the case, that the Arduino is driving it's pin HIGH, while the DAQ driving it LOW. That would be a short through the pin driving circuit's of both devices and most likely the flowing current will exceed the maximum current rating of the pin. This can fry the involved pins hardware or even the complete devices. You get some kind of race condition here: The device, that can handle drain/source more current will be the winner.

In general you have to implement rules, how the devices should work together. Do you need the actions from the DAQ to be executed no matter what the Arduino does? Or should the Arduino be the master here? Or something inbetween? It is not clear, what do you need here.

I will give you 2 suggestions about possible ways:

  1. You could control the relay only with the Arduino. The DAQ can be connected to a digital input of the Arduino (so that it can sense the DAQ's output state) and in the Arduino code you can implement all the logic you need to drive the relay to your liking.

  2. You could define an idle state of your relay input and set it with a pullup or pulldown resistor. It will ensure, that the relay input is at the defined idle state, as long as no device is driving the line to the opposite state. For this you need the devices outputs to be high impedance (on the Arduino this means the pin is configured as input; for the DAQ you need to know yourself or research it).

    Let's say the idle state would be HIGH. We would connect the relay pin with 5V through a high resistor (this is the pullup resistor) (maybe 10k, the value is not critical). Both devices can be connected directly. If one device needs to change the state to LOW, it can drive it's output pin actively low, forcing the relay pin to also go to LOW. If it doesn't need the state to be LOW anymore, it should put it's pin into high impedance mode. The pullup resistor will pull the state to HIGH again. You can also add relatively low resistors between the devices to protect against damages from accidentally driving active HIGH while the other is LOW (These can be calculated from the maximum current rating for the pins; 20mA for the Arduino). This kind of logic is often called open drain logic.

schematic

simulate this circuit – Schematic created using CircuitLab

If the DAQ cannot put it's pins to high impedance, you can setup that circuit yourself with a single MOSFET:

schematic

simulate this circuit

If you use this circuit on both devices, you don't need the small resistors anymore.


The second possibility already implements a specific logic. You need to decide if this logic is good for you. You can invert it's logic (idle state LOW). Personally I would go with the first option, because it is easier and more flexible.

3
  • the signal pin is only TTL logic. almost no current.
    – Juraj
    Commented Jun 28, 2019 at 7:22
  • Do you mean the pin of the relay module? Then yes, it is. But when you directly connect the 2 output pins of the devices to the same relay module pin, you can get a strong cross current (from one device to another, not through the relay pin). That is the problem that I've described. Is there something wrong with it?
    – chrisl
    Commented Jun 28, 2019 at 8:05
  • sorry. no problem, you are right.
    – Juraj
    Commented Jun 28, 2019 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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