# 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="/files/Bv0SR7qCofd0fJMCw3YH" 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:

![](/files/K7zKeDOeXAX4oXzbgdOA)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.monokot.io/scripts/programming-examples/how-to-do-simulation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
