PLC Not fast enough?

If you really want to detect button presses in the right order on a PLC, you use an input card with µs timestamping capability like the Beckhoff EL1254. Afterwards you simply compare the timestamps in the proces image.
Pretty easy, but not exactly cheap.
 
Still does not solve the issue of timestamps being the same whether it be ms ns or that elusive thing scientists think exists travels faster than light (had to put that one in) if it's the same, it's the same.
 
one way is to assign each button a number 1-20
create a tag Button Number
when a button is pressed if the tag= 0 then move the button number into the tag
all other button will be locked out until you reset
To reset the tag just set the tag to 0
only 1 button can update the tag the first one wins.
the chance of 2 or more buttons activated in the same scan is relay remote you are talking about a few ms you are never going to get around that but the time is quicker then the blink of an eye a higher speed processor would be even faster
 
Still does not solve the issue of timestamps being the same whether it be ms ns or that elusive thing scientists think exists travels faster than light (had to put that one in) if it's the same, it's the same.


I agree. There's no way to eliminate a tie because the occurrence of an exact tie actually is a possibility. The only solution I see is to nullify a tie and skip to the next question.
 
Is it even possible to program a PLC to randomly select a #? How would you even do that?

No, but I think he meant pseudo random. It’s fairly easy to make a sequence of numbers that appear random enough to be considered random. I’ve heard of using scan time as a random number.
 
In this application a random number generator will do you no good
First a true random number generator does not exist all of them follow some code
That code results in a pattern and if there is a pattern then it is not random
That was brought out about 5 years ago by some very smart engineers there is a paper published out there someplace.
Second it takes many loops to run a random number generator it could be several thousand to complete the first step. Foe each step the result then must be checked to make sure it is within upper and lower limits. If it’s not within the limits then it must repeat the step While all that is happening a second or third input could go active. So you would still not know what input came first.

Forget about timers again they take too much time and to many scans to update check the timers on Logix processor they always run past the set point look when the DN bit is set check the ACC and the PRE values it’s rarely the same. Because the scan time doesn’t match the timer count speed the system only updates the ACC value and the DN bit when the rung is true and scanned.
In the original post you were looking to determine the first button pushed
That means check should be completed in just one scan of the program. It would be very rare to have 2 inputs activate with in just one scan even relay contacts on a single multi pole relay can be read in at different sans. I have seen this many times so I really don’t see how 2 people could ever do it.
You said that you want to make sure that nobody can hold a button down that’s simple to do just don’t allow any of ladder rungs to be active until all the inputs are clear / reset then start scanning for the first activated input. Then after the scan finds the first input that’s on the rest of the rungs are set to false until the number tag is reset. This type of code is done all the time. One function that works similar to this is the FIFO.
On the new PLC’s the ladder scan rates and the Input and Output rates are not synchronized together in most cased the ladder scan is much faster than the I/O update times.
You show an input filter time of 3ms the processor will probably scan the ladder over 1000 times in that time. The input filter time is the time for the input module takes to recognize the change of state in actual input and then update the module so the plc can read in you case any sort duration pulse less than 3 ms long will not be updated in the module data table and with that the plc will never see it. It has nothing to do with the plc scan time. Again the IO table is updated independent of the scan time.
You show a watchdog timer why you really don’t need one, and input is active or not active what are you looking for to see if somebody can activate a button in a few ms.

What is the cycle time for 20ms X2 or 40ms is the update time at for the IO handler to read and update IO table so the ladder program can use the data. It’s not nearly enough time for use humans to push a button.
The watchdog timer is the time allow before the processor posts a lost communication to a module fault. In your case it is inactive so no fault will be set.

I find that default setting are a good place to start if you are going to change them have good reason for the change.
Keep it simple it will be far more reliable and easier to understand.
 
There is no solution using a PLC. There is no way to keep two or more people from hitting the button at the same time. However,a faster scan rate will reduce the probability. I would use interrupts but this is not a perfect solution either because interrupts are disabled during the "house keeping" part of the scan. I would use a FPGA ( field programmable gate array ). Even then there is a possibility of a tie but if the clock rate is high enough this is extremely unlikely.


