Ladder Logic help needed

I have "translated" a schematic of a discrete CMOS controller to ladder logic, keeping a labelling one-to-one correspondence (eg: U5 pin

3 becomes XU503 or YU503 or RU503 depending on pin 5 being input, output, or internal respectively. No attempt was made to simplify any of the logic, so about 98 rungs were necessary including comment rungs. But the problem is that the resulting ladder logic has the two delays reversed: transfer time being set by the heater timer, and vice-versa. I hate to post a loooong listing, and the schematics are in PDF (only suitable for ABSE). Would anyone volunteer to help; would be happy to pay a small fee if needed. Thanks in advance.
Reply to
Robert Baer
Loading thread data ...

On 02/27/2009 11:59 PM, Robert Baer sent:

What PLC do you wish to use?

--
1PW  @?6A62?FEH9:DE=6o2@=]4@> [r4o7t]
Reply to
1PW

Help with the solution, or help with posting all that stuff on a webpage somewhere?

To post, first find out if your ISP has already given you a "personal" web space - every one I've ever had has sone so. Or, you can still try

formatting link
or
formatting link
which are free, but your personal web page is primarily ads.

I've also heard that there are places that will let you post graphics for free, but have never needed them, so haven't.

Good Luck! Rich

Reply to
Rich Grise

Presently i am using LCmicro.exe to write laddder logic and reate the hex for a PIC16F877A. I have simplified the schematic and its corresponding ladder logic to about 25 rungs including comments. But the simplified program has exactly the same problem(s) as the original slavish emulation.

Reply to
Robert Baer

Would have to ask my ISP; else use ABSE for posting. Need help on a solution for the problem.

Reply to
Robert Baer

Which editor did you use? Maybe you can export it in text format or copy it from the PDF in a text format and then posting it like this (read with a non-proportional font like Courier)

x0001 x0002 Y0001 |---| |-----|/|---------( )-----| | | | | | x0001 Y002 | |---| |--[01000 TON T012]--( )--| | | | | | R001 | |--[D0140 = 0001]--------( )--| | | | R001 Y004 | |--| |---------------------( )--| | | |-{END}-------------------------|

(found on

formatting link
)

You've already optimized it to 25 rungs, so should be no problem for a newsgroup posting.

BTW: is there a computer readable interchange format for Ladder Logic programs? I've read the 61131-3 standard and looks like it just defines these strange ASCII graphics for Ladder Logic, which would be difficult to write a parser for.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

I've sent email to you.

Pete

--
1PW  @?6A62?FEH9:DE=6o2@=]4@> [r4o7t]
Reply to
1PW

The save file .LD used by LDmicro.EXE should be an excellent computer readable interchange format. And it has the advantage that it is displayable in the ||---| |----()---|| form. All one needs is an Win gooie; it does not get registerd, so an association between filetype and program is not functional.

Reply to
Robert Baer

Seen it and responded; thanks.

Reply to
Robert Baer

Here is your sample, as closely as i could get it with my limited understanding: LDmicro0.1 CYCLE=10000 CRYSTAL=4000000 BAUD=2400

IO LIST X0001 at 0 X0002 at 0 Y0001 at 0 Y002 at 0 Y004 at 0 END

PROGRAM RUNG CONTACTS X0001 0 CONTACTS X0002 1 COIL Y0001 0 0 0 END RUNG CONTACTS X0001 0 TON TT012 1000000 COIL Y002 0 0 0 END RUNG EQU D040 1 COIL R001 0 0 0 END RUNG CONTACTS R001 0 COIL Y004 0 0 0 END The IO list is populated after one selects a MCU and assigns inputs and outputs to the MCU pins. One also sets the cycle time, which works in the simulation mode as well as on the MCU.

Reply to
Robert Baer

LDmicro.exe looks like a nice program. I've downloaded the source from the webpage:

formatting link

and compiled it with my Visual Studio 2008, which worked (nearly) without problems. The GUI has already a text export, so you could post the ladder logic diagram as a normal newsgroup posting, and maybe the .ld-file, too, if someone wants to simulate it with LDmicro. Experienced users should see the problem. And it could be useful for me, because I'm planning to develop a PLC, too, so learning ladder logic looks like a good idea, because I could offer it as an optional target, in parallel to a more programmer friendly Basic implementation.

