Hi all !
In my testing of a simulink sample and hold block, I notice that the time (t = 0) output of the simulink sample and hold block (during a simulink simulation) will be equal to the 'initial value' setting (such as the default initial value of 'zero'). This is probably expected behaviour.
However, if I have some applications (simulations) where I would like the sample-and-hold block to capture the sample-and-hold's input value at t = 0 (such as an input value of '1'), then is there a method or setting that overrides the 'initial value' of the sample-and-hold block?
I've provided an example of my current situation here. The simulink file is from Matlab R2013b.
The simulation (running with fixed-step solver) simply involves a counter (that counts from 1 to 7). The counter just counts the rising edge events of the pulse generator. The pulse generator produces only regular squarewaves. The rising edge of those square-waves triggers the counts of the counter.
The sample and hold block is set up to sample the output value of the counter at each rising-edge trigger event of the counter's input.
The following behaviour is noticed with the simulation:
When the simulation runs ----- the output of the counter at time t = 0 will be '1', so that there is a step of '1' at time t = 0 for the output of the counter.
The sample-and-hold does not capture the output = 1 value of the counter associated with time t = 0.
Instead, the sample-and-hold block at time t = 0 captures the 'initial value setting' of the sample-and-hold block (ie. setting of '0'). And if I had chosen to change the initial value of the sample-and-hold block to some other value (such as -9), then the output of the sample-and-hold block would be some other value (such as -9).
Extra notes: The simulink fixed-step sampling period is 'base_sample_period, set to 5 nanosecond' (which is set in View -> Model Explorer -> Callbacks -> InitFcn*). And the pulse generator produces regular square-waves with a period of 5 microsecond.
I've included a couple of screen-shots. The first image shows the counter output (seen with a 'scope') - showing a step of '1' at time t = 0.
The second image shows the output of the sample-and-hold block, where the step of '1' is not there at time t = 0. That is, the sample-and-hold is not capturing the t = 0 step jump of the counter?
Is there a general method that everybody uses where we can get the sample-and-hold to capture the t = 0 value of the counter?
Thanks very much for any help in advance!