Timer vs Counter, Data Types and Solver Types in Simulink
Hello everyone. Welcome to MAE Learning. In this article, we will explore timer vs counter. We will also discuss data types used in Simulink. Lastly, we will cover solver types.
Timer Vs Counter
1. Timer in Simulink
- A timer is used to track time.
- Example: If you want to turn on a signal after 5 seconds.
- In Simulink, you can use the Clock block to get the current simulation time.
- Use it with the Compare block to check if the time is > 5 seconds.
Example


2. Counter in Simulink
- A counter is used to count.
- Example: Every time a pulse arrives, the counter increments by 1.
- Simulink has a Counter block that counts on either the rising edge or the falling edge.
- You can also set a maximum count and a reset condition.


Examples
- Timer: Turns on the fan 3 seconds after the engine starts.
- Counter: Calculates distance after every 10 wheel rotations.
| Feature | Timer | Counter |
| Definition | It will track the time | Counts pulses or events |
| Input | Simulation time | Trigger signal (pulse) |
| Output | Time based condition (For example > 5 sec) | Number of counts (0,1,2,3…) |
| Example Block | Clock + Compare | Counter Free-Running / Counter Limited |
| Use Case | Fan after 3 seconds | Taking action after 10 pulses |
| Reset Option | Time reset occurs from simulation start | There is an option to reset the counter. |
Data Type
Default Data Type in MATLAB
- The default data type in MATLAB is double (double precision floating point).
- In Matlab if you write any variable a = 5, it is stored in double by default.
| Data Type | Description | Example | Automobile Use Case |
| double | Default stores numeric, decimal values | speed = 80.5 | Vehicle speed, battery voltage |
| single | Less memory, lower precision | temp = single(35.2) | Sensor data where memory is saved |
| int8 / int16 / int32 / int64 | Signed integers (negative + positive) | rpm = int16(3000) | Engine RPM, wheel rotation count |
| uint8 / uint16 / uint32 / uint64 | Unsigned integers (sirf positive) | soc = uint8(85) | Battery SOC percentage (0 to 100) |
| char | Stores a character or string | msg = ‘Error’ | DTC message (Diagnostic Trouble Code) |
| logical | True (1) Or False (0) values | flag = true | Engine ON/OFF status, brake switch |
| string | Text to string format | str = “EV Mode” | Drive mode display |
| cell | Mixed data types together | c = {80, ‘kmph’} | Speed with unit |
| struct | Data ko structure form me | car.speed = 120 | ECU parameters grouping |
| table | Tabular data store | T = table(speed, rpm) | Drive cycle data analysis |
Example
% Vehicle dataspeed = 80.5;ย ย ย ย ย ย ย ย ย % double, km/hrpm = int16(3000);ย ย ย ย % engine rpmsoc = uint8(85);ย ย ย ย ย ย % battery SOC %engineOn = true;ย ย ย ย ย ย % logicalmode = "EV Mode";ย ย ย ย ย % string

Solver Types
Solver in MATLAB/Simulink
- The solver’s job is to solve the system equations over time.
- Meaning, differential equations are created in your model, and the solver solves them step-by-step and gives the output.
- Example: The change in vehicle speed depends on acceleration. The solver will calculate the speed over time.
| Type | Description | Example Solver | Use Case in Automobile |
| Fixed-step | Each time step is equal (e.g. 0.01 sec, 0.1 sec) | ode1 (Euler), ode3, ode4 (Runge-Kutta) | Real-time ECU testing, HIL bench, controller design |
| Variable-step | Step size changes automatically (for error control) | ode45, ode15s, ode23t | Accurate plant modelling, vehicle dynamics simulation, battery thermal model |
We can change solver type from configuration parameter setting.

Example
- Fixed-step: If you set a 0.01 second step, the solver will solve equations every 0.01 seconds.
- Variable-step: If the system is smooth, it will take a large step. If the system is changing rapidly, it will take a small step.
Automobile Example
- Fixed-step: Cruise control ECU simulation, because the controller needs exact step size in real-time.
- Variable-step: Battery thermal model or vehicle longitudinal dynamics, where accuracy is more important.