Interfacing Two Digital Devices

Thread Starter

Timbergetter2

Joined May 8, 2017
10
I have a device that outputs 8 channels each of which activates an output signal level of 5V to turn other devices on. I have a second device that has eight channels of input that I would like to control with the first device, again using 5V logic levels.

The problem I have is the first device has all 8 channels with a common rail for the +ve side of its outputs and individually switched –ve output lines. The second device has a common ground (-ve) rail and individually controllable inputs expecting a +ve signal level.

I suspect this can be handled with op amps that would invert the signal level but I have not had any success so far due to my negligible knowledge with op amps. I would be very grateful if someone could steer me in the right direction here.
 

djsfantasi

Joined Apr 11, 2010
9,156
It appears (without more details of the two devices) that a CMOS inverter will work. A couple of CD4069 Hex Inverter chips would give you eight inverters to wire between device 1's outputs and device 2's inputs. (Wire the unused inverter inputs to ground).
 

absf

Joined Dec 29, 2010
1,968
I was thinking the same. If the 2 devices have to be electrically isolated, TS may use opto-couplers or relays.

Allen
 
Last edited:

Thread Starter

Timbergetter2

Joined May 8, 2017
10
Thanks so much guys. That does seem to be exactly what I need. I did get sidetracked onto op amps at the outset. It now seems like overkill to get a device like an op amp to perform such a simple task. All is not lost though, I did discover a lot of interesting things about op amps. It will be at least a few days before I can get hold of an inverter so I’ll have to wait till then to try it out.

This was my first post on this site and I’m certainly grateful for the friendly feedback.
 

crutschow

Joined Mar 14, 2008
34,285
An inverter may work, but that's not clear to me from your explanation.
What do you mean:
.....the first device has all 8 channels with a common rail for the +ve side of its outputs and individually switched –ve output lines.....
What exactly does the output signal look like?

Are both devices connected to the same +ve and -ve?
 

Thread Starter

Timbergetter2

Joined May 8, 2017
10
The second device has 8 opto couplers as a front end with a common isolated reference ground, so I guess the logic level and ground that it receives will be determined by the hex inverter output, or whatever interface I finally adopt.

With respect to the first device output, it presents a potential 5v rail to each of the channel outputs. The output of a particular channel becomes high (5v) when its respective ground is switched on. I don’t know what the switched line status is when that channel is off. It might be pulled up to 5v. The outputs of the first device are designed to energize relays (supplying 5v). I am trying to repurpose the outputs to provide logic levels.
 

crutschow

Joined Mar 14, 2008
34,285
The second device has 8 opto couplers as a front end with a common isolated reference ground, so I guess the logic level and ground that it receives will be determined by the hex inverter output, or whatever interface I finally adopt.

With respect to the first device output, it presents a potential 5v rail to each of the channel outputs. The output of a particular channel becomes high (5v) when its respective ground is switched on. I don’t know what the switched line status is when that channel is off. It might be pulled up to 5v. The outputs of the first device are designed to energize relays (supplying 5v). I am trying to repurpose the outputs to provide logic levels.
It's still not clear to me how this works.
How can you do an interface when you don't know what the first device is doing when it is off?
What is this "device"?

Can you a schematic of what you propose to do?
 

Thread Starter

Timbergetter2

Joined May 8, 2017
10
These are the devices that I am trying to interface:

DEVICE 1
https://www.freetronics.com.au/products/relay8-8-channel-relay-driver-shield#.WRLqiLhIww8

DEVICE 2
https://www.jaycar.com.au/medias/sys_master/images/8955340357662/XC4418-dataSheetMain.pdf

Device 1 is an Arduino shield that is intended to directly drive up to 8 external relays.
Device 2 is a bank of eight relays that is driven by input logic levels.

I realise that I could drive relays directly from Device 1 however I am keen to drive Device 2 without carving it up.

I have tried to create a sketch of the relevant parts of the two devices.
Interface-X.jpg


I can’t get my head around how to manage the ground referencing from Device 1 to Interface to Device 2.

Thanks again to everyone who has looked at this and I do apologize that I am struggling to describe the objectives here.
 

MrChips

Joined Oct 2, 2009
30,714
Install 220-470Ω ½W resistor across +ve and -ve terminals on Device 1.
Connect -ve terminal of Device 1 to +ve terminal of Device 2.

