# TTL logic level circuit 5v <> 24v

Discussion in 'Digital Circuit Design' started by jacques0kruger, Jul 25, 2016.

1. ### jacques0kruger Thread Starter New Member

Jul 19, 2016
7
0
Hello guys,

I am referring to this article created by Jared regarding communication to a Outback Flexmax charge controller. I have built the circuit as per his specs but cans seem to get it working properly. I am sure there must be a better way to create this circuit. Basically the outback device communicates on a TTL logic at 24v (actually 23v to be exact), the circuit needs to convert the logic levels to 5v. The Opto-couplers i have been using is 4N25.

I have attached the circuit created by Jared.

Any help would be great.

Thanks,
Jacques Kruger

File size:
39 KB
Views:
24
2. ### AlbertHall Well-Known Member

Jun 4, 2014
1,929
381
The 4N25 has a minimum current transfer ratio of 20% - that is the output current may be only 20% of the input current.
For the bottom part of the circuit, input current is (23-1.5)/1.8k which is around 12mA (so max output available is 12mA/5 = 2.4mA) while the max output current is 5/1.8K which is 2.7mA so this is borderline.
For the top part of the circuit, the input current is (5-1.5)/1k = 3.5mA, so the maximum output current available is 3.5mA/5 = 0.7mA. However, the necessary output current is 24/1.8k = 13mA, so this part will not work.

To fix this you could increase the 1.8k in this part of the circuit to 39k. Whether this would cause problems for the input of the outback device I don't know, but it won't damage anything.

3. ### jacques0kruger Thread Starter New Member

Jul 19, 2016
7
0
Thanks Albert. I have noticed that playing around with this size of that resistor on the 5v side 1k does make a big difference on the 24v side, makes sense if you think about it. The way i understand it is the 24v side will communicate at a faster rate so we need to bring that down to the 5v rate (correct me if i am wrong). The outback device would not respond to requests if the message is garbage or not understood. Having the 1k resistor (5v side) with a 4k resistor on the 24v side the outback device does respond to the message. So what you are saying is i should try changing the 1.8k resistors on the 24v side to 39k and see what happens. The 1.8k on the 5v side could go a little lower as well?

The diagram is a bit misleading as TX / RX should be swapped on the 24v side of the circuit. I will give it a try and revert.

4. ### AlbertHall Well-Known Member

Jun 4, 2014
1,929
381
This circuit is simply changing the voltages of the signals - nothing to do with a 'faster rate'.

Change the 1.8k on the phototransistor (top of the diagram) on the 24V side to 39k. Do not change the 1.8k on the LED.

5. ### Bordodynov Active Member

May 20, 2015
637
188
See

absf likes this.
6. ### ci139 Member

Jul 11, 2016
341
38
• ###### maybe.jpg
File size:
182.7 KB
Views:
11
absf likes this.
7. ### AlbertHall Well-Known Member

Jun 4, 2014
1,929
381
Min CTR 80%, but yes, definitely better than the 4N25.

8. ### crutschow Expert

Mar 14, 2008
13,001
3,229
What Albert is saying is that the LED current on the transmit side of the circuit needs to be at least 5 times the current on the transistor side of the circuit to meet the requirement of 20% minimum transfer ratio between the LED and the output transistor currents.
So you use resistor values on both sides ot the opto to meet that requirement.
Just make sure the resistor values are high enough so the source can supply the required current.
Higher resistor values take less power, lower resistor values allow faster speed (what speed do you require?)

Note that for the LED current you need to subtract the LED forward voltage from the supply voltage to calculate the resistance (R = (Vsup-Vled) / Iled).

9. ### jacques0kruger Thread Starter New Member

Jul 19, 2016
7
0
AlbertHall - Tried the 39k last night but that doesn't work. It brings the 23v down below 50% of vbat and causes the outback device to not receive the message. I will source some other opto-couplers and see if they work better.

crutschow - the bound rate is 9600...

I am also thinking of trying one of these H11L1/2/3/4 - Optically coupled schmitt trigger, also trying to source the ps2561 from my supplier

10. ### AlbertHall Well-Known Member

Jun 4, 2014
1,929
381
I don't understand this. What/where is vbat? Do you mean that the 23V is lower using the 39k than with 1.8K?

11. ### jacques0kruger Thread Starter New Member

Jul 19, 2016
7
0
Yes, the 23V then goes lower than 50% of 24V. The outback TTL logic works at 50% of vbat in this case vbat=24v. So any voltage below say 12V the outback device would see as logic low.

12. ### AlbertHall Well-Known Member

