Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

learning Simulink

Status
Not open for further replies.

PG1995

Active Member
Hi

I'm working on my first Simulink model of series RC circuit. I hope that the modelling is okay but I'm getting the following error.

"Warning: Using a default value of 0.2 for maximum step size. The simulation step size will be equal to or less than this value. You can disable this diagnostic by setting 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics page of the configuration parameters dialog"

I had initialized R=5 and C=500*10^-6 in Matlab. I have attached Simulink model for RC circuit. Could you please guide me? Thanks.

Regards
PG
 

Attachments

  • rc_ckt.rar
    6.9 KB · Views: 266
  • RC_MODEL.jpg
    RC_MODEL.jpg
    13.4 KB · Views: 1,713
That is not an error, but just a warning.

I recommend that you go into the "model configuration parameters" menu. Set the solver to "fixed step" and "ode4". This will use the Runge-Kutty fixed step-size method of solving. This is not the fastest solver, but I find it works well and is less likely to give you problems. You also want to set the step size. I prefer to set it manually, and you can set it to 1e-6 to start, and modify from there. The step size should be much smaller than the time constant.
 
Belated thanks, Steve.

I did the recommended tweaks and it works now. I set R=5 and C=6*10^-6.

The model represents RC circuit and the step function represents a fixed DC voltage source. Here is the screenshot of the scope and sadly it doesn't make any sense to me. The maximum voltage should not go above the rated value of step function. The final value for step function is '3' and I presume that it can be taken to be maximum value for voltage. I have also attached the working model. Kindly help me with this. Thanks.

Regards
PG
 

Attachments

  • rc_screenshot.jpg
    rc_screenshot.jpg
    123.8 KB · Views: 733
  • rc_ckt_updated.rar
    7 KB · Views: 253
Last edited:
PG,

I see a very big mistake you made in that model. I'm sorry I didn't notice it before, but you are using the FCN block incorrectly.

First of all, instead of a function block, you should use a gain block for the 1/R and 1/C multiplications. That is more straightforward, and I just automatically assumed that that's what you did.

If you prefer to use the FNC blocks, it is certainly no problem, but then you need to change the formulas to u(1)/R and u(1)/C inside. This is because this block is a general arbitrary function block and you can have any number of inputs. In this case you have 1 input to each block, but that input is labeled as u(1).
 
Last edited:
Another thing you can do is to change the settings in the scope. If you double click on the scope, you will open the plot window. Then in the upper left corner there is a little icon that looks like a gear. It is next to the printer icon. Click on that icon and then go to the history tab and unclick the "Limit data points to the last 5000".

This is why your plot does not start at zero, because only the last 5000 points are being shown in the plot. Typically you want the entire time range in your plot. However, this might overuse your memory, and if it does, you can use the "decimation" parameter on the General tab. If you change this from 1 to 10 or 100 or 1000, then only every 10th 100th or 1000th point will be plotted. Be careful though because decimation can cause you to miss key aspects of the plot if it is changing rapidly.
 
Thanks a lot, Steve.

It works now. Attached is the working model. I have used R=5 and C=6*10^-6. Here is the screenshot of the scope.

Q1:
You can see in the screenshot that the output is a step function but this is not how the output of an RC circuit looks like. This picture shows the output of an RC circuit in response to step input.

Q2:
Further, I believe that Simulink is mostly a good tool for those who really understand control theory. For example, even the implementation of simple circuit like RC requires knowledge of control theory. But I believe that I'm wrong because I can see that it's widely used everywhere so it should offer something of value.

Q3:
I wanted to use decay exponential input instead of a step input. How do I do it? There is block "e^u" in "Math Operations" section and I tried to manipulate it but it didn't work. Thank you.

Best regards
PG
 

Attachments

  • simulink111.jpg
    simulink111.jpg
    84 KB · Views: 677
  • rc111.GIF
    rc111.GIF
    9.4 KB · Views: 865
  • rc_ckt_working.rar
    7 KB · Views: 461
It works now. Attached is the working model. I have used R=5 and C=6*10^-6. Here is the screenshot of the scope.

Good work.

Q1:
You can see in the screenshot that the output is a step function but this is not how the output of an RC circuit looks like. This picture shows the output of an RC circuit in response to step input.
LOL Your time constant is RC= 30 us, and you ran your simulation from 0 to 10 seconds. Obviously you are not going to se the exponential shape on that time scale. Zoom in the time axis to 1.0000 seconds to 1.0002 seconds and you will see it. Or, you can run the simulation from 0 to 0.0003 seconds an start you input step function at 0.0001 seconds rather than at 1 second.

Q2:
Further, I believe that Simulink is mostly a good tool for those who really understand control theory. For example, even the implementation of simple circuit like RC requires knowledge of control theory. But I believe that I'm wrong because I can see that it's widely used everywhere so it should offer something of value.
Simulink is a general numerical solution tool that is particularly good for nonlinear systems. In the old days we used to do numerical analysis with Fortran, and later with C, and Matlab. Now, it is typically done with Simulink to save time. I can build simulation programs more than ten times faster with Simulink than by programming it myself.

Q3:
I wanted to use decay exponential input instead of a step input. How do I do it? There is block "e^u" in "Math Operations" section and I tried to manipulate it but it didn't work. Thank you.
You can put a step function into an integrator and set the step value to -1, which creates a negative ramp function and then feed the negative ramp into the e^u function. Or you can grab the ramp block directly from the library, use a gain block to multiply by -1 and feed that into the e^u. By changing the slope of the ramp, you can change e^(-t) into e^(-at) where a is a constant which depends on the ramp slope.
 
Status
Not open for further replies.

Latest threads

Back
Top