matlab programmed arduino output frequency error

Hi everyone :slight_smile:

I have been working with arduino mega 2560 R3 from my power electronics project. In which we program the board using matlab support package for arduino.
In the simulink program through which board will programmed, I gave the parameter configuration settings as follows

Type: Fixed point
solver: ode23 (Bogacki Shampine)
sampling Rate: auto
Target harware: Arduino Mega 2560
Baud rate:9600

The error is there in the output pulse frequency who frequency is reduced by 1000 times compared to actual pulse pattern frquency

Please suggest me what should I change in the configuration parameters to get rid of this frequency error.

What differential equation are you working with? Is possible you have a misplaced decimal point, wrong initial conditions, etc? It looks like the Bogacki Shampine is a numerical method for solving ode's that relays on a step size which is normally defined by h = b-a/n, is it possible that your step size is to big causing error in the expected output? I'm kind of just spit balling here but hopefully something in there helps.