Solved: Opto-isolated UART

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I want to build a DIY logic analyser that will feed the data to computer through UART. Because I can't power the whole circuit that I want to analyse via USB port, I need to isolate the communication somehow. So I decide to try opto-isolated UART. I bought some High Speed (up to 10MBd) TTL Compatible Optocoupler - HCPL-2631 and a logic inverter (74HCT04) since the optocoupler provides inverted signal. I wired it up according to the attached schematic.

I wrote simple UART program for the ATMega168, that just writes alphabet on the terminal screen, in order to test, if it's working. When I power the circuit shown on the image (according to the schematic) from the USB port (which means that +5V and +5C are both connected to the power source of the USB port and both GND and GNDS are connected to USB ground), everything works fine. The alphabet is displayed in the terminal window as it should. BUT when I power +5V and GND from my external power supply and +5C and GNDS from the USB port (which means that the circuits should be completely isolated), the signal is somehow corrupted and I see a mess in the terminal window.

Any suggestions why is that?

Thank you in advance.

Ondra

Attachment(s): 

Last Edited: Tue. Jan 2, 2018 - 10:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

how do you power the 7404? just make sure it correct!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:

how do you power the 7404? just make sure it correct!

It is powered from the USB port

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What happens if grounds (not 5vs)  are connected together? (this is a milder constraint than full isolation, but yout optocoupler is linked with a lack of sufficint USB power, not a need for full isolation)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dbrion0606 wrote:

What happens if grounds (not 5vs)  are connected together?

I am not sure, if it is possible to connect grounds of my external power supply and the USB port. I think there is a danger of damaging the USB (just a greenhorn point of view).

dbrion0606 wrote:

yout optocoupler is linked with a lack of sufficint USB power

If I understand this part correctly, you say that the USB port can't power the optocoupler sufficiently, right? But why then the circuit worked correctly when all of the components were powered from the USB port? I think the USB can deliver enough power for the optocoupler.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, if you use a USB hub, the PC(RPi....) USB wonot be damaged (and I never had issues with external USB Hub being damaged : I made shorts and other horrible things with Arduini, Arduini clones, classical Avrs, Ti Launchpads -16 bits and arms-  and STM32 : never broke an USB...). 

 

I think you chose to have optoisolation because of power limitations (and not for safety reasons)  from what I read (and understood) : then, grounds can be connected together , with separate 5 v supplies  : this is the way some serial adapters are connected ) 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dbrion0606 wrote:

I think you chose to have optoisolation because of power limitations (and not for safety reasons)  from what I read (and understood)

Yes, that is what I meant in the first post. I probably misunderstood you. You are correct.

 

dbrion0606 wrote:

then, grounds can be connected together , with separate 5 v supplies  : this is the way some serial adapters are connected ) 

As the external power supply, I use an ATX computer power supply. When I tried to measure the potential difference between my USB GND and the ATX GND, I measured a potential difference of 30mV and the number kept increasing slowly. I am still concerned, if there isn't a possibility of some ground loops.

According to these threads:

https://electronics.stackexchang...

https://electronics.stackexchang...

they seem not to use an external USB hub.

Are you sure that it is safe?

Last Edited: Thu. Dec 28, 2017 - 04:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you sure that it is safe?

Empirical evidence cannot lead to being 100% sure, but :

 

a) if something should burn, better is an external hub than a PC/RPi. (I am very clumsy, my soldrings are disasters, brodbeards are even worse and I never broke a hub ... nor a PC/RPi : I bet you are more careful than I am). My implicit bet -10 years ago- is that, if something goes very wrong, the cheap external hub will be the first to collapse ... and protect the expensive, hard to replace PC/xxxPis.

 

b) hubs are always very useful (you can plug a mouse, a Keybeard, x arduini, y other circuits and .... ). They are necessary for nanoPis (have "only one USB plug ; is not enough for a mouse, an Arduino clone and a keybeard).

 

You are measuring differences of voltage but you do not tell about the impedance (if voltage is slowly drifting and weak, I bet this voltage  can be neglected and shorted if impedances are high)

Last Edited: Thu. Dec 28, 2017 - 04:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not trying to discourage your DYI, but your trying to build one of these, correct?

https://www.banggood.com/USB-Log...

 

Jim

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, yes. But I don't need 8 channels.

Why it should be discouraging?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've not studied the breadboard layout carefully, but:

 

Know that the power rails on the bread board may not cross the middle of the breadboard.

So that gray ground wire on the lower right might not be connected to anything.

You need to check your BB and see if the rails are complete, or if they are broken in the middle.

 

Next, you can get rid of the inverter if you invert the LED signal itself.

 

You presently have a high on the micro turning  on the LED, which is connected to ground.

If you connect the LED to Vcc, and the "ground end" of the LED, (through a resistor), to the micro, then the signal will be inverted.

Now when the micro is high, the LED is off, and when the micro is low, the LED is on.

 

So, easy to "flip" or invert the sense of the LED, and then do away with the extra chip.

 

Finally, you included some / all of the micro's power connections.

Make sure you have AVcc tied to  the micro's Vcc, also.

You didn't show that connection in your abbreviated schematic, but make sure you have it made on the real circuit!

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Back when I was your age, we did a series of 3-phase monitoring apps that needed to have the outside world connection isolated.  Indeed, it was a tricky business to do it properly and safely.  [I'llleave the discussion on re-inventing a $10 device "because I will learn so much more doing it myself" to others.]

 

Anyway, fast forward to this millennium and for isolated RS485 we use ADM2483, for less than ten bucks.  Yeah, your discretes might cost less.  How many are you making?  How much of your hobby time is worth ten bucks?

 

I'm guessing there are isolated RS232 transceivers as well. (ADM3251, ADM3252, ...)

 

 

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I second the Doc’s suggestion of having the port pin go to the led cathode. Thus removing the need for an inverter. The critical problem is the opto’s output is open collector - you need a pullup resistor in order for your circuit to work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Dec 28, 2017 - 10:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I gave up on doing this. The reason why I was doing it was I needed to examine my I2C bus, because it was not working. Because the project is for school and I need to finish it until deadline, I made some changes that I didn't want to make earlier and the I2C is working now. So no need for logic analyser now.

Thank you all for your suggestions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For anyone interested there is this.

 

https://www.kickstarter.com/proj...

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many options available; eg,

 

USB-ISO - Full Speed USB 2.0 Compliant Port Isolator with 1000V Isolation Voltage

USB-ISO - 

 

Full Speed USB 2.0 Compliant Port Isolator with 1000V Isolation Voltage

http://uk.farnell.com/olimex/usb...

 

 

Optically Isolated 7-Port USB Hub

http://www.sealevel.com/store/hu...

 

etc, etc, ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...