Pages: [1] 2   Go Down
Author Topic: Making an USB-TTL using opto-coupler  (Read 4890 times)
0 Members and 1 Guest are viewing this topic.
Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys;

I am trying to build an USB - TTL using opto-coupler.  My goal is : Using USB to program a new sketch into a Ardiuno project who has it own power.  Work like this : Connect the USB to the computer, connect the TX, RX, 5, GND and DTR to the Ardiuno with it own power. The isolation is being done by using opto-coupler.  The computer side power : 2 transmitter, one receiver <-- TX, DTR, RX.  The Arduino side power : 2 receiver and one transmitter <-- RX, DTR, TX.

I did one version and I did the "loop test", work until 9600 baud. At that rate <-- 9600 baud, I received "garbage", at lower baud, I received OK. My circuit was the same for the fiber optic one.

I re-design it, and test it using a frequency generator using the frequency of 120 K Hz - close to 115200 baud rate, and I got it work just fine, by swapping resistors, adding transistors and re-select resistors.  But I even use an op-amp, but it did not work at all. I use in my design two stage transistor amplifier.

I would appreciated if you guys can give me a better design than mine. Maybe the 2N3904 is not "quick" enough <-- low bandwith.

Anyway, here the schematic of one channel.  I will use : 2 opload direction and one download direction. The schematic is for upload direction. ( from the FDTI board ) 


* opto-coupler_channel.jpg (31.19 KB, 1024x476 - viewed 203 times.)
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Why are you AC coupling with C1 & C2?
There is no need to use the transistor on the emitter side of the opto, just drive it directly. Similarly why a 2 stage amplifier and then a buffer. It seems all so very much overkill.
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I did try that... directly, and it did not work well, at lower frequency ...yes but not at 150 K Hz... The signal output at 150 k Hz without anything connected at the opto-coupler, the signal was around 0.3 V p-p and 2 V above the 0 V line,  and it is not square, not sine either, but rather distord signal. I just measure the frequency using my meter, it read : 161.4 kHz.

So I decide to use the cap to place the signal at 0 V line, amplify using a simple transistor circuit, I and another stage and the signal at the last stage go into a 74LS14, the output of the NOT gate is almost a nice square wave.

Sorry that my design look overkill, I want the circuit to work at those conditions I tested for. I was trying to follow the datasheet of the opto-coupler 4N35.

Here a picture of the signal output of the opto-coupler - at collector - pin 5.
   


* opto-coupler-signal.jpg (84.92 KB, 1024x768 - viewed 32 times.)
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Here a picture of the signal output of the opto-coupler
Well that is not right, there should be little or no AC component to the waveform, so I would track that down first.