Jun 4, 2014
1,929
381
Using a 39k resistor imposes a lower load on the supply voltage than the 1.8k so I am at a loss to understand why the 23V would be lower using the 39k resistor. How is the 23V derived (from the 24V vbat?)?

13. ### jacques0kruger Thread Starter New Member

Jul 19, 2016
7
0
Not sure how/why the voltage output is at 23V. The outback device is a Flexmax 80(FM80) solar charge regulator, Batt voltage during charge could go as high as 31V (even at this charge voltage output still sits at 23V). The output from this FM80 is via RJ45 using their proprietary protocol to connect to either a outback hub or a outback mate. Now the idea with the Optocoupler circuit is to simulate the PC as a Outback Mate device. I have attached the diagram Jared made of the Mate he used to listen in on the protocol for reference. They include a RS232 on this device for third party comms. The mate device will set me back around ZAR9000 just to get communication for me to output data to the internet. Jared seems like the first to have cracked the protocol from outback.

I did manage to get data from the device but the connection was not stable and could not get it replicated...this was with a few resistors connected in series and the 5V on the PC RX side sitting at 1.7V.

File size:
97.3 KB
Views:
6
14. ### ci139 Member

Jul 11, 2016
341
38
Oops!
. . . does not specify the Opto.-s - i'm just blind guessing by their case they're NEC something
(mail ↑him↑ mail him now (help!?))

15. ### AlbertHall Well-Known Member

Jun 4, 2014
1,929
381
Jared Sanson Mod jacques krugera month ago
Yes my system is 24V. I don't remember the exact opto-isolators I used, they were just what I had on hand. Anything should work really as long as it can convert TTL to the correct voltage levels, just choose resistor values for your particular system voltage and opto-isolator.

• jacques kruger Jared Sanson6 days ago
Thanks, i managed to get 4N25 opto-isolators. I am still fighting with the logic levels with the resistor values as the ones on your diagram does not seem to work on my system/opto-isolator setup. Any advice you can give me for calculating these resistor values?

16. ### ci139 Member

Jul 11, 2016
341
38
<SNIP> . . . (the lower the CTR the faster the transistor might to turn off ? less susceptible to input noise) - i would first put resistors with no interface to both sides signal~R~ground (( at all the time tracking you wont overload your inverter side outputs )) sample the |_|¯|_|¯|_|¯| , tune R for best edges e.c. use fastest optos you got (the ps2561 might just about manage the 9600baud by their datasheet transition delays´ load dependecy)

? as far as i get what an opto does is it elongates the input pulse -- if it energizes the input LED enough (so you need to adjust the input pulses before feeding em to optos (!keeping timing valid))
or it wont trigger a valid output if LED is not sufficienly energized
there are are also tricks to (with addit.) co(mponents )-form the required output(pulse shape at transistor side) - but . . .) . . . with PC-side 3k6 for RS232 requires preamplifying data lines in prior
- you may spend a lot time to find the "magical" resistances (for both sides - without other signal shaping)

there might be some help from: http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=slla037&fileType=pdf and https://en.wikipedia.org/wiki/RS-232#Related_standards
i never done the EIA-232 - 'm not a best person to say anything here.

Moderators note: removed improper text

Last edited by a moderator: Jul 27, 2016
17. ### ci139 Member

Jul 11, 2016
341
38
Last edited by a moderator: Jul 27, 2016
18. ### AlbertHall Well-Known Member

Jun 4, 2014
1,929
381
There may be another reason why this doesn't work indicated in that document. It says:

The Mates’ serial port is optically isolated from the rest of the
OutBack products it is connected too. This isolation requires
that the Mate ‘steals’ power from the PC in order to
communicate. Figure 2 shows which lines of a standard PCs’
serial port are used. All pin numbers and names are referenced
from the PC.
The Mate requires that the DTR (pin 4) be driven high
(set) and that RTS (pin 7) be driven low (cleared), in order to
power the port.

Last edited by a moderator: Jul 27, 2016
19. ### jacques0kruger Thread Starter New Member

Jul 19, 2016
7
0
Yes if you have the mate comms would be simple, as this gives you the interface to do this.

20. ### jacques0kruger Thread Starter New Member

Jul 19, 2016
7
0
Magic....ok only partial.
Mange to get data from the unit, but the unit doesnt always respond so my thinking is that it doesnt always understand the message.
Current setup:

Opto's: KB817
5v TX - 1000 ohm
24v RX - 1730 ohm
24v TX - 4.64 K ohm
5V RX - 1600 ohm

The data i get from the charger (for some interest)
Getting log page... (day:-4)
MX Log Page:
Day: -4
159Ah 4.4kWh
40Vpk 35.4Apk 0.830kWpk
Min: 24.2V Max: 29.2V
Absorb: 240min Float: 101min