The .ld file format looks good, maybe converting it to XML makes it even easier for more programs to read it, because then you don't need to write a full parser yourself.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

Here is the .LD lising: LDmicro0.1 MICRO=Microchip PIC16F877 40-PDIP CYCLE=10000 CRYSTAL=3686400 BAUD=2400 COMPILED=G:\\Documents and Settings\\Robert Baer.ASUSBAER\\My Documents\\CMOS\\MCUctrlr.hex

IO LIST XBelt at 24 XExtremeLevel at 26 XHiLevel at 16 XLid at 25 XLoLevel at 15 XMot1 at 6 XMot2 at 7 XReset at 18 XRotation at 2 XSafety at 23 XThermostat at 17 Xrate at 20 YBelt at 33 YCOUNTER at 28 YHTR at 22 YROT at 21 YStop at 29 YXFR at 27 END

PROGRAM RUNG COMMENT begin Row 1 Page 1; RUB111 = LO @ full, RUB209 = HI @ empty END RUNG PARALLEL CONTACTS XLoLevel 1 CONTACTS XHiLevel 1 END COIL RUB111 0 0 0 END RUNG CONTACTS XLoLevel 1 CONTACTS XHiLevel 1 COIL RUB209 0 0 0 END RUNG CONTACTS RUB209 1 CONTACTS YStop 1 COIL RUB206 0 0 0 END RUNG CONTACTS YStop 1 CONTACTS RUB111 1 COIL RUB309 1 0 0 END RUNG PARALLEL CONTACTS RUB103 1 CONTACTS RUB206 1 END COIL RUB104 0 0 0 END RUNG PARALLEL CONTACTS RUB309 1 CONTACTS RUB104 1 END COIL RUB103 0 0 0 END RUNG COMMENT begin Row 2 Page 1 END RUNG CONTACTS XThermostat 0 CONTACTS RUB103 0 COIL YHTR 0 0 0 END RUNG PARALLEL SERIES CONTACTS XThermostat 1 CONTACTS RUB103 0 END SERIES CONTACTS XThermostat 0 CONTACTS RUC311 0 END END COIL YXFR 0 0 0 END RUNG COMMENT begin Row 3 Page 1 END RUNG PARALLEL CONTACTS XSafety 0 CONTACTS XLid 0 CONTACTS XBelt 0 CONTACTS XExtremeLevel 0 CONTACTS XMot1 1 CONTACTS XMot2 1 CONTACTS RSC6 0 END COIL RFault 0 0 0 END RUNG CONTACTS XReset 1 CONTACTS YBelt 1 COIL YStop 0 0 0 END RUNG CONTACTS RFault 1 CONTACTS YStop 1 COIL YBelt 0 0 0 END RUNG COMMENT begin Input Page 2 END RUNG CONTACTS XRotation 0 COIL YROT 0 0 0 END RUNG CONTACTS Rmins 1 TON T_onm 59800000 TOF T_offm 200000 COIL Rmins 0 0 0 END RUNG CONTACTS Rsecs 1 TON T_ons 900000 TOF Toffs 100000 COIL Rsecs 0 0 0 END RUNG CONTACTS YBelt 0 CONTACTS Rmins 0 COIL YCOUNTER 0 0 0 END RUNG COMMENT UC1 output clock for timing delays. Was nominal 4.55min, now 1.00min;\\r\\nselectable to 1.00sec for debug. END RUNG PARALLEL SERIES CONTACTS Xrate 1 CONTACTS Rmins 0 END SERIES CONTACTS Xrate 0 CONTACTS Rsecs 0 END END COIL RUC103 0 0 0 END RUNG COMMENT UC3 transfer time (after heater which is enabled if cold)\\r\\n CLOCK INHIBIT count Reset UC315 from UB104 END RUNG CONTACTS RUC103 0 CONTACTS RUC311 1 CTU CUC3 45 COIL RUC311 0 0 0 END RUNG CONTACTS RUB104 0 RES CUC3 END RUNG COMMENT UC5 "hot" counter; selectable heater time before transfer\\r\\n CLOCK INHIBIT count Reset UC515 from UB511=not(XFR) END RUNG CONTACTS RUC103 0 CONTACTS RSC6 1 CTU CUC5 15 COIL RSC6 0 0 0 END RUNG COMMENT Set UC5 CTU count limit for desired preheat time END RUNG CONTACTS YXFR 1 RES CUC5 END When programmed, the MCU gives a HTR time of 45 and a XFR time of 15; i use that select line for seconds so i do not have to wait so long...

