In this situation, multiple signals are sent when the button is pressed. There are a few different ways to ensure that only one signal is sent when the button is pressed, but one simple method is to add a short delay after that button is pressed before reading its value. This delay can be implemented in software using a timer or delay loop.
Here's a simple example of how you could implement debouncing in your Simulink model:
- Add a "Delay" block to your model, and set its delay time to a few milliseconds (e.g. 5ms).
- Connect the output of your button to the input of the Delay block.
- Connect the output of the Delay block to your save condition block.
- When the button is pressed, it will send a signal to the Delay block, which will delay the signal by a few milliseconds before passing it to the save condition block. This will ensure that only one signal is sent, even if the button bounces multiple times.