开云体育

Sine modulated PWM voltage source (PWL file=xxx)


 

I'm again at simulating a PWM. The pulses are generated from a file with the statement:

PWL file=pwm_pulses.txt

It's a while back I generated that file or in other words, I generated a new dataset for that file
and I'm suddenly gettings somthing like "time value pairs for V1 out of chronological order".

To narrow down the cause, I'm in need again for the file format of such a pulse input file.
Where again can I find the documentation for that? I found the PWL section in the wiki
but I blinded what the file format is concerned.

Thank you.

--
Christoph


 

开云体育

I suggest you upload your pwm_pulses.txt, so we can see what you did, and send a new message to say that you uploaded it.

On 2025-04-25 10:22, Christoph via groups.io wrote:

I'm again at simulating a PWM. The pulses are generated from a file with the statement:

PWL file=pwm_pulses.txt

It's a while back I generated that file or in other words, I generated a new dataset for that file
and I'm suddenly gettings somthing like "time value pairs for V1 out of chronological order".

To narrow down the cause, I'm in need again for the file format of such a pulse input file.
Where again can I find the documentation for that? I found the PWL section in the wiki
but I blinded what the file format is concerned.

Thank you.

--
Christoph




--
Best wishes John Woodgate RAYLEIGH Essex OOO-Own Opinions Only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


 

开云体育

Will do that. Nonetheless it would be helpful if I can have a look at the documentation. I'd better had documented what I did a year before :)
Just uploaded kuku_pwm_pulses.txt to the tem area:


--
Christoph



Am 25.04.2025 um 11:26 schrieb John Woodgate <jmw@...>:

I suggest you upload your pwm_pulses.txt, so we can see what you did, and send a new message to say that you uploaded it.

On 2025-04-25 10:22, Christoph via wrote:
I'm again at simulating a PWM. The pulses are generated from a file with the statement:

PWL file=pwm_pulses.txt

It's a while back I generated that file or in other words, I generated a new dataset for that file
and I'm suddenly gettings somthing like "time value pairs for V1 out of chronological order".

To narrow down the cause, I'm in need again for the file format of such a pulse input file.
Where again can I find the documentation for that? I found the PWL section in the wiki
but I blinded what the file format is concerned.

Thank you.

--
Christoph




--
Best wishes John Woodgate RAYLEIGH Essex OOO-Own Opinions Only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


 

I'm really trying hard to make the error messages clear, but there is always room for improvement.
?
The message "time value pairs for V1 out of chronological order" means that there are at least two pairs (t1,y1) and (t2,y2) where t2<=t1.
?
Best Regards,
Mathias
?
?


 

开云体育

Sorry, I will upload the whole project in a minute.

--
Christoph

Am 25.04.2025 um 11:49 schrieb Mathias Born via <mathias.born@...>:

I'm really trying hard to make the error messages clear, but there is always room for improvement.
?
The message "time value pairs for V1 out of chronological order" means that there are at least two pairs (t1,y1) and (t2,y2) where t2<=t1.
?
Best Regards,
Mathias
?
?


 

开云体育

Forgot the mechanism how uploads work here. Is the group notified automatically when an upload occurs?
Recall there's been something like this. Anyway, here's the link to my recent upload:


It's nothing peculiar, just added a voltage source that reads the pulse file.
I'm aware that I did a mistake when generating the pulses and I probably can take measures to avoid the conflict, but most important to me
is at the moment to know the format tha pulses are sent.

My generator (python notebook) does the following:

```
F=60.
step=1./(256.*F) # ?s

with open("/Users/kuku/Documents/LTspiceXVII/pwm_pulses.txt", "w") as f:
? ? for i in range(3*256):
? ? ? ? t=1E6*float(i)*step # us
? ? ? ? t1=1E6*float(i+1)*step #us
? ? ? ? u=1e6*step*a[i%256]
? ? ? ? if((t+u + trise + tfall)>t1):
? ? ? ? ? ? u=u-tfall-trise
? ? ? ? print(f'{t:0.3f}us 0 +{trise:0.3f}us 5 +{u:0.3f}us 5 +{tfall:0.3f}us 0 ',file=f)
```

