SimEvents - Entity Output Switch
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I'm having trouble controlling an entity output switch via a control port.
End Goal:
Model an inspection machine that rejects parts based on whether the inspection passes or not. Entity should be sent to one of two output ports. Entity should be sent to port 1 if a downstream conveyor (i.e., Diverter1Infeed) is running and the entity's Pass attribute is true. Entity should be sent to port 2 if downstream conveyor is stopped or if the entity's Pass attribute is false.
Environment:
- MATLAB Version 9.5 (R2018b)
- Simulink Version 9.2 (R2018b)
- Control System Toolbox Version 10.5 (R2018b)
- SimEvents Version 5.5 (R2018b)
- Stateflow Version 9.2 (R2018b)
- Symbolic Math Toolbox Version 8.2 (R2018b)
- System Identification Toolbox Version 9.9 (R2018b)
Current Subsystem Implementation:
Simulink Function getPort(pass):
Matlab System globalGetInspectionOutPort:
Note: "Diverter1InfeedRunning" is a global signal defined in the model workspace.
classdef globalGetInspectionOutPort < matlab.System
% Determines which port a syringe should take when exiting
% the inspection machine
methods(Access = protected)
function setupImpl(obj)
% Perform one-time calculations, such as computing constants
end
function port = stepImpl(obj, pass)
global Diverter1InfeedRunning;
if (Diverter1InfeedRunning && pass)
port = 1;
else
port = 2;
end
end
function resetImpl(obj)
% Initialize / reset discrete-state properties
end
end
end
Error Generated:
Comments:
- I suspect that the error essentially indicates that the Simulink function getPort() is either generating an error and therefore outputing a value of 0, or it's not being called/executed before the entity output switch control port is needed.
- I have tried using the SimEvents debugger but it only flashes momentarily on the screen before the Diagnostic Viewer is displayed.
Questions:
- Is this approach valid?
- Is using a global variable (e.g., Diverter1InfeedRunning) a viable means of monitoring subsystem status for the purpose of making decisions, such as to which port an entitiy should go?
- What are recommended ways of feeding the status of other subsystem(s) of the model into the this subsystem for use in making decisions?
3 comentarios
Renato SL
el 9 de Sept. de 2019
Hi Bob,
Have you thought about representing the status of the equipment with some kind of signal?
I imagine that a signal generator could generate numbers that would represent the status, for example the system is working if the value is greater or equal to zero and the system isn't working if the value is less than zero (or something like that). Maybe a Repeating Stair Sequence or Random Number block could be used.
Respuestas (0)
Ver también
Categorías
Más información sobre Discrete-Event Simulation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!