Help with modeling CdS cell in LTspice - Page 1
Forum section: electronics / beginners

author: jj5
author_rank: Unknown
timestamp: May 07, 2024, 02:42:04 am
content: Hi there. I have drawn up the schematic shown below in LTspice (you can downloadhere). What I want to do is simulate light hitting the CdS cell (R12). Can someone please explain to me how I could go about that? Thanks in advance!

author: aliarifat794
author_rank: Regular Contributor
timestamp: May 07, 2024, 05:56:08 am
content: Are you looking for a light source in LTspice?

author: jj5
author_rank: Unknown
timestamp: May 07, 2024, 07:30:04 am
content: Quote from: aliarifat794 on May 07, 2024, 05:56:08 amI'm not sure. Is that even possible? I guess if I had a light source I would need to change R12 to a CdS cell and not a plain resistor.

author: Ian.M
author_rank: Super Contributor
timestamp: May 07, 2024, 08:46:37 am
content: Fully modelling a CdS cell is *HARD*. The resistance not only depends on the illumination, but also on the illumination history. However if you *MUST*, have a good mathematical or tabulated model for it, and cant settle for a param sweep of R12's value, the way to do it is with aLTspice behavioral resistorand a source (probably PWL) to control it.

author: Zero999
author_rank: Super Contributor
timestamp: May 07, 2024, 10:40:13 am
content: Don't bother with trying to simulate the light. Just use a voltage controlled resistor.

author: MrAl
author_rank: Super Contributor
timestamp: May 08, 2024, 07:42:54 am
content: Quote from: jj5 on May 07, 2024, 02:42:04 amHi,To do something like this you would usually set it up so that a voltage controls the device. That way you can change the voltage in order to see what the device does. The device would be a linear voltage-controlled resistor, but the drive will be nonlinear and depend on a variable we deem to be the Lux input light level. You could then do an equivalent light level sweep with whatever light levels you wanted to work with.For this the input light level units would be in Lux. Depending on where you are going to use it the range of Lux would be different so you'd have to figure out where you want to use it and it may be in more than one location. You might also want to get a feel for what Lux you might find in different locations like around the house or outdoors. You could look that up online. For example, moon lighting at night could be around 1 Lux while at home it may be 100 Lux and in the kitchen 500 Lux.Next you need the control formula. The data sheet for your CdS cell will normally give at least two data points, one for low level lighting and another for brighter light. The low level might be at 1 Lux while the higher level at 100 Lux or more. You can use a simple curve fit method to calculate the formula which would involve an exponential.For a quick example:V=90/x^0.8266This is a behavioral voltage source that provides a voltage that is related to the light input 'x' in Lux. This voltage 'V' is then used to control a linear voltage-controlled resistor with or without a scaling factor.You can set this up with different scales, so V=90 volts might be R=90k and V=10 volts might be 10k, etc.The variable x is the Lux input and you can vary that any way you want to and get a feel for what to expect with different lighting levels.Don't expect this to be perfect though as there are a lot of other variables including part number unit to unit differences.Note there are also spectral factors that come into play, and also time related factors that delay the change of resistance as the light levels change. You could add some capacitance for this, but if you only need to look at static operation you don't need that.

author: mag_therm
author_rank: Frequent Contributor
timestamp: May 08, 2024, 10:07:16 am
content: The CdS LDR can be approximately linearized as follows:Original transfer function: R = C1* (Q^-m) where C1 is a constant Q is the light level, m ~= 0.85Reciprocate the transfer function: 1/R = C2* (Q^0.85)Approximate as 1/R =C2* Q , the error is Q^0.15, per unit error decreases as Q increasesAdd a voltage divider:e_out = e_ref * r2/(R+r2)Approximate using a low value of r2; r2 << R, then e_out ~=e_ref * r2/RBOTTOM LINE ( Phew !) : make a voltage divider with CdS as top resistor and r2 for example, as Rin of an emitter followere_out ~=e_ref* rin * (1/R)With the above , a qucs simulation resulted in this circuit, used to replace the corroded circuit in old Pentax SpotmeterThe original CdS, lens and 40 microamp meter were retained.It is accurate for photography down to EV 1 or so (dark evening etc)https://app.box.com/s/p4vftz8mfcvkksjdot6j5bmhj89ravt5

author: jj5
author_rank: Unknown
timestamp: May 12, 2024, 11:24:00 pm
content: Quote from: Zero999 on May 07, 2024, 10:40:13 amHey @Zero999, how did you add the LDR1 component to the schematic? Yours shows properly as a CdS cell (with the circle and double arrows pointing in) but when I try to add an LDR I can only find a standard resistor... do I add a standard resistor and then change the symbol somehow? Or do I have to add a specific component?

author: Zero999
author_rank: Super Contributor
timestamp: May 13, 2024, 08:08:10 am
content: Quote from: jj5 on May 12, 2024, 11:24:00 pmI simply used the standard resistor symbol and drew the other parts, with the edit -> draw tools. Hold ctrl for a finer grid. You can just copy and paste it from my .asc file to your circuit, if you want to save time.