This article uses the OSCAT NETWORK library for the Berghof Controller and sends CSV Files stored on USB to the FTP Server The FTP Server is a SeeedStudio RecomputerR1125.
Come on, let’s enjoy FA.

Foreword
Thank you from the bottom of my heart for visiting my technical blog and YouTube channel.
We are currently running the “Takahashi Chris” radio show with Full-san (full@桜 八重 (@fulhause) / X) which I deliver every Wednesday night.
Sharing, not hoarding, technical knowledge
We publish technical information related to factory production technology and control systems for free, through blogs and videos.
With the belief that “knowledge should be accessible to everyone,” we share practical know-how and real-world troubleshooting cases from our own field experience.
The reason we keep it all free is simple: to help reduce the number of people who struggle because they simply didn’t know.
If you’ve ever thought:
- “Will this PLC and device combination actually work?”
- “I’m having trouble with EtherCAT communication—can someone test it?”
- “I want to try this remote I/O, but we don’t have the testing environment in-house…”
Feel free to reach out!If lending equipment or sharing your configuration is possible, we’re happy to verify it and share the results through articles and videos.
(We can keep company/product names anonymous if requested.)
How can you support us?
Currently, our activities are nearly all unpaid, but creating articles and videos takes time and a proper testing environment.If you’d like to support us in continuing and expanding this content, your kind help would mean a lot.
Membership (Support our radio show)
This support plan is designed to enhance radio with Mr Full.
https://note.com/fulhause/membership/join
Amazon Gift List (equipment & books for content production)
Lists equipment and books required for content creation.
https://www.amazon.co.jp/hz/wishlist/ls/H7W3RRD7C5QG?ref_=wl_share
Patreon (Support articles & video creation)
Your small monthly support will help to improve the environment for writing and verifying articles.
https://www.patreon.com/user?u=84249391
Paypal
A little help goes a long way.
https://paypal.me/soup01threes?country.x=JP&locale.x=ja_JP
Just trying to share things that could’ve helped someone—if only they’d known.
Your support helps make knowledge sharing more open and sustainable.
Thank you for being with us.
soup01threes*gmail.com
Technical knowledge shouldn’t be kept to ourselves.
Reference Link
What is OSCAT?
OSCAT=”Open Source Community for Automation Technology”, an open source library compliant with the IEC61131-3 standard has been created. The library eliminates vendor-specific features and can therefore be ported to all IEC61131-3 compatible programmable logic controllers.
The trend of PLCs using vendor-specific libraries is usually efficiently resolved and these libraries are also partly free of charge, but there are still significant drawbacks to using them.
- Most manufacturers’ libraries are protected and the source code is not freely accessible, this is the case when errors occur and error correction is extremely difficult and often impossible.
- The development of graphical programmes using vendor-specific libraries can quickly become confusing, inefficient and error-prone, as existing functionality cannot be tailored or extended to suit actual needs, and source code is not available.
- Hardware changes, especially migration to other manufacturers, are hampered by proprietary libraries, which also limit the benefits offered by standards such as IEC 61131. Replacing a competitor’s proprietary library is often ruled out because the scope and content of the manufacturer’s library differs significantly.
- Understanding complex modules without understanding the source code is often very difficult, which makes programmes inefficient and error-prone.
OSCAT creates a powerful and comprehensive standard for PLC programming with the open OSCAT library. The standard is available in source code and has been validated and tested in detail by a wide range of applications.
FTP_CLIENT
The module FTP_CLIENT is used to transfer files from the PLC to the FTP server and from the FTP server to the PLC. It also starts the transfer process if a TRUE edge is sent to ACTIVATE.
VAR_INPUT
Variable | Type | Description |
ACTIVATE | BOOL | Start up and start communicating. |
FILE NAME | STRING | File path/file name |
FTP_URL | STRING(STRING_LENGTH) | FTP access path |
FTP_DOWNLOAD | BOOL | UPLOAD = 0 DOWNLOAD = 1 |
FTP_ACTIV | BOOL | PASSIV = 0ACTIV = 1 |
FILE_DELETE | BOOL | 1 = Delete File after transmission. |
TIMEOUT | TIME | Timeout setting |
Dns_ip4 | DWORD | IP4 address of the DNS server |
PLC_ip4 | DWORD | IP4 address of the DNS server |
VAR_OUTPUT
Variable | Type | Description |
DONE | BOOL | 1 = Transfer completed without error. |
BUSY | BOOL | 1 = Transferring. |
ERROR_C | DWORD | Error Code |
ERROR_T | BYTE | Error Type |
URL examples
This is an example of a URL setting.
ftp://username:password@servername:portnummer/directory/ ftp://username:password@servername ftp://username:password @ servername / directory / ftp://servername ftp://username:password@192.168.1.1/directory/ ftp://192.168.1.1 |
Implementation
FTP Server Side
The first step is to install the FTP Server.
Install FTP Server
Install the FTP Server on the SeeedStudio Recomputer with this command.
sudo apt-get update sudo apt-get install vsftpd |
Configuration
The next step is to configure the FTP Server settings.
sudo nano /etc/vsftpd.conf listen=NO listen_ipv6=YES local_enable=YES write_enable=YES |
Codesys Side
The next step is to build the Codesys side.
Install OSCAT NETWORK Library
Download the OSCAT Network library from the Link below.
https://store.codesys.com/en/oscat-network.html
Start the OSCATNetwork.package.
Select the CODESYS version in which you want to install the OSCAT NETWORK library.
Select the CODESYS version in which you want to install the OSCAT NETWORK library.
Please wait a moment…
Done!
Install Library
The next step is to start the Library Manager in order to import the OSCAT NETWORK library into the Codesys project.
Click Add Library.
Add the OSCAT NETWORK library.
Done!
Go ahead and add the OSCAT_BASIC library as well.
Program
This is the FTP Server communication program created in this article.
VAR
This is a variable defined programmatically. fbFtpClient is an Instance of OSCAT_NETWORK.FTP_CLIENT.
PROGRAM pFTP VAR fbFtpClient:OSCAT_NETWORK.FTP_CLIENT; PLC_IP:DWORD; DNS_IP:DWORD; xActivate:BOOL; x1:BOOL; FILENAME : STRING; xDownload:BOOL; xCommand:BOOL; xDone:BOOL; END_VAR |
Network1
Network1 uses OSCAT_BASIC.DWORD_OF_BYTE to convert DNS addresses to DWORDs.
Network2
Network2 uses OSCAT_BASIC.DWORD_OF_BYTE to convert the IP address of the FTP Server into a DWORD.
Network3
Network3 determines whether the operation that is about to be performed is Download or Upload.
Network4
For Download operations, FILENAME sets the storage location of the File downloaded from the FTP Server; FTP_URL is the Path of the File you want to download to the FTP Server.
fbFtpClient.FILENAME:=
‘/media/usb1/datafromFtp.csv’;
fbFtpClient.FTP_URL:=
‘ftp://kali:kali@192.168.0.202/home/kali/datafromFtp.csv’;
Network5
For Upload operations, FILENAME is set to the Path of the File you want to upload to the FTP Server; FTP_URL is the destination Path of the File you have uploaded to the FTP Server.
fbFtpClient.FILENAME:=’/media/usb1/test2.csv’;
fbFtpClient.FTP_URL:=
‘ftp://kali:kali@192.168.0.202/home/kali/’;
Network6
Finally, We can call the OSCAT_BASIC.FTP_CLIENT.
Login
Download the project at Online>Login.
Result
ERROR_C and ERROR_T to get information on when the FTP_CLIENT FB encounters an execution error.
The exchange between Codesys Runtime and FTP Server can also be viewed from Wireshark.
Done!Transfer Complete replies.