ladder_parser - ladder logic parsing with Nx

ladder_parser

I don’t have a computer science background, so I’m not sure if there is a better way of doing this, but I had a great time parsing ladder logic using Nx.

Ladder logic is a graphical programming language for PLCs (programmable logic controllers) that was designed to mimic electrical schematics. Ladder logic is popular in industrial settings and has been for decades. I thought it would be useful to be able to transform ladder logic into Elixir.

The solution I settled on was to convert the text that represents a rung to a matrix, then scan the matrix looking for certain symbols.

Not sure if there are many control systems engineers in the elixir community, but hopefully someone finds this approach useful.

4 Likes

Hi @AnthonyMujic. I’m a control systems engineer too :smiley:. I’ve seen some talks on creating a web based IDE and IEC 61499 implementation.

Question: what PLCs use this ACSII format for ladder logic? I’m used to Rockwell stuff, i.e writing XIC XIO OTE etc. Do you know if IEC 61131 defines a standard for the textual representation?

Hi @cmo, I’m not sure if IEC 61131 defines a standard for the textual representation. The ASCII format used in the example is from a Siemens Simatic 505 PLC. Rather than saving as text or XML as can be done with Allen Bradley PLCs, the only option close on a 505 is to ‘output as text’.