SuperCoupe (Customer) asked a question.

ASCII from scale to BCD, DLO6

I am getting a ASCII string form a scale that I need do to a little math with and display on a HMI. I can read the ASCII string just fine, but I am trying to use AEX to pull out and convert the data I need. With the AEX I can get one digit or number and several periods, example . 2...........

Format from scale the is: ST,GS,+/-, "data"lb,CR,LF, for a total of 18 spots. "data" is the reading of the scale. Not sure what I am doing wrong with this or am I using the wrong commands. Have searched on here and on PLCS forum with no luck.

 

Thanks,

aex-2aex


  • ADC TechnologyGroup_05 (AutomationDirect)

    In this scenario

    V2000 holds the character count for the ASCII string.

    V2001 (byte 0) is the start of the ASCII string data.

    Starting at V2001, byte offsets 7 through 13 hold the actual weight value. However, the byte order makes sense for a STRING, but NOT for a DWORD integer. Therefore, the byte order must be manipulated and some math must be performed.

     

    Below, I used the VPRINT instruction to create your string but used a weight of 1,234,567 for testing. I've included the CR/LF ($N), as well.

     

    I used a decimal format to populate V5000 and V5001 with the DWORD value 1,234,567. See if this approach will help your project.

     

    ASCII_Parse01 

    ASCII_Parse02 

     

    Expand Post
    Selected as Best
  • bcarlton (Customer)

    Could you please show each V location in hex/BCD format? Try setting number of bytes to at least 2. Display the resulting V registers in hex/BCD as well as text. Try setting the index starting at 1 and increase by 1 with each attempt (brute force method). It looks like the numeric data starts at byte index 14.

  • SuperCoupe (Customer)

    Here is the data

     

    1st Pic:96lb from scale in BCD format, with the AEX to convert string to BCD

    2nd Pic: 96lb from scale in text format, with the AEX to convert string to BCD

    3rd: wrong pic not sure how to delete it

    4th Pic: 98lb from scale in text format, with the AEX not to convert string to BCD

    5th Pic:98lb form scale in BCD format, with the AEX not to convert string to BCD

    I can not find a correlation with the data to be able to use it.

    96lb-hex with convertbcd96lb-text with convertbcd98lb-text98lb-text98lb-hex

    Expand Post
  • SuperCoupe (Customer)

    Here is the program

    PLC 06

     

    // Rung 1

    // Address 0

    #BEGIN COMMENT

    "THIS INFORMATION PROVIDED BY AUTOMATIONDIRECT.COM TECHNICAL "

    "SUPPORT IS PROVIDED ""AS IS"" WITHOUT A GUARANTEE OF ANY KIND."

    "These documents are provided by our technical support department to assist others. We "

    "do not guarantee that the data is suitable for your particular application, nor do we "

    "assume any responsibility for them in your application."

    ""

    "ASCII In Example Program"

    ""

    "The Processor is waiting for another ASCII message. The AIN is controlled by C100. "

    "Once a valid message has been recieved, the AIN needs to be deactivated and then "

    "restarted."

    #END

    STR C100

    AIN K0 K0 K2 V2000 K18 K0 K0 K0 C0 C1 K0 K0

     

    // Rung 2

    // Address 8

    #BEGIN COMMENT

    "If the AIN is not enabled, turn it back on."

    #END

    STRN C100

    SET C100

     

    // Rung 3

    // Address 10

    STR C1

    RST C100

     

    // Rung 4

    // Address 12

    #BEGIN COMMENT

    "Count the number of valid messages that the PLC recieves. This is not needed for any "

    "control, but just to see that a message was recieved by the processor correctly."

    #END

    STRPD C1

    STR CT1

    OR SP0

    CNT CT1 K9999

     

    // Rung 5

    // Address 18

    STR SP1

    AEX V2000 K14 K2 K0 K0 K1 V3760

     

    // Rung 6

    // Address 24

    END

     

    // Rung 7

    // Address 25

    NOP

     

    // Rung 8

    // Address 26

    NOP

     

     

    #BEGIN ELEMENT_DOC

    "UW0","o400","",""

    "UW1","V2008","",""

    "UW2","K7","",""

    "UW3","K","",""

    "C0","","","AIN Busy"

    "C1","","","AIN Complete"

    "C2","","","AIN Overflow"

    "C100","","","Enable AIN"

    "CT1","","","Valid Message Counter"

    "V400","","","Start of ASCII Data"

    "V2000","SCALE DATA","",""

     

    #END

     

    Expand Post
  • bcarlton (Customer)

    The AEX now seems (with index at K14) to be extracting correctly but not converting. You'll probably need to call AD for further help. I don't have a unit to check this on.

  • SuperCoupe (Customer)

    Thank you for your time, i will contact them.

  • SuperCoupe (Customer)

    I contacted Automation Direct and they just referred me to the users manual, so they did not help at all.

  • bcarlton (Customer)

    That response is similar to the one I received several years ago regarding AFIND command. The demo code in the manual shows a ​timer utilized to allow time for the AFIND instruction to complete. I called to ask how long the.AFIND instruction took given that the manual shows only one time with no consideration for string length. They assured me it completed in one scan. I asked what the labeled timer in the demo code was for. They didn't know. I asked if someone there knew (since it was AD's manual). They said the only ones who actually knew were developers in Japan and many of them were no longer available.

     

    This is a reason I liked using the Do-more line. The developers are right here in the US and easily accessable.

    Expand Post
  • SuperCoupe (Customer)

    After days of trying to figure it out, I ended up wiping the PLC clean and starting over, and I got it to work close enough where I can use it. There must have been something in the memory causing issues. Below is was I used to get it working, which is very similar to what I had before. working

    • working
  • ADC TechnologyGroup_05 (AutomationDirect)

    In this scenario

    V2000 holds the character count for the ASCII string.

    V2001 (byte 0) is the start of the ASCII string data.

    Starting at V2001, byte offsets 7 through 13 hold the actual weight value. However, the byte order makes sense for a STRING, but NOT for a DWORD integer. Therefore, the byte order must be manipulated and some math must be performed.

     

    Below, I used the VPRINT instruction to create your string but used a weight of 1,234,567 for testing. I've included the CR/LF ($N), as well.

     

    I used a decimal format to populate V5000 and V5001 with the DWORD value 1,234,567. See if this approach will help your project.

     

    ASCII_Parse01 

    ASCII_Parse02 

     

    Expand Post
    Selected as Best
  • SuperCoupe (Customer)

    I used the above program and it worked well, thank you for you help.