Makers Blog
134 views 0 comments

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 – follow the steps for “…any other IDE or tool”.

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 admin@192.168.178.221:~

Then in a shell session on the PLC:

$ ./2048

Here is my first attempt on a PLC:

image

Enjoy!

Note:

The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.

Discussion

Please login/register to comment

Login/Register

Leave a Reply

Newsletter
Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users