Industrielle styresystemer - Wiki
Industrielle styresystemer - Wiki
Input:
(NEEDS TO BE UPDATED WHEN I HAVE THE FUNCTION IN FRONT OF ME)topic : STRING(255);
xTrigger : BOOL;
message : STRING;
Output:
v : ARRAY [0..2] OF LREAL;
Output:
norm : LREAL;Info |
---|
Type: FunctionblockFunctionBlock Responsible: Andre |
The first implementation of MQTT on the Wago-PLC. This enables external visualization, such as CDP-Studio. The intention of this implementation was to make a 24_7 CDP-Studio Dashboard, that shows near realtime updates of the actual and the target motorspeed and position in CDP-Studio. Since it publishes the information is also used in 24_7 3D-Visualization in Blender.
: André |
To set up a MQTT publisher in codesys the following libraries are necessary to use:
Before the PLC can publish to over MQTT, the WagoAppCloud settings needs to be changed to fit the system this is done by writing the PLC's IP into the searchbar of a web browser, then cloud connectivity → connection 1. The settings are set to:
Image Added
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
FUNCTION_BLOCK MQTTPublisher
VAR_INPUT
topic : STRING(255);
xtrigger : BOOL;
message : STRING;
END_VAR
VAR
mqttPub : wagoappcloud.FbPublishMQTT_2(econnection := econnectionid.Connection1);
dwSize : DWORD;
aData : ARRAY[0..100] OF BYTE;
xRetain : BOOL := FALSE;
xError : BOOL := FALSE;
xBusy : BOOL := FALSE;
eQualityOfService : eQualityOfService := 1;
END_VAR
wagosysplainmem.MemCopy(pDest:=ADR(aData),pSource:=ADR(message),udiSize:=TO_WORD(len(message)));
mqttPub(sTopic:=topic,eQualityOfService:=eQualityOfService,xRetain:=xRetain,dwSize:=TO_WORD(len(message)),aData:=aData,xTrigger:=xtrigger,xBusy=>xBusy,xError=>xError); |