Logic will be reversed, i.e., logic LOW to Device 1 is required to activate Device 2 driver.
Reverse the logic in Arduino software.

Is there a reason why you need Device 1?
Connect Device 2 directly to Arduino output.
 

Thread Starter

Timbergetter2

Joined May 8, 2017
10
Many thanks MrChips for your suggested reworking of the interface. I think I did try this arrangement a while ago without success. I can’t remember now exactly what I did and the result obtained so I will definitely try your recommendation with more care and fully record the results. The thing that confuses me somewhat is the proposal to apparently reverse the polarity on the led side of the opto coupler.

I am keen to maintain the Device-1 because it operates with the i2c bus thereby consuming only two analog pins on the Arduino for up to 16 relays (and maybe more).
 

MrChips

Joined Oct 2, 2009
30,714
Both Device 1 and Device 2 are intended to be relay drivers.

If you had used Device 1 alone, you would connect the coil of a relay between the +ve and -ve terminals of Device 1.
A logic HI signal to the gate of the MOSFET turns on the MOSFET and draws current through the relay coil. The relay is activated.

When you replace the relay coil with a resistor, the same thing happens. However, we are now using the -ve terminal as a voltage/current source. A logic Hi signal to the gate of the MOSFET turns on the MOSFET and the -ve terminal goes close to 0V. A logic LOW signal turns the MOSFET off. The -ve terminal voltage rises to +5V. This can source current through the resistor and as a result, will turn on the opto-coupler of Device 2.

You don't have to do anything to Device 1 or Device 2. You simply reverse your logic in the code of the Arduino.

If you want to keep Device 1 because it uses serial interface then that is ok.
 

Thread Starter

Timbergetter2

Joined May 8, 2017
10
I am using 560Ω. I did try 1kΩ and that appears to work fine also. I do plan to spend some time looking at power loss and thresholds before I lock down the final selection.
 

MrChips

Joined Oct 2, 2009
30,714
I am using 560Ω. I did try 1kΩ and that appears to work fine also. I do plan to spend some time looking at power loss and thresholds before I lock down the final selection.
Sounds good.
Here is the rationale for choice of load resistor.

Focusing on DEVICE 2 opto-coupler circuit, if we assume the voltage drop across the LED is 2.5V,
then the current through the LED is (5V - 2.5V)/1kΩ = 2.5mA

If you insert a 1kΩ load resistor, the LED current will decrease to 50%, i.e. 1.2mA,
whereas a 500Ω will decrease the current to 1.7mA, that's a decrease to about 70% which is quite acceptable.

From the perspective of DEVICE 2, you want the load resistor to be as low as possible.
From the perspective of DEVICE 1, you want the load resistor to be as high as possible.

Your choice of 560Ω is a suitable compromise.
 

Thread Starter

Timbergetter2

Joined May 8, 2017
10
Thanks to the help I’ve received on this site I have got my project working, sort of.

I have placed a call in my Arduino setup routine to send all the Device-1 outputs high which drives the inputs to Device-2 low. This is my attempt to ensure that all relays are off when the project is powered on. Unfortunately there is a 2 to 3 second delay before this takes effect. So when powering on, the relays are on momentarily before settling down to waiting in the off state.

It seems to me that if I introduce capacitors of the right value and in the appropriate location I may be able to force the output of Device-1 high until the Device-1 setup routine has fired and can keep then keep the relays off. Is my thinking on track here?
 

Thread Starter

Timbergetter2

Joined May 8, 2017
10
These words follow on from my previous post on Friday. I have included the notional capacitor C1 in the attached sketch. The intention here was to provide an initial low impedance path to ground during the powering up of the project. I had hoped this path could be sustained long enough so that node A could be pulled low keeping the relay(s) in the off state until the command from the Arduino Setup took effect in turning relays off. Unfortunately even a large 2200 mf capacitor keeps node A in the low state (and therefore the relays off) for about 0.5 seconds after powering up. Then about 2 seconds later the Arduino command takes effect and turns relays off.

Once the project is powered up everything works well. However I do need the project to tolerate power interruptions without momentarily turning all the relays on. Any wise words would be most gratefully received.
Schematic2.jpg
 
Top