Interfacing Two Digital Devices

Discussion in 'Digital Circuit Design' started by Timbergetter2, May 8, 2017.

  1. Timbergetter2

    Thread Starter New Member

    May 8, 2017
    10
    2
    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.
     
  2. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    4,539
    1,688
    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).
     
    Timbergetter2 and absf like this.
  3. absf

    AAC Fanatic!

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

    Allen
     
    Last edited: May 8, 2017
    Timbergetter2 likes this.
  4. Reloadron

    Distinguished Member

    Jan 15, 2015
    4,155
    1,951
    My thinking also based on the explanation. Just a few hex inverters should make it happen. A 74HCT04 or the CD4069.

    Ron
     
    Timbergetter2 likes this.
  5. Timbergetter2

    Thread Starter New Member

    May 8, 2017
    10
    2
    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.
     
  6. crutschow

    Expert

    Mar 14, 2008
    21,694
    6,251
    An inverter may work, but that's not clear to me from your explanation.
    What do you mean:
    What exactly does the output signal look like?

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

    Thread Starter New Member

    May 8, 2017
    10
    2
    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.
     
  8. crutschow

    Expert

    Mar 14, 2008
    21,694
    6,251
    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?
     
  9. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    7,684
    2,164
    What are the "devices"? IC's, circuit boards, industrial control devices, PLC I/O boards-???

    ak
     
  10. Timbergetter2

    Thread Starter New Member

    May 8, 2017
    10
    2
    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.
     
  11. MrChips

    Moderator

    Oct 2, 2009
    18,330
    5,793
    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.
     
  12. Timbergetter2

    Thread Starter New Member

    May 8, 2017
    10
    2
    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).
     
  13. MrChips

    Moderator

    Oct 2, 2009
    18,330
    5,793
    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.
     
    Timbergetter2 likes this.
  14. Timbergetter2

    Thread Starter New Member

    May 8, 2017
    10
    2
    Thank you very much MrChips. The prototype is firing on all eight cylinders now. I do appreciate your patience in leading me to that solution.
     
    MrChips likes this.
  15. MrChips

    Moderator

    Oct 2, 2009
    18,330
    5,793
    Good to hear.
    What value resistor did you end up using?
     
  16. Timbergetter2

    Thread Starter New Member

    May 8, 2017
    10
    2
    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 likes this.
  17. MrChips

    Moderator

    Oct 2, 2009
    18,330
    5,793
    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.
     
    Timbergetter2 likes this.
  18. Timbergetter2

    Thread Starter New Member

    May 8, 2017
    10
    2
    That is so helpful.
    Thanks again.
     
  19. Timbergetter2

    Thread Starter New Member

    May 8, 2017
    10
    2
    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?
     
  20. Timbergetter2

    Thread Starter New Member

    May 8, 2017
    10
    2
    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
     
Loading...