--
Christoph


Am 25.04.2025 um 11:52 schrieb Christoph Kukulies <kuku@...>:

Sorry, I will upload the whole project in a minute.

--
Christoph

Am 25.04.2025 um 11:49 schrieb Mathias Born via <mathias.born@...>:

I'm really trying hard to make the error messages clear, but there is always room for improvement.
?
The message "time value pairs for V1 out of chronological order" means that there are at least two pairs (t1,y1) and (t2,y2) where t2<=t1.
?
Best Regards,
Mathias
?
?



 

开云体育



Am 25.04.2025 um 11:49 schrieb Mathias Born via <mathias.born@...>:

I'm really trying hard to make the error messages clear, but there is always room for improvement.
?
The message "time value pairs for V1 out of chronological order" means that there are at least two pairs (t1,y1) and (t2,y2) where t2<=t1.
?

It's difficult to find the location in the generated data. Easier it would be to avoid the situation at the side where the data is generated.

--
Christoph

Best Regards,
Mathias
?
?
_._,_._,_


 

Christoph,
?
In the first of the two files you uploaded (kuku_pwm_pulses.txt.zip), you have some data points that are not sequential.? The very first line is this:
0.000us 0 +0.010us 5 +0.000us 5 +0.010us 0?
which has a point at 0.000 us, then one at 0.010 us, then another at 0.010 us, and one at 0.020 us.? The second and third points are a problem because they are both at the same moment in time, not incrementally increasing.? Fortunately they both have the same voltage or current value (5 V or 5 Amps), but it is fundamentally in error for duplicating a time point.
?
That might be the cause of an error.? Hard to say for sure.
?
But later in the file, I see lines such as these:
8398.438us 0 +0.010us 5 +-1.598us 5 +0.010us 0?
8463.542us 0 +0.010us 5 +-3.195us 5 +0.010us 0?
and those are surely wrong.? ?The time increments are negative, coming before the previous time points.? Those need to be fixed.? (They are also confusing to read, so there is that too.)
?
Andy
?
?


 

Just to be clear, those two lines of data look like this:
8398.438us 0
+0.010us 5
+-1.598us 5
+0.010us 0?
8463.542us 0
+0.010us 5
+-3.195us 5
+0.010us 0?
which then expands into this:
8398.438us 0
8398.448us 5
8396.850us 5? ?; This one is earlier than the one above it
8396.860us 0?
...
?
Andy
?


 