Reply to
Robert Baer

Thanks. I've tried to convert it to text format, but the program crashed while exporting. At least it works in the simulator.

I'm new to ladder logic, could you explain the meaning of the inputs and outputs and how it should work? I've clicked some X-inputs, but the counters are all the time set to reset.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

Frank Buss wrote:

I've found the bug in the source (in draw_outputdev.cpp, line 528, the CheckFree(ExportBuffer[i]) is wrong) and notified the author of the program. Below is the exported ladder logic diagram in text format.

This was the simple part. Now your ladder logic diagram. After starting, I set XReset to 1. Then I set XThermostat to 0 and XLoLevel and XHiLevel to 1 and XRate to 0, for second debug mode, and CUC3 starts counting. YHTR is set to 1. After CUC3 reaches 45, YXFR is set to 1. So if you want 15 seconds max for the heater, like you wrote in the comment, then 45 seconds transfer time, just swap the delays: Set 15 for counter CUC3 and 45 for CUC5.

BTW: I'm not a puzzle fan, but do you think, PLCs would attract people who are playing Sudoku and the like? The goal of the game would be that one output has to switch to high. Which buttons do you have to push in which order and with which time delays to make it high?

LDmicro export text for 'Microchip PIC16F877 40-PDIP', 3.686400 MHz crystal, 10.0 ms cycle time

LADDER DIAGRAM:

