Today is...
Tuesday, October 24, 2017
Welcome to Control.com, the global online
community of automation professionals.
Featured Video...
Featured Video
A tutorial introduction to programming using the QuickBuilder Programming Environment.
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
Simulated Integer Values
I would like suggestions on how to "fluctuate" integer values randomly within a certain range in a Siemens S7/TIA Portal project and display these values on an HMI.

I am working on a simulated TIA Portal project which entails generating integer values and would like it to display on the HMI screen. The way I chose to generate these values is to initialize them as an integer value on a data block. To make it look more realistic to the process, I would like these values to fluctuate close to the initialized value in the data block. I would like to "fluctuate" these values a few units or a percentage and show this fluctuation on an HMI screen. I would like some suggestions as to how to do this in a looping manner.

Writing simulation software for testing control software is an art in itself - but not too difficult!

You want to vary some integer values? Ramp up from say zero to hundred, pause then ramp down to zero - but at what speed? Or start from an initialized value and jump to several preset values in sequence.

The only limitation are your specific requirements and imagination - coding is the easy part.

Thank you for your reply.

Yes, I would like to vary integer values. I am not as concerned about the ramp up/down from a start or shutdown as I am having it vary at a predetermined value while in the run mode so the reading would not be static. An example would be a 3600 rpm motor varying within a few rpm in either direction randomly.

Still trying to figure out the best way to do this-adding noise to an integer in a data block. Any help is very much appreciated.

Look at something like this:
https://en.wikipedia.org/wiki/Linear_congruential_generator

Should be easy to implement a 2^16 version if using 16 bits registers.

Not good for cryptography.