MATLAB software for 24-452 Mechanical Systems Experimentation at CMU. Students drive an EMB spring–mass–damper (SMD) kit from ROBOTS5 through Simulink Desktop Real-Time.
- Plant —
MSE_PLANT.slxruns in Desktop Real-Time (external) mode and reads force, stiffness, and damping from the MATLAB base workspace. - Forcing function builder —
SignalBuilderAppstacks sine, step, ramp, swept sine, band-limited noise, custom (F(t)), and zero-output, then returns atimeseries. With the controller on, the same builder is a reference trajectory in mm. The main app writes that tosim_input. - Student app —
src/App/is an MVC window with time/frequency tabs and a sidebar. Start Simulation compiles and connects Desktop Real-Time; Create Forcing Function opens the builder and plots the result as the reference. - Labs — Live scripts (
Lab_1.mlx,lab_3.m, …) build the samesim_inputby hand and start the plant. Five labs; each has or will have the minimum code to run the kit. - Same contract everywhere — Labs,
AppModel.setForcingInput, and the lab scripts all writesim_input,k_sim, andb_siminto the base workspace forMSE_PLANT.
From the repo root in MATLAB:
addpath(genpath('src/App'));
addpath('src');genpath('src/App') also puts src/App/components/Images on the path so sidebar icons resolve.
mainThat opens a 1900×900 figure, loads MSE_PLANT, and wires the sidebar. Create Forcing Function runs SignalBuilderApp in force mode; Enable Controller switches that button to Create Reference Trajectory (mm). Start Simulation builds/connects Desktop Real-Time (hardware must be attached).
tsData = SignalBuilderApp; % blocks until Finish or the window is closed
tsData = SignalBuilderApp("Mode", "reference"); % mm + travel limitAdd waveforms, preview Single vs Overall, then Finish Signal Building. That returns a timeseries. Closing without Finish returns an empty timeseries (Length == 0).
model = SignalBuilderModel;
model.addSignal(StepSignal(2, 5, 5)); % magnitude [N], on [s], off [s]
model.addSignal(SineSignal(1, 2, 0, 5)); % A [N], f [Hz], phase [deg], duration [s]
[t, y] = model.compileCompositeSignal; % superposition from t = 0
plot(t, y);Signals overlay on one time axis; they are not played back-to-back. See docs/signals.md.
appModel = AppModel;
appModel.setForcingInput(tsData); % writes sim_input, k_sim, b_sim; sets StopTime
appModel.startSimulation; % external (SLDRT) modeLab 1 is src/Lab_1.mlx; Lab 3 sine-sweep is src/lab_3.m. Those scripts assign sim_input themselves, then set_param('MSE_PLANT', ...).
src/
MSE_PLANT.slx % Desktop Real-Time plant
Lab_1.mlx, lab_1.m, lab_3.m
App/
main.m % app entry (MVC)
AppModel.m, AppView.m, AppController.m
components/
forcing_builder/ % standalone forcing-function UI
main_panels/ % Time, Frequency, Sidebar
Images/
docs/ % developer guides
Changing code? Start at docs/README.md.
| Guide | When to open it |
|---|---|
| architecture.md | How the app, builder, plant, and labs fit together |
| app.md | Main window, sidebar, Simulink wiring |
| signal-builder.md | Forcing-function UI, or adding a new waveform type |
| signals.md | How each *Signal is computed |
| labs-and-plant.md | MSE_PLANT, hardware parameters, lab scripts |
MATLAB classes use the SignalBuilderModel header style: a short description plus an Example usage block you can paste into the Command Window.