# Control Simulation Events From a File

**URL:** <https://forum.plexim.com/t/control-simulation-events-from-a-file/430>\
**Category:** PLECS\
**Tags:** simulation-script, csv-file, automated-events\
**Created:** [May 9, 2018, 7:44am UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430 "2018-05-09T07:44:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vasileios\_tso](https://avatars.discourse-cdn.com/v4/letter/v/7ab992/32.png) [@Vasileios\_tso](https://forum.plexim.com/u/Vasileios_tso)\
**Post date:** [May 9, 2018, 7:44am UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/1 "2018-05-09T07:44:39Z")

</div>

Hello all,

Is it possible to have a .csv file to control events on my simulation in PLECS standalone?

For example, I would like to have two columns in my file, one for Time and one for Power values.

What I would like to achieve is to change the variable that corresponds to Power when the simulation time equals the time in column 1.

The csv file can look something like this:

Time | Power  
0.1 | 10  
1 | 20  
3 | 15

Thank you very much for your response.

---

<div class="post-metadata">

**Author:** ![Falk\_Kyburz](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@Falk\_Kyburz](https://forum.plexim.com/u/Falk_Kyburz)\
**Post date:** [May 9, 2018, 11:24am UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/2 "2018-05-09T11:24:58Z")

</div>

Hello Vasileios,

I would suggest to use the Initialization tab in the Simulation Parameters. Convert your values into two Octave arrays in a way the 1D Look-Up Table block can use it:

```auto
Time | Power
 0.0 | 10

```

```auto
 0.1 | 10

```

```auto
 0.1 | 20
   1 | 20

```

```auto
   1 | 15
   3 | 15

```

With this method you can output arbitrary waveforms using the modulo function.

See attached minimum example.

[arbgen.plecs](https://forum.plexim.com/uploads/short-url/xDGCrGeTaXiCePr9RHJnbfCuWQ0.plecs) (5.49 KB)

---

<div class="post-metadata">

**Author:** ![Vasileios\_tso](https://avatars.discourse-cdn.com/v4/letter/v/7ab992/32.png) [@Vasileios\_tso](https://forum.plexim.com/u/Vasileios_tso)\
**Post date:** [May 9, 2018, 11:35am UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/3 "2018-05-09T11:35:39Z")

</div>

Hello Falk,

Thank you very much for your suggestion and for providing me with an example model. I think I can make it work as you suggest.

Let me think about it and try to implement it. The reason I am hesitant is that ideally, I would like to implement this on a ramp (change its Starting time and its Final output accordingly).

I will let you know as soon as I implement your example. Thank you once again.

---

<div class="post-metadata">

**Author:** ![Manu\_Parimi](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/manu_parimi/32/6_2.png) [@Manu\_Parimi](https://forum.plexim.com/u/Manu_Parimi)\
**Post date:** [May 10, 2018, 10:15am UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/4 "2018-05-10T10:15:31Z")

</div>

Hello,

The answer to your question has been addressed here – [https://forum.plexim.com/11/is-it-possible-to-import-waveform-data-into-plecs?show=12](https://forum.plexim.com/11/is-it-possible-to-import-waveform-data-into-plecs?show=12).

Regards,

Manu

---

<div class="post-metadata">

**Author:** ![Vasileios\_tso](https://avatars.discourse-cdn.com/v4/letter/v/7ab992/32.png) [@Vasileios\_tso](https://forum.plexim.com/u/Vasileios_tso)\
**Post date:** [May 10, 2018, 11:36am UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/5 "2018-05-10T11:36:11Z")

</div>

Thank you Manu,

I guess I wasn’t looking at the right place. That is exactly what I wanted to do.

Best regards,  
Vasileios

---

<div class="post-metadata">

**Author:** ![Mich4](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mich4](https://forum.plexim.com/u/Mich4)\
**Post date:** [May 17, 2018, 8:03am UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/6 "2018-05-17T08:03:35Z")

</div>

Hi this is nearly what i search so i maybe get the right answer here.

I want to Use diffent DutyCyle Vallues in one Curve maybe the first second from 0-1sec with 0.5 and from 1-2 sec with with 0.4 can i maybe realise that as well?

This is my first Projekt with Plecs so probebly there is an easy way for it but i didn t finde it right now.

---

<div class="post-metadata">

**Author:** ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)\
**Post date:** [May 17, 2018, 1:03pm UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/7 "2018-05-17T13:03:14Z")

</div>

Hello,

Yes, the material provided in this question is certainly an appropriate way for you to do what you mentioned.

Thanks,

Kris

---

<div class="post-metadata">

**Author:** ![Mich4](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mich4](https://forum.plexim.com/u/Mich4)\
**Post date:** [May 17, 2018, 2:09pm UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/8 "2018-05-17T14:09:36Z")

</div>

My Problem is that i don t know how to get the value in my PulsGenerator Block so that the value is given to the Variable “DutyCycle”.

I have a “graph” that is like the one from the example that [Falk Kyburz](https://forum.plexim.com/user/Falk+Kyburz) postet.

But i don t know how the step into my PulsGenerator works.

---

<div class="post-metadata">

**Author:** ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)\
**Post date:** [May 17, 2018, 3:12pm UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/9 "2018-05-17T15:12:05Z")

</div>

You would need to build up your pulse generator logic from other components. I attached a simple PLECS Standalone example where a step function changes the modulation index (duty cycle) for our prebuilt Symmetrical PWM block and the resulting pulse train can be seen in a Scope. You can see the implementation of the PWM block under its mask and can replace the step function with a table of duty cycle values as in the examples above.

[variable\_duty\_cycle.plecs](https://forum.plexim.com/uploads/short-url/vD5G589p9gTteCkiUbFd9FzbzrF.plecs) (5.22 KB)

---

<div class="post-metadata">

**Author:** ![Mich4](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mich4](https://forum.plexim.com/u/Mich4)\
**Post date:** [May 17, 2018, 5:28pm UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/10 "2018-05-17T17:28:15Z")

</div>

Thank you, that was exactly what i needed 🙂

---

<div class="post-metadata">

**Author:** ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)\
**Post date:** [June 10, 2020, 12:26pm UTC](https://forum.plexim.com/t/control-simulation-events-from-a-file/430/11 "2020-06-10T12:26:00Z")

</div>

UPDATE: As of PLECS 4.4, the PLECS library now has a “From File” component that can be used for this purpose.
