Author Topic: Help with modeling CdS cell in LTspice  (Read 471 times)

0 Members and 1 Guest are viewing this topic.

Offline jj5Topic starter

  • Regular Contributor
  • *
  • Posts: 96
  • Country: au
  • Still learning about electronics...
    • In The Lab With Jay Jay
Help with modeling CdS cell in LTspice
« on: May 07, 2024, 02:42:04 am »
Hi there. I have drawn up the schematic shown below in LTspice (you can download here). 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!

 

Offline aliarifat794

  • Regular Contributor
  • *
  • Posts: 88
  • Country: bd
Re: Help with modeling CdS cell in LTspice
« Reply #1 on: May 07, 2024, 05:56:08 am »
Are you looking for a light source in LTspice?
 

Offline jj5Topic starter

  • Regular Contributor
  • *
  • Posts: 96
  • Country: au
  • Still learning about electronics...
    • In The Lab With Jay Jay
Re: Help with modeling CdS cell in LTspice
« Reply #2 on: May 07, 2024, 07:30:04 am »
Are you looking for a light source in LTspice?

I'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.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12887
Re: Help with modeling CdS cell in LTspice
« Reply #3 on: May 07, 2024, 08:46:37 am »
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 a LTspice behavioral resistor and a source (probably PWL) to control it.
 
The following users thanked this post: tooki, jj5

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19591
  • Country: gb
  • 0999
Re: Help with modeling CdS cell in LTspice
« Reply #4 on: May 07, 2024, 10:40:13 am »
Don't bother with trying to simulate the light. Just use a voltage controlled resistor.


« Last Edit: May 07, 2024, 09:22:01 pm by Zero999 »
 
The following users thanked this post: jj5

Offline MrAl

  • Super Contributor
  • ***
  • Posts: 1460
Re: Help with modeling CdS cell in LTspice
« Reply #5 on: May 08, 2024, 07:42:54 am »
Hi there. I have drawn up the schematic shown below in LTspice (you can download here). 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!



Hi,

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.8266
This 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.

« Last Edit: May 08, 2024, 07:47:07 am by MrAl »
 
The following users thanked this post: RJSV, jj5

Offline mag_therm

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: us
Re: Help with modeling CdS cell in LTspice
« Reply #6 on: May 08, 2024, 10:07:16 am »
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.85

Reciprocate 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 increases

Add 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/R

BOTTOM LINE ( Phew !)  : make a voltage divider with CdS as top resistor and r2 for example, as  Rin of an emitter follower
 e_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 Spotmeter
The 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
 
The following users thanked this post: jj5

Offline jj5Topic starter

  • Regular Contributor
  • *
  • Posts: 96
  • Country: au
  • Still learning about electronics...
    • In The Lab With Jay Jay
Re: Help with modeling CdS cell in LTspice
« Reply #7 on: May 12, 2024, 11:24:00 pm »
Don't bother with trying to simulate the light. Just use a voltage controlled resistor.

Hey @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?
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19591
  • Country: gb
  • 0999
Re: Help with modeling CdS cell in LTspice
« Reply #8 on: May 13, 2024, 08:08:10 am »
Don't bother with trying to simulate the light. Just use a voltage controlled resistor.

Hey @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?
I 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.
 
The following users thanked this post: jj5


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf