Re: Try/Catch
- Posted by jimcbrown (admin) Jan 07, 2015
- 5776 views
Thank you.
These answers are really ambiguous for me. Honestly, I don't feel that I got an answer at all.
The results of popularity contests are often baffling.
Once I've programmed a PLC ... In these machines, something goes wrong almost all the time.
I've worked with PLCs as well. I feel your pain.
I don't know why computer program has to break its own logic and fall into a dangerous game of throw and catch. In more critical programs, such as PLC programs, this considered to be the most non-robust behaviour.
Uh, trapping and handling faults (the PLC verion of try-catch) is actually very common. I speak from experience here, but don't just take my word for it: http://www.plctalk.net/qanda/showthread.php?t=68857
Programming a PLC is different then programming computer, in a way that the program must work; and if it doesn't: you call the programmer back to finish his work. Machines don't understand bugs, and improper behaviour of machine can cause a big accident.
This is the main difference between PLC programming and computer programming; In PLC programming the programmer must take responsibility for his mistakes ("bugs"), while in computer programming bugs are part of any program.
Again, speaking of experience, some complex PLC programs can have bugs that remain hidden for years until some obscure set of complex conditions are triggered. Just because it runs on a PLC is no exception - software is software, and complex software is never bug free, PLC or otherwise.
That's why there is no "fatal error" in PLC, since PLC should never stop its operation. There might be an adjustable watchdog that continuously test the proper operation of the PLC (similar to computer BIOS chip), and stops the PLC in case of improper operation - but PLCs are built to be reliable and robust.
PLCs do have "fatal errors", they're just called faults. If a major fault is unhandled, the PLC cpu will stop and someone will need to reset the PLC (the equivalent of a cold reboot). Again, don't just take my word for it: http://www.plctalk.net/qanda/showthread.php?t=68857
And yes, I know from experience that PLCs have faulted and stopped in the middle of an important hours-long operation - and then someone has to reset it and try and pick up where things were left off. It's a lot of extra work when this happened, no one wants it to happen, there's a lot of incentive to make sure it doesn't happen, but it still happens.
I really don't understand the answers since my experience proves the opposite...
I don't understand where your experience comes from.