On Fri, Apr 25, 2025 at 06:07 AM, Christoph wrote:
Forgot the mechanism how uploads work here. Is the group notified automatically when an upload occurs?
No, not necessarily.? There is a checkbox when you upload, which sends an auto-generated message, which most everyone ignores, and it self-destructs in a few days.? We ask that you always compose and send a real message here, in your message thread, not the auto-generated one, telling us what you uploaded (and why, if it's not obvious).
?
Andy


 

Mathias,
The error message clearly led me to the correct guess of the problem, time sequence out of order or unrealizable (zero or negative time step).??

Christoph,
I've never used a text file to generate a PWM signal.? I suppose it'd be handy to generate a random bit, or send in a bit of audio or a modulating waveform.? For a simpler PWM signal, I'd suggest using a PULSE source (V or I), and building the first period of the waveform in the setup, and then entering a value for the Period, which will cause the waveform to repeat indefinitely if all is set up right.? An example statement:

PULSE (0 {Clock_Vhi} 0 100n 100n 2.5u 5u)

generates a 200kHz clock with 50% duty cycle, Vlo=0, Vhi=(Passed in parameter, defined by statement .param Clock_Vhi = 3.3), 100ns rise & fall times, 2.5microsecond time at Vhi, 5microsecond period.
The LT Spice XVII help documentation covers this well.? ?
I'm still getting used to the new key bindings and help system in LT Spice 24 (keep learning, or get run over!).
-Rick, WA2YMS (an occasional contributor)

On Friday, April 25, 2025 at 07:48:14 AM EDT, Andy I via groups.io <ai.egrps+io@...> wrote:


On Fri, Apr 25, 2025 at 06:07 AM, Christoph wrote:
Forgot the mechanism how uploads work here. Is the group notified automatically when an upload occurs?
No, not necessarily.? There is a checkbox when you upload, which sends an auto-generated message, which most everyone ignores, and it self-destructs in a few days.? We ask that you always compose and send a real message here, in your message thread, not the auto-generated one, telling us what you uploaded (and why, if it's not obvious).
?
Andy


 

I'm having internet connectivity problems. Resorting to my cell phone but cannot upload anything right now.
I'm assuming that the file format is

Timepoint V0 Trise. Von Ton V? Tfall Toff
0.000000000000000000us 0 0.010us 5 32.552083333333335702us 5 0.010us 0


The error is:

PWL time, value pairs out of chronological order in source V1
3.25521e-005 is not before 1e-008

it already occurs on the first line.

--
Christoph

Am 25.04.2025 um 12:09 schrieb Christoph via groups.io <kuku@...>:



Am 25.04.2025 um 11:49 schrieb Mathias Born via groups.io <mathias.born@...>:

I'm really trying hard to make the error messages clear, but there is always room for improvement.

The message "time value pairs for V1 out of chronological order" means that there are at least two pairs (t1,y1) and (t2,y2) where t2<=t1.
It's difficult to find the location in the generated data. Easier it would be to avoid the situation at the side where the data is generated.

--
Christoph

Best Regards,
Mathias



 

开云体育

Andy,

could it be that I'm assuming a different file format as I posted in the other email:


Timepoint ??????????????????????????V0 Trise. ??Von Ton ?????????????????????????????????????V? ?Tfall ??????Toff
0.000000000000000000us 0 ?0.010us 5 ???32.552083333333335702us 5 ??0.010us 0


Some (undocumented) data formatting? My idea was, that the first parameter is the proceeding point on the time axis, followed by
the start voltage, the rise time, the on voltage, the on-time, followed by another voltage (at the end of the pulse), then the fall time and the off voltage.

I built that python program about a year or two ago and I think that file format could be sprung of a discussion here and someone pointed me to "undocumented"
PWL file formats.?

I may be totally wrong and that example may have only worked before (with other data) by accidence :)

--
Christoph

Am 25.04.2025 um 13:43 schrieb Andy I via <AI.egrps+io@...>:

Just to be clear, those two lines of data look like this:
8398.438us 0
+0.010us 5
+-1.598us 5
+0.010us 0?
8463.542us 0
+0.010us 5
+-3.195us 5
+0.010us 0?
which then expands into this:
8398.438us 0
8398.448us 5
8396.850us 5? ?; This one is earlier than the one above it
8396.860us 0?
...
?
Andy
?


 

I'm having internet connectivity problems. Resorting to my cell phone but cannot upload anything right now.
I'm assuming that the file format is

Timepoint V0 Trise. Von Ton V? Tfall Toff
0.000000000000000000us 0 0.010us 5 32.552083333333335702us 5 0.010us 0


The error is:

PWL time, value pairs out of chronological order in source V1
3.25521e-005 is not before 1e-008

it already occurs on the first line.

--
Christoph

Am 25.04.2025 um 12:09 schrieb Christoph via groups.io <kuku@...>:



Am 25.04.2025 um 11:49 schrieb Mathias Born via groups.io <mathias.born@...>:

I'm really trying hard to make the error messages clear, but there is always room for improvement.

The message "time value pairs for V1 out of chronological order" means that there are at least two pairs (t1,y1) and (t2,y2) where t2<=t1.
It's difficult to find the location in the generated data. Easier it would be to avoid the situation at the side where the data is generated.

--
Christoph

Best Regards,
Mathias



 

On Fri, Apr 25, 2025 at 07:49 AM, Christoph wrote:
I'm assuming that the file format is ...
The file format is described in the LTspice help (Help->LTspice Help or F1) under Circuit Elements -> Voltage Source in the section Arbitrary Piece-Wise Linear Voltage Source.
?
There is no structure to the sequence of datapoints. Each point defines the voltage at a point in time. LTspice connects these points with straight lines from the previous point. The PWL source has no knowledge of Trise, Ton, Tfall, or Toff. It's just a sequence of (time, voltage) pairs.?
?
The FILE=<filename> format just allows the (time, voltage) pairs to be read in from a file rather than included directly on the spice line that defines the voltage source.
?
There are a few features which allow easier definition of the time points, most importantly, a "+" before the time value defines a relative time, the given value is the difference between the new time point and the previous time point. There is also an option for a TIME_SCALE_FACTOR parameter on the PWL source which could be set to 1u to define all your times in microseconds rather than seconds, so you don't? need the "u" multiplier on each time point value.??
?
As others have said, if you want to define pulsed waveforms you should perhaps look at the section Time-Dependent Pulsed Voltage Source earlier in the same help page.
?
?


 

On Fri, Apr 25, 2025 at 09:59 AM, Christoph wrote:
could it be that I'm assuming a different file format as I posted in the other email:
File format?? No.? The file formal for a PWL file is ordinary text.
?
Data format?? Possibly.
?
PWL data is always pairs of numbers, where the first number of the pair is time, and the second number is the voltage or current.? This is very well documented and every SPICE since the beginning of time uses the same format.

Syntax: Vxxx n+ n- PWL(t1 v1 t2 v2 t3 v3...)

Note that "t1 v1" is the first pair, "t2 v2" is the second pair, and so on.
?
PWL means "piece-wise linear".? The data points describe a set of points, and then LTspice "connects the dots" between the points, giving you a piece-wise linear waveform.
?
Timepoint ??????????????????????????V0 Trise. ??Von Ton ?????????????????????????????????????V? ?Tfall ??????Toff
0.000000000000000000us 0 ?0.010us 5 ???32.552083333333335702us 5 ??0.010us 0
I don't know where you got that from, but it definitely does not describe PWL.? That is similar to the description of a SPICE "PULSE" source, not PWL.? But it is incorrect for PULSE too.? I think it is not any SPICE syntax.
?

Some (undocumented) data formatting?
PWL is not "undocumented".? What you used above is undocumented, and incorrect, and definitely will not work for a PWL file.
?
Andy
?


 

Christoph,
?
Off-topic:
?
By the way, you can register your other email address that you used earlier today that bounced.? Then you can send messages to this group from your university address and they won't bounce.? It is known as an "Email Alias" for purposes of these groups.
?
To do that, go to the LTspice group webpage, then click your name in the upper right corner and choose "Settings".? Or go directly to .??Then scroll down to "Advanced Settings for Email Aliases" and click there.? Then type your alternate email address into the box above the "Add Email Alias" button, and then click that button.
?
Adding an Email Alias tells the [LTspice] group server to accept emails send from your Alias address as if it was sent from the address you normally use for this group, and it won't bounce.
?
From Groups Help:
If the email provider you use for your Groups.io account sends your outgoing messages from an address that is different from your account address, or if you want to be able to send messages to groups from an additional address (for example, a work address) that is different from your account address, you can add an email?alias?to your account:
?
Andy
?


 

开云体育

Thanks, Andy.
I‘m after it.
Probably my formula is producing this wrong input.
And what my confusion about the file syntax is concerned, I‘m on track again . I was totally besides the rails :)
It‘s indeed pointwise drawing the curve.
I was drawing one pulsetrain per line:

