Posted 14 Dec 2017 I am playing with sending ASCII string commands back and forth between my CP1H and another device. I learned first how to do it using ladder and now that I'm getting into more advanced stuff (parsing, searching for certain chars, converting to INT, ect) I want to do it in Structured Text because the ladder for this gets hard to follow. My very first experiment (count string length) throws an error at me: It apparent takes exception that I've use the "STRING" data type But it this works just fine in ladder: So am I really not allowed to use STRING data type in ST on CP1H or am I doing something wrong? Share this post Link to post Share on other sites
Posted 14 Dec 2017 I just tried to do the same thing in a ladder FB. String variable, it gave me the same error. But then in the FB I changed the variable type to WORD and it worked. "neat" little workaround in ladder FB, but too bad it doesn't work in ST. in ST I get this error: Share this post Link to post Share on other sites
Posted 14 Dec 2017 https://www.fa.omron.com.cn/data_pdf/mnu/r144-e1-04_cx-programmer.pdf?id=1605 Try to convert the information before sending. Syntax Source_data_type_TO_STRING (Variable_name) Example: WORD_TO_STRING (SerialBuffer) See page 95 of the above quick reference. This may help you out. Regards, Garry Share this post Link to post Share on other sites
Posted 14 Dec 2017 (edited) 27 minutes ago, gclshortt said: https://www.fa.omron.com.cn/data_pdf/mnu/r144-e1-04_cx-programmer.pdf?id=1605 Try to convert the information before sending. Syntax Source_data_type_TO_STRING (Variable_name) Example: WORD_TO_STRING (SerialBuffer) See page 95 of the above quick reference. This may help you out. Regards, Garry I appreciate it but, no, it's not having any of that either. It won't let me define a string variable in ST. And if I try to get away without defining a variable (put conversion directly into TXD) it tells me "instruction not available for current PLC" How frustrating! I didn't see this restriction printed in any documentation before I selected CP1H for this application, and I still don't. I have looked hard through all my manuals twice and I don't see this printed. In CP1L/H Programming manual W451, CX-Programmer manual W447, CP1H operation manual W450, it is never mentioned that I can find! It really lead me to believe it as capable. Omron is trying to make me feel stupid, successfully. Next time I buy a new car I will have to verify that it has gear oil in the differential. Because every car on the lot will have shipped with diff oil except the one that I select, and the owner's manual won't tell me that on this very specific model the owner is expected to put it in. Edited 14 Dec 2017 by strantor_ Share this post Link to post Share on other sites
Posted 14 Dec 2017 From W451: NO MENTION of fb restriction on string functions Share this post Link to post Share on other sites
Posted 16 Dec 2017 On 12/14/2017 at 5:23 AM, strantor_ said: How frustrating! I didn't see this restriction printed in any documentation before I selected CP1H for this application, and I still don't. I have looked hard through all my manuals twice and I don't see this printed. In CP1L/H Programming manual W451, CX-Programmer manual W447, CP1H operation manual W450, it is never mentioned that I can find! It really lead me to believe it as capable. Omron is trying to make me feel stupid, successfully. Next time I buy a new car I will have to verify that it has gear oil in the differential. Because every car on the lot will have shipped with diff oil except the one that I select, and the owner's manual won't tell me that on this very specific model the owner is expected to put it in. Well... if you go to CX-Programmer Help-->Manual--> Function Block/Structured Text Part, you'll find this on page 147. The CP, CJ, CS manuals only talk about ladder instructions. Omron kept the Structured Text manual separated as a single manual for all PLC since it was implemented after initial series launch. Share this post Link to post Share on other sites
Posted 17 Dec 2017 (edited) 23 hours ago, innoaloe said: Well... if you go to CX-Programmer Help-->Manual--> Function Block/Structured Text Part, you'll find this on page 147. The CP, CJ, CS manuals only talk about ladder instructions. Omron kept the Structured Text manual separated as a single manual for all PLC since it was implemented after initial series launch. Thank you. I did come across that later, but I still feel somewhat justified in being irritated with Omron on this matter. That little blurb that you circled is only half-way informative. It is the only mention anywhere in any of the manuals, and it doesn't come close to saying "CP series cannot support ST instructions for String type." I understand that the ST function came after the release of CP1H, but can Omron not create a manual revision covering CP1H ST instructions? And if they're not into revising manuals, how am I to know that the circled blurb is even current? Maybe the manual came out before CP1H? I don't know the timelines of these things. This should be spelled out in bold, in a logical place that someone would look for it if they were considering purchasing it for their application. Like in the datasheet released may of this year, page 1, Features, 8th bullet down, where it says " • The structured text (ST) language. Makes math operations even easier ." Maybe instead it could say " • The structured text (ST) language - Partial Support. Makes math-only operations even easier. (See W451 Rev 2017 section 5 - Structured Text)" - and then actually release a new W451 with a section on structured text. Anyway, rant over. Thank you for your response and I'm sorry if my reply seemed negative. I'm still a little butthurt. I'm moving on though. The CP1H is in pieces in the bottom drawer of my cabinet, and I have a CJ2M on the desk now. This one DOES support string. All good now (except the money). Edited 17 Dec 2017 by strantor_ Share this post Link to post Share on other sites
Posted 28 June Sorry for the necro post but I've found it very hard to find much help online for Omron and this thread matches my problem almost exactly. @strantor_ Like you, I'm VERY frustrated that this limitation isn't explicitly stated anywhere in the multitude of Omron's reference documents. On 12/13/2017 at 1:31 PM, strantor_ said: in the FB I changed the variable type to WORD and it worked. "neat" little workaround in ladder FB Would you please elaborate a little more about how you did this? I tried changing my STRING in-out variable to a WORD and still have issues because the data/string length is much bigger than a WORD. Was the string you were passing to the FB just 1 or 2 characters? Mine can be up to 30 characters (15 WORDs or 240 bits) which is much longer than the largest other option which is an LWORD (64 bits or 8 characters). I'd assume the last character would have to be NULL too so that would be 7 usable characters at most. I considered writing logic to copy the string to an array of LWORDs but that's about as complicated as what I want to use the FB for in the first place (extract a sub-string and convert it to a real/float). For the moment I think I'm just going to abandon the FB and use a sub-routine instead. The way I understand it, Omron FB in-out variables are effectively pass-by-reference. It's hard for me to understand why the CP1H function blocks wouldn't be able to take pass-by-ref strings if they're capable of working with string variables internally. Is it because of the variable length of strings? But if that's the case, why couldn't they just require you to pass the length as an int in addition to the string address? Share this post Link to post Share on other sites