Well... as you can see in my picture above, you do not necessarily need a S-function. If your S-function is m-based, then you can use the Mathscript node to define the nonlinear equations and, then, use the 'integrator' from Simulation Palette to integrate the signal (if you have derivative).
However, if your S-function is C based, then you can try to use another function in Simulation called External Model Interface. You will need to create a DLL and code your features into it. But probably you have all this code already and I think it can be somewhat easy to do... Here is the documentation:
http://zone.ni.com/reference/en-XX/help/371894D-01/lvsimconcepts/sim_using_emi/
If you still have difficulty to do this after you look into my information, it would help if you could create a simple schematic or some paper that describes what you are trying to do.
Hope this helps,
Barp - Control, Simulation, RTT and HIL - National Instruments