Quote
and it did not work well, at lower frequency
An opto for serial communications needs to work at DC, because that is what it is sending when there is no data being sent. That is why the AC coupling is wrong.
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright Mike, I agree with you. I check my input of the opto-coupler, and I saw a spike wave form, so I add a cap to place the signal at 0 V line, and the signal at collector ( of the input side of the opto-coupler was better - square wave, but the output of the opto coupler is a small sine wave.

I will keep you guys posted
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't forget the ground on the scope needs to be on the same side you are doing the measurements on.
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Of course Mike, of course...  smiley-wink

Updated :

The problem earlier is this : The signal at collector - Q2 was not 50 % duty, it was 80 to 90 duty.... yeah... not good.

So I modify the input side of the opto-coupler, and I did a small modification of the ouput side - Q3. change R5 and R4.

Here the revised schematic.

 


* opto-coupler_link_v2.jpg (36.82 KB, 1024x496 - viewed 103 times.)
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes again C3 should not be there, it should be all DC coupled.
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now, here the picture of the input signal of the opto-coupler and the output of the coupler.

Top image : signal at Q1 - collector

Bottom image : signal at opto-coupler - pin 5 - collector.

Setting : 1 V / div - 2 us / div.  Frequency : 160 kHz. = 160 000 baud rate.

And I know, the probe has to be ground properly ...  smiley-wink   at the input side and at the output side.  Opto-coupler = isolation...

The idea of using C1, C2 and C3 is to place the signal at 0 V line, and over-saturated the signal ( flat the top and bottom ) so I can get a square wave at 50 % duty... At least close to it.

Next step : construct 3 channel, loop-test at 115 200 baud rate, and upload a sketch into the Arduino to see it working.  


* opto-coupler-input.jpg (80.1 KB, 1024x768 - viewed 28 times.)

* opto-coupler-ouput.jpg (89.81 KB, 1024x768 - viewed 32 times.)
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK Mike, in some cases, yes <-- no cap ... in others cases, no <-- with cap.

In my case, I try  - with cap and without cap - C3...

Without C3... direct wire. Duty is about 25 %.... With C3 ....Duty is about 30 to 40. At the output of the LS14, with C3, it is much better.

Here the pictures.

Top :

Without C3

Bottom :

With C3

I will keep C3 in that case.

Sorry Grumpy_Mike.

Beside, thank for helping and tips.


* input_LS14_without_cap.jpg (80.14 KB, 1024x768 - viewed 28 times.)

* input_LS14_with_cap.jpg (89.93 KB, 1024x768 - viewed 31 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

None of those low cost optocouplers are designed for high speed.  Look up high speed photocouplers in a disti catalog and you'll get sticker shock. The 4N35 datasheet I'm looking at (vishay) says 110 kHz cutoff. Based on Ton and Toff times, you should be able to gt a bit more than that (as you seem to be doing). One thing you can do to coax more speed is decrease the collector current.  I'd shoot for 2mA or maybe even 1 mA. You're north of 30 mA.  Definitely lose the coupling cap.  In fact, I'd lose everything except the pullup resistor (and the emitter resistor, of course).  Try not to load the output - I'd feed straight into the Schmidt trigger.
« Last Edit: February 18, 2012, 07:58:15 pm by philba » Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am aware of the low bandwith of the opto-coupler.

Quote
One thing you can do to coax more speed is decrease the collector current.  I'd shoot for 2mA or maybe even 1 mA. You're north of 30 mA.

I did try that also, but my speed was below 9600 baud.  I investegate and I reduce the R2, see the wave, it improve, so I lower and lower, and the datasheet said 100 ohms is OK. And that was their test circuit. So I look closely at the graphs in the datasheet to figure things out. And I even try to fix the input side <-- the led side, that is why the new schematic have a cap after the output of the LS14. If I did not, the collector signal of Q2 square wave is no longer 50 % duty, but more 10 % duty and it affect the outside of the opto-coupler.

Quote
Definitely lose the coupling cap.  In fact, I'd lose everything except the pullup resistor (and the emitter resistor, of course).  Try not to load the output - I'd feed straight into the Schmidt trigger.

I did that too... not working to well either...

When I build a circuit, I always check the circuit to see if it work fine, if not, I will do some modification to make it work.

I appreciated the help and sudgestions... in theory...yes... practical... well...not so so... need to test...

Anyway, it work fine at low speed ( at 4800 , not higher )...I tested that.   I am building a programer link fot the Arduino chip in a live circuit...programing "on-the-fly", the opto-coupler provided the isolation. And I could modify the file "boards.txt" to change the speed from 115200 to 4800, and that will limit the access data rate speed.

Hey, I am still open minded... 
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Look up high speed photocouplers in a disti catalog and you'll get sticker shock

Sticker shock like : EXPENSIVE .... <--- That what you mean ?

I search the net, typing < high speed opto-coupler and I have a few hits...

I check Digikey.... they have, but you have to order a min of a few hundrends.... yeah... right.... NO THANK...

than I can across the part : http://www.futurlec.com/LED/6N135pr.shtml, not to expensive, under 1.50 US, not bad...

OK... here what I am going to do. I will breadboard the 3 channels ( RX, TX, DTR ) of my circuit, test and see what happen.  I will download the datasheet of that part, and I will check the local store if they have it, if yes, I will buy it, if not, I will order it and re-do my circuit and re-design around that part 6N135.
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found the 6N135 available locally. It sold a pack of 2 at Active Components - Steeles Ave / Victoria Park Ave - 1 block south, for 3.59 ca. Not bad...
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem with ordinary optocouplers at speed is that they are slow to turn off. As Mike says, you should DC couple the whole circuit. To speed it up you can connect a resistor between base and emitter of the phototransistor of the optocoupler. The value of this resistor is a compromise, because it reduces the sensitivity of the optocoupler. About 100K is a good value to try. Lower is better if you can get it to work. You may need to increase the drive current of the IR emitter to near its maximum rating to compensate for the reduced sensitivity.

Another thing to avoid is too high a value for the resistor between the collector of the phototransistor and +5v. Again, lower is good for speed but bad for sensitivity. Aim to use a value in the range 1k to 10K.

If you can't get the speed you are looking for in this way, then you will need to use the optocoupler receiver as a photodiode instead (i.e. use the collector and base connections only), and use a load resistor and a high speed comparator IC to detect the small current flow in the photodiode.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: [1] 2   Go Up
Jump to: