Driving a FX2N' digital input with a LDR

lwmar

Member
Join Date
May 2021
Location
In a house
Posts
22
Dear all,


I want to connect a LDR to one of the digital inputs of my chinese clone FX2N PLC (it has no analog inputs) and make that input active when the LDR is not receiving my laser's light. For that, first I measured the resistance value of the LDR and I've got this:


32kOhms when the laser is illuminating it

430 Ohms when the laser is not illuminating it



I know that the simplest circuit I can make is like this one (where R2 is my LDR), however I am asking here because I don't want to blow up the transistor and I think that over 4 Volts in R2 is probably too much. (I tried increasing R3 but in that case the LED does not light up) My intention is to connect the transistor's emitter to the PLC's input I want to drive and the collector to the common connection of the PLC (which is located next to the inputs). R1 and the LED you can see in the simulation are there just to simulate the ones located inside the PLC. I would like to know why the current meters at the transistor's base are showing 0.00 each.


Many thanks, best regards


Marcelo

LDR_PLC.jpg
 
First of all connecting the PLC input to the emitter will not give enough voltage to the PLC to trigger the input, in simple terms the emitter in an NPN transistor will only have a difference of 0.5v below base, remember transistors are essentially current devices, you need a PNP in real terms for voltage sourcing.
Many years since I have designed & implemented discrete transistors so a little rusty. From the circuit I cannot see why you are not getting base current.
 
I would like to know why the current meters at the transistor's base are showing 0.00 each.

The following is less than rigorous to be sure, and may be out to lunch entirely for that matter. But it may suggest, if not an answer to that query, then at least a path for further investigation.

  1. Base voltage is 4.05V
  2. Emitter voltage is 3.35V
    • = Base voltage - forward bias voltage = 4.05V - 0.7V
  3. D1:R1 junction voltage is 3.3V minimum
    • D1 LED forward voltage is around 3.3V
    • Cf. Pure-Green LED per The Google
  4. Voltage across R1 is 0.05V
    • = 3.35V - 3.3V
  5. Emmitter current iE across R1 is 23μA
    • = 0.05V / 2.2kOhm
    • Collector iC current is roughly the same
  6. Q1 BC549 DC gain iC/iB is 200 to 270
  7. Base current iB is 0.08μA to 0.12μA
    • = iC / gain = 23μA / 270 or 23μA / 200
Which iB is pretty small, but still not too small for the simulated μA ammeter.

That said, the (0.05V = 3.35V - 3.3V) difference in step 4 above is sensitive to the forward bias voltages of Q1 BC549 and D1 LED. E.g. relatively small increases in either or both of those forward bias voltages on the order of 45mV+ could drop iB below the 0.005μA limit to show 0.00 on that μA ammeter, while a yellow-green LED, with a forward bias voltage of around 1.9V, instead of the pure-green LED assumed above throws this post in the trash.

Obviously this is a ballpark approach with concomitant assumptions. It might be interesting to add meters on the load side of the circuit to infer what assumptions the simulator is making.


xxx.png
 
This circuit is probably irrelevant as the emitter connected to the PLC will probably not be enough to turn it on.
 
This circuit is probably irrelevant as the emitter connected to the PLC will probably not be enough to turn it on.


Ah, I think I see it now: is that because the base never goes higher than 4.05V, so the emitter cannot go above that 4.05V less the forward bias?
 
Only way to use an NPN transistor to drive the PLC input would to make the PLC input sinking and put everything in the collector, in other words, the transistor collector will sit at 24v when the transistor is effectively switched off (no base current) so PLC input would be at 24v, when the transistor turns on the collector voltage will drop below the threshold of the PLC input & change state.
 
Thanks Parky and Drbitboy. They guy who sells me the electronic components is normally busy but this time he wasn't and suggested me this other circuit, I am going to build it in a few hours and I will let you know the results.

LDR_TO_PLC_2.jpg
 
Yes, that makes more sense, just remember, if the PLC is wired as 24v source then your logic will be opposite i.e. when the led is off the input to the PLC will be on, the average current drawn on PLC inputs is around 10ma so to ensure the PLC input switches correctly the resistor needs to be around 2.5k at 24v supply & the PLC input might not switch at 12v although I have seen them switch at 8v.
 
Please bear with me, I am trying to understand.

The PLC input is in the middle of a voltage divider between the [R5/R1] (sub-?)circuit and Q1, where the "resistance" of Q1 is either very high or very low. So to get the voltage at the PLC input side, we use Ohm's Law on a two-elements-in-series circuit where the resistance ratio is either very high or very low.

In the image, below, the LDR is lit and its resistance is 32kΩ, so the Q1 Base voltage is at or above the the 0.7V "forward bias." That bias allows current flow through Q1 from Collector to Emitter, which makes the Q1 Collector voltage ~ PLC input voltage low. I.e. Q1 "resistance" is near zero and therefore low compared to the [R5 8200Ω/R1 2.2kΩ] circuit, so Q1 "pulls" the mid-voltage-divider PLC input voltage low toward the Ground/PLC common to which Q1 Emitter is connected.

