Still not clear what comes from the PLC relay. Is it just a contact closure to ground or does it actually output 24V and 0V?
You may need actually need apullup and not a down
check what size of number can be stored in which variable type.
This also depends on the controller you are using. On an AVR based 8bit controller like used on an Uno R3 the maximum value for int is much smaller than 50000!
I had changed the code and made the value a const unsigned int, but also changed the relay to a 5 post instead of using a stepdown resistor, that way I would have a distinct high or low input as you were saying. I can try and quickly draw a schematic at some point so you can get a better understanding of the system. Currently do not have a cad program with electrical schematic capabilities so it will be hand drawn.
You changed your constant to unsigned int but you did not change the variable you use in the for loop. It is still an int
If you had turned on all warnings in the IDE (which you should do). the compiler would have been happy to tell you.
C:\sketch_oct16a.ino: In function 'void loop()':
C:\sketch_oct16a.ino:20:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < numberOfSteps; i++) {
~~^~~~~~~~~~~~~~~
C:\sketch_oct16a.ino:20:5: warning: iteration 32767 invokes undefined behavior [-Waggressive-loop-optimizations]
for (int i = 0; i < numberOfSteps; i++) {
^~~
C:\sketch_oct16a.ino:20:23: note: within this loop
for (int i = 0; i < numberOfSteps; i++) {
~~^~~~~~~~~~~~~~~
...