It is said that PLC engineers have high salaries, but learning is difficult. Today, I had a sudden idea to use GPT-4 to write PLC programs and see how it performs.
First, let’s try using GPT-4 to write a simple PLC program:
Input to GPT-4: write a Siemens PLC function block, that can run on TIA portal platform, the program has 2 inputs and 1 output. 2 inputs are light on and light off, 1 output is relay on.(编写一个Siemens PLC功能块,可以在TIA门户平台上运行,该程序有2个输入和1个输出。2路输入为灯亮、灯灭,1路输出为继电器亮。)
GPT-4 replied immediately (translated to Chinese):
It provided specific operational steps, almost like a nanny-style tutorial, and also gave an example program:
There were basically no errors, and it also provided deployment testing steps, which means it could basically run. Amazing, it saved me a lot of foundational work time. It was much more accurate than Baidu.
Next, let’s try something more challenging and modify the above program:
Input: Rewrite the above program to change it to one input, lightButton, where pressing it once turns the light on and pressing it again turns the light off.
Before long, the result came out:
I carefully reviewed it, and there were basically no problems. This question would require some thought from an intermediate PLC engineer and is prone to errors. GPT-4 has greatly improved efficiency and showed no complaints.
Those who have done projects should know that the client often changes requirements. Today, I let GPT-4 experience this and see what the result is.
Input:Change to two inputs, lightButton1 and lightButton2, so that each input can toggle the current output when pressed.
GPT-4’s output is as follows:
After testing, it basically works. Amazing.
I challenged GPT-4 further:No, change Siemens to Mitsubishi.
This requirement is completely a rebuild; if it were a PLC engineer, they might argue with the client. However, GPT-4 still outputs without any complaints:
The code is basically correct and can continue to be improved according to the client’s requirements.
GPT-4 makes PLC programming simple, and for those who are eager to learn PLC programming but worry they can’t learn it, they can use GPT-4 to assist in learning and easily master PLC knowledge.
Of course, mastering PLC programming requires practical experience and an understanding of PLC principles, so I still recommend that beginners go for systematic PLC learning.
If you want to learn PLC engineer courses, leave a message or comment ‘1’ at the end of the article, and I will send you free tutorials on using GPT-4 and Siemens and Mitsubishi PLC learning materials.