Hi All
I am wondering if anyone has a nice way of implementing a switch statement in ladder logic. I have attached the version that I currently use (I haven't tested it, I'm writing it from memory as the actual code I don't have access to right now). What you see may not work perfectly but the basic Idea is correct, you enter the routine with some non zero value in the "Write" word. Then you jump to the parameter and then to sending the message. Now you might say, why not just write 2 separate message instructions, in the example that would work fine, but there are cases when we have 20+ parameters to write, so it becomes a lot of memory to have 20+ messages.
My boss wont let me implement this code in structured text, using the "Case of" instruction (Allen Bradleys version of Switch), he says that the ladder logic version is easier to understand, I disagree but he's the boss.
Has anyone come up with a better way, that does not make use of a lot of JMP & LBL instructions?
Thanks
Ian
I am wondering if anyone has a nice way of implementing a switch statement in ladder logic. I have attached the version that I currently use (I haven't tested it, I'm writing it from memory as the actual code I don't have access to right now). What you see may not work perfectly but the basic Idea is correct, you enter the routine with some non zero value in the "Write" word. Then you jump to the parameter and then to sending the message. Now you might say, why not just write 2 separate message instructions, in the example that would work fine, but there are cases when we have 20+ parameters to write, so it becomes a lot of memory to have 20+ messages.
My boss wont let me implement this code in structured text, using the "Case of" instruction (Allen Bradleys version of Switch), he says that the ladder logic version is easier to understand, I disagree but he's the boss.
Has anyone come up with a better way, that does not make use of a lot of JMP & LBL instructions?
Thanks
Ian