Home Programming

Discussion

Left ArrowBack to discussions page
SweiskittelSweiskittel Posts: 4 Apprentice
I am using data from a TCP/IP to determine if a part passes or fails so that the UR can place it correctly. The socket works correctly throughout the rest of the program. The socket takes a command "Dio 2 ?" and returns "Dio 2 = OFF" or "Dio 2 = ON" based on the status of the output. I then concatenate the string at the 8th character: str_sub(socket_read_string("gagemate"),8). This leaves me with a string of "ON" or "OFF". When I try to compare the string to another string I always get back FALSE. I am using the popups to show the values of Part_Pass, Part_Fail, PartPassCheck, and PartFailCheck. Regardless of the values of Part_Pass and Part_Fail, the checks always return false.This method is how I have checked other inputs in the program (see below) but does not seem to be working here. Is there something else that I need to be doing or is there some simple error that I missed?
     Part Status Check
       Part_Pass≔"OFF"
       Part_Fail≔"OFF"
       socket_send_line("Dio 2 ?","gagemate")
       Part_Pass=str_sub(socket_read_string("gagemate"),8)
       socket_send_line("Dio 3 ?","gagemate")
       Part_Fail=str_sub(socket_read_string("gagemate"),8)
       Popup
       Popup
       PartPassCheck≔Part_Pass≟"OFF"
       Popup
       PartFailCheck≔Part_Fail≟"ON"
       Popup
       If Part_Pass≟"ON" and Part_Fail≟"OFF"
         Popup
       ElseIf Part_Pass≟"OFF" and Part_Fail≟"ON"
         Popup
       Else
         Popup
Here is a working check at a different section in the program
 Check Input
               GM_Status≔"OFF"
               Loop GM_Status≟"OFF"
                 socket_send_line("Dio 1 ?","gagemate")
                 GM_Status=str_sub(socket_read_string("gagemate"),8)
                 Wait: 0.01
               socket_send_line("Dio 17 ON","gagemate")
               socket_read_string("gagemate")
               Wait: 0.1
               socket_send_line("Dio 17 OFF","gagemate")
               socket_read_string("gagemate")

Best Answer

  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    Answer ✓
    What is the string that is being returned by your sub_string method?  Are you sure it is "ON" or "OFF" that there aren't any other spaces or anything?  That's the first place I would look.

Comments

  • SweiskittelSweiskittel Posts: 4 Apprentice
    The string returned is either "ON" or "OFF". When I check with str_len() I get a value of 5, however when I send the strings to the log they are only three or two characters long. The odd thing is that the same commands are used later in the program will not work. I will try to see if only using a sub string of length 2 may work.
Sign In or Register to comment.
Left ArrowBack to discussions page