# How to: Do Simulation

The guide demonstrates how to create expressions that generate a sinusoidal signal and a saw signal for simulation and testing purposes.

Open Monokot Server Administrator and double-click *Scripts* on the *Server Explorer* pane. Click *New Expression* and set the name *Sin* for the expression that appears. Insert the following code into the expression code editor:&#x20;

```javascript
// "token" is a property in which you can put a custom value that 
// will be available during the next code execution
context.token += 0.1;

var value = Math.sin(context.token) * 50;
return value;
```

Go to the *Triggers* tab and click *Add Periodic*. Now, we have created an expression that will be executed every 500 ms.

<figure><img src="https://4282443477-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3cwznMbQcEQxtnjiRDYX%2Fuploads%2FnFe1fRHZfWGkSEcZvHc4%2FHow%20to_%20Do%20Simulation%20(360054648511)_mceclip0.png?alt=media&#x26;token=a998600b-3430-4a96-bfbd-08c0c65e8524" alt=""><figcaption></figcaption></figure>

In the same way, create a second expression named *Saw* and specify a periodic trigger for it, but to simulate the saw signal, use the following code:

```javascript
// ...by default, token is null
if (context.token == null)
    context.token = 0;
else context.token += 1;

if (context.token > 50)
    context.token = -50;

var value = context.token;
return value;
```

In order for the changes to take effect on the server, click the Sync button. Now, if you write the data (for example, in InfluxDB) generated by these expressions, you will see something similar as in the figure below:

![](https://4282443477-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3cwznMbQcEQxtnjiRDYX%2Fuploads%2FvuOIThVFT9LEE99z6kcG%2FHow%20to_%20Do%20Simulation%20\(360054648511\)_mceclip0%20-%201.png?alt=media\&token=0b99f1e9-b448-4e20-a4f4-c92b97a92b32)
