Simulink dashboard button matching
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I'm looking for suggestions on how to approach a Simulink interface problem.  
In case 1 below, both dashboard buttons have connections to constant S1 such that if you change either button, the other button will track.  
In case 2 I'm looking to do something similar but with a constant and a button.  If I entered 0b0 for desired state, then S2 would change to zero, and the button would shift to A.  If I moved the button to B, then S2 would change back to 1, and Desired State would also change to 0b1.
This is a simplified test case of a more complex scenario I want to work up, where there is one binary input (e.g. 0b01010), and 5 buttons, and 5 constants.  
In one direction, I could use a matlab function to call set_param if the binary input is changed to set the value of S2.  But I am unsure about the other direction.

0 Commenti
Risposte (1)
  Epsilon
      
 il 26 Gen 2025
        Dear Matthew,
The 'S2' block linked to the slider switch and the 'Desired State' can be updated using the set_param function. These set_param calls can be added to the callbacks section in block properties. However, slider switch and constant blocks lack a callback that can instantly update the parameters during modelling. Instead, consider using an 'Edit block' from the dashboard library.
An alternative is to use a masked subsystem to represent the ‘Desired State’ block. This block can update the mask instantly to display the value if a current value of a parameter is used as a mask display. We can also update the value of the subsystem, the slider switch and the constant block by placing callbacks in the OpenFcn section of the subsystem block callback parameters. This will enable instant updating of the Desired State (Subsystem), the slider switch and the constant block when double clicking the subsystem. 
Example code for mask editor Icon drawing commands:
val=get_param(gcb,'Parameter1');
disp(val);
Example code for changing parameter values, from subsystem block properties OpenFcn callback:
curr = get_param(gcb, 'Parameter1');
if strcmp(curr, 'ob0')
set_param(gcb, 'Parameter1', 'ob1');
set_param('control_toggle_test/S2', 'Value', '0');
elseif strcmp(curr, 'ob1')
set_param(gcb, 'Parameter1', 'ob0');
set_param('control_toggle_test/S2', 'Value', '0');
end
Additionally please find the attached Simulink file with the above mentioned implementations.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Event Functions in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

