I am running into a strange issue, using 4.9.7 on a LAUNCHXL-F28379D. Using the Random Numbers block, this however does not seem to give a number within the range (min,max) rather a much smaller range. When given a range 0,1. The output seems to be (0,~0.4). The seed is set to 0.5 and sample time to 0.
Thanks for the info. I have the same version of PLECS on my machine and ran your model with the parameters you specified but I am unable to replicate your results. Here is what I am getting:
Hi, thanks for clarifying that it’s when you are running on the MCU - I had missed that part!
The issue you are running into is based on how the random number generator is implemented in PLECS. All blocks in PLECS are open to inspection unless they are are basic building blocks (e.g. gains, addition, integrator, etc). If you look under the mask of how the random number generator is implemented in PLECS you’ll notice that it returns the results as a double while the MCU only supports float. So while code generation can makes it easy to take your controls and flash it onto the MCU these nuances can get you into trouble. This is specially true when you are generating code for a model that contains C-Scripts. You have to be very careful that the code implementing your feature can be supported by the HW you are going to be generating code for.
While in offline simulation you don’t have to worry about how long the algorithm might take to compute as the simulation is not running in realtime in the microcontroller you might run into issues or see unexpected results.
May I ask what is the purpose of using a random number generator in your model? Maybe there is an alternate solution that might be easier for the microcontroller to handle.