kohesohai
I want to send a Json string containing the state of the inputs and outputs via the MQTT protocol. but i don't know how to concatenate all those values ​​into 1 Json string. Looking forward to everyone's help.
Reply 0 0
kohesohai
[203128%2F8340252%2Fmceclip0]
Reply 0 0
kohesohai
[203128%2F8340255%2Fmceclip0]
Reply 0 0
thiagoralves
In ladder logic it will be a bit confusing. This is something that can be done better on structured text. Maybe you can define a function block that gets the button state and spits out a formatted json with the button value for example. You can use the convert blocks to convert from numeric inputs to string, and can also use the add blocks to concatenate different portions of your string
Reply 0 0
kohesohai
In ladder logic it will be a bit confusing. This is something that can be done better on structured text. Maybe you can define a function block that gets the button state and spits out a formatted json with the button value for example. You can use the convert blocks to convert from numeric inputs to string, and can also use the add blocks to concatenate different portions of your string
I understand what you say. many thanks @thiagoralves. I have 1 more question. What function do we use to concatenate strings?
Reply 0 0
kohesohai
In ladder logic it will be a bit confusing. This is something that can be done better on structured text. Maybe you can define a function block that gets the button state and spits out a formatted json with the button value for example. You can use the convert blocks to convert from numeric inputs to string, and can also use the add blocks to concatenate different portions of your string
[203128%2F8340449%2Fmceclip0]
Reply 0 0
kohesohai
i did it, many thanks @thiagoralves.
Reply 0 0
kohesohai
In ladder logic it will be a bit confusing. This is something that can be done better on structured text. Maybe you can define a function block that gets the button state and spits out a formatted json with the button value for example. You can use the convert blocks to convert from numeric inputs to string, and can also use the add blocks to concatenate different portions of your string
@thiagoralves. i have 1 question, my mqtt_receive function is not working when i send 1 msg from my MQTT Broker. How should I handle it?
[203128%2F8341745%2Fmceclip0]
Reply 0 0
thiagoralves
Make sure you have the latest version of the OpenPLC Editor. Check on file -> check for updates
Reply 0 0
kohesohai
[203128%2F8342004%2Fmceclip0]
Make sure you have the latest version of the OpenPLC Editor. Check on file -> check for updates
Reply 0 0
thiagoralves
How are you handling the msg_received string? The easiest way to check if it is working is to publish the received message on a different topic when RECEIVED is TRUE. Keep in mind that the message might not stay in the string forever. It is only guaranteed to be there when RECEIVED is TRUE.
Reply 1 0
johnquoc
kohesohai wrote:
[203128%2F8340449%2Fmceclip0]
Could you give me the name of this software?
Reply 0 0
Reply