tr/tf=trise/tfall
Starting time 0V
time+tr high 5V
time+tr+ton 5V
time+tr+ton+tf 0V

Still gotta find the error in the generator.
Christoph?



Am 25.04.2025 um 13:34 schrieb Andy I via groups.io <AI.egrps+io@...>:

?
Christoph,
?
In the first of the two files you uploaded (kuku_pwm_pulses.txt.zip), you have some data points that are not sequential.? The very first line is this:
0.000us 0 +0.010us 5 +0.000us 5 +0.010us 0?
which has a point at 0.000 us, then one at 0.010 us, then another at 0.010 us, and one at 0.020 us.? The second and third points are a problem because they are both at the same moment in time, not incrementally increasing.? Fortunately they both have the same voltage or current value (5 V or 5 Amps), but it is fundamentally in error for duplicating a time point.
?
That might be the cause of an error.? Hard to say for sure.
?
But later in the file, I see lines such as these:
8398.438us 0 +0.010us 5 +-1.598us 5 +0.010us 0?
8463.542us 0 +0.010us 5 +-3.195us 5 +0.010us 0?
and those are surely wrong.? ?The time increments are negative, coming before the previous time points.? Those need to be fixed.? (They are also confusing to read, so there is that too.)
?
Andy
?
?


 

