DRA
Hello, I hope you're having a good day.
My question is about how to correctly use function blocks like `string to bool`. My project requires that it receives a letter, for example "D", and transforms it into a boolean value.
[203128%2F9714383%2Fmceclip0]
This is the basic structure I'm using
 
[203128%2F9714384%2Fmceclip0]
I am receiving the data through a C++ block function.
 
[203128%2F9714385%2Fmceclip0]
 
I understand that if I am sending and receiving the letter D (I am using a Nextion display)
 
 
In short, I'm using an ESP32 and communicating with a Nextion HMI. I've successfully established communication, as I can get the image on the Nextion HMI to change when an input or output is activated on the ESP32. However, I haven't been able to receive data, specifically letters like "D". I want to use these letters to differentiate page changes on the Nextion HMI and to lock or unlock functions in the OpenPLC program. Do you have any advice on how to receive letters correctly in OpenPLC?
Please excuse my English I'm using a translator.
Reply 0 0
thiagoralves
On your C/C++ block define a “received” variable of type STRING and then set it to the character you received with
 
received.body = c;
received.len = 1;
 
Then you can use comparison blocks on the ladder side to check the value of “received”.
 
Also, you should remove the delays from your C code. They block the entire execution of your project, including the PLC side.
Reply 0 0
Reply