Important for using these examples:
1. Update device (rightclick on Pi in the device tree - this is needed for fieldbus stacks too)
2. set current compiler Version
3. set current visuprofile
then the projects are up to date.
-How to use Oscat calendar and timer2 for starting Outputs once a day or only on specific weekday
-How to Show the raspberry pi current ip address on / internal visu and webvius page
-Rotate bitmap in visu
Example how to use SoftMotionLight with Raspberry Pi.
(no realtime is needed for SoftMotionLight - drive should support DS402)
Check your drive for SoftMotionLight capability with:
"c:\Program Files (x86)\3S CODESYS\CODESYS\Projects\SoftMotion\SoftMotionLight\SML_CompatibilityCheck_DS402.project"
Read ProcessorTemperature of the Pi and Show cpuinfo in IEC -
add in /etc/CODESYSControl.cfg the [SysProcess] section
Output of the executed command will be filled into pszStdOut
here I can show example of saving INT values int txt file on Raspberry Pi SD
I have used pymodbus TCP to create modbusMaster(client) on port 503, with 10 holdt_register and 10 input_registers
in Cosesys v3 create ModBusSlave TCP also with 10 holdt_register and 10 input_registers,
if raspberry pi shut down , at start you can get 10 int values from file vars.txt on SD
Read the onewire sensor in an own onewire Task / scan connected sensors
Rescan while running is possible by reset - x
IF NOT x THEN
x := TRUE;
//scan function Onewire_master.Scan();
FOR ui:=1 TO MIN(Onewire_master.uiScannedDevices, 20) DO
astrID[ui] := Onewire_master.pasScannedDevices^[ui-1].StringRepresentation;
//dynamic write the scanned sensors to the configuration
DS18B20.ID := Onewire_master.pasScannedDevices^[ui-1];
END_FOR
END_IF
Raspberry Pi appliation examples and code snippets:
Applications which come with the Pi package:
'c:\Users\<youwindowsusername>\CODESYS Control for Raspberry PI\2.1.1.0'</youwindowsusername>
Camera.project
CameraStream.project
EtherCAT.project GPIO.project
I2CExamples.project
MCP23S17.project
MCP3008Temperature.project
Onewire.project
OPCUA.project
PiFace.project
PiFace_FB.project
PiFaceControlAndDisplay.project
PiFaceIoDrv.project
SoftMotion Servo Example.project
Webvisu.project
Important for using these examples:
1. Update device (rightclick on Pi in the device tree - this is needed for fieldbus stacks too)
2. set current compiler Version
3. set current visuprofile
then the projects are up to date.
Application shared by CODESYS Pi users:
Delta Robot wth rc servos
Show Ip and use calendar from OSACT for timer functions (starting once a day Events) , visu: rotate bitmap
Communication with Domoticz , bulding automation
How to use SoftMotionLightwith the Pi
How to use a table in the visualisation for Input values
How to implement a FTP Client by using the OSCAT Network lib
How to get the result of Shell comand to IEC code
Profinet with Raspberry Pi (using Pi2 recommended) acyclic read -Service / diagnosis
PiFace with ladder / read and Show own IP address in visu
Visu User Login see Client IP Address
CODESYS V3 RPi DATABASE .txt file on SD if RPI shut down Address
Elsner P03/3-RS485 RS485-Weatherstation with Raspberry Pi
TextEditor Example Application
Raspberry Pi 3 Modbus TCP Master and Arduino Mega Modbus TCP Slave
Raspberry Pi - GoogleMaps with Webvisu
Webbrowser Element
Imported CODESYS V2.3 Project Example
Check the Raspberry PI CODESYS License on Runtime Key and SoftLicense
Raspberry PI as Profinet Slave project example
Raspberry PI Onewire - improved Project two tasks
Communication - 2 Raspberry PI Modbus TCP
1-Wire Busmaster / USB Hostadapter DS9490R OWFS
2 Raspberry Pi communication with Ethernet IP
Using RFID USB Reader with Raspberry PI
Communication with SONOS speaker
sending notifications by pushover
Using a python opcua client to access symbold in the CODESYS project
add python scripts in CODESYS as external file and execute them on PI
Unicorn HAT example
Using I2C Port-Expander PCF8574 without I2C library
Visu UserManagement Switch logged in User by IECcode
Enocean example
IO-Link example based on Control RTE
Play sound on Raspberry PI
How to use/enable serial communication on Raspberry Pi
How to use targetvisu on Raspberry Pi for example with PI Touch LCD
CmpCharDevice example
MQTT
Play sound on Webvisu connected device
How to connect mutible serial USB devices
mega_modbus_analog_slave.project
CSV Writes a file on the raspberry storage Card
Using CoDeSys on Raspberry Pi to poll ModbusTCP slave data, and uplink by using LoRaWAN ATIM ACW-XB
more posts ...
https://www.youtube.com/watch?v=h9rLOWm7NiU m
DeltaRobot_Raspi_helix.project [196.61 KiB]
-How to use Oscat calendar and timer2 for starting Outputs once a day or only on specific weekday
-How to Show the raspberry pi current ip address on / internal visu and webvius page
-Rotate bitmap in visu
TimerExample2.project [147.6 KiB]
Building Automation example, comunication with Domoticsz
Domoticz_rfxcom_lan.project [1.17 MiB]
Beside CAASerialCom using Syscom.library is possible too.
Here is the example for it.
(See l viewtopic.php?f=21&t=5699 l for CAASerialCom example)
on Linux side you need to indentify your serial port and activate it in /etc/CODESYSControl.cfg
How to do this:
1. you need to check on linux side which tty port is available.
Example a USB to serial converter:
Check under Linux with 'dmesg' which device is used for it:
in my case it reports: ttyUSB0
so you need to add in /etc/CODESYSControl.cfg
(Attention you need to remove the 0 from USB0)
[SysCom]
Linux.Devicefile=/dev/ttyUSB
portnum := COM.SysCom.SYS_COMPORT1;
this was the pi side under Linux
SysComTestRaspi.project [50.56 KiB]
Example how to use SoftMotionLight with Raspberry Pi.
(no realtime is needed for SoftMotionLight - drive should support DS402)
Check your drive for SoftMotionLight capability with:
"c:\Program Files (x86)\3S CODESYS\CODESYS\Projects\SoftMotion\SoftMotionLight\SML_CompatibilityCheck_DS402.project"
SML.project [89.44 KiB]
Visu_Table_Online.project [135.64 KiB]
FTP Client example.
(OSCAT Network and OSCAT Basic is used)
FTPCLient.project [156.61 KiB]
Read ProcessorTemperature of the Pi and Show cpuinfo in IEC -
add in /etc/CODESYSControl.cfg the [SysProcess] section
Output of the executed command will be filled into pszStdOut
SysProcessExecuteCommand2.project [211 KiB]
I noticed that this view does not work on new versions. I have a target of 4.5.0.0. I can't get the temperature
Profinet Example with Raspberry Pi (Pi2 recommended)
RaspiProfinet.project [115.03 KiB]
PiFace with ladder example
PiFaceIoDrv_LadderExample.project [105.82 KiB]
Visu Userlogin
VisuClientIPAdresse_v1.1.project [91.11 KiB]
here I can show example of saving INT values int txt file on Raspberry Pi SD
I have used pymodbus TCP to create modbusMaster(client) on port 503, with 10 holdt_register and 10 input_registers
in Cosesys v3 create ModBusSlave TCP also with 10 holdt_register and 10 input_registers,
if raspberry pi shut down , at start you can get 10 int values from file vars.txt on SD
How to make start at boot pymodbus master(client)
using PuTTY:
#sudo nano /etc/init.d/autorun
and paste text from autorun.txt
Ctrl + x
y
Enter
#sudo chmod 777 /etc/init.d/autorun
#sudo update-rc.d /etc/init.d/autorun defaults
#cd /home/pi/Documents/pymodbus/examples/common
root@raspberrypi:/home/pi/Documents/pymodbus/examples/common# sudo nano test.py
and paste text from test.py.txt
Ctrl + x
y
Enter
before ShutDown RaspberryPi Download CodesysProject and try:
#sudo /etc/init.d/autorun start
output:
Starting autorun
done
wait to start ethernet , wait for Codesys Slave to start 20sec
cycle: 1
Input0: 57648
Input1: 57649
Input2: 57650
Input3: 57651
Input4: 57652
Input5: 57653
Input6: 57654
Input7: 57655
Input8: 57656
Input9: 57657
line0: 57648
line1: 57649
line2: 57650
line3: 57651
line4: 57652
line5: 57653
line6: 57654
line7: 57655
line8: 57656
line9: 57657
cycle: 2
WebvisuMBtcpSlave.project [478.19 KiB]
steps DB master.txt [4.24 KiB]
test.py.txt [3.47 KiB]
autorun.txt [910 Bytes]
Example Application with RS485 connected Elsner P03/3-RS485
Prefered Interface (USB to RS482 Serial adapter)
https://www.amazon.de/gp/product/B00GWE ... UTF8&psc=1
(Advantage does not use any specific kernel module - you could use latest Debian)
For Raspi Comm the following is needed:
/etc/CODESYSControl.cfg
[SysCom]
Linux.Devicefile=/dev/ttyUSB
maybe another options is:
Link: http://www.elsner-elektronik.de/shop/de ... rs485.html
RS485 Extension: RasPi Comm
For Raspi Comm the following is needed:
/etc/CODESYSControl.cfg
[SysCom]
Linux.Devicefile=/dev/ttyRPC
wget http://downloads.amescon.com/rpc_setup.sh && chmod +x ./rpc_setup.sh && sudo ./rpc_setup.sh
sudo raspi-config
enable:
1. Devicetree
2. I2C
3. SPI
RS485 Port is
/dev/ttyRPC0
WetterstationPi.project [386.56 KiB]
TextEditor Application, edit and save/read your textfiles
Visu_TextEditor_Online.project [76.8 KiB]
Autor: alecudr
l viewtopic.php?f=21&t=6884 l
Google Maps Application in Webvisu
New:
googlemaps_ext1.js
Line 395 set 'TODOSETKEY' with GOOGLE API KEY
How to get an API KEY https://developers.google.com/maps/docu ... et-api-key m
GoogleMapsDemoRaspiSP14.project [255.61 KiB]
GoogleMapsDemoRaspiSP12.project [261.94 KiB]
Could you help me find a working example with SP17? Thank you in advance. Andrea
Example for using the Webbrowser Element
WebBrowserVisuExample_v1.1_RASPI.project [172.26 KiB]
Check the if license is activated on Runtime KEY and SoftLicense!
CheckLicenseRaspi.project [73.19 KiB]
Imported CODESYS V2.3 Project Example
Fuellstand.zip [166.39 KiB]
In this project eth1 interface is used for the profinet connection to the ProfinetMaster
you need to add in /etc/CODESYSControl.cfg (Version <3.5SP12)
[SysSocket]Adapter.0.Name="eth1"Adapter.0.EnableSetIpAndMask=1
and execute in the Linux console
<3.5Sp13
ifconfig eth1 promisc
das in /etc/rc.local einbauen
If you use a Pi3B+ you Need the following steps:
Using VLAN-Tags Need to be enabled:
sudo apt install vlan # install VLAN-Packetsudo modprobe 8021q # load 8021q Kernelmodul
for having this in every Startup automatically:
sudo su -c 'echo "8021q" >> /etc/modules'
2RaspiProfinetController_PNDevice.project [100.18 KiB]
Read the onewire sensor in an own onewire Task / scan connected sensors
Rescan while running is possible by reset - x
IF NOT x THEN
x := TRUE;
//scan function
Onewire_master.Scan();
FOR ui:=1 TO MIN(Onewire_master.uiScannedDevices, 20) DO
astrID[ui] := Onewire_master.pasScannedDevices^[ui-1].StringRepresentation;
//dynamic write the scanned sensors to the configuration
DS18B20.ID := Onewire_master.pasScannedDevices^[ui-1];
END_FOR
END_IF
actDate := DS18B20.stdTimeStamp;
SysTimeRtcConvertDateToUtc(actDate,dwActDate);
dtTimestamp := DWORD_TO_DT(dwActDate);
Onewire_twoTasks.project [74.01 KiB]
Communication - 2 Raspberry PI Modbus TCP
2RaspisModbusMasterSlaveCommunication.project [85.17 KiB]