Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - When compiling ANSIC with the yPlcCycleDuty checkbox ticked in Settings -> MCU Parameters no C code is generated for setting and unsetting the yPlcCycleDuty pin each cycle.

(you are viewing a thread; or go back to list of threads)

When compiling ANSIC with the yPlcCycleDuty checkbox ticked in Settings -> MCU Parameters no C code is generated for setting and unsetting the yPlcCycleDuty pin each cycle. (by Greg Blackwell)
Test case to demonstrate the issue:
Start the current version of LDmicro version 4.3.3
Create a simple program that has a single rung with a single contact and a single coil:
- Menu: Instruction -> Insert Contacts: Input Pin
- Menu: Instruction -> Insert Coil: Output Pin
Enable the Plc Duty Cycle feature
- Menu: Settings -> MCU Parameters ...
- Tick the YPlcDutyCycle check box
Compile to ANSI C
- Menu: Compile -> Compile ANSIC
The "Compile To" dialog is displayed. Accept the default filename new.c
Save the ladder program
- Menu: File -> Save
The "Save As" dialog is displayed. Choose the filename new.ld

Examing the contents of the file new.ld.
- This is the IO list from the file new.ld includes the two ouput pins Ynew and YPlcCycleDuty:
IO LIST
Xnew at 0 0 0
YPlcCycleDuty at 0 0 0
Ynew at 0 0 0
END

Examine the contents of the file new.c
- Search the file new.c for the string "YPlcCycleDuty". Nothing is found
- There are function prototypes delcared for setting the ouput pin coil Ynew but there are no function prototype declarations generated to set the YPlcCycleDuty pin.
- The function PlcCycle() does have a call to the function Write_Ub_Ynew() for setting the output pin Ynew but does not have any code for setting the output pin YPlcCycleDuty.

My investigation into the reason for this behaviour
In the file ansic.cpp the function GenerateDeclarations() is called to generate the C code for declarations of variables and function prototypes while the function GenerateAnsiC() is called to generate C code for the contents of the function PlcCycle(). Both functionsGenerateDeclarations() and GenerateAnsiC() loop through the IntCode[] array to generate the C code.

The IntCode[] array is populated in the file intcode.cpp. There are no reference to YPlcCycleDuty anywhere in intcode.cpp so it appears that no op's are inserted into the IntCode[] array when the YPlcCycleDuty option is ticked. As the ANSI C code is being generated from the contents of the IntCode[] array this means that nothing is generated for the YPlcCycleDuty option when it is checked.
Wed Jan 10 2018, 06:45:48
(no subject) (by Ihor Nehrutsa)
will fixed in Release 4.3.4
Wed Jan 10 2018, 17:32:38
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):