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.
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.
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)
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
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.
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.
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
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...
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
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
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.
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.