Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

UART RX TX LED Driver using Op-Amp

Status
Not open for further replies.
UART LEDs.JPG

Does the UART GPIO's go low or high when data is transmitted? What is the Idle state?
Just use BJT's, you also get them in double packages.
 

View attachment 122880

Does the UART GPIO's go low or high when data is transmitted? What is the Idle state?
Just use BJT's, you also get them in double packages.

It goes low on transmit. I did a test with directly connecting the LED to GPIO pin and it works when I manually toggle the pins high/low.

I did VDD@3.3v --->LED -->RES-->GPIO@1.8v == LED Off since there is only a 1.5v and forward voltage to light is 2v (I don't know if this is bad though since I'm connecting a 1.3v source to 1.8v)

and VDD@3.3v --->LED -->RES-->GPIO@0v == LED On

Problem is even this won't work since I'm transmitting at 115k baud, so the LED won't be visible in its on state. Could I put in a capacitor in parallel with a diode on one end to keep the LED longer?
 

The brightness of the LED is determined by its on time duty-cycle. If the data is mostly 01111110 then the LED will be bright. But if the data is mostly zeros then the LED might blip pulses of light that are too short in duration to be seen or the LED will appear to be dimmed.
 

The brightness of the LED is determined by its on time duty-cycle. If the data is mostly 01111110 then the LED will be bright. But if the data is mostly zeros then the LED might blip pulses of light that are too short in duration to be seen or the LED will appear to be dimmed.

Im using the GPIO LED pins which stay active (low) for as long as the UART bus is transmitting (its essential the same as RX/TX lines but 0 bits flipped). Even using these pins though for a 8 byte RX transmission at 115k thats only .55ms on, which is not long enough for the LED to be visible.
 

You need a monostable that is triggered by the digital. Its time should be between 30ms and 100ms and it drives a transistor that turns on the LED.
 