If the LDR is not lit and its resistance is low (430Ω), then the Q1 Base voltage will be low, below the 0.7V forward bias, which prevents current flow through Q1 from Collector to Emitter, which makes the Q1 Collector Voltage ~ PLC input voltage high. I.e. the [R5 8200Ω/R1 2.2kΩ] circuit's resistance is low compared to Q1's near infinite and therefore high "resistance", so the [R5 8200Ω/R1 2.2kΩ] circuit "pulls" the mid-voltage-divider PLC input voltage high toward the +12V to which it is connected.

Is that about right?

If yes, what is the purpose of [R5 8200Ω] (and why is it not [R5 8.2kΩ])? R5 not current limiting because more current will be flowing through the [R1 2.2kΩ + D1 LED] circuit. Wouldn't the circuit work almost identically without R5, or at least with a much larger resistance for R5?

For that matter, since it's a voltage divider, why not skip all the gubbins on the left and put the LDR directly where Q1 is. I realize that would switch the relative polarity of the light/no-light state and the state of the PLC input, but that could be remedied by connecting +12V to one end of the LDR, then the other end of the LDR to the PLC input and the positive side of [D1 LED], then [R1 2.2kΩ] between the negative side of [D1 LED] and Ground/PLC Common.

What does the transistor buy us here? Isn't the LDR analogous a to an NPN transistor, but with a light window and photons in the LDR replacing the base and electrons in the transistor?

If I am way off base here, feel free to mock.

[Update: maybe putting the LDR over controlling the base of Q1 limits the current flow through the LDR?]





attachment.php
 
Last edited:
Thanks all for the answers:

Drbitboy:

You can forget about R1 and D1 as those are not necessary and I didn't put them in the circuit I built. Where you ask me "is that about right?" I answer I think so (as this circuit was designed by the Engineer who sells me the electronic components). I have to apologise as I think I made a mistake in the circuit as the low resistance of 430 ohm happens when the LDR is illuminated.

I am not sure if he understood me as the results I am getting while measuring voltage between that PLC's input and ground are: 18V while the LDR is not illuminated and 5,8V when the LDR is illuminated. However I cannot find the LDR that shows 430 ohm and I am using one that shows 26,5 kohm without being illuminated and 2,8 kohm while being illuminated.

You ask me why 8200 ohm is not 8.2 kohm: it is the same value, isn't it?
Then you mention the possibility of not using the transistor in the circuit: Could you please draw that circuit?
 
Re: 8200 vs.8.2k

I was asking why the diagram used "8200" to display the R5 resistance instead of "8.2k" - as long as they mean the same thing it does not matter.
 
Then you mention the possibility of not using the transistor in the circuit: Could you please draw that circuit?

Maybe I am missing something obvious, but it would be a basic voltage divider, with two states; see below. I know you say the LDR lit/unlit resistances are different now, but something like this might still be possible.

In the schematic in Post #7 with the transistor, when the transistor is conducting the +12V flows to ground through only [R1 2.2k], the LED and the transistor. So the max current on the PLC sidehas to be at least a few mA (< 12V / 2.2kOhm ~ 5ma). The current in the circuit in this post could be about the same, depending on the final characteristics of the LDR and the pulldown resistor chosen.


xxx.png
 
DR is right, however, one or two points, the PLC is usually rated at between 5-10ma drawn current (will depend on how the circuit is configured, very often the input transistor & LED are driven directly & the opto isolator after that hence the possible 10ma per input) what typical current will the LDR stand this is important as if it was rated at 10ma max then it could destroy it.
The other problem is the LDR will act like an analogue signal i.e. the voltage drop will vary with it's resistance (no light through to full light), therefore the PLC input may hover around it's switching point so cause intermittent switching although the hysteresis may help. you really need a positive transition from off to on for reliable operation. so a transistor to amplify is best.
 

Similar Topics

We have a handful of nearly identical flywheel-driven machines. About a year ago, we installed a 15HP Powerflex 525 drive in simple V/Hz mode...
Replies
2
Views
865
Is there any issue with running a VFD-controlled 3-phase induction motor in torque control mode in the braking region continuously (back-driven by...
Replies
14
Views
3,973
Hello everyone, we're trying to get some information from our screwdrivers. - The control chain is IqR plc with RD77MS16, connected to MR-J4 and...
Replies
1
Views
820
Hi All, trying to restore a runtime application that i have been reliably informed was created in version 10 ftview, i get the below error:-...
Replies
1
Views
962
This is the tab order I have in the e-sign component in Rockwell. Is it set in stone can this be modified? The ideal set up would be to get to...
Replies
1
Views
1,275
Back
Top Bottom