Errors in simple peak detector (State-Souce dependence during switching)

I built a very simple peak detector (attached), but i get an error that i have state/source-dependence during switching.

It must be a basic error, so what am i doing wrong ?

Model attached

peakDetector.plecs (6.44 KB)

Sorry, have added the model to original post

peakDetector.plecs (6.44 KB)

Hi Srinath,As the error states, the capacitor state is directly dependent on the voltage source. What this means has been elaborately answered here – https://www.plexim.com/support/solutions/166. If you add a small resistance in series either to the source or to the capacitor, you won’t have this direct dependence anymore.Also, if all you’re trying to do is find out the peak value of your periodic waveform, then this could be implemented in a better way either using the C-script block or the State Machine block. Please see the attached example.Regards,Manu

periodic_maximum.plecs (23.4 KB)