Mark_R
Member
Hi,
I'm an accomplished ladder logic programmer trying to transition to embedded micro controllers. I'm struggling with the basic concept of program flow control. I have avoided C/Basic/Etc. like the plague, but the project at hand is forcing me in that direction.
In ladder logic, the ladder scans continuously, updating rungs as it goes. If there is a timer running, or some other task / condition pending on a rung, program execution moves on. The rung gets re-visited on the next scan and so on. The point is, multiple things can be happening simultaneously.
In C, BASIC whatever, I'm missing the big picture here.
An example of somthing we have built with a PLC;
Let's say I have a machine that controls a widget filler and has a serial modem for reporting status.
The widget filling is ongoing, one widget after another, I can visualize this code well enough.
Now, lets say I need to send information out of the modem, I branch to a loop to open the serial port and initialize the modem, now I need to wait for the modem to open a port and reply ready, so I loop until success or error comes in on the receive buffer. Let's say this takes 20 seconds, What about the widgets? has production stopped? Are they overflowing?
It seems to me that only one thing can happen at once and if one has to wait for an event then everything else has to stop. This can't be the case.
I don't get it, and I can't seem to find the answer.
Anyone?
Thanks.
I'm an accomplished ladder logic programmer trying to transition to embedded micro controllers. I'm struggling with the basic concept of program flow control. I have avoided C/Basic/Etc. like the plague, but the project at hand is forcing me in that direction.
In ladder logic, the ladder scans continuously, updating rungs as it goes. If there is a timer running, or some other task / condition pending on a rung, program execution moves on. The rung gets re-visited on the next scan and so on. The point is, multiple things can be happening simultaneously.
In C, BASIC whatever, I'm missing the big picture here.
An example of somthing we have built with a PLC;
Let's say I have a machine that controls a widget filler and has a serial modem for reporting status.
The widget filling is ongoing, one widget after another, I can visualize this code well enough.
Now, lets say I need to send information out of the modem, I branch to a loop to open the serial port and initialize the modem, now I need to wait for the modem to open a port and reply ready, so I loop until success or error comes in on the receive buffer. Let's say this takes 20 seconds, What about the widgets? has production stopped? Are they overflowing?
It seems to me that only one thing can happen at once and if one has to wait for an event then everything else has to stop. This can't be the case.
I don't get it, and I can't seem to find the answer.
Anyone?
Thanks.
Last edited: