How do I create a button trigger that records a button press as a rising/falling edge in the scope?

1 次查看(过去 30 天)
I would like to produce a button that triggers a rising edge within a scope.
This will all be with respect to time and ideally I'd like to record the data as variables.
Amplitude vs time.

回答(1 个)

RANGA BHARATH
RANGA BHARATH 2023-7-10
Hi @Martin. Here is the solution and relevant images for your question.
Question: How can I generate a button that initiates a rising edge within a time-based scope, while recording the resulting data as variables representing the amplitude versus time?
Solution:
To generate a button-like signal with a rising edge within a time-based scope and record the resulting data as variables representing the amplitude versus time using Simulink, you can follow the below steps:
  • Open Simulink and create a new model.
  • Double-click anywhere inside the model and search for "Step". This block will generate a step signal.
  • Double-click anywhere inside the model and search for "Scope". This block will visualize the amplitude versus time.
  • Similarly, create a "To Workspace" block and connect the output of "Step" block to the input of this "To Workspace" and "Scope" blocks.
  • Double-click on the To Workspace block and specify the variable name where you want to store the data.
  • Configure the Step block as follows:
  1. Set the "Initial Value" to 0 (or any desired initial value).
  2. Set the "Final Value" to the desired amplitude for the rising edge.
  3. Set the "Step Time" to the duration of the rising edge.
  4. Set the "Sample Time" to the desired time at which the rising edge should occur.
  • Run the simulation by clicking the "Run" button in Simulink.
  • The Scope block will display the amplitude versus time, and the data will be saved as variables with the specified name in the MATLAB workspace.
Relevant images:
Here are some images you can use as a reference. Basically, I have taken some arbitrary values and ran the simulation.
Links to Documentation:
Here are some documentation links that you can refer to for more information:

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by