As for random number generators. LFSR ( linear feedback shift registers ) can be very long. I have seen a table that will make patters 2^4096-1 long. I think the universe will be dead by the time it repeats even if a new number is generated every millisecond. The pattern is not truly random but will look that way to us. LFSR are easy to implement and execute quickly. I think a 32 bit LFSR is good enough.


I wouldn't use a random number at all. I would have a simple way of choosing a winner then set a flag that indicates he/she will lose the next tie.
 
Still does not solve the issue of timestamps being the same whether it be ms ns or that elusive thing scientists think exists travels faster than light (had to put that one in) if it's the same, it's the same.
Yeah, if it's the same. Even if you had 5 guys coordinating their efford to push the buttons at the exact same time, I don't think you would end up with exactly the same timestamps when the input filter time is <1 µs + 10 ns precision.
 
there certainly is a solution using a plc see other post
but I keep seeing reference to a time stamp in order for a time stamp to work you processor must support it (Real Time Clock) not all processors do.
just move the RTC value to a tag using a one shot when the rung goes from false to true
no 2 rungs will have the same RTC value
 
Still stick to my guns on this, murphy's law suggests that if it can happen it will.
The only way to make it a little more random is that even if two presses were exactly at the same time (within the scan of I/O even in interrupts), use the rtc (even the seconds) mask off all but the lsb and if it is 0 then buttons 1,3,5,7 etc. take priority if buttons are even and lsb is 1 then they take priority, not exactly random but taking all into consideration a more than one button pressed and the randomness of time of press will give a sort of randomness, however, in the unlikely case more than two buttons are pressed at the same time solutions please?. I love this post :mad:
 
In theory you are correct but we don’t deal in theory the chances of having 2 inputs arrive exactly at the same time as greater the 100 billion to 1 so yes it is possible but you will never see it.
If you really want to break it down to smallest level. Since most plc communicate with the IO using a serial link even if all the inputs on a 16 point module were set to a one at the start of the data table update bit 1 would be updated before bit 2 and so on but those kinds of speed are not going to matter because we mere humans can’t respond that fast. And we are pushing the button. There are a lot of time delays in processors that we just don’t know about. Ever on a simple 60hz line it takes a full 16 ms for the zero to full value back through zero and to the full value and back to zero again( Full Cycle), and yet there is not a human on earth that can even see it let alone respond to it but a computer can do many thousand calculations in that time. Even a TV or computer monitor( Both are very slow by todays computer standards ) is only updated at a rate of 60 times per second, that’s displaying a new still picture on the screen 60 times a second but we see it as a single moving picture we are the slow ones.
Even at that all computers can still only do one thing at a time, a different thing for every clock pulse
When I was studying electronics I had professor that to try to put in perspective. A computer is a fast idiot it can count from 0 to 1 but it can do very fast and many times, we have increased the computer speed many times since then so thing just get faster but still happed one at a time.
That was before the modern day computers high speed computer we use today.
A plc will evaluate rung 2 before it dose rung 3 and rung 3 before rung 4. So the priority would be rung 2 if it is true then all the other rungs will evaluate to false so only the input on rung 2 will set the output in rung 2
 

Similar Topics

Hello Beckhoff experts. I want your opinion on whether the hack I explain below is possible or whether I should forget about it. Our Beckoff PLC...
Replies
8
Views
4,629
Old equipment, trying to run faster than designed. I have a client that is still running a PLC5/40 on an extruder line. They are using a 10ms STI...
Replies
16
Views
2,845
Task Description: Currently I am working on a program in C # for reading data from RSLogix5000 Series controllers (v18.11). The idea is to do...
Replies
36
Views
18,373
I have a need for a system to monitor multiple pressure transducers to detect transients in the 1mS time range. After looking at numerous A/B...
Replies
8
Views
2,886
Hi everyone, long-time reader of the forum, first-time poster. I have a customer that we've built a number of machines for that would like to do...
Replies
8
Views
3,336
Back
Top Bottom