Adding limits
drbitboy, any chance you can put limits to the number range [...] Thanks
(Hey, it's on Github: fork the repo, fix it th'self, and issue a PR;-)
For the AOI I don't have anything that can edit it; maybe my brother can fix it, or I can fiddle with the XML in the .L5X file. I thought we included Out_lo and Out_hi input parameters on the AOI for scaling ... yes, I just checked the XML and we did that for the uniform LCG AOI, but nothing for the Gaussian AOI.
In the MicroLogix 1100 example the limits are (0:1] for the uniform LCG and the gaussian data have a mean of ~zero with a variance (and standard deviation) of ~unity; neither is a self-contained object like an AOI that would lend itself to adding limits or scaling. One should be able to use the SCL or SCP instructions to scale the outputs. Hmm, it might be useful to turn this into a subroutine to make it AOI-like.
That said, I would not add limit parameters for the Gaussian RNG; I think it makes more sense to specify the mean and the standard deviation as a one-sigma value (or three-sigma e.g. for modelling noise that should stay mostly within a deadband in a control application); the SCL instruction does that in one step. There is no theoretical limit to a gaussian value, but in practice for a 31-bit LCG I think the algorithm is limited to around six or seven sigma.
P.S. Don't be intimidated by the algorithms: I'd be glad to lead anyone through them; and nothing in there goes beyond high-school math plus The Google plus a feel for how numbers behave*; 90% of engineering is multiplying by one in some form or another.
P.P.S. The MicroLogix example doesn't need any hardware; it can be run PC-standalone with the RSLogix Emulator500.
P.P.P.S. Thank you for your kind words. It really is my first PLC program**, and I am still interested in anybody's critique; maybe no one is interested in yet another RNG, but style is something I probably need to learn. E.g. my rungs tend to be very long vertically (and I had my reasons***), but I find that rungs taller than the one-screen window make reading/editing/understanding awkward at best, so maybe someone more experienced has a better approach.
* Sure, I spent my life doing this kind of thing and it comes naturally, but anyone who was taught and understood long division in elementary should have the chops to understand the LCG algorithm.
** Although my brother has been regaling me with tales of his exploits for years, which often require some pedagogy to follow - you wouldn't believe the number of times he's drawn a self-sealing on switch for me.
*** Out of habit I group things by function and I didn't want to have to put my ODDEVEN bit on every rung