adccommunitymod (AutomationDirect) asked a question.

Click ASCII Questions

Created Date: August 28,2014

Created By: pkshaver

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

I'm interfacing a Click PLC with a machine with some interesting RS485 output, using an Analog CPU Port3. I 've worked out how to get the info I need into text registers (one ASCII character per TXT address), but the question is where to go from there. The data received will be something like this: STX 01N,115,2000,M CR LF The STX at the beginning I can just ignore. The CR and LF i plan to program into my receive function as the closing bits. The 01 is an address, the N is a data type, and the commas are data separators. No problem so far. The 115 and 2000 in this example would be values that could vary in the number of characters. The 2000 is "Run Hours " on the machine. It could just as easily be 200 or 20000, and the machine sending the data will not provide a fixed number of characters. So, first question: Does this sound feasible to convert this data to a usable form?: 1) Call a subroutine to scan the values of the affected TXT registers for the locations of the commas, and store them in a few DS registers. 2) Using the values in the DS registers, and relative addressing to determine where the data is, copy the values of each data to a DD using the COPY-PACK function. Second Question: Assuming above works, will the COPY >Pack assume that each character going into a DD is a decimal digit? ie Will TXT10 value of 1, TXT11 value of 1, and TXT12 value of 5 copy into a DD with a value of 115, or is there some conversion to be done? The last text digit (M in the example) relates to the Mode of the machine. That will be no problem for me to process as long as I know what TXT address to find it in. I think I have this pretty well worked out, but wanted to see if you guys see any potential pitfalls. Thanks in advance!


  • adccommunitymod (AutomationDirect)

    Created Date: August 28,2014

    Created by: Tinker

    2) Using the values in the DS registers, and relative addressing to determine where the data is, copy the values of each data to a DD using the COPY-PACK function.

    Well, there is your problem, the "relative addressing " in a CLICK is very limited.

    One can NOT do, say, Pack Copy TXT through TXT to DS you'll have to reserve a block of TXT addresses and copy your characters one by one to it, then use pack copy with fixed addresses from that temporary buffer. Indirect addressing Only works with single copy

    Someone once posted an example of a program that parsed a variable length string to these forums. I remember it being wonderfully complex to work around the CLCIK's limitations. However I can't find it now.

    While I haven't personally used a Do-More yet, I suspect it would be much better suited to this job.

    "will the COPY>Pack assume that each character going into a DD is a decimal digit? ie Will TXT10 value of 1, TXT11 value of 1, and TXT12 value of 5 copy into a DD with a value of 115, "

    Yes, I believe that is the way it works, help Topic: CL059 seems pretty clear on that point, now anyway, I remember finding it very confusing at one point in the past, perhaps they updated the help with one of the software revisions.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: August 28,2014

    Created by: pkshaver

    Thanks. I made a FOR next loop with the single copy to move the individual text characters into DS locations with no problem, but it looks like it is going to be cumbersome to find the commas.

    They are lost when sending the TXT to DS (go to 0). I tried to find the commas with a FOR loop, but cant address the TXT with a pointer in the Equality.

    I may just use the loop to copy each character to a temporary TXT value and use that temp value in an equality contact in the loop (to see if TXT100 = ", "), and if so, put the loop number in a data register.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: August 28,2014

    Created by: pkshaver

    I'm interfacing a Click PLC with a machine with some interesting RS485 output, using an Analog CPU Port3.

    I 've worked out how to get the info I need into text registers (one ASCII character per TXT address), but the question is where to go from there.

    The data received will be something like this:

    STX 01N,115,2000,M CR LF

    The STX at the beginning I can just ignore. The CR and LF i plan to program into my receive function as the closing bits.

    The 01 is an address, the N is a data type, and the commas are data separators. No problem so far.

    The 115 and 2000 in this example would be values that could vary in the number of characters. The 2000 is "Run Hours " on the machine. It could just as easily be 200 or 20000, and the machine sending the data will not provide a fixed number of characters.

    So, first question: Does this sound feasible to convert this data to a usable form?:

    1) Call a subroutine to scan the values of the affected TXT registers for the locations of the commas, and store them in a few DS registers.

    2) Using the values in the DS registers, and relative addressing to determine where the data is, copy the values of each data to a DD using the COPY-PACK function.

    Second Question:

    Assuming above works, will the COPY>Pack assume that each character going into a DD is a decimal digit? ie Will TXT10 value of 1, TXT11 value of 1, and TXT12 value of 5 copy into a DD with a value of 115, or is there some conversion to be done?

    The last text digit (M in the example) relates to the Mode of the machine. That will be no problem for me to process as long as I know what TXT address to find it in.

    I think I have this pretty well worked out, but wanted to see if you guys see any potential pitfalls. Thanks in advance!

    Expand Post