Trouble using CSV voltage source, or expressions in Voltage source

I'm trying to stimulate a circuit by applying a signal which repeatedly does this:

  1. Output sine wave (square would suffice), -1v to +1v, 50Hz for 5 cycles
  2. Output rectified sine wave (square would suffice), 0v to 1v, 50Hz for 5 cycles

I tried using the CSV voltage source to implement this with PWS-generated square waves, but it seems it just DC at +1v with the following used as the value:

0,1,0.01,0,0.02,1,0.03,0,0.04,1,0.05,0,0.06,1,0.07,0,0.08,1,0.09,0,0.10,1,0.11,-1,0.12,1,0.13,-1,0.14,1,0.15,-1,0.16,1,0.17,-1,0.18,1,0.19,-1,0.20,1

I also tried using the following with a voltage source, but it just output 0v:

if( t>0.1, sin( 2 * pi * 50 ), max( sin( 2 * pi * 50),0 ) )

what am I doing wrong? Thanks

by Jodes
March 23, 2014

@Jodes,

i) You haven't posted a public or unlisted circuit so no-one can see what you might have done wrong.

Using the CL CSV source and pasting your CVS list into it does not appear to work: you just get a steady 1V out as you already found however, your CVS list works OK when pasted into an ideal voltage source using a PWS() function;

I don't know why the CL CSV source doesn't work.

You probably should raise a BUG REPORT about it as described in:

https://www.circuitlab.com/forums/support/topic/8s9n9hav/how-to-use-the-circuitlab-support-forum/

ii) The reason your if() statement didn't work is that your arbitrary source expressions are missing the "T" for time. Hence they are stuck at a multiple of 2*pi and so the sine is always zero.

To make a time varying sinusoid, the expression should be of the form:

sin(2*pi*T*50)

See:

https://www.circuitlab.com/docs/circuit-elements/#behavioralsources

:)

by signality
March 23, 2014

Thanks again @Signality.

The PWS function within the ideal voltage source component worked.

I will investigate your suggestions on the other methods at some point soon and report back. (Although I must point out that when using the sine functions, I used lower case T rather than upper case, which perhaps was not recognised as the time variable?)

by Jodes
March 24, 2014

Hi,

CL, unlike spice, is case sensitive so an expression like:

1-exp(-T/100u)

will work but

1-exp(-t/100u)

will not.

As I said earlier, your circuit is private, so I based my comment on the missing 'T' in your sine sources on the text you quoted:

"f( t>0.1, sin( 2 * pi * 50 ), max( sin( 2 * pi * 50),0 ) )"

which has no time parameter in it.

:)

by signality
March 24, 2014

Hi folks,

I was facing the same problem with the "non-working" CSV Voltage source. In fact, there is something very important: 1 instruction per line !! Here is the corrected version:

by scharpen
March 24, 2015

Oups !!! It is a 1year old message. I saw 2014, but read 2015... Pfff... getting old ;-)

by scharpen
March 24, 2015

This posting still helped me in 2020. Thanks.

by Dan.Ka
November 11, 2020

This post still helped me in May 2021, too. Thank you.

by dirkmeier
May 14, 2021

Post a Reply

Please sign in or create an account to comment.