|| || || ; begin Row 1 Page 1; RUB111 = LO @ full, RUB209 = HI @ empty || 1 || || || || || || || || || || || XLoLevel RUB111 || 2 ||-------]/[------+----------------------------------------------------------( )-------|| || | || || XHiLevel | || ||-------]/[------+ || || || || || || || || || || XLoLevel XHiLevel RUB209 || 3 ||-------]/[--------------]/[------------------------------------------------( )-------|| || || || || || || || || || RUB209 YStop RUB206 || 4 ||-------]/[--------------]/[------------------------------------------------( )-------|| || || || || || || || || || YStop RUB111 RUB309 || 5 ||-------]/[--------------]/[------------------------------------------------(/)-------|| || || || || || || || || || RUB103 RUB104 || 6 ||-------]/[------+----------------------------------------------------------( )-------|| || | || || RUB206 | || ||-------]/[------+ || || || || || || || || || || RUB309 RUB103 || 7 ||-------]/[------+----------------------------------------------------------( )-------|| || | || || RUB104 | || ||-------]/[------+ || || || || || || || || || || ; begin Row 2 Page 1 || 8 || || || || || || || || || || || XThermostat RUB103 YHTR || 9 ||-------] [--------------] [------------------------------------------------( )-------|| || || || || || || || || || XThermostat RUB103 YXFR ||

10 ||-------]/[--------------] [------+-----------------------------------------( )-------|| || | || || XThermostat RUC311 | || ||-------] [--------------] [------+ || || || || || || || || || || ; begin Row 3 Page 1 || 11 || || || || || || || || || || || XSafety RFault || 12 ||-------] [------+----------------------------------------------------------( )-------|| || | || || XLid | || ||-------] [------+ || || | || || XBelt | || ||-------] [------+ || || | || || XExtremeLevel | || ||-------] [------+ || || | || || XMot1 | || ||-------]/[------+ || || | || || XMot2 | || ||-------]/[------+ || || | || || RSC6 | || ||-------] [------+ || || || || || || || || || || XReset YBelt YStop || 13 ||-------]/[--------------]/[------------------------------------------------( )-------|| || || || || || || || || || RFault YStop YBelt || 14 ||-------]/[--------------]/[------------------------------------------------( )-------|| || || || || || || || || || ; begin Input Page 2 || 15 || || || || || || || || || || || XRotation YROT || 16 ||-------] [-----------------------------------------------------------------( )-------|| || || || || || || || || || Rmins T_onm T_offm Rmins || 17 ||-------]/[--------[TON 59.800 s]---[TOF 200.0 ms]--------------------------( )-------|| || || || || || || || || || Rsecs T_ons Toffs Rsecs || 18 ||-------]/[--------[TON 900.0 ms]---[TOF 100.0 ms]--------------------------( )-------|| || || || || || || || || || YBelt Rmins YCOUNTER || 19 ||-------] [--------------] [------------------------------------------------( )-------|| || || || || || || || || || ; UC1 output clock for timing delays. Was nominal 4.55min, now 1.00min; || 20 || ; selectable to 1.00sec for debug. || || || || || || || || || || Xrate Rmins RUC103 || 21 ||-------]/[--------------] [------+-----------------------------------------( )-------|| || | || || Xrate Rsecs | || ||-------] [--------------] [------+ || || || || || || || || || || ; UC3 transfer time (after heater which is enabled if cold) || 22 || ; CLOCK INHIBIT count Reset UC315 from UB104 || || || || || || || || || || RUC103 RUC311 CUC3 RUC311 || 23 ||-------] [--------------]/[----------[CTU

|| || || || || || || || || RUB104 CUC3 ||

24 ||-------] [----------------------------------------------------------------{RES}------|| || || || || || || || || || ; UC5 "hot" counter; selectable heater time before transfer || 25 || ; CLOCK INHIBIT count Reset UC515 from UB511=not(XFR) || || || || || || || || || || RUC103 RSC6 CUC5 RSC6 || 26 ||-------] [--------------]/[----------[CTU

|| || || || || || || || || ; Set UC5 CTU count limit for desired preheat time ||

27 || || || || || || || || || || || YXFR CUC5 || 28 ||-------]/[----------------------------------------------------------------{RES}------|| || || || || || || ||------[END]--------------------------------------------------------------------------|| || || || ||

I/O ASSIGNMENT:

Name | Type | Pin ----------------------------+--------------------+------ XBelt | digital in | 24 XExtremeLevel | digital in | 26 XHiLevel | digital in | 16 XLid | digital in | 25 XLoLevel | digital in | 15 XMot1 | digital in | 6 XMot2 | digital in | 7 XReset | digital in | 18 XRotation | digital in | 2 XSafety | digital in | 23 XThermostat | digital in | 17 Xrate | digital in | 20 YBelt | digital out | 33 YCOUNTER | digital out | 28 YHTR | digital out | 22 YROT | digital out | 21 YStop | digital out | 29 YXFR | digital out | 27 RFault | int. relay | RSC6 | int. relay | RUB103 | int. relay | RUB104 | int. relay | RUB111 | int. relay | RUB206 | int. relay | RUB209 | int. relay | RUB309 | int. relay | RUC103 | int. relay | RUC311 | int. relay | Rmins | int. relay | Rsecs | int. relay | T_onm | turn-on delay | T_ons | turn-on delay | T_offm | turn-off delay | Toffs | turn-off delay | CUC3 | counter | CUC5 | counter |

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

OK, set XLowLevel, XHiLevel, XThermostat, XMot1, XMot2, Xrate to 1. This forces full tank status, cold, motor OK, and seconds instead of minutes for counting (you do nnot want to wait an hour for a full cycle). Momentary 1 on XReset to start and let it run (15+45 seconds) to fault condition (Stop).

Yes, interchange labels and times and one is OK.

*** PS i found the cause of the problem with some help. In the schematic, i had the leads going to/from UC3 and UC5 interchanged; their labelled functions were correct in the original discrete CMOS board. Now i have the schematic corrected as well as the ladder logic. Thanks.
Reply to
Robert Baer

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.