It was brought up to us a while ago that it might be useful to have a block for Siemens that generates a random number in order to simulate noise or other various random conditions. We searched online to try and find an example but found that most of them were in actuality not very random at all. Other blocks use the system time and a sin/cos or exponential function to generate the random number, but the results end up being sinusoidal.
So we decided to make a quick version of our own. We took the same general idea and premise of the examples we found and made a couple tweaks to make it more random in nature. The block source and a graph of the results are shown below.
When you call the block, you tell it a maximum value and it will spit out a random number between 0 and that value (including 0 but excluding that number).
Siemens Random Number Generator Block
Brave Controls Solutions is a Certified Siemens Solution Partner specializing in Automation Drives.
Contact our team today and check out some of our past Siemens solutions for a better idea of how we can help.

Check out more of our Siemens knowledge base articles here:
Announcing NEW Simulation Capabilities & Services
As part of our commitment to continually expanding our technical knowledge base, we are pleased to announce our ability to provide simulation services utilizing Siemens Digital Industries Software (formerly Siemens PLM software). Using Siemens [...]
Siemens S120 Acyclic Communication Block
When working with Siemens Sinamics S120 drives, it's common to have to home/reference the drives at a known location. The drive should be referenced during commissioning, after replacing the motor, or after any event [...]
Byteswapping in Siemens S7
When dealing with communication between two devices, often times we need to swap the bytes in the incoming/outgoing words to have the data correctly represented on both devices. Rockwell has the handy SWPB function [...]
Siemens Random Number Generator
It was brought up to us a while ago that it might be useful to have a block for Siemens that generates a random number in order to simulate noise or other various random [...]
“Unable to Copy Block” Error in Siemens Step7
As s Certified Siemens Solution Partner we are used to working with Siemens software and have received extensive training. But we are still human beings and as we all know, errors can occur and [...]