how can i have step input signal in signal editor?

I have 3 signals for a SCARA robot. I want to input a step input for these 3 signals in the Signal Editor. How should I enter the time and data inputs in the Signal Editor?
x=[1.412,0.8696,1.412,1.412,1.821,1.545,1.8312.382,1.412]
y=[-3.142,-2.088,-3.142.-3.142,-3.142,-2.31,-3.142,-3.142,-3.142]
z=[-0.086,-0.086,-0.086,-0.186,-0.186,-0.186,-0.186,-0.386,-0.086]
t=[0,1,1.5,2,3,4,4.5,5,6]

1 Comment

Umar
Umar on 1 Sep 2024
Edited: Umar on 1 Sep 2024

Hi @elham,

You asked, “ How should I enter the time and data inputs in the Signal Editor?

Please see my response to your comments below.

You have three signals (x, y, z) that represent positions or movements of the SCARA robot, and you want to configure these signals in the Signal Editor with respect to specific time intervals. You also provided the time data, indicating how these signals change over time. Using the information you've given, access the Signal Editor via the command line by typing signalEditor or through the Root Inport Mapper by selecting Signals > New MAT-File. Select Insert > Signal to create a new signal. You will need to repeat this process for each of your signals (x, y, z). For each signal, you will need to enter the time (t) and the corresponding data values ( x, y, z). Here’s how to do it:

For Signal x, in the Author Signal dialog box, set:
Time: [0, 1, 1.5, 2, 3, 4, 4.5, 5, 6]
Data: [1.412, 0.8696, 1.412, 1.412, 1.821, 1.545, 1.8312, 2.382,     1.412]
For Signal y, Set:
Time: [0, 1, 1.5, 2, 3, 4, 4.5, 5, 6]
Data:[-3.142, -2.088, -3.142, -3.142, -3.142, -2.31, -3.142, -3.142, 
-3.142]
For Signal z,Set:
Time: [0, 1, 1.5, 2, 3, 4, 4.5, 5, 6]
Data: [-0.086, -0.086, -0.086, -0.186, -0.186, -0.186, -0.186, 
-0.386, -0.086]

After entering the data, you can modify properties such as the signal name, unit, and interpolation method. This can be done in the Signal Properties section. Once the signals are entered, you can visualize them on the plot. If the signals do not align as expected, you can adjust them using the Snap to Grid feature for better precision.

To save your work, select the Save button in the Signal Editor. This will create a MAT-file that can be used for simulations or linked to root-level ports.

For more information regarding creating and editing a signal, please refer to the following documentation at the link provided below.

https://www.mathworks.com/help/simulink/ug/insert-and-edit-signal-data.html

Hope this helps. Please let me know if you have any further questions.

Sign in to comment.

Answers (2)

Hi Elham,
I understand that you have 3 step signal inputs which you want to plot in the signal editor.
You can follow the following steps to input the step signals for your robot:
1. Open Signal Editor by typing the following command in the command line of MATLAB:
>> signalEditor
2. Define your signals programatically by running the following MATLAB script:
% Define the time vector
t = [0, 1, 1.5, 2, 3, 4, 4.5, 5, 6];
% Define the data vectors
x = [1.412, 0.8696, 1.412, 1.412, 1.821, 1.545, 1.831, 2.382, 1.412];
y = [-3.142, -2.088, -3.142, -3.142, -3.142, -2.31, -3.142, -3.142, -3.142];
z = [-0.086, -0.086, -0.086, -0.186, -0.186, -0.186, -0.186, -0.386, -0.086];
% Create a timetable for each signal
x_signal = timetable(seconds(t)', x');
y_signal = timetable(seconds(t)', y');
z_signal = timetable(seconds(t)', z');
3. To import the signals, open the Signal Editor and choose the Import option. A window will appear where you can select the signals. Proceed by selecting the following signals: x_signal, y_signal, z_signal, and t.
Here is the output from the Signal Editor, displaying the configured step inputs for the SCARA robot signals.
I hope it helps.
Thanks

5 Comments

thank you for your comments.I have already entered these signals into the Signal Editor, and the shape of the signals exactly matches your output signals. I am sending the figure below. I mean an input in the shape below. I don't know how to enter my data.
Hi @elham,
Please read my above comments which will help you guide through the process you are seeking. I even provided link to documentation as well.
These signals are not step inputs. I want to enter them as step inputs in the Signal Editor. I have carefully reviewed the links. I don't know the order in which to arrange these numbers to achieve a step input similar to what I sent in the attached image.
Hi Elham,
There needs to be a criteria to convert x,y and z into corresponding arrays of step values and this criteria should be unique to your case.
Upon further investigation I found that, the step value changes from 0 to some max value(0.2, 0.4 and 0.3 for x, y and z respectively) when input signal's value decreases for the first time.
For x signal, it happens at t = 0.5 (traced from provided figure since data is provided for t = 0.5). Similarily, for y and z signal, it happens at t = 1.5 and 2 sec respectively.
From the attached image, I have derived these input signals:
t = [0, 0.5, 1, 1.5, 2, 3, 4, 4.5, 5, 6];
% Define the step signals
x = [0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2]; % Max value 0.2, changes at 0.5 sec
y = [0, 0, 0, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4]; % Max value 0.4, changes at 1.5 sec
z = [0, 0, 0, 0, 0.3, 0.3, 0.3, 0.3, 0.3]; % Max value 0.3, changes at 2 sec
Then, you can insert Step waveform which asks to input data corresponding to time.
Please refer to the attached image to look into step signal corresponding to x signal.
However, the actual input data requested by @elham are not utilized in the code to produce the desired step outputs for the SCARA robot. The code should not rely on manually defined specific points to "trick" the robot. Instead, a step function that is dependent on the input data should be designed.
% Time vector
t = [0, 1, 1.5, 2, 3, 4, 4.5, 5, 6];
% Data
x = [ 1.412, 0.8696, 1.412, 1.412, 1.821, 1.545, 1.831, 2.382, 1.412];
y = [-3.142, -2.088, -3.142, -3.142, -3.142, -2.31, -3.142, -3.142, -3.142];
z = [-0.086, -0.086, -0.086, -0.186, -0.186, -0.186, -0.186, -0.386, -0.086];
% Plot
figure
subplot(311)
plot(t, x, 'o--'), grid on
title('input x data')
subplot(312)
plot(t, y, 'o--'), grid on
title('input y data')
subplot(313)
plot(t, z, 'o--'), grid on
title('input z data'), xlabel('t')

Sign in to comment.

Hi @elham,

To achieve a step input configuration, you need to make that the data values remain constant until the next specified time point. For instance:

For signal x, if you want it to rise at t = 1 and stay constant, the structure should look like: From (t = 0 ) to (t = 1 ), Constant value (e.g., 1.412). At (t = 1) Jump to a new constant value (e.g., 1.821). From here on, continue at the new value for the remaining duration.

Here’s how to arrange the data for each signal:

Rearranging Data for Step Inputs

   Signal x
   Time: [0, 1, 2, 3, 4, 5, 6]
    Data: [1.412, 1.412, 1.821, 1.821, 1.8312, 2.382, 1.412]
   Signal 
   Time: [0, 1, 2, 3, 4, 5, 6]
    Data: [-3.142, -3.142, -2.31, -2.31, -2.31, -3.142, -3.142]
   Signal z
   Time: [0, 1, 2, 3, 4, 5, 6]
    Data: [-0.086, -0.086, -0.186, -0.186, -0.186, -0.386, -0.086]

Entering Data in Signal Editor

At this point, I know that you are already familiar with Signal Editor but I will provide instructions anyway like I did in my previous comments as outlined below.

Open Signal Editor via the command line by typing signalEditor or select Signals > New MAT-File through the Root Inport Mapper.

