microphone capsule capacitance


 

Trying to simulate a microphone capsule, which capacitance varies sinusoidally.
LTspice rejects my syntax.
File globalrecordsRF mic.asc   uploaded to Temp


 

On 04/12/2024 19:17, Jerry Lee Marcel via groups.io wrote:
Trying to simulate a microphone capsule, which capacitance varies sinusoidally.
LTspice rejects my syntax.
File globalrecordsRF mic.asc   uploaded to Temp
That's because you tried to make its value time-dependent. Only certain elements allow that, and the normal capacitor isn't one of them.

You need to be using the charge model capacitor. This is described in:

Help > LTspice > LTspice® > Circuit Elements > C. Capacitor

..down near the bottom of the page

--
Regards,
Tony


 
Змінено

On Wed, Dec 4, 2024 at 01:18 PM, Jerry Lee Marcel wrote:

LTspice rejects my syntax.

There is no syntax of the form ".C2=<value>" for the value of a capacitor.
 
Technically, you could use similar formulas for a capacitor, by changing that line to {<formula>}, i.e., {75p+2pcos 1kt}.  But I think your formula has missing pieces, like multiply operators and parentheses.  Should it be 75p+2p*cos(1*k*t)?  Does "t" represent time, or temperature?  If it's a microphone, it probably means time, and I believe the correct term for time is "time".  That would make it something like {75p+2p*cos(1*k(time)} - which still might not be proper.  It might be necessary to generate the capacitance argument as a voltage, from a B-source, and then refer to it with something like {V(n010)}.
 
HOWEVER - and this is the big problem - it does not do the right thing.  Even if you get that formula to be accepted, what you end up with is a capacitor whose static (DC) capacitance follows the formula, but its dynamic capacitance does not, making it violate the conservation of charge.  It would not behave like a capacitor should.
 
The remedy for that is to use LTspice's charge model, as Tony said.
 
Andy
 


 

Also, even from a logic point of view,

.C2=75p+2pcos 1kt   wouldn’t do what I imagine you want.

 

“75p + 2*PI*cos(1k * time)” is adding Farads to picoFarads

 

 

From: LTspice@groups.io <LTspice@groups.io> On Behalf Of Tony Casey
Sent: Wednesday, December 04, 2024 10:37 AM
To: LTspice@groups.io
Subject: EXTERNAL: Re: [LTspice] microphone capsule capacitance

 

On 04/12/2024 19:17, Jerry Lee Marcel via groups.io wrote:

Trying to simulate a microphone capsule, which capacitance varies sinusoidally.
LTspice rejects my syntax.
File globalrecordsRF mic.asc   uploaded to Temp

That's because you tried to make its value time-dependent. Only certain elements allow that, and the normal capacitor isn't one of them.

You need to be using the charge model capacitor. This is described in:

Help > LTspice > LTspice® > Circuit Elements > C. Capacitor

..down near the bottom of the page

--

Regards,
Tony


 

I corrected some typos in the message I just sent.  I did not bother re-sending the message to the group, because most of it is moot.  Varying capacitance by using a time-dependent formula for C is the wrong way to do it.  One must use the charge formula.
 
Andy
 
 


 

I didn't mean 2*pi*cos (1k*time), I meant 2p*cos(1k*time). 2pF mulitplied by cos() .That would have resulted in a frequency of 159Hz, but at the time I didn't care.
Anyway, it doesn't work like I would like it to.
I'll try the charge formula, but what I've seen so far raises more questions than answers...

Le 04/12/2024 à 20:13, Bell, Dave via groups.io a écrit :

Also, even from a logic point of view,

.C2=75p+2pcos 1kt   wouldn’t do what I imagine you want.

 

“75p + 2*PI*cos(1k * time)” is adding Farads to picoFarads

 

 

From: LTspice@groups.io <LTspice@groups.io> On Behalf Of Tony Casey
Sent: Wednesday, December 04, 2024 10:37 AM
To: LTspice@groups.io
Subject: EXTERNAL: Re: [LTspice] microphone capsule capacitance

 

On 04/12/2024 19:17, Jerry Lee Marcel via groups.io wrote:

