HCBBS Forum (English)
Submit Chemical Projects / Find Solutions
Amplify Your Requirements on a Broader Chemical Platform *Engineering · Technology · Equipment · Solutions*
Submit Request

Practical Tutorial on Creating a PLC Using Raspberry Pi

2019-06-09 View Original

Thread Content

Changhui Instruments introduces the use of Raspberry Pi to create PLCs, with CoDeSys as the programming software for writing programs and developing human-machine interfaces. Setting up a simple PLC environment helps with conducting relevant security research on this software. Common PLC manufacturers today include SIEMENS, Rockwell, Schneider, Mitsubishi, Beckhoff, GE, Omron, Delta, and so on. However, the programming languages used for PLCs are similar across these devices, such as LD, ST, FBD, CFC, IL, GRAPH, etc. CoDeSys supports LD, ST, IL, FBD, CFC, and other languages; it allows one to learn multiple PLC programming languages, and it is also possible to switch to other PLC programming software – TwinCAT2 and SoMachine, for example, were developed based on CoDeSys. Using a Raspberry Pi instead of the PLCs used in industrial settings facilitates learning and various types of research. 1. Prepare materials: ① CoDeSys V3.5_SP8 ② CODESYS Control for Raspberry PI 3.5.8.0.package ③ Win32DiskImager ④ Windows 7 PC ⑤ Raspberry Pi3 ⑥ Micro SD card ⑦ USB power supply ⑧ Monitor and HDMI cable ⑨ Mouse, keyboard. 2. Installation: ① Install Win32DiskImager on a Windows computer, then open it. http://yunrun.com.cn/upload/201906/08/201906080109288178.png ②Select the system image and the device to which it should be written (Micro SD card), then choose “Write”. http://yunrun.com.cn/upload/201906/08/201906080110563296.png ③ After completion, a completion dialog box will appear; click “OK”. http://yunrun.com.cn/upload/201906/08/201906080114117440.png ④Insert the Micro SD card into the Raspberry Pi, connect a monitor, and plug in the power cable. ⑤Turn on the power to start it. 3. Install CODESYS Control for Raspberry PI 3.5.8.0 package. ① Connect the Raspberry PI to a network cable as well as a mouse and keyboard. ②Configure the IP address. http://yunrun.com.cn/upload/201906/08/201906080116400959.png ③Enable the SSH service. http://yunrun.com.cn/upload/201906/08/201906080120410903.png ④Install CoDeSys on Win7. ⑤Install the CODESYS Control for Raspberry PI 3.5.8.0.package. ◆ Double-click on the CODESYS Control for Raspberry PI 3.5.8.0.package, check “I have read…”, and then click “Next”. ◆Select “Full Installation”, then keep pressing “Next” and finally “Finish”. http://yunrun.com.cn/upload/201906/08/201906080124472086.png ◆ After the installation is complete, open CoDeSys; the software packages that were just installed can be seen in “Tools” → “Package Manager”. http://yunrun.com.cn/upload/201906/08/201906080126519903.png ◆ Open “Update Raspberry PI”, select the version of the package, click “Scan” to automatically locate the Raspberry PI device (the Raspberry PI and Windows PC must be on the same local network), select the detected device, then click “OK”. Enter the username and password for the Raspberry PI, and then click “OK”. ◆After completion, the following information can be seen in CoDeSys’ messages: http://yunrun.com.cn/upload/201906/08/201906080128438929.png. ◆ After completion, this package file will appear in the Raspberry PI as well. http://yunrun.com.cn/upload/201906/08/201906080130501707.png ◆ Use the Telnet command on a Windows PC to test whether this software package has been installed successfully on the Raspberry Pi. (The Telnet service must be enabled on the Windows PC.) http://yunrun.com.cn/upload/201906/08/201906080134511874.png 4. Write PLC and HMI programs 4.1 Programming PLC programs ①Create a new project: select “Projects” → “Standard project”, give the project a name, choose the storage location, and then click “OK”. ②“For \"Device\", select \"CODESYS Control for Raspberry Pi……\". You can choose any programming language; here choose \"Ladder Logic Diagram\", then click \"OK\". ③Open the program editor. ④Define three bool variables named Start, Stop, and Lamp, which represent “start”, “stop”, and “light” respectively. ⑤Write PLC programs. 4.2 Programming the HMI program: ① Right-click on “Application” and add a “View”. ②Once confirmed, select “Active” in the pop-up dialog box, then “Open”. ③Open “Visualization”, then drag the “Light” and “Button” elements from the “Toolbox” on the right, and enter “Start” and “Stop” for the buttons; the result will be as follows. ④“The “Start” button is connected to the “Start” variable. ⑤Similarly, connect the “Stop” variable to the “Stop” button. ⑥“The “light” is connected to the “Lamp” variable. 4.3 Configure the “Network View”: Enter the view that was just drawn as the initial view; enter your own name for the .htm file – I chose the default value here. For the best match, select “Isotropic”. 4.4 Compile and save http://yunrun.com.cn/upload/201906/08/201906080138413467.png 4.5 Download ① Configure the network connection: Double-click on “Device”, enter the IP address of the Raspberry PI in the node name field, then press Enter. After accessing the target, it appears as shown in the figure below. http://yunrun.com.cn/upload/201906/08/201906080140274849.png ②Log in to the device; when a pop-up dialog appears, click “OK”. ③After the download is complete, click to start. ④It will look like this after completion. 5. Web login: Enter “http://192.168.0.168:8080/webvisu.htm” in the browser. 6. Summary: During the testing process, several versions of the Raspberry Pi Package were used; some of them were incompatible with CoDeSys, and some could not run on Raspberry Pi. If anyone encounters similar problems while learning, they can reinstall the files on Raspberry Pi. It is also possible to run higher versions of Package on a Raspberry Pi, and lower versions of CoDeSys on CoDeSys. Source: Changhui Instruments http://yunrun.com.cn/

Submit a Project

**Looking for Chemical Technology, Equipment & Solutions?** No Registration Required Broader Platform Exposure | Global Chemical Service Provider Connections

Submit Request — Free Consultation

Disclaimer

This is an automated machine translation of the original thread. Some technical terms may have inaccuracies; the original text shall prevail. Click "View Original" at the top right to access the source page, which supports IP-based automatic real-time language translation. Please watch out for contact details and sales inducements to prevent fraud. All content and translations are for reference only, representing solely the poster's personal views. For enquiries, email service@hcbbs.com.

Quick Links