LPC_DEBUG на материнской плате — что это такое?
Вообще какие разьемы и для чего они — должно быть описано в инструкции, если ее нет, то стоит посмотреть мануалы в интернете (правда обычно они на английском идут).
POST-коды уже давно используются для анализа материнки, если она вышла из строя. Как все примерно работает — к материнке подключается устройство, которое может выводить POST-коды. Потом включается материнка и по коду определяется в каком узле неисправность.
Чаще всего для таких целей используется специальная PCI-карта, которая имеет небольшой экран для отображения кода ошибки:
На некоторых игровых платах или платах класса премиум такой индикатор может быть встроенным:
Но карты были даже во времена шины ISA — она была еще до простой PCI, а это на минуточку еще до выхода Pentium 4, то есть очень давно. Вот собственно карта для ISA:
Надеюсь информация оказалась помогла. Удачи и добра, до новых встреч, друзья!
Оборудование для мебельного производства и деревообработки
Не бойся поломать. Бойся не починить ))
Re: PLC Debug
Сообщение Lexasun » 25 мар 2015 21:40
PLC Debug
Сообщение demonlibra » 25 мар 2015 22:15
Не бойся поломать. Бойся не починить ))
Re: PLC Debug
Сообщение Lexasun » 25 мар 2015 22:16
Re: PLC Debug
Сообщение demonlibra » 25 мар 2015 22:19
Не бойся поломать. Бойся не починить ))
Re: PLC Debug
Сообщение Lexasun » 25 мар 2015 22:31
PLC Debug
Сообщение AWS MLK » 11 мар 2021 12:45
PLC Debug
Сообщение demonlibra » 11 мар 2021 13:31
Не бойся поломать. Бойся не починить ))
myCNC Online Documentation
PLC controller can load and run small binary programs (PLC procedures). PLC procedure should be written in a simplified C-like language, compiled and stored in PLC controller memory to be ready to run. myCNC software includes PLC Builder — tiny IDE (Integrated Development Environment) to create and modify PLC procedure source files, compile them to binary code and upload it as RomFS iso image disk to PLC controller memory.
myCNC control has 2 types of built-in PLC systems that named Hardware PLC and Software PLC.
Note that hardware PLC can be launched from software PLC if necessary, through the use of gvarset(100040,HARDWAREPLC); command (replace HARDWAREPLC with your M-command of choice). You can read more on the process in the Software PLC section down below.
Hardware PLC
“Hardware PLC” means PLC system runs inside the CNC control board and able to access directly to CNC controller peripherals (inputs, outputs, PWMs, DACs, ADCs etc). PLC has also API to access to Motion Controller of a myCNC control board, so positioning commands are possible from Hardware PLC.
Hardware PLC is a tiny virtual machine that runs pre-compiled PLC procedures. PLC procedure can be started from
Hardware PLC loop cycle time is 1ms. PLC core runs PLC procedure until the end of next loop. At the end of each loop PLC sleeps for 1ms, then continue running PLC. N-times repeat loop (even empty) will be executed N milliseconds. For example, delay for 10ms can be programmes as
PLC Language
For example, changing the value of PWM01 can be done using the following PLC procedure:
Operator | Description | Example |
---|---|---|
sum | ||
subtract | ||
multiply | ||
divide | ||
logical AND | ||
logical OR | ||
binary right shift | ||
binary left shift | ||
equal to | ||
not equal to | ||
more than | ||
more or equal than | ||
less than | ||
less or equal than | ||
variable post increment | ||
variable post decrement |
Address | Description |
---|---|
20000…20100 | Print variable value in myCNC control message widget for debugging purpose. Values written to this registers will be printed in myCNC control software in Message widget — this is useful to see values of certain variables directly in the log window as the program is running. |
It is possible to access the state of the output via gvarget commands from within the PLC process:
Starting from 0x400 to represent OUT0, this is a hexadecimal system that is simple to convert to dotted decimals (through the likes of a simple reference site here). Thus, for example, gvarget(0x40d); will return the state of Output #13.
The hardware access registers
Name | Address | Description |
---|---|---|
GVAR_HW_INPUTS0 | 7180 | |
GVAR_HW_INPUTS1 | 7181 | |
GVAR_HW_INPUTS2 | 7182 | |
GVAR_HW_INPUTS3 | 7183 | |
GVAR_HW_OUTPUTS0 | 7184 | YouTube tutorial |
GVAR_HW_OUTPUTS1 | 7185 | |
GVAR_HW_OUTPUTS2 | 7186 | |
GVAR_HW_OUTPUTS3 | 7187 | |
GVAR_HW_INPUTS4 | 7188 | |
GVAR_HW_INPUTS5 | 7189 | |
GVAR_HW_INPUTS6 | 7190 | |
GVAR_HW_INPUTS7 | 7191 | |
GVAR_HW_OUTPUTS4 | 7192 | |
GVAR_HW_OUTPUTS5 | 7193 | |
GVAR_HW_OUTPUTS6 | 7194 | |
GVAR_HW_OUTPUTS7 | 7195 | |
GVAR_HW_ADC0 | 7196 | |
GVAR_HW_ADC1 | 7197 | |
GVAR_HW_ADC2 | 7198 | |
GVAR_HW_ADC3 | 7199 | |
GVAR_HW_ADC4 | 7200 | |
GVAR_HW_ADC5 | 7201 | |
GVAR_HW_ADC6 | 7202 | |
GVAR_HW_ADC7 | 7203 | |
GVAR_HW_DAC0 | 7270 | |
GVAR_HW_DAC1 | 7271 | |
GVAR_HW_DAC2 | 7272 | |
GVAR_HW_DAC3 | 7273 | |
GVAR_HW_DAC4 | 7274 | |
GVAR_HW_DAC5 | 7275 | |
GVAR_HW_DAC6 | 7276 | |
GVAR_HW_DAC7 | 7277 | |
GVAR_HW_PWM0 | 7278 | |
GVAR_HW_PWM1 | 7279 | |
GVAR_HW_PWM2 | 7280 | |
GVAR_HW_PWM3 | 7281 | |
GVAR_HW_PWM4 | 7282 | |
GVAR_HW_PWM5 | 7283 | |
GVAR_HW_PWM6 | 7284 | |
GVAR_HW_PWM7 | 7285 |
Software PLC
“Software PLC” means PLC system runs inside the myCNC software and controls CNC controllers peripherals through Software API .
The main advantage of Software PLC is multitasking. All PLC procedures are running simultaneously and independent from each other.
Software PLC cycle time is 100ms, so Software PLC is suitable for wide range of slow applications like automatic lubricant control, fume exhaust control, alarm sensors control etc.
symbols. “System” procedures are not started automatically with the myCNC software start, but instead can be started automatically with some events or manually. There are a few pre-defined “System” PLC handlers-
Handler Name | Comments |
---|---|
The procedure executed just after myCNC software started AND configuration is sent to the myCNC control board. The procedure can be used to perform some inputs testing and switch outputs just after the software started. | |
The procedure executed just before the myCNC software closed. | |
The procedure executed just before the myCNC software run g-code (after pressing PLAY button) | |
The procedure executed just after the myCNC software finished g-code running (after pressing STOP/PAUSE button) | |
Initially named BV17, this Software PLC had double underscores added to remove an issue with automatic enabling of the testing mode for the controller peripherals (by becoming a System PLC, it prevents the procedure from starting automatically when the program is loaded). |
Variables used in Software PLC:
Variable | Use | Example | Comment |
---|---|---|---|
100020 | Jog the selected axis (100020 through to 100027) | gvarset(100020, 100); | Negative values are not accepted, use 0-X (for example, gvarset(100020, 0-100);) |
100040 | Launch a Hardware PLC from within a Software PLC | gvarset(100040, 607); | This will launch Hardware PLC M607 |
100041 | Eparameter to feed into the Hardware PLC being launched using 100040 | gvarset(100041, 333); | Used before gvarset(100040, 607);, this will set eparam=333 |
Compare Software and hardware PLC
Parameter | Software PLC | Hardware PLC |
---|---|---|
Loop time | 100ms | 1ms |
Hardware access | Slow, through the software and Ethernet communication | Fast, direct in myCNC controller |
Multitasking | Yes, all PLC procedures are running simultaneously in separate threads | No, starting new procedure will terminate a current procedure |
Code size for PLC procedure | 16k bytes | 512 bytes |
Total disk size for PLC procedures | Unlimited | 8k bytes |
Language Core for Software and Hardware PLC are almost the same so language syntax is pretty the same and similar to C-language but VERY VERY stripped down.
PLC Language
PLC variables
PLC builder will define variable “output0” and assign the value to “15”
PLC predefined variables
PLC defines
Name | Value | Comment |
PLCCMD_MOTION_CONTINUE | 1001 | |
PLCCMD_MOTION_SKIP | 1002 | |
PLCCMD_MOTION_SOFT_SKIP | 1003 | |
PLCCMD_MOTION_PAUSE | 1004 | |
PLCCMD_PLC_PAUSE | 1005 | |
PLCCMD_PLC_FORK_PAUSE | 1006 | |
PLCCMD_LINE_SOFT_STOP | 1007 | |
PLCCMD_LINE_STOP | 1008 | |
PLCCMD_REPLY_TO_MYCNC | 1100 | |
PLCCMD_SET_CNC_VAR | 1010 | |
PLCCMD_SET_THC_VAR | 1011 | |
PLCCMD_SET_DEVICE_VAR16 | 1012 | |
PLCCMD_SET_DEVICE_VAR32 | 1014 | |
PLCCMD_SET_CNC_EXTVAR | 1020 | |
PLCCMD_MOTION_ABORT | 1032 | |
PLCCMD_MOTION_BREAK | 1033 | |
PLCCMD_SAVE_POS | 1040 | |
PLCCMD_THC_START | 1050 | |
PLCCMD_THC_STOP | 1051 | |
PLCCMD_THC_PAUSE | 1052 | |
PLCCMD_THC_CONTINUE | 1053 | |
PLCCMD_WATCHBIT1_ON | 1060 | |
PLCCMD_WATCHBIT2_ON | 1061 | |
PLCCMD_WATCHBIT3_ON | 1062 | |
PLCCMD_WATCHBIT4_ON | 1063 | |
PLCCMD_TRIGGER1_ON | 1060 | |
PLCCMD_TRIGGER2_ON | 1061 | |
PLCCMD_TRIGGER3_ON | 1062 | |
PLCCMD_TRIGGER4_ON | 1063 | |
PLCCMD_TRIGGER1_OFF | 1064 | |
PLCCMD_TRIGGER2_OFF | 1065 | |
PLCCMD_TRIGGER3_OFF | 1066 | |
PLCCMD_TRIGGER4_OFF | 1067 | |
PLCCMD_WATCHBIT1_OFF | 1064 | |
PLCCMD_WATCHBIT2_OFF | 1065 | |
PLCCMD_WATCHBIT3_OFF | 1066 | |
PLCCMD_WATCHBIT4_OFF | 1067 | |
PLCCMD_WATCHBIT5_ON | 1068 | |
PLCCMD_WATCHBIT6_ON | 1069 | |
PLCCMD_WATCHBIT7_ON | 1070 | |
PLCCMD_WATCHBIT8_ON | 1071 | |
PLCCMD_WATCHBIT5_OFF | 1072 | |
PLCCMD_WATCHBIT6_OFF | 1073 | |
PLCCMD_WATCHBIT7_OFF | 1074 | |
PLCCMD_WATCHBIT8_OFF | 1075 | |
PLCCMD_WAIT_FOR_CAMERA | 1090 | |
PLCCMD_WAIT_VARSET | 1091 | |
PLCCMD_WAIT_VARCLEAR | 1092 | |
PLCCMD_CAMERA_START | 1093 | |
PLCCMD_CAMERA_FINISH | 1094 | |
PLCCMD_PLC_DEBUG | 1098 | |
PLCCMD_PLC_RESTART | 1099 | |
PLC_BROADCAST_INQUIRY0 | 1200 | |
PLC_BROADCAST_INQUIRY1 | 1201 | |
PLC_BROADCAST_INQUIRY2 | 1202 | |
PLC_BROADCAST_INQUIRY3 | 1203 | |
PLC_BROADCAST_INQUIRY4 | 1204 | |
PLC_BROADCAST_INQUIRY5 | 1205 | |
PLC_BROADCAST_INQUIRY6 | 1206 | |
PLC_BROADCAST_INQUIRY7 | 1207 | |
PLC_BROADCAST_INQUIRY8 | 1208 | |
PLC_BROADCAST_INQUIRY9 | 1209 | |
PLC_BROADCAST_INQUIRY10 | 1210 | |
PLC_BROADCAST_INQUIRY11 | 1211 | |
PLC_BROADCAST_INQUIRY12 | 1212 | |
PLC_BROADCAST_INQUIRY13 | 1213 | |
PLC_BROADCAST_INQUIRY14 | 1214 | |
PLC_BROADCAST_INQUIRY15 | 1215 | |
PLC_BROADCAST_OK | 1220 | |
PLC_BROADCAST_ABORTED | 1221 | |
PLCCMD_MODBUS_SPINDLE_SPEED | 1230 | |
PLCCMD_MODBUS_SPINDLE_CMD | 1231 | |
PLCCMD_SET_PIDTIME | 1240 |
Note on PLC define naming
Please note that there exist some limitations of the preprocessor that parses the #define lines. Specifically, it is not possible to have a full name of one parameter be part of the name of another parameter.
For example, an argument name such as OUTPUT_SPINDLE (present by default in the pins.h file), means that there must be no other define-names containing this substring. As such, names such as
are NOT allowed, ssince they all contain the string “OUTPUT_SPINDLE”. Instead, you can make argument names such as
since those do not contain the exact string from before. Failure to properly define your arguments in such a manner and then utilizing them in your PLC commands will result in a error during compilation with a label “syntax error, unexpected ID”.
PLCCMD_MOTION_CONTINUE and PLCCMD_MOTION_SKIP
The abovementioned PLCCMD_MOTION_CONTINUE and PLCCMD_MOTION_SKIP commands are highly useful for certain applications since typically the motion controller runs commands one by one. By design, if within a running program the next code is a PLC M-code, then the movement will be stopped and the controller will run the PLC program. A message from within the PLC called PLCCMD_MOTION_CONTINUE is used to instruct the Motion controller to read and run the next code from the buffer (thus starting the next motion command).
After this code, the PLC procedure continues running through its code while at the same time the next motion code is launched. In this way, both the PLC procedure and the motion command will be running simultaneously.
This is useful for applications such as homing since it makes it possible to both move the axis and monitor the home sensor in the PLC procedure at the same time. That way when the sensor is activated, the current movement command will need to be stopped. A different message called PLCCMD_MOTION_SKIP is then used — the motion controller will cancel current motion (it will stop moving) and will read the next code from the buffer.
PLC processes named
PLC process name | Value | Comment |
plc_proc_check_plasma | 10 | |
plc_proc_venting | 11 | |
plc_proc_start_power | 12 | |
plc_proc_cooling | 14 | |
plc_proc_plasma | 15 | |
plc_proc_wait_plasma | 18 | |
plc_proc_pierce | 27 | |
plc_proc_no_plasma | 62 | |
plc_proc_check_preflow | 16 | |
plc_proc_check_cutflow | 17 | |
plc_proc_check_gases | 23 | |
plc_proc_test_out | 24 | |
proc_m_function | 30 | |
proc_zeroing | 32 | |
plc_proc_probing | 33 | |
plc_proc_ignition | 50 | |
plc_proc_preheat | 51 | |
plc_proc_soft_start | 52 | |
plc_proc_piercing | 53 | |
plc_proc_flame | 54 | |
plc_proc_cutting | 60 | |
plc_proc_purge | 61 | |
plc_proc_no_cutting | 62 | |
plc_proc_moveup | 65 | |
plc_proc_spindle | 70 | |
plc_proc_idle | 0 |
PLC exit codes list.
Normally PLC procedure should return code 99.
In case Error happened PLC procedure may return an error code. MyCNC software will catch exit code and report about Error if the error code is in PLC exit codes list.
Exit code name | Value | Comment |
plc_process | 0 | exit code is zero when PLC process is not finished yet |
plc_exit_gas_fail | 2 | PLC aborted, No air pressure sensor |
plc_exit_plasma_timeout | 3 | PLC aborted, No Arc sensor signal Timeout |
plc_exit_plasma_fail | 4 | PLC aborted, PLC Plasma Start cutting procedure error |
plc_exit_alarm_key | 5 | PLC aborted, Emergency key pressed |
plc_exit_coolant_fail | 6 | PLC aborted, No Coolant flow sensor |
plc_exit_probe_error | 7 | PLC aborted, No signal from probe sensor |
plc_exit_motor_shorted | 8 | PLC aborted, Motor short circuit detected (ET2/ET4 boards) |
plc_exit_broadcast_error | 10 | Error send broadcast message in multi-device configuration |
plc_exit_normal | 99 | Normal exit |
plc_exit_extern_break | 100 | PLC procedure aborted from outside of PLC core |
PLC messages
Message name | Value | Comment |
PLC_MESSAGE_PLASMA_OK | 101 | |
PLC_MESSAGE_WATCHBIT_ACTION | 110 | |
PLC_MESSAGE_SPINDLE_SPEED_CHANGED | 120 | |
PLC_MESSAGE_PULL_OUT_TOOL | 130 | |
PLC_MESSAGE_SPINDLE_TURNING 131 | ||
PLC_MESSAGE_ENCODER_DATA | 140 | |
PLC_MESSAGE_GVAR_VALUE | 141 | |
PLC_MESSAGE_UID | 142 | |
PLC_MESSAGE_HCONTROL_OFFSET | 144 | |
PLC_MESSAGE_TANGENT_ANGLE | 145 | |
PLC_MESSAGE_USER | 146 | |
PLC_MESSAGE_HCONTROL_JSPEED | 147 | |
PLC_MESSAGE_HCONTROL_DC | 148 | |
PLC_MESSAGE_ASK_RECALC | 150 | |
PLC_MESSAGE_SOFTLIMIT_STOP | 151 | |
PLC_MESSAGE_GVARSET | 153 | |
PLC_MESSAGE_IHC_NOT_CONNECTED | 155 | |
PLC_MESSAGE_IHC_ERROR | 156 | |
PLC_MESSAGE_LATHE_GEARS | 160 | |
PLC_MESSAGE_ERR_VM | -1 | |
PLC_MESSAGE_ERR_ROMFS | -2 | |
PLC_MESSAGE_MOTION_BUFFER_EMPTY | -5 | |
PLC_MESSAGE_ERR_SENSOR_COOLANT | -10 | |
PLC_MESSAGE_ERR_SENSOR_AIR | -11 | |
PLC_MESSAGE_ERR_SENSOR_GAS | -12 | |
PLC_MESSAGE_ERR_SENSOR_OXYGEN | -13 | |
PLC_MESSAGE_ERR_SENSOR_PLASMA | -14 | |
PLC_MESSAGE_ERR_PROBING | -15 | |
PLC_MESSAGE_ERR_PLASMA_FAIL | -20 | |
PLC_MESSAGE_ERR_PLASMA_TIMEOUT | -21 | |
PLC_MESSAGE_PRESSED_ALARM_KEY | -30 | |
PLC_MESSAGE_PRESSED_STOP_KEY | -31 | |
PLC_MESSAGE_MOTOR_SHORTED | -35 |
MAPPED_OUT_THC_LOWSPEED | 63 |
MAPPED_OUT_LOW_MOTOR_CURRRENT | 65 |
Controller peripherals API from PLC procedures
A number of Global variable addresses are mapped to Hardware Inputs/Outputs. PLC procedure can access the controller peripherals through GVarGet/GVarSet function. Addresses to access to controller hardware are listed below
Variabe Name | Address | Description |
---|---|---|
GVAR_HW_INPUTS0… GVAR_HW_INPUTS3 | 7180… 7183 | |
GVAR_HW_OUTPUTS0… GVAR_HW_OUTPUTS3 | 7184… 7187 | |
GVAR_HW_INPUTS4… GVAR_HW_INPUTS7 | 7188… 7191 | |
GVAR_HW_OUTPUTS4… GVAR_HW_OUTPUTS7 | 7192… 7195 | |
GVAR_HW_ADC0… GVAR_HW_ADC7 | 7196… 7203 | |
GVAR_HW_DAC0… GVAR_HW_DAC7 | 7270… 7277 | |
GVAR_HW_PWM0… GVAR_HW_PWM7 | 7270… 7277 | |
GVAR_ET5_ENCODER … | ||
GVAR_ET5_ENCODER_Z … | ||
GVAR_ET5_ENCODER_WZ … | ||
GVAR_ET5_ENCODER … | ||
GVAR_MODBUS_READ | ||
GVAR_THC0_CONTROL | 7570 | |
GVAR_THC1_CONTROL | 7575 | |
GVAR_CURRENT_MOTION_CODE | 6060 | |
GVAR_MD_MASTER_MOTION_CODE | 7140 | |
GVAR_CURRENT_TOOL_NUMBER | 5400 | |
GVAR_HCONTROL2_VREF | ||
GVAR_PLC_MOVE_PROCESS | ||
GVAR_CAMERA_READY | 7090 | |
GVAR_CURRENT_MACHINE_POSITION | 5021, 5022, 5023, 5024, 5025, 5026 | |
GVAR_CURRENT_PROGRAM_POSITION | 5041, 5042, 5043, 5044, 5045, 5046 | |
GVAR_ENCODER_Z_EVENT | ||
— | 17001 | Return Current PROGRAM X Position in PLC units (0.01mm) |
— | 17002 | Return Current PROGRAM Y Position in PLC units (0.01mm) |
— | 17003 | Return Current PROGRAM Z Position in PLC units (0.01mm) |
— | 17004 | Return Current PROGRAM A Position in PLC units (0.01degree) |
— | 17005 | Return Current PROGRAM B Position in PLC units (0.01degree) |
— | 17006 | Return Current PROGRAM C Position in PLC units (0.01degree) |
— | 17007 | Return Current PROGRAM U Position in PLC units (0.01mm) |
— | 17008 | Return Current PROGRAM V Position in PLC units (0.01mm) |
— | 17009 | Return Current PROGRAM W Position in PLC units (0.01mm) |
— | 17021 | Return Current MACHINE X Position in PLC units (0.01mm) |
— | 17022 | Return Current MACHINE Y Position in PLC units (0.01mm) |
— | 17023 | Return Current MACHINE Z Position in PLC units (0.01mm) |
— | 17024 | Return Current MACHINE A Position in PLC units (0.01degree) |
— | 17025 | Return Current MACHINE B Position in PLC units (0.01degree) |
— | 17026 | Return Current MACHINE C Position in PLC units (0.01degree) |
— | 17027 | Return Current MACHINE U Position in PLC units (0.01mm) |
— | 17028 | Return Current MACHINE V Position in PLC units (0.01mm) |
— | 17029 | Return Current MACHINE W Position in PLC units (0.01mm) |
Launching a PLC command using an on-screen button
The following video illustrates the process of creating a button to launch a software PLC command (a similar process can also be used for hardware PLCs):
Launching a Hardware PLC procedure from Software PLC
It is possible to launch Hardware PLC procedures from within a Software PLC command. This can be done for purposes such as utilizing certain commands are not available from the Software PLC, and that some require low-latency sensor monitoring. It also has the added benefit of utilizing the unlimited number of procedures that can work simultaneously in Software PLC, allowing the user create things such as permanent while loops, etc.
For example, a code such as:
will launch Hardware PLC M602 from the specified Software PLC.
Additionally, the Param variable can also be used to call a Hardware PLC with a certain eparam variable.
For example, adding a line such as
will launch the M602 Hardware PLC with the Param variable.
Jog from PLC
NOTE: Jog from PLC requires a firmware update. As of February 2022, the feature is available in the Testing firmware branch.
myCNC allows the user to call for a jog command from within PLCs. The advantage of this motion mode is that it allows to perform tasks (such as changing the speed and direction of movement, as well as turning the motion for a particular axis on or off), all without stopping. This is useful in such applications as homing along multiple (for example, three) axes.
In this mode, the acceleration is set via the following command:
while the speed is set via the global variable #8634 (the axis mask is stored in the high-order byte):
Drives & Systems
PLC's, PAC's, Variable Speed Drives and Industrial Automation
PLC Program Debugging Checklist: 5 Things to do to correct errors during PLC Program development
So, you’re programing in a PLC platform that is new to you. The functions, tools and syntax may be different from what you are used to. As you get acquainted with them, there are probably going to be errors showing up in the message list when a build or compile is performed. The following are 5 things to do to debug or correct these errors when developing a PLC program.
Checklist item 1: Compile as you go (don’t wait until the end) and check the messag e s
a. About compiling often: Nobel Prize winner Daniel Kahneman in his book ‘Thinking, Fast and Slow’ states a correlation between the ability to build expertise on a topic and the speed and quality of feedback during the process of learning. The inference of this in building PLC programs, specifically in an environment you are new to, is:
- Compile or build the program often
- Decipher the compile errors and messages accurately.
Some programs or programming environments are going to take longer to compile so this habit is dependent on the environment too.
b. The second part about deciphering the error message accurately is highly reliant on the environment itself. For instance, I am working in an IEC 61131-3 environment called SoMachine HVAC. The error message said ‘Token not found’ and pointed to an inexistent line number in the POU. After using Step 2 below, it turned out that one of the variables had a period/dot (.) in front of it which is acceptable in the CODESYS environment but not in the new environment. Removed the period/dot and the error message went away.
About checking the messages, observe if there are root cause messages that are effecting other error conditions. In CODESYS for instance, addressing the errors at the top of the error message list often results in the solving of multiple other errors that are lower in the list.
Checklist item 2: Check the help files and any example programs available
Some environments may have a manual. Some may have a good Help section. On either one of those, browse through the contents of the manual and Help files. When a problem arises, it may come in handy.
Another good reference is an example program. Trying to figure out how a read operation is performed over a comms network? Or maybe just the usage of a simple CASE structure sequence? Having one good written up program helps and can serve as a ‘go to’ program. When starting in a new environment, ask the vendor for some example code and programs.
Checklist item 3: Test only the suspect function, in a separate POU.
The idea here is to test the function and its utilization method. If you are using the function wrongly then this step will pick that up. Break the function down to the arguments that are fed to it. Check if any one of the arguments are of incorrect type of using wrong syntax. The ideal case is if the compiler picks up the error and tells you what is wrong but that is not always the case.
Checklist item 4: Comment out sections of the program and check if the errors persists.
As is common in tackling any engineering feat, ‘divide and conquer’. Comment out sections of the code and perform compiles systematically. Start with the section you suspect to be the root cause and then expand from there.
A note about the psychology of debugging; sometimes it is easy to blame the problem on the programming environment or a vendor. You might be telling yourself ‘This programming environment is buggy’ or ‘It’s not user friendly’. Try to quash this, have some faith and be bullish about solving the problem. This has helped me tackle problems much quicker rather than going back and forth with tech support or giving up only to find a simple solution I had overlooked.
Checklist item 5: Build your go to resource list … and Google away
Document your findings somewhere. Preferably somewhere searchable. This step takes time but will save you time later. Also, when someone comes to you for help, you will have something to give them – which helps me since I work for a vendor.
As stated above, collect examples from the vendor. I collect examples from colleagues, previous projects, development team…
Vendors may also have an online FAQ list, forum or wiki page. Get to know those resources.
Another resource maybe online forums like PLCTalk. For CODESYS, check out the CODESYS forum.
Hope this helps as a debug checklist. If there are any other methods out there, please add them to the comments section below. Given the thousands of hours controls engineers and PLC programmers spend debugging, there is probably a part 2 that needs to happen on this topic.