Trying to simulate a microphone capsule, which capacitance varies sinusoidally.
LTspice rejects my syntax.
File globalrecordsRF mic.asc   uploaded to Temp

That's because you tried to make its value time-dependent. Only certain elements allow that, and the normal capacitor isn't one of them.

You need to be using the charge model capacitor. This is described in:

Help > LTspice > LTspice® > Circuit Elements > C. Capacitor

..down near the bottom of the page

--

Regards,
Tony


 

As I said, you will not get the correct results by simply changing the capacitance on-the-fly.  That "works" (or it can "work"), but it does not simulate how either the voltage or the capacitor's charge must simultaneously change along with the capacitance.  Only by using the charge model, can you get the desired result.
 
Andy
 
 


 

I've looked at the Help, and I'm none the wiser.
How is the formula "Cnnn n1 n2 Q=100p*x" included in the schematic?
To me it looks like a line in the netlist.
Then, should I use Q=
{75p+2p(cos(1*k(time)}*x ? With or wihout the parentheses?

2p is the maximum excursion from the rest value of 75p.

Le 04/12/2024 à 20:15, Andy I via groups.io a écrit :

On Wed, Dec 4, 2024 at 01:18 PM, Jerry Lee Marcel wrote:

LTspice rejects my syntax.

Also, there is no syntax of the form ".C2=<value> for the value of a capacitor.
 
Technically, you could use similar formulas for a capacitor, by changing that line to {<formula>}, i.e., {75p+2pcos 1kt}.  But I think your formula has missing pieces, like multiply operators and parentheses.  Should it be 75p+2p*cos(1*k*t)?  Does "t" represent time, or temperature?  If it's a microphone, it probably means time, and I believe the correct term for time is "time".  That would make it something like {75p+2p(cos(1*k(time)} - which still might not be proper.  It might be necessary to generate the capacitance argument as a voltage, from a B-source, and then refer to it with something like {V(n010)}.
 
HOWEVER - and this is the big problem - it does not do the right thing.  Even if you get that formula to be accepted, what you end up with is a capacitor whose static (DC) capacitance follows the formula, but its dynamic capacitance does not, making it violate the conservation of charge.  It would not behave like a capacitor should.
 
The remedy for that is to use LTspice's charge model, as Tony said.
 
Andy
 


 

On Thu, Dec 5, 2024 at 06:16 AM, Jerry Lee Marcel wrote:

How is the formula "Cnnn n1 n2 Q=100p*x" included in the schematic?
To me it looks like a line in the netlist.

I take it you have never looked at the Help before.  That is how every element is described - in Netlist form.
 
When you put a component on a schematic, and then press Run, LTspice turns it into a line of SPICE Netlist.  It includes (a) the element name, (b) the nodenames to which you connected it, and (c) its value and optional parameters.  For a capacitor, the normal value would be just a number.  For the charge model, you would use a formula such as "Q=100p*x" in place of the capacitor's value.
 
Like many components, there are two if not three ways to do that.
  • One is to right-click on the capacitor's body and then type that formula, "Q=100p*x" (without the quotes), in the box where the value would go.
  • Another is to right-click on just the capacitor's value, specifically on the text next to the capacitor, and type that formula in place of the capacitor's value.  When you first place a cap, its value is the placeholder "C".
  • The third is to Ctrl-right-click on the capacitor's body and type the formula on the Value line, replacing the capacitor's normal value.

Then, should I use Q={75p+2p(cos(1*k(time)}*x ? With or wihout the parentheses?

If I remember correctly, you have to do some differentiation first, to turn voltage into charge,  or vice-versa.  For me, it is not intuitive.
 
I'm not sure that you understood what I wrote before about missing operators.  What is "2p(cos(...)"?  Is 2p a pre-defined function, or is it 2p times the cos() function?  The same thing with k(time).  I don't think you meant for k() to be a function; I think you wanted 1k*(time), or just 1k*time.
 
Be prepared to work on this a while.  I have always needed to do that with the charge model until I got it right.  Maybe that's just me and my stupid little brain.
 
Andy
 


 

I do not think curly braces are needed in the Q= formula, unless the Q formula has user-defined parameters.
 
Andy
 


 


Le 05/12/2024 à 14:35, Andy I via groups.io a écrit :
On Thu, Dec 5, 2024 at 06:16 AM, Jerry Lee Marcel wrote:

How is the formula "Cnnn n1 n2 Q=100p*x" included in the schematic?
To me it looks like a line in the netlist.

I take it you have never looked at the Help before. 
Actually I did, many times. Had I not, I wouldn't hav efound references to "Cnnn n1 n2 Q=100p*x"
That is how every element is described - in Netlist form.
If you say so. Actually I use a GUI that saves me having to type a netlist.
 
When you put a component on a schematic, and then press Run, LTspice turns it into a line of SPICE Netlist.  It includes (a) the element name, (b) the nodenames to which you connected it, and (c) its value and optional parameters.  For a capacitor, the normal value would be just a number.  For the charge model, you would use a formula such as "Q=100p*x" in place of the capacitor's value.
Does it mean that, by seeing this formula, LTspice recognizes the fact that it should not expect a capacitance value, but a charge value that is interpreted differently? I see no mention of that in the Help.
 

Then, should I use Q={75p+2p(cos(1*k(time)}*x ? With or wihout the parentheses?

If I remember correctly, you have to do some differentiation first, to turn voltage into charge,  or vice-versa.  For me, it is not intuitive.
Maybe you should read the Help?...
 
I'm not sure that you understood what I wrote before about missing operators.  What is "2p(cos(...)"?  Is 2p a pre-defined function, or is it 2p times the cos() function? 
2p is two pico. I thought it would be understood tha same as k (or Meg, or G). So yes, it was meant to be a cos function of amplitude 2p Farad.
The same thing with k(time).  I don't think you meant for k() to be a function; I think you wanted 1k*(time),
This is exactly what I meant.


 

On Thu, Dec 5, 2024 at 11:57 AM, Jerry Lee Marcel wrote:
Actually I did, many times. ...
Yes, I am quite sure you do.  I apologize.  That was my very bad attempt at some light humor.

hat is how every element is described - in Netlist form.
If you say so. Actually I use a GUI that saves me having to type a netlist.
Yes, we all do.  But this is one of the weaknesses of LTspice's Help.  All of the descriptions of each element, are stated as if we were writing netlists.
Everything there that describes each element, is described as if we were writing netlists.  It is up to us to interpret what that means.
 
If it showed graphical examples of each and every component type, it would be much longer.  I think Mike E. wanted to keep it compact.

Does it mean that, by seeing this formula, LTspice recognizes the fact that it should not expect a capacitance value, but a charge value that is interpreted differently? I see no mention of that in the Help.
Indeed, that is what happens.  Using the Charge formula with Q=<expression> is an alternate way of using capacitors.  There is no capacitance value as such, because you are specifying Charge, not Capacitance.
 
You might have missed that it states it this way: "There is also a general nonlinear capacitor available. Instead of specifying the capacitance, one writes an expression for the charge."  Note it says "Instead of specifying the capacitance" in that sentence.
 
And then the Help lists the syntax (netlist) line this way:

    Syntax: Cnnn n1 n2 Q=<expression> [ic=<value>] [m=<value>]
and there is no capacitance value on that line.

Both of those should make it clear that LTspice does not expect a capacitance value.

LTspice's Help is a mostly complete reference, but it is not the easiest to read.

I'm not sure that you understood what I wrote before about missing operators.  What is "2p(cos(...)"?  Is 2p a pre-defined function, or is it 2p times the cos() function? 
2p is two pico. I thought it would be understood tha same as k (or Meg, or G). So yes, it was meant to be a cos function of amplitude 2p Farad.
LTspice does not understand that "2p(cos(1k(time))" means 2p times cos(), nor 1k times (time).  On a blackboard we can write 2p(cos()) and the humans around us understand what we mean, but computers do not.  Computers need explicit multiply operators.  Without them, they misinterpret what we write.  By writing 2p(anything), LTspice would think that 2p() is supposed to be a function, not two values multiplied together.
 
(By the way, in your schematic yesterday, where you wrote "cos 1kt", I had incorrectly thought that the "k" was the Boltzmann constant.  I guess I came to that conclusion because it was next to "t", so my mind went in that direction.  Of course 1k will be 1000.  But it needed a "*" between the "1k" and "(time)".)
 
Andy


 


Le 05/12/2024 à 18:50, Andy I via groups.io a écrit :
On Thu, Dec 5, 2024 at 11:57 AM, Jerry Lee Marcel wrote:
Actually I did, many times. ...
Yes, I am quite sure you do.  I apologize.  That was my very bad attempt at some light humor.

Indeed, you're pardoned. 🙂

And many thanks, anyway.


hat is how every element is described - in Netlist form.
If you say so. Actually I use a GUI that saves me having to type a netlist.
Yes, we all do.  But this is one of the weaknesses of LTspice's Help.  All of the descriptions of each element, are stated as if we were writing netlists.
Everything there that describes each element, is described as if we were writing netlists.  It is up to us to interpret what that means.
 
If it showed graphical examples of each and every component type, it would be much longer.  I think Mike E. wanted to keep it compact.

Does it mean that, by seeing this formula, LTspice recognizes the fact that it should not expect a capacitance value, but a charge value that is interpreted differently? I see no mention of that in the Help.
Indeed, that is what happens.  Using the Charge formula with Q=<expression> is an alternate way of using capacitors.  There is no capacitance value as such, because you are specifying Charge, not Capacitance.
 
You might have missed that it states it this way: "There is also a general nonlinear capacitor available. Instead of specifying the capacitance, one writes an expression for the charge."  Note it says "Instead of specifying the capacitance" in that sentence.
 
And then the Help lists the syntax (netlist) line this way:

    Syntax: Cnnn n1 n2 Q=<expression> [ic=<value>] [m=<value>]
and there is no capacitance value on that line.

Both of those should make it clear that LTspice does not expect a capacitance value.

LTspice's Help is a mostly complete reference, but it is not the easiest to read.

To say the least. There is a problem when concision verges towards deficiency.


I'm not sure that you understood what I wrote before about missing operators.  What is "2p(cos(...)"?  Is 2p a pre-defined function, or is it 2p times the cos() function? 
2p is two pico. I thought it would be understood tha same as k (or Meg, or G). So yes, it was meant to be a cos function of amplitude 2p Farad.
LTspice does not understand that "2p(cos(1k(time))" means 2p times cos(), nor 1k times (time).  On a blackboard we can write 2p(cos()) and the humans around us understand what we mean, but computers do not.  Computers need explicit multiply operators.  Without them, they misinterpret what we write.  By writing 2p(anything), LTspice would think that 2p() is supposed to be a function, not two values multiplied together.
OK, I'll try to accomodate that.
 
(By the way, in your schematic yesterday, where you wrote "cos 1kt", I had incorrectly thought that the "k" was the Boltzmann constant.  I guess I came to that conclusion because it was next to "t", so my mind went in that direction.  Of course 1k will be 1000.  But it needed a "*" between the "1k" and "(time)".)
 
Andy


 

On Thu, Dec 5, 2024 at 06:35 AM, Andy I wrote:
Be prepared to work on this a while.  I have always needed to do that with the charge model until I got it right.  Maybe that's just me and my stupid little brain.
It's actually fairly simple. The charge model is based on the relationship between current and voltage in a capacitor:
 
I = C dV/dt
 
and the fact that the total charge on the capacitor is the integral of the current:
 
Q = integral ( I dt )
 
Therefore
 
Q = integral ( C dV/dt dt ) = integral ( C dV )
 
If the capacitance C is not a function of V then it can be moved outside the integral, and Q is simply C times V since the integral of dV is just V.
 
Q = C integral ( dv ) = C V
 
If C is a function of V, i.e. C(V), then you must take the anti-derivative of C(V).
 
Q = integral ( C(V) dV )
 
In the LTspice charge expressions, the voltage across the capacitor is the variable x.
 
In the case of the OP, his capacitance is not a function of voltage so his charge expression is:
 
Q= (75p+2p*cos(2*pi*1k*time))*x
 
HTH