Quiz 7 (Homework 7): Scilab/Xcos Simulation

Note — this is a long homework. Do not leave it to the last day!

27 thoughts on “Quiz 7 (Homework 7): Scilab/Xcos Simulation

  1. Matlab? Yes, if you insist, sure (I think I wrote that somewhere as a footnote that it is allowed). But why would you want to do that?

  2. In Task 4, it asks for the range of 100g to 400g in which the step response overshoot must stay below 5% (the magic number is actually 4.6%, but never mind that).

    Then, in a separate section, the question is, if you add 10 grams (instead of 100), how long is the settling time? We can probably assume that it is longer, or…?

  3. Is there a way to plot a horizontal line in an already generated plot in Xcos? Specifically for locating the settling time in Task 4.
    Thanks

  4. A really good question. I looked at the plot window itself. The Ticks looked like they might be useful (Edit -> AxesProperties, select Y axis, click on “Ticks”), but I was unable to find a way to extend the ticks across the graph. I guess that’s why they are called tick marks.

    However, I think the Datatip Manager can help you — once you enable the Datatip Manager, you can drag a small rectangle along the curve and get its x and y values.

    Here is a kludge, but it works: Use a cmscope as normal, but also use the “To Workspace” block from the “sinks” palette. Connect “To Workspace” as you would connect a CScope. It can create a new array (right-click). By default the array is A with 128 elements, this needs to be adjusted depending on your red clock, i.e., the total datapoints you create. If we assume you kept the name A, then you can plot it with

    plot (A.time, A.values)

    The kludge consists of now adding a horizontal line via linspace. Let’s say you have 512 data points and want a horizontal line at 0.98. Then you create

    hline = linspace (0.98, 0.98, 512);

    and plot them jointly with

    plot (A.time, A.values, A.time, hline)

    • On a side note, there is a library called “scilab-plotlib”. It is described as plot functions matching those of Matlab. Unfortunately, these are not included in the CScope and CMscope functionality.

  5. What is the exact difference in purpose of an integrator, and a differentiator in terms of the controller? I understand the reason behind using one or the other calculation wise, but not in physical means. I know that the integrator reduces steady state tracking error, but what exactly does the differentiator do? I couldn’t find an answer in the book, but I am probably overlooking it.

    • I guess you are not referring to its realization in hardware, right? If you do, let me know so I can respond to that question.

      An integrator in a control element is responsible for the steady-state behavior. Consider the integrator as accumulating the error over time:

      $$
      A_I(t) = k_I \int_0^\tau \epsilon(\tau) \textrm{d}\tau
      $$

      where $A_I(t)$ is the integral component of the corrective action. You can consider $A_I(t)$ as the area under the curve of $\epsilon(t)$. The area under the curve is constant iff the control deviation is zero. And only then has the overall system reached equilibrium.

      A differentiator in the feedback loop amplifies high-frequency components. If used as a compensator in the feedback path, high-frequency components have a higher loop gain than low-frequency components. We have not yet discussed frequency-domain considerations, but we’ll get to this after the root locus method. However, you have already seen what the D-component does — it augments the first-order term relative to the zero-order term of the closed-loop characteristic polynomial. Therefore (Routh-Hurwitz!) it can give stability to a system, and it can dampen a tendency to oscillate. In fact, in a second-order system, the first-order term is the damping term.

  6. I have absolutely no idea how to use Scilab and don’t know where to begin for the quiz. I don’t even know how to recreate Figure 2 you included. What should I do/do you have any advice how to use this program? I would like to get a good grade on this quiz, but I only know how to do Task 1 and 2, which is only 10 out of 50 points.

    • Were you able to follow the in-class examples? If no, why didn’t you ask? And if yes, can you download and run the in-class examples that I uploaded to eLC?

      You probably got the the point where you start Scilab and use the Xcos button (or type xcos) to start the xcos module? Then you probably have a canvas for your model and a window with the palette browser open. If so, you should be able to put a step function on the canvas, add a csope and the corresponding red clock and make it show the step function.

      These simple steps should give you a start — something that you know what the result should look like. From there, try to build it up to higher complexity.

  7. I believe my block diagram is correct, but whenever I run the SciLAB from xCos it give me the error “invalid index” in the console. Any ideas?

    • I have not had this problem. It sounds like a look-up table issue, but you shouldn’t have one. Does removing the saturation function help?

      Can you send it to me so I can take a look?

        • I’d still be curious what this was. This is an error message that should really not be associated with a step function.

  8. Did you say that you were going to change the due date on Quiz 7 to be due on Tuesday(4-11-17) or is it still due tomorrow?

  9. For task 3, should kp and kd be chosen such that the steady state is approximately 0.5 for a weight of 200 grams?

    • The sensor is a balance between two photodiodes, meaning, its center position (= horizontal position) is represented by the value zero. This is the implicit setpoint. The balance should equilibrate at this point.

      A certain steady-state deviation is allowed, specifically, $\pm0.5$mm from that horizontal position. The reason is that the sensor deviates from the linear curve at large deviations.

      So, direct answer — the steady-state position needs to stay within 0.5mm of the zero position that is the setpoint.

  10. I’m having a couple problems while running my block diagram: 1) The “Prod_f” shows up as “A-” in the circle instead of a “X” . 2) when i run it, the graph is a flatline that runs continuously until I force stop it. I don’t know if they are related or not too. Any help would be be appreciated, thank you.

    • I think they are not related. The long runtime might be related to the simulation setup: you need to limit the simulation to a few seconds. At least, this is what it looks like to me.

      The Prod_f? Strange. Can you try this: Use a sine generator and connect both inputs to a multiplication function. Is the result a sine squared? (or, use a ramp, the output should be a parabola) If so, you can safely use it — it may have something to do with fonts.

  11. My position graph X(s) seems to have a steady state of about .35, however my understanding of the assignment says that the steady state should be 0. I don’t understand what could cause this since I am just using the same block diagram as yours (with the added double integration before the graph and a sensor gain of .1). I don’t believe the issue is in the controller because I don’t see any promising changes by playing around wth kp or kd.

    • Are you sure about that? If you look at the closed-loop equation in Task 2 (assume a constant mass), what is the steady-state step response? How would this fit in the context of Task 6?

      Side note: The critical design criterion is that the steady-state deflection of the beam stays within the linear range of the photodiode pair, thus the limit to $\pm$5 mm.

      • When I introduce an integral component, it does settle back to zero, however it never oscillates into the negative area. If I reduce the Kd enough, it will oscillate a little in the positive before it settles and slowly returns back to the horizontal origin.

        My steady state for both Task 1 and Task 2 is Fx/.0981kp. Not sure if this is correct, or if I am achieving anything close to the expected behavior, but I am a little stumped.

        • Yes, the integral component *will* force it to zero (this is what it does), question is, do we really need it?

          Let me ask a related question: If there is a steady-state deflection that is within the sensor linearity, does it hurt you in any way? Does it reduce accuracy?

          Keep in mind — ultimately, the current through the electromagnet is the proxy for the mass, meaning, what you need most is a very high correlation between this current and the applied weight — at steady state!

Leave a Reply

Your email address will not be published. Required fields are marked *