Odd Behavioural Voltage source behaviour

Status
Not open for further replies.

alec_t

Well-Known Member
Most Helpful Member
The attached simple sim is meant to produce a 0-10kHz swept sine over a 1 sec period, but instead produces 0-20kHz. Where am I going wrong?
 

Attachments

  • BV-anomaly.asc
    448 bytes · Views: 291
hi alec,
Move that right end bracket, left , [ make time outside the *2]
Eric
 
Thanks. Just tried that, but all I get then is a constant 10kHz with a rising 0-1V amplitude (as expected).
I'm puzzled as to why the original version gives exactly twice the expected frequency.

Edit:
Removing the factor of 2 from the original version gives the wanted 0-10kHz, but is mathematically incorrect.
I've tried reducing the maximum step time for the sim, but that doesn't fix the anomaly.
 
Last edited:
You do not need the "time" in the expression.

Proof, make V(a) = a ramp that goes from 0V to 10,000V.
Then make the BV expression sin(2*pi*V(a))

Alternatively, you do not need V(a). Make the BV expression sin(2*pi*10k*time)
 
Thanks Mike. Tried that, but...... that results unexpectedly in a constant 10kHz. What's going on??? I'm getting the impression that a BV prefers fixed parameters to variables in its expression, but surely it's meant to accept any formula you throw at it?

Edit:
Tried the second suggestion in post #5, but again the frequency is not swept.
 
Last edited:
You are right, the "time" variable must be in the expression.

For B1, the expression V=sin(2*pi*5000*time^2) does what you want. It starts at near zero frequency, and is making 10kHz at the end of the second. I dont understand why 5000 instead of 10000, either, but it likely has something to do with "time" effectively being squared, either if it comes from V(a) or is put directly into the argument of the sin() function.
 
Last edited:
hi alec,
This alternative also works.
Mod to the 'a' source voltage, keeps the 10K in the equation.
E
 

Attachments

  • BV-anomaly.asc
    448 bytes · Views: 261
Thanks, both.
Ok, between us we've got a few workarounds I can live with, but it still doesn't explain that factor of 2.
 
The attached simple sim is meant to produce a 0-10kHz swept sine over a 1 sec period, but instead produces 0-20kHz. Where am I going wrong?

Try idt() function to integrate the quantities.

v=sin(2*pi*10k*idt(v(a)*time))

eT
 
Thanks. That works without the spurious freqency doubling (but I don't understand why).
 
Try idt() function to integrate the quantities.

v=sin(2*pi*10k*idt(v(a)*time))

eT

Can you explain? It looks to me that coincidentally, idt(V(a) just happens to be one half of time^2 at time=1s. Why is this any better than just 0.5*time^2 ?



My V(a) plots well behaved. Why do you need to integrate it? If you integrate it, it makes a very different V(b).
 
It gets weirder. With v(a) ramped from 0 to 1 over 1 sec, followed by v(a) = 1 for 1 sec, a 2 sec sim gives a 0-20kHz sweep followed by a 10kHz sine, with the frequency suddenly halving at the 1 sec point ???


Edit:
Weirder still. Changing V(a) to ramp from 0.5 to 1 over the first 1 sec gives a 5kHz (expected) to 15kHz (unexpected) frequency sweep, followed by 10kHz from 1 sec onwards.
 
Last edited:

Because the time computation should occur after each time slice (idt()) and then fed to the remainder of the equation.
That's what idt() will do. At least that's the way I understand it.
This also means that "maxtimestep" will have an influence on the results. It should be set to something less than the shortest period. The period of 20khz is about 50us, so I'd set that value to maybe 1us to get good results but not slow down the sim too much.

eT
 

I don't see where you've changed anything from post 1 except broke out part of the equation and placed it in a param.
 
I don't see where you've changed anything from post 1 except broke out part of the equation and placed it in a param.
The param thing was just to simplify the BV expression while I was experimenting with it.
I extended the sim time from 1 sec to 2 secs so that, from time 1s to 2s, v(a) stays at 1V. That results in LTS correctly identifying the sine frequency from 1s onwards.
I agree the max timestep seems to be the root of the anomaly. I used 1uS for the post #13 sim. If you set maxtimestep progressively >2uS you start to see changes in the sine envelope. Set it at 50uS, for example, and you create a nice noise generator!
It's beginning to look as though any BV expression which is a time function of something which is itself a time function will give unpredictable results.
 
Last edited:

Hi

Yes...the maxtimestep will have an effect. And...yes..you need to use idt() function in the expression or the anomaly (which really isn't an anomaly) will continue.

The attached sim should be self explanatory but V1 adjust the amplitude, V2 adjusts the frequency and rate of change (via rise time).
The output frequency will change based on the rise time set in V2.

eT

 
Nice solution. Thanks. I'm sure LTS has a lot more 'gotchas' awaiting me .
 
Nice solution. Thanks. I'm sure LTS has a lot more 'gotchas' awaiting me .

Heh...the best way to avoid this type of gocha is to use the LTspice modulate or modulate2 device.
It's designed for this kind of application.

eT
 
Thanks. I was aware of the modulate device, but was experimenting with the standard BV one with a view to building a model which could be ported to Pspice if necessary. Do you know if Pspice has a native modulate device, or is that proprietary to LT?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…