How does the simualtor works internally?
![momos](https://simulide.com/p/core/modules/2c3734368b/assets/img/default_avatar.jpg)
Quote from momos on March 20, 2024, 11:23 amHello,
i was wondering how the simulator works internally.
As far as I can tell, there is the timerEvent method which runs every 50ms?
The circuit gets calculated “inside” the timer with an extra thread?, so I assume that electronic components like a
resistor are updated every 50ms like the timer?
What about the microcontrollers? They seem to be called inside the timerEvent too with
runEvent from e_mcu.cpp. How does this work with the clock speed of the MCU for example 16MHz for the ATmega328p?Is it also possible to run the simulator at speeds above the 100% real time? Like 300% real time for example?I really would like to understand this because it's really interesting to me.Best regards
Hello,
i was wondering how the simulator works internally.
As far as I can tell, there is the timerEvent method which runs every 50ms?
The circuit gets calculated “inside” the timer with an extra thread?, so I assume that electronic components like a
resistor are updated every 50ms like the timer?
What about the microcontrollers? They seem to be called inside the timerEvent too with
![arcachofo](https://simulide.com/p/storage/ultimatemember/2/profile_photo-80x80.png?1725762870)
Quote from arcachofo on March 20, 2024, 9:10 pmHi.
As far as I can tell, there is the timerEvent method which runs every 50ms?
The circuit gets calculated “inside” the timer with an extra thread?, so I assume that electronic components like a
resistor are updated every 50ms like the timer?
There are certain tasks that are executed in the timerEvent and then a concurrent thread is launched to do all the circuit calculations.
What about the microcontrollers? They seem to be called inside the timerEvent too with
runEvent from e_mcu.cpp. How does this work with the clock speed of the MCU for example 16MHz for the ATmega328p?This is done in a concurrent thread (runEvent), so not in the timerEvent.
MCUs or any other component work based in events.
Is it also possible to run the simulator at speeds above the 100% real time? Like 300% real time for example?
Currently it is not possible in SimulIDE, but it could be done (if the computer can keep with it).
Hi.
As far as I can tell, there is the timerEvent method which runs every 50ms?
The circuit gets calculated “inside” the timer with an extra thread?, so I assume that electronic components like a
resistor are updated every 50ms like the timer?
There are certain tasks that are executed in the timerEvent and then a concurrent thread is launched to do all the circuit calculations.
What about the microcontrollers? They seem to be called inside the timerEvent too with
runEvent from e_mcu.cpp. How does this work with the clock speed of the MCU for example 16MHz for the ATmega328p?
This is done in a concurrent thread (runEvent), so not in the timerEvent.
MCUs or any other component work based in events.
Is it also possible to run the simulator at speeds above the 100% real time? Like 300% real time for example?
Currently it is not possible in SimulIDE, but it could be done (if the computer can keep with it).
![momos](https://simulide.com/p/core/modules/2c3734368b/assets/img/default_avatar.jpg)
Quote from momos on March 21, 2024, 2:30 pmHi, thanks for the answer. One thing I'm still not really sure about is the "speed" of the simulator.
Do the AVRs run at their native clock frequency, e.g. 16MHz, while the electronic circuits run at 20Hz?
Hi, thanks for the answer. One thing I'm still not really sure about is the "speed" of the simulator.
Do the AVRs run at their native clock frequency, e.g. 16MHz, while the electronic circuits run at 20Hz?
![arcachofo](https://simulide.com/p/storage/ultimatemember/2/profile_photo-80x80.png?1725762870)
Quote from arcachofo on March 21, 2024, 9:49 pmDo the AVRs run at their native clock frequency, e.g. 16MHz, while the electronic circuits run at 20Hz?
The simulation engine does not run at any specific frequency, it is event driven, not clock driven.
What runs at 20 Hz is the "repaint" and other updates related to the the circuit canvas .
Do the AVRs run at their native clock frequency, e.g. 16MHz, while the electronic circuits run at 20Hz?
The simulation engine does not run at any specific frequency, it is event driven, not clock driven.
What runs at 20 Hz is the "repaint" and other updates related to the the circuit canvas .