I developed a ladder logic compiler for a PC environment that used EAGLE as the editor for the ladder "schematic". I parsed the exported netlist to create a 'p-code' representation of the ladder, which was then 'compiled' into X86 instructions to 'execute' the ladder. It optimized the p-code sequences so that, for example, a complete subtree driven by an open contact would not have to be evaluated on every iteration of the ladder. A similar scheme could certainly be used to generate PIC assembly language to execute the ladder. -- Bob Ammerman RAm Systems ----- Original Message ----- From: "alan smith" To: "Microcontroller discussion list - Public." Sent: Monday, November 02, 2009 12:05 PM Subject: Re: [PIC]: Ladder Logic on a PIC This was posted Jan of 2005 (wow...almost 5 years ago now) Link still appears active ----------------------------------------------------------------------- Ladder logic is a graphical programming language often used with PLCs. Instead of writing a list of statements you draw a stylized electric circuit. For example, in the example given below, Xa, Xb, and Xc are digital inputs; Yout is a digital output. || Xa Xb Yout || 1 ||-------] [------+-------] [------+-------( )-------|| || | | || || | Xc | || || +-------]/[------+ || (please view in a fixed-width font) This is a boolean expression: Yout = (Xa and (Xb or (not Xc))). This makes sense if you think of Xa and Xb as normally-open relay contacts, Xc as normally-closed relay contacts, and Yout as a relay coil. (Imagine that there is some voltage across the left and right `bus bars'.) There are additional instructions for time delays, arithmetic, counters, and so on. It is a Turing-complete programming language; you can write any kind of program in ladder logic, though you probably wouldn't want to. I have written a ladder logic compiler for PIC16 and AVR platforms. You use a graphical editor to draw a diagram like the one above. Then you bind input and output variables to GPIO pins, and the compiler will generate an IHEX (.hex) file to program into the micro. The ATmega128 and PIC16F877 are supported and tested; a few more parts are supported but not tested. I believe that the compiler is fairly stable. Consider it an early beta. I developed the compiler under Windows XP. I would appreciate any bug reports; I would also appreciate success reports if it works with any of the untested parts or with other versions of Windows. More information at: http://cq.cx/ladder.pl There is a manual. --- On Tue, 10/27/09, Giles Honeycutt wrote: > From: Giles Honeycutt > Subject: [PIC]: Ladder Logic on a PIC > To: "Microcontroller discussion list - Public." > Date: Tuesday, October 27, 2009, 8:42 AM > Has anyone worked with or know of a > ladder logic compiler or interface > for PICs? > Ladder logic as in the relay rungs used in PLC > programming. I am > interested in just the basics, like relay contacts, coils, > counters, and > timers. > > Best regards, > Giles Honeycutt > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist