Simulink - how to hold signal value after change (transmission)

10 次查看(过去 30 天)
I need a way to hold a signal value after it changes for a specific amount of times with only simulink blocks.
My Simulink model specifically is a transmission and I want to add a shift suppresor. So basically when the current gear changes it should not shift for 3 seconds. I've tried around with a detect change block that detects a new gear and then a subsystem gets triggered that goes into a switch which is activated as soon as the subsystem has an output and then the gear which is stored in the subsystem gets transmitted instead of the gear that would've been transmitted.
You can see a screenshot of my transmission. The basic principle is that the upshift and downshift logic always check if the gear should be changed and if yes puts out a 1 which is either added or subtracted from the current gear.
I'm thankful for every help!

采纳的回答

TED MOSBY
TED MOSBY 2025-7-11
You can use MATLAB's "monostable" block for your use case. It will create an output that stays "on" for a specific time after being triggered.
First, detect the moment the gear changes by comparing its current value to its previous value:
  • Unit Delay block: Feed the current gear signal into it.
  • Relational Operator block: Compare the current gear with the output of the Unit Delay. Set the operator to "not equal" (~=). The output will be a pulse (1) when the gear changes.
Now, use the Monostable block to create the 3-second hold:
  • Connect the output of your Relational Operator (the change pulse) to the input of the Monostable block.
  • Double-click the Monostable block and set the Pulse duration to 3.
The output of this Monostable block is now your "lock" signal. It will become 1 as soon as it's triggered by a gear change and will automatically return to 0 after 3 seconds.
Use the "lock" signal from the Monostable block to control a Switch that allows or blocks the shift commands.
  1. Get your shift_command (+1 or -1 from your up/downshift logic).
  2. Connect the shift_command to the bottom input of a Switch block.
  3. Connect a Constant block (value 0) to the top input of the Switch.
  4. Connect the "lock" signal (from the Monostable block) to the middle control input of the Switch.
Here is the documentation:
Hope it helped!

更多回答(1 个)

Altaïr
Altaïr 2025-7-10
One straightforward approach to achieve this is by using a Stateflow chart, as illustrated below.
For those who prefer to work with Simulink blocks, building a counter with the Detect Change block and implementing the if-else logic using "If" and "If Action Subsystem" blocks is a suitable method.
Both approaches produce the desired output, as shown.
For more information on the blocks refer the following links:
  1 个评论
Dominik
Dominik 2025-7-10
Hey @Altaïr, thank you very much for taking the time to look into my problem!
I tried to copy your Simulink model but unfortunately I still haven't been able to solve it. The output looks exactly like the input. I think I'm missing the logic in the if action subsystem even tho it seems like there is nothing in the subsystem.
Let me show the gear curve, I marked all the "illegal" shifts (signal changes). All the shifts that are 3s and above are fine and should be displayed in the result and the ones below should not because the logic does not allow a shift if a previous shift is less than 3 seconds ago. The vector for the repeating seq. stair is: [3 3 3 4 4 4 4 5 4 4 4 4 5 5 5 5 5 5 4 4 4 5 5 4 3].' if you want to try this sequence.

请先登录,再进行评论。

类别

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

标签

产品


版本

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by