For each signal (x, y, z) Select Insert > Signal

In the Author Signal dialog box, enter the rearranged time and data values as outlined above. Modify properties like the signal name, unit, and interpolation method in the Signal Properties section.

Visualizing the Step Inputs

After entering all signals, visualize them on the plot within the Signal Editor. If necessary, use the Snap to Grid feature to fine-tune the data points for better alignment.

Saving the Configuration

Once satisfied with the setup, click the Save button to create a MAT-file for further simulations or linking to root-level ports.

Please make sure that you select the appropriate interpolation method (e.g., "Zero-Order Hold") for step inputs to maintain the desired constant value between the defined time intervals.

In case, you need more guidance or you need detailed steps on signal creation and editing, I will consider reviewing the official MathWorks documentation:

https://www.mathworks.com/help/simulink/ug/insert-and-edit-signal-data.html

Hope, at this point you should be able to configure the SCARA robot signals effectively in the Signal Editor and represent them as step inputs as required. Please let me know if this helped resolve your problem.

25 Comments

Hi @Umar,
The OP @elham has provided the desired step outputs based on the given x, y, z input data. But @elham is struggling to find an approach or mathamatical fomula to make the "output = function(input)".
% Time vector
t = [0, 1, 1.5, 2, 3, 4, 4.5, 5, 6];
% Input Data
x = [ 1.412, 0.8696, 1.412, 1.412, 1.821, 1.545, 1.831, 2.382, 1.412];
y = [-3.142, -2.088, -3.142, -3.142, -3.142, -2.31, -3.142, -3.142, -3.142];
z = [-0.086, -0.086, -0.086, -0.186, -0.186, -0.186, -0.186, -0.386, -0.086];
% Desired outputs
T = interp1(t, t, 0:0.001:6);
out1= 0.2*heaviside(T - 0.5);
out2= 0.4*heaviside(T - 1.5);
out3= 0.3*heaviside(T - 2.0);
% plot results
tl = tiledlayout(2, 3, 'TileSpacing', 'Compact');
nexttile
plot(t, x, 'o--'), grid on, title('input x')
nexttile
plot(t, y, 'o--'), grid on, title('input y')
nexttile
plot(t, z, 'o--'), grid on, title('input z')
nexttile
plot(T, out1, 'linewidth', 1.5), grid on, title('step output x'), ylim([-0.1, 0.5])
nexttile
plot(T, out2, 'linewidth', 1.5), grid on, title('step output y'), ylim([-0.1, 0.5])
nexttile
plot(T, out3, 'linewidth', 1.5), grid on, title('step output z'), ylim([-0.1, 0.5])
The attached image actually shows a pattern from an RRR robot. I want to apply step inputs to my SCARA RRP robot by modeling them based on these input values. I've watched the video multiple times to implement the pattern on my robot's data, but I still haven't achieved satisfactory results. That's why this question has arisen in my mind, wondering if there are specific calculations involved. I have no problem with entering the data into the Signal Editor, but I can't figure out the logic or order in which the instructor placed these numbers. I appreciate all your collaboration.

Hi @Sam Chak,

Thanks for providing clarification regarding @Elham issue. However, I did notice the screenshot and you are using signal editor but when I tried to study the documentation, it displayed the following message. Apparently it was introduced for Matlab version R2007a. Afterwards, for version R2019a, they stopped recommending it and advice to use signalEditor instead. Please see attached.

Hi @Elham,

Could you please share the link to video that involves implementing the pattern on your robot’s data, so we can match apples to apples.

