9/7/2018 5:24 PM | |
Joined: 7/7/2010 Last visit: 11/19/2024 Posts: 15406 Rating: (2446)
|
Store all the data in your HMI. When you need data, set the "constant" index, and set a bool true that is only true when you want the HMI to send over the string. Monitor that bool in your HMI. Trigger a script that grabs the string, moves it to a PLC tag, and then toggles the bool. In the PLC, it waits for the bool to go from hi to low, the uses the string sent over from the hmi. If you find there is a delay in the string arriving, you can "constantly" move the string last sent from the HMI to another tag. The HMI monitors what it sent with what is in the "holding" area and sets a bool when they match. The PLC can monitor for that bool to know it has the entire string and can process it. After processing, it can reset the "HMI data received" bool, and start the cycle over again for the next text. For a more algorithm-based approach, you might consider a scheme where you have 2 DBs, 1 with a dictionary of all available "words" that make up all the "constant" string messages. The other DB is a 2-dimensional array, where 1st dimension is say your 0.999, and the 2nd dimension handles the building of the string for that index For example, let's say this is the constants you need to send for 3 different cases (for simplicity):
Dictionary DB could look like this: Dictionary DB :Token : array[0.499] of string[10]
The output string would get built based on the above token indexes. Let's say the definition is defined something like this: Constant.Def is [array[0.999] of array[0..25] of int] in general terms. Note that using the last element of the int array is the NULL character (and building the output string can stop. Not proper syntax. Just conveying the concept.
Create an FB that accepts the index for the constant, passing dictionary as InOut, Constant Definition array at that specific index, and outputs the built constant string using the tokens and the constant definition. It would loop through the constant.def array row at index, using the array value as index into the dictionary.token array, concatenating token by token until the string is fully built, and spitting the final string out for using by your project.
|
science guy |
|
This contribution was helpful to3 thankful Users |
9/12/2018 9:15 AM | |
Posts: 14 Rating: (3) |
Thank you all for your suggestions! I will take your advices into consideration. You gave me lot of nice ideas. |
Follow us on