B4R Question plcLib - PLC Software

Adie

Member
Licensed User
Longtime User
We use something similar but probably much more complex/effiecient/bulletproof etc etc.

For a start the PLC Ladder program is actually a list of IF statements for speed and effieciency. The way they implemented it (the few samples I looked at) will result in slow and wastefull execution. The final code is also not that readable compared to the simplicity of even complex ladder program.

In our search to solve the problem we decided on the following procedure.
1. Create a data table with two main columns (see picture)
a) the IF side and
b) the then side.

2. Develop a program to convert this in into C code. In our case we then convert this source into a Windows executable during runtime :). (It was originally uploaded on a Microchip PIC)

Sample C code snip generated
/*********************/
if (STRT)
{
if( lSTRT && (PTIMERr(9) > 1000))
{
STRT = false; AGR = true; OPC = true; <----- Here we switch the IF block off -It must only be executed once
DISC = true; H2OW = true; ADDW = true;
PTIMERs( 9, "C" ); oMIXRUN = false;
}
if( !lSTRT)
{
PTIMERs(9, "S" ); lSTRT = true; oMIXRUN = true;
}
}
/********code normally auto formatted properly ***************/

the beauty of this method is not only that it is all 100% automated and the code is easy to read. the second BIG feature is that the main IF block (STRT) in this case can be switched 'off' and will be skipped during execution. I did see similar code in one of their samples.

Adie
 

Attachments

  • Start.JPG
    Start.JPG
    37 KB · Views: 304
Upvote 0
Top