Thank you for helping me with my issue. I have provided the link to the video below for further review. This video is related to MATLAB 2021. In the video, Signal Builder is used, but I have used Signal Editor instead, which has replaced it in the newer version.
https://www.youtube.com/watch?v=qku7HLpwFLM
Hi @elham,
The video you shared briefly demonstrates how to create the step input signals. However, the step input signals do not clearly depend on your {x, y, z} data shown below.
% Time vector
t = [0, 1, 1.5, 2, 3, 4, 4.5, 5, 6];
% Input Data
x = [ 1.412, 0.8696, 1.412, 1.412, 1.821, 1.545, 1.831, 2.382, 1.412];
y = [-3.142, -2.088, -3.142, -3.142, -3.142, -2.31, -3.142, -3.142, -3.142];
z = [-0.086, -0.086, -0.086, -0.186, -0.186, -0.186, -0.186, -0.386, -0.086];
I am confident that you can follow @Shivam's demonstration on using the Signal Editor (a point-based interpolation tool), and @Umar can advise you on how to construct them using pure mathematics, with formulas that can be transferred to Python, C++, Mathematica, and other programming languages.
Umar
Umar on 3 Sep 2024
Edited: Umar on 3 Sep 2024

Hi @Elham,

Please see my response to your comments below.

You mentioned,“ I've watched the video multiple times to implement the pattern on my robot's data, but I still haven't achieved satisfactory results. That's why this question has arisen in my mind, wondering if there are specific calculations involved.

So, after watching the video link provided by you, the author is creating three step signals corresponding to the robot's joint angles using the Signal Builder dialog. He defined the following parameters for each step signal as

Signal 1: Step amplitude of 0.2 radians, activating at 0.5 seconds.

Signal 2: Step amplitude of 0.4 radians, activating at 1.5 seconds.

Signal 3: Step amplitude of 0.3 radians, activating at 2 seconds.

Then, he dragged the necessary blocks to represent three-degree-of-freedom (3-DOF) manipulator by including blocks for the robot's dynamics and kinematics. Afterwards, he connected the output of the Signal Builder to the inputs of the robot model to feed the joint angles and also connected the output of robot model (joint angles) to the PID Controller input. Also, using the Scope to compare the reference trajectory (from the Signal Builder) with the actual trajectory output from the robot model. The reason for your error was due to x,y, and z data not set in radians.

However, I did some research and found a video link that should help you achieve your goal using signal editor in simulink.

https://youtu.be/5494D0X7nf4?si=wfi0CNV6H4rXwEbw

Hope this answers your question.

The pattern data of the model is completely different from my data. I just don't know what values to use for the step input based on my data. I have checked all the videos. For example, at 0.5 seconds, a value of 0.2 radians is used... How are the times 0.5, 1.5, and 2 seconds determined? For instance, in my data, the maximum value of signal x is 2.382. Should I use this maximum value for the step input for each signal? And how should I determine the timing sequence?

Hi @elham,

To address your question effectively, I need to break down the process of defining step inputs for your robot's joint angles in a systematic manner. The key aspects to consider are the amplitude of the step signals, the timing of these signals, and how they relate to your specific data.

Understanding Step Inputs

In the context of control systems and robotics, step inputs are used to simulate changes in the desired state of a system—in this case, the joint angles of your robot. The step inputs you mentioned (0.2 radians at 0.5 seconds, 0.4 radians at 1.5 seconds, and 0.3 radians at 2 seconds) are designed to represent specific commands to the robot's joints over time.

Determining Amplitude Values

The amplitude values for your step inputs should be based on the operational range of your robot's joints. If your data indicates that the maximum value of signal x is 2.382, you might consider using this value as a reference point. However, it is crucial to ensure that the values you choose do not exceed the physical limits of your robot's joints. For instance, if your robot's joint can safely operate within a range of -2.5 to 2.5 radians, then using a step input of 2.382 radians is acceptable. If you want to create a more gradual response, you might opt for lower values, such as 1.5 or 2.0 radians, depending on the desired performance.

Timing Sequence

The timing of your step inputs is equally important. The times (0.5, 1.5, and 2 seconds) in the example you provided were likely chosen based on the dynamics of the robot and the desired response time. To determine appropriate timing for your signals, consider the following:

Response Time: How quickly do you want your robot to respond to changes in joint angles? If your robot has a fast response time, you may want to use shorter intervals between step inputs.

Data Analysis: Analyze your data to identify key moments where changes in joint angles occur. For example, if your data shows significant changes at specific timestamps, you can align your step inputs with these moments.

Simulation Testing: It may be beneficial to run simulations with various timing sequences to observe how your robot responds. This iterative approach allows you to fine-tune the timing based on performance.

Here’s a structured guide to help you effectively utilize the Signal Editor in Simulink for robot control based on the video link that I shared with you.

https://youtu.be/5494D0X7nf4?si=wfi0CNV6H4rXwEbw

Configure Signal Editor

Double-click on the Signal Editor block to open its properties. In the Signal Properties settings, click the button to create new signals. A new window will open displaying the scenario for your signals.

Create Signals for Each Joint

You will need to create three signals corresponding to the three joints of your robot:

For Joint 1:

Click on the checkbox to reveal the existing signal (it will be blank initially).

Double-click on the signal name and rename it to Joint 1.

Add rows by clicking the appropriate button and enter the time values:

Time: 0, 0.5, 1, 1.5, 2, 4 Data: 0, 50, 110, 110, 60, 0

Right-click on the plot area and select Zoom and Pan > Fit to View to visualize the signal.

For Joint 2:

Right-click in the Signal Editor and select Insert > Blank Signal Rename this signal to Joint 2.

Enter the time and data values: Time: 0, 0.5, 1, 1.5, 2, 4 Data: 0, 45, 60, 60, 20, 0

Hide this signal by unchecking the checkbox next to it.

For Joint 3:

Insert another blank signal and rename it to Joint 3. Enter the time and data values:

Time: 0, 1.5, 2, 3, 4 Data: 0, 4, 0, 0, 0

Make sure this signal is checked to display.

Define Signal Units and Interpolation

Click on each signal and specify their units:

Joint 1: Degrees Joint 2: Degrees Joint 3: Meters

Check the Interpolate Data option for each signal to ensure smooth transitions between data points. Click Apply after setting units and interpolation for each joint.

Save Your Configuration

Before closing the Signal Editor, save your configuration by clicking on the save icon or using File > Save. Name your signal file appropriately for future reference.

Connect to the Robot Model

Use appropriate blocks (like the PS Converter) to convert the degrees to radians if necessary, ensuring that the robot receives the correct input format. Connect the outputs of the Signal Editor to the inputs of your robot model.

Run the Simulation

Click on the Run button in Simulink to start the simulation. Observe the robot’s movements according to the defined trajectories

Hopefully, following these instructions should help you get started with project now.

i am deeply grateful for your guidance,im gonna try your solutions.hope to achieve favorable outcomes.
"I followed the guidance provided ..., did some research, and I successfully plotted the step response. However, in the attached image, my system experiences oscillations before the step response. I have not entered any additional data in the Signal Editor. Can anyone help me with this issue?"
my x signal:
time:[0 0.5 0.5 10]
data:[0 0 2.382 2.382]
Hi @Elham,
Can you share the screenshot of your simulink model along with blocks utilized with in model
i have loaded my simulink modek below...
Hi @Elham,
Can you do me a favor, connect signal block directly to scope, and tell me what the signals output looks like?
In previous comment, I have attached the output using the scope, but I will definitely attach it again below... Thank you for your follow-up...
Hi @Elham,
This is not what I meant. What I want you to do is troubleshooting this problem. So, connect signal block outputs q1,q2 and q3 directly to scope and run the simulation and observe the signals output. I would like to isolate the problem. Hope you understand.
I have connected and attached the outputs of q1, q2, q3, as well as the outputs of q1m, q2m, q3m, to the scope. If any additional data is needed, I will send it to you.

Hi @Elham,

After observing the plots you provided shows minor oscillations and watching the YouTube video which was shared by you does not show any oscillations as shown attached.