Ok I think I have finally figured it out....I will use a dual PNP transistor that already has resistors internally (https://www.onsemi.com/pub_link/Collateral/DTA124ED-D.PDF).

So 5v VCC will be connected to LED resistor -> LED -> PNP Collector

1.8v GPIO pin will be connected to Anode of Diode --> PNP Base

In parallel to the Cathode of diode will be a 10nF cap connected to 5v VCC.

Emitter is grounded.

So when GPIO pin goes 0V PNP transistor turns on and LED lights...at the same time cap is charging to 5v so when GPIO pin goes back to to high 1.8v there is a negative voltage on the base due to the cap while its discharging which should keep the LED on for a few milliseconds.

The only thing I'm not sure about is whether this circuit assumes that Vcc == input pin high voltage, which is not the case for me since Vcc is 5v and IO voltage is 1.8v. I do have access to 3.3v as well if that will make a difference.

Here is the schematic I based my idea off of.

102304.png


Going to radio shack to buy some pnp transistors to test this, if someone can chime in on whether this will work would be appreciated.
 
Last edited:

Your text of using a PNP transistor has the polarities backwards. Your text uses the polarities for an NPN transistor (LED and its resistor from +5V to the collector. Emitter is grounded).
Then you show a schematic that is different and has no current-limiting resistor in series with the LED so when the transistor turns on then the LED and transistor might instantly burn out.
We do not know if the GPIO will burn out when it tries to charge the capacitor without anything limiting the charging current.

EDIT: You did not look at the datasheet of an old J176 P-channel Jfet. It will NEVER turn off in your circuit.
 
Last edited:

Your text of using a PNP transistor has the polarities backwards. Your text uses the polarities for an NPN transistor (LED and its resistor from +5V to the collector. Emitter is grounded).
Then you show a schematic that is different and has no current-limiting resistor in series with the LED so when the transistor turns on then the LED and transistor might instantly burn out.
We do not know if the GPIO will burn out when it tries to charge the capacitor without anything limiting the charging current.

EDIT: You did not look at the datasheet of an old J176 P-channel Jfet. It will NEVER turn off in your circuit.

Yes I mixed up PNP emitter and collector...current will flow from emitter to collector is what I meant.

The schematic was a quick thing I found ignore the right pfet image. The led would obviously have a resistor. I just need to know if the left setup would work theoretically.

The gpio pin would have a 100 Ohm resistor before the diode.

Again I think this circuit assumes that GPIO VCC high == the emitter power supply voltage. I know it will work when GPIO is 0v but what happens when it goes back up to 1.8v? Is this high enough to shut off the transistor?
 

I think I finally figured this out link to sim is below...not sure how good this sim program is but this circuit turns on the LED from the 1.8v GPIO and uses 5v power source to power the LED with about a 10ms delay before it turns off even after the GPIO pin goes high...only problem is component count... to drive both RX/TX LEDs I would need 2 PNPs 2 NPNs 4 resistors and two caps/diodes.

https://goo.gl/lHMPkc

I know there are npn/pnp packages to reduce components for this, but if anyone has any other idea on how to reduce components needed let me know!
 

So I just went with a single PNP pre-biased transistor (https://www.digikey.com/product-detail/en/DTA123JUAT106/DTA123JUAT106CT-ND/1158734) that will operate similarly to this https://goo.gl/K5XWwH

Im trying to keep the parts down so I'm limiting current to the LED without a resistor and just using the voltage drop on LED and bias resistors on transistor to limit current. That simulator is very basic though so is there a way to calculate the exact current value across the LED with that transistor? Or do all PNP based resistors draw the same amount of current based on Vce and input current?

I tested it with a 2N3906, but I have no idea whether that will match the transistor I have linked above.
 

A transistor part number has a range of current gain. Some have low gain and will not light the LED or dimly and others have high gain and will burn out the LED. Design the current-limiting resistor for a suitable LED current then the current gain of the transistor does not matter. The simulator (and the curves on a datasheet) show a transistor with typical (average) current gain.
 

So I just went with a single PNP pre-biased transistor (https://www.digikey.com/product-detail/en/DTA123JUAT106/DTA123JUAT106CT-ND/1158734) that will operate similarly to this https://goo.gl/K5XWwH

Im trying to keep the parts down so I'm limiting current to the LED without a resistor and just using the voltage drop on LED and bias resistors on transistor to limit current. That simulator is very basic though so is there a way to calculate the exact current value across the LED with that transistor? Or do all PNP based resistors draw the same amount of current based on Vce and input current?

I tested it with a 2N3906, but I have no idea whether that will match the transistor I have linked above.

The simulator is as accurate as your model for current gain at operating Vce and diode forward voltage, neither of which you know how to specify.
Trying to save parts count is a lazy man's approach or a feeble effort to have an elegant simple design without thorough awareness of all the parameters, that you need to specify and may be added to Falstad's primitive ( yet accurate as your model) design.


No you cant add a part number to the simulator but you can add an ESR based on power of diode or VI curve when saturated and you can specity colour for appearance and Vf for saturated characteristic.
Vf of diode, may be edited, then add ESR of diode with discrete R, both based on selected LED, none of which you have specifiied.

Cost of design and production and performance far outweights parts count.

Now if you can you add more specs you can get a better design.
 
Last edited:

The simulator is as accurate as your model for current gain at operating Vce and diode forward voltage, neither of which you know how to specify.
Trying to save parts count is a lazy man's approach or a feeble effort to have an elegant simple design without thorough awareness of all the parameters, that you need to specify and may be added to Falstad's primitive ( yet accurate as your model) design.


No you cant add a part number to the simulator but you can add an ESR based on power of diode or VI curve when saturated and you can specity colour for appearance and Vf for saturated characteristic.
Vf of diode, may be edited, then add ESR of diode with discrete R, both based on selected LED, none of which you have specifiied.

Cost of design and production and performance far outweights parts count.

Now if you can you add more specs you can get a better design.

I understand how the simulator works and it has the correct forward voltage, my main concern is what the gain will be for that particular transistor and setup with LED and how to calculate it. The only parameter that can be changed on the transistor is just gain, but gain is dependent on the current drawn from the LED.

Im here to learn, so instead of calling my efforts feeble and lazy I would appreciate more constructive feedback. I understand you know more about electrical engineering than I do, but Im sure you started somewhere too.

BTW the LED im using has a foward voltage of 2v and 30ma foward current at that voltage.
 

Transistors with the same part number have a range of current gain. Some have low gain and others have high gain. You get whatever they have.
The datasheet for EVERY transistor shows that when it is used as a saturated switch like you are doing then you simply plan that its base current is 1/10th its collector current and EVERY transistor will switch properly.

Your LED does not have a forward voltage of 2.0V unless you bought hundreds of them, tested them all and selected the one that has a forward voltage of 2.0V. Like most electronic parts, LEDs have a range of forward voltage. Yours might be 1.7V or 2.2V or anything in between and you must calculate the current for each end of the range so that the LED does not burn out but is bright enough.

Another problem might be that your LED probably has a maximum never to be exceeded current rating of 30mA if it is cooled properly. Most LEDs are rated and operated at 20mA.
 

I understand how the simulator works and it has the correct forward voltage, my main concern is what the gain will be for that particular transistor and setup with LED and how to calculate it. The only parameter that can be changed on the transistor is just gain, but gain is dependent on the current drawn from the LED.

Im here to learn, so instead of calling my efforts feeble and lazy I would appreciate more constructive feedback. I understand you know more about electrical engineering than I do, but Im sure you started somewhere too.

BTW the LED im using has a foward voltage of 2v and 30ma forward current at that voltage.

I gave you 3 solutions. THe Op AMp bandwidth doesn't matter as the eye bandwidth is much less. AN open collector Comparator would be better with more drive current or low ESR (=Vol/Iol). THe last solution with an LV CMOS logic gate which has proper input threshold and an output ESR of 50 Ohms for driving current and a RED 5mm LED which has an ESR of ~12~16 OHms at rated current of 20mA can be used in your simulation to determine the optimum R series of either the Ic current limiting value needed to protect from a wide range of hFE .

Always use hFE of 10 for a fully saturated transistor which can rise to 20 just out of saturation. not the rated linear hFE of the device if using a transistor. THe ESR of any logic or comparator can be determined by the Vol/Iol from the datasheet and similarily for the LED the Vf rise for If rise of the VI characteristics. From my experience the LED ESR is 1/Pd rating or 16 Ohms approximately for a 65mW rated 5mm LED. or a 1Ohm for a 1W rated LED. THis is my best rule of thumb for including in your simulation or to use Ohm's Law.
3188663800_1446238497.png


I showed two Green LED's which are 3.3V and I showed how tying high or low inverts the polarity of the indicator. Pick one.
TO extend the duration of ON, a simple one shot into a Schmitt trigger with a diode CR time constant or a more precise 1 shot chip can be used as adding a big cap may will slow down the rise time of current excessively.

- - - Updated - - -

THe problem with your original design was the comparator had the wrong reference voltage needed for 1.2V then later design although EMitter follower has high gain, you lose sensitivity of threshold detection by the R Ratio in feedback, so threshold detection is poor for a logic 0 to 1 which is around 1.2V for a 1.8V signal. THusa logic gate with proper threshold detection is better and has the current drive capacity to saturate an LED with suitable series R.
 
Last edited:

Transistors with the same part number have a range of current gain. Some have low gain and others have high gain. You get whatever they have.
The datasheet for EVERY transistor shows that when it is used as a saturated switch like you are doing then you simply plan that its base current is 1/10th its collector current and EVERY transistor will switch properly.

Your LED does not have a forward voltage of 2.0V unless you bought hundreds of them, tested them all and selected the one that has a forward voltage of 2.0V. Like most electronic parts, LEDs have a range of forward voltage. Yours might be 1.7V or 2.2V or anything in between and you must calculate the current for each end of the range so that the LED does not burn out but is bright enough.

Another problem might be that your LED probably has a maximum never to be exceeded current rating of 30mA if it is cooled properly. Most LEDs are rated and operated at 20mA.

LED has a forward voltage range of 1.8 to 2.1v and transistor as a MINIMUM gain of 80, so at the very least I can plan that the base current will be 1/80th of collector, yes?

So in the case were transistor is minimum gain of 80 the LED will see between 18-25ma of current with a base resistor of 2.2k, and is guaranteed to turn on since at even 2.1 forward voltage the collector will see at least 1v which is enough to turn it on when base is grounded. And according to charts the maximum gain is 200, which at worst case at 1.8v forward the LED would see about 35ma.

The LED is also rated for 30ma continuous with 80ma .1ms burst @1/10 duty cycle. So 35ma at .5ms bursts every few seconds for my application is well within tolerance.

I assumed an ESR for LED of 16 as Sunny suggested.
 

LED has a forward voltage range of 1.8 to 2.1v and transistor as a MINIMUM gain of 80, so at the very least I can plan that the base current will be 1/80th of collector, yes?
Absolutely NOT!
The current gain is specified with plenty of collector to emitter voltage so the transistor is linear and is not a saturated switch. When saturated its current gain is much lower, so low that the manufacturer says to use a forced gain of only 10.

So in the case were transistor is minimum gain of 80 the LED will see between 18-25ma of current with a base resistor of 2.2k, and is guaranteed to turn on since at even 2.1 forward voltage the collector will see at least 1v which is enough to turn it on when base is grounded. And according to charts the maximum gain is 200, which at worst case at 1.8v forward the LED would see about 35ma.
I guess you are talking about the PNP emitter-follower transistor in the Falstad simulation that has a series 2.2k base resistor? What input device drives it to ground with no voltage loss?
Assuming that the input is a saturated NPN transistor with 0.2V and the base-emitter voltage of the transistor will be maybe 0.7V and the LED might be 1.8V then the 2.2k base resistor has 0.6V across it with a current of 273uA. The collector is grounded on the PNP emitter-follower (not at 1V) so the collector-emitter voltage is 1.5V then it is not saturated and might have a current gain of 200 so the LED gets 55mA and blows up!

The other way is with a 2.1V LED and a transistor with a current gain of only 80. The LED current will be 11mA. Do you want each circuit you make to have different brightness?
You talked about 0.5ms bursts every few seconds? But our vision sees a light burst duration less than 30ms as being dimmed. A Pulse Width Modulation light dimmer relies on it.

Don't you want this circuit to be repeatable and work every time, or do you want to select parts that go together?


The LED is also rated for 30ma continuous with 80ma .1ms burst @1/10 duty cycle. So 35ma at .5ms bursts every few seconds for my application is well within tolerance.

I assumed an ESR for LED of 16 as Sunny suggested.[/QUOTE]
 

I meant emitter voltage will be at least 1v so the transistor will never be saturated. As long as the LED can handle gains of up to 200 which it can I am fine with it. I don't care about uniform brightness between circuits as all that matters is that I get a small visible light burst. This is a UART activity LED, so how bright it gets during the short pulse width does not really matter as long as its visible and does not burn the LED. I tested the circuit with a 2N3906 transistor and it works perfect.

BTW does that emitter to base resistor even matter in this circuit? Or can I go with just a pre biased transistor with just a base resistor?
 

The pre-biased transistor already has a base-emitter resistor. It helps to quickly turn off the transistor. It also has a series base resistor.
 

I understand how the simulator works and it has the correct forward voltage, my main concern is what the gain will be for that particular transistor and setup with LED and how to calculate it. The only parameter that can be changed on the transistor is just gain, but gain is dependent on the current drawn from the LED.

Im here to learn, so instead of calling my efforts feeble and lazy I would appreciate more constructive feedback. I understand you know more about electrical engineering than I do, but Im sure you started somewhere too.

BTW the LED im using has a foward voltage of 2v and 30ma foward current at that voltage.


It is possible to get one sample of parts to work in your configurations , but not really for production the variation would be too high ( low functional spec yield). The std deviation of hFE and ESR of LEDs would result in a >80% difference in currents.

Making a precise logic comparator and regulated current limit is harder than it looks with a wide tolerance of hFE in an common emitter. So was never done that way in logic chips. None of these compare using a proper logic gate to drive the LED with a fixed current limiting R, which would be the best solution. (LVC type only)

Sorry to be harsh, but that's the reality.

Unfortunately the diode and transistor characteristics are not well defined in Falstad's sim. nor accurate without passive loss adjustments for ESR which is related to rated power dissipation. Falstad simulator on your design has limitations of active part accuracy and makes assumptions that are not accurate for different power rated parts by simply setting hFE or Vf.

YOu have to verify , adjust and compensate. SO I used 2.3V @1A and added 11 Ohms to get 2.3V drop at 22mA

I used a 40Hz triangle wave so you can see the transfer function and timing effect of cap.

- - - Updated - - -

OF course you can get lucky or order binned parts at greater expense.

- - - Updated - - -

If I change the LED to make Vce min=2.91 and thus LED= 2.09 the LED current rises to 28mA
here
then with hFE=80 the If =9.4mA there with Vf~=1.9and Vce=3.1 so the design is very hFE sensitive with this CE config.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top