PLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

 

 How to create a Blog Entry

2048

If you want to wind down after a long day of coding, it is possible to have a little fun with your PLCnext Control device.

If you are familiar with the popular 2048 app, here is how to build and run a version it on a PLCnext Control device.

You will need:

  • A PLCnext Control device.
  • A host machine (I am using a Debian machine), connected to the internet and to the PLC, and with the corresponding PLCnext SDK.

Procedure:

On the host PC (in this case, running Debian):

$ mkdir 2048 && cd 2048
$ wget https://raw.githubusercontent.com/mevdschee/2048.c/master/2048.c
$ #
$ # Change the path below to the one for your installed SDK.
$ source /opt/pxc/sdk/AXCF2152/2020.3.1/environment-setup-cortexa9t2hf-neon-pxc-linux-gnueabi
$ #
$ # Build the executable
$ $CC -o 2048 2048.c
$ #
$ # Check that the executable has been built for the correct platform
$ file 2048
2048: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=c005e1aa177eca6dde350ceb5d5739de3e80d888, for GNU/Linux 3.2.0, with debug_info, not stripped
$ #
$ # Copy the executable to the PLC.
$ # Change the IP address below to the IP address of your PLC.
$ scp 2048 This email address is being protected from spambots. You need JavaScript enabled to view it.:~

Then in a shell session on the PLC:

$ ./2048

Here is my first attempt on a PLC:

image

Enjoy!