So, based on these observations, I am drawing the following conclusions due to the oscillations on your plot:

*The PID gains (P, I, D) may not be set optimally, leading to excessive overshoot and oscillations.

*The initial values of the integrator or other states in the PID controller might be causing transient behavior.

*If the system is using a discrete-time controller, the sampling time may not be configured properly, leading to aliasing or instability.

*The system may be improperly configured regarding the PID block and its parameters, such as external reset or tracking mode.

To mitigate these oscillations, consider the following approaches:

Damping Adjustment: Check the parameters of your system, particularly the damping ratio. Increasing the damping ratio can help reduce oscillations.

Input Smoothing: Instead of a step change, you might want to implement a smoother transition using a ramp or a sigmoid function to gradually increase the input value.

Simulation Settings: Make sure that your simulation settings, such as the solver type and step size, are appropriate for the dynamics of your system. A smaller step size may yield more accurate results.

Here’s a simple example of how to implement a smoother input using a ramp function:

time = [0 0.5 10];
data = [0 2.382 2.382];
ramp_time = linspace(0, 0.5, 100);
ramp_data = linspace(0, 2.382, 100);

If the problem still persists after following above mentioned steps, review the PID controller documentation

https://www.mathworks.com/help/simulink/slref/pidcontroller.html

Also, review the YouTube video shared by you.

*Make sure feedback loop is correctly configured to prevent unexpected oscillations.

*When making adjustments, change one parameter at a time to isolate effects and understand their contributions to the oscillation behavior.

Hope, this should help resolve your problem.

thank you for your guidance...i will check them...
Hi @elham, please consider sharing the Simulink slx file so that @Umar can look into problem directly.
Hi @Sam Chak,
It would be better idea if you take initiative to take a look in to this problem directly. I have contributed enough and it is turning into a science project.
It would be beneficial for you to identify the specific knowledge that @elham may be lacking in order to solve the problem. You can then gradually guide him on how to achieve these goals. However, the more detailed technical steps you provide, the greater the risk of confusion for him—and for observers like me.
The following steps you listed do not truly address the actual "mathematical" problem related to the desired transient behavior that @elham wishes to achieve. It is important to note that the issue did not arise from MATLAB or Simulink.
  • Rearranging Data for Step Inputs
  • Entering Data in Signal Editor
  • Visualizing the Step Inputs
  • Saving the Configuration
  • Understanding Step Inputs
  • Determining Amplitude Values
  • Timing Sequence
  • Response Time
  • Data Analysis
  • Simulation Testing
  • Configure Signal Editor
  • Create Signals for Each Joint
  • Save Your Configuration
  • Connect to the Robot Model
  • Run the Simulation
  • Damping Adjustment
  • Input Smoothing
  • Simulation Settings
Hi @Sam Chak,
It sounds like you are trying to address Elham’s specific knowledge gap such as lacking understanding in areas like system dynamics, control theory, or signal processing, so that is why you are suggesting me to provide targeted resources which includes foundational literature on control systems, tutorials on MATLAB/Simulink, or practical examples of similar problems. Sounds good.
I'm working on robot control for the first time, and I didn’t take robotics-related courses in university. That’s why it’s taking me some time to complete the tasks.
This issue pertains not to robotics, but to the pure mathematics of mass-spring-damper that describes the desired response signal, which is typically covered in degree-level S.T.E.M. courses. You should provide the Simulink file that was requested earlier so that we can have a closure on this thread.
Please click the paperclip icon .
Hi @elham,
Please don’t take our comments as negative. I can assure you that @Sam Chak is very knowledgeable and kind person. He does help lot of OPs in the past by tackling complex problems and helped found solutions for them. We are here to help you. I don’t even have access to Simulink or Robotics toolbox, but still trying my best to help you find the solution, so you can achieve your desired goal.

Sign in to comment.

Categories

Asked:

on 1 Sep 2024

Commented:

on 10 Sep 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!