开云体育

Thanks, Dennis, for pointing that out. At the moment I'm trying to get the points row defined by fixed time points with relative steps between each new pulse.
It is allowed to change between absolute and relative timepoints, right? Is the unit "u" or "us" in the format of the time values?

It seems that the error occurs after 64 steps:

0.00423177 is not before 0.00423177

I uploaded the project file and a little explanation. Thanks.

--
Christoph

Am 25.04.2025 um 16:31 schrieb Dennis <dennisc@...>:

On Fri, Apr 25, 2025 at 07:49 AM, Christoph wrote:
I'm assuming that the file format is ...
The file format is described in the LTspice help (Help->LTspice Help or F1) under Circuit Elements -> Voltage Source in the section Arbitrary Piece-Wise Linear Voltage Source.
?
There is no structure to the sequence of datapoints. Each point defines the voltage at a point in time. LTspice connects these points with straight lines from the previous point. The PWL source has no knowledge of Trise, Ton, Tfall, or Toff. It's just a sequence of (time, voltage) pairs.?
?
The FILE=<filename> format just allows the (time, voltage) pairs to be read in from a file rather than included directly on the spice line that defines the voltage source.
?
There are a few features which allow easier definition of the time points, most importantly, a "+" before the time value defines a relative time, the given value is the difference between the new time point and the previous time point. There is also an option for a TIME_SCALE_FACTOR parameter on the PWL source which could be set to 1u to define all your times in microseconds rather than seconds, so you don't? need the "u" multiplier on each time point value.??
?
As others have said, if you want to define pulsed waveforms you should perhaps look at the section Time-Dependent Pulsed Voltage Source earlier in the same help page.
?
?


 

开云体育

This is a test, whether both of my emails now work. Please ignore

--
Christoph


Am 25.04.2025 um 18:39 schrieb Andy I via <AI.egrps+io@...>:

Christoph,
?
Off-topic:
?
By the way, you can register your other email address that you used earlier today that bounced.? Then you can send messages to this group from your university address and they won't bounce.? It is known as an "Email Alias" for purposes of these groups.
?
To do that, go to the LTspice group webpage, then click your name in the upper right corner and choose "Settings".? Or go directly to .??Then scroll down to "Advanced Settings for Email Aliases" and click there.? Then type your alternate email address into the box above the "Add Email Alias" button, and then click that button.
?
Adding an Email Alias tells the [LTspice] group server to accept emails send from your Alias address as if it was sent from the address you normally use for this group, and it won't bounce.
?
From Groups Help:
If the email provider you use for your account sends your outgoing messages from an address that is different from your account address, or if you want to be able to send messages to groups from an additional address (for example, a work address) that is different from your account address, you can add an email?alias?to your account:
?
Andy
?