If you know the exact time range you want, you can tell Simulink to log data only in that range. For example, suppose you already know the piston hits its limits at 9.99 seconds, so you want to log data from times 10 to 11 seconds. To do this, you can
- Go to Model Configuration Parameters (Ctrl+E) > Data Import/Export Pane
- Set the "Output options" to "Produce specified output only" ( doc link )
- Set the "Output times" to your time vector to, e.g., 10:0.001:11
If you want this to be "smarter", you can
- Place a motion sensor on the cylinder and measure its position. Put this through a 10 ms Transport Delay block since you want to start logging 10 ms AFTER the event.
- When the output of that block is greater than the max piston displacement, have Simulink output "true" and then feed that into an Enabled Subsystem.
- Inside the Enabled Subsystem block, pass in the measured pressure value into, e.g., a To Workspace block.
Since the To Workspace block will be inside a subsystem that runs only when its control signal is true, you will essentially log data only after the piston hits its maximum displacement.
Now, if you want additional logic that STOPS logging after some time, you'd have to implement that as well...
- Sebastian