Kuka VisionTech how to set output?

  • Hi Guys,


    Iam very new in visiontech.I connected camera to the robot and now im taking picture and taking some result.

    But how i set output?

    For example, if i get good result i want to set output in kuka.If result bad reset output in kuka.

    Then later i will process this signal in PLC side with profinet.

  • Code
    IF ResultIsGood THEN
      $OUT[3]=TRUE
    ELSE
      $OUT[3]=FALSE
    ENDIF


    or shorter


    Code
    $OUT[3]=ResultIsGood

    thank you for answer. Iam reading Qr kod and i have 18 digit string .

    i need the verify first 6 digit and set some output.

    BTW ''Resultisgood'' an autpmatic identification for visiontech?

    For example in ABB robots we are use somespecial rapid code.

    Im very new in kuka world

  • i cannot read minds. perhaps check pinned topic READ FIRST, post some code and state product versions.


    your previous post asked how to set an output and answer shows just that. variable "ResultIsGood" is made up to match your own question and used example.


    there are no strings in KRL. they are actually character arrays. so you can loop through first 6 characters and do comparison. there is also a KRL function for that.



    to compare parts of the string you would need to either extract substrings of needed length and compare them with above function or use loop and stop comparing after some character...


    here is an example of DIY comparison, also with or without case sensitivity.


    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Here is my code block. My text[] result is XU756217802. Last 3 digit always changing because of 2D barcode.

    I want to verify first 6 digit. If first 6 digit is XU7562 i will set Cam_OK Signal.

    I tried to findstr() but not function for me.

  • Here is my code block.

    i see nothing resembling string comparison...


    I tried to findstr() but not function for me.

    to the best of my knowledge, KRL does not contain function with that name but - there is a function STRFIND() and it should do the trick nicely.


    Code
    $OUT[3333]=STRFIND(1,TEXT[],"XU7562",#NOT_CASE_SENS)


    another option is to simply discard part of the string after the 6th character and use regular compare:


    Code
    TEXT[7]=0 ; 7th character will be string end
    $OUT[3334]=STRCOMP(TEXT[],"XU7562",#NOT_CASE_SENS)

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • TEST[7]=0 ; 7th character will be string end

    $OUT[3334]=STRCOMP(TEXT[],"XU7562",#NOT_CASE_SENS)


    I will try this. Why are you set the text string to =zero?

  • exactly... sting will not match if it is different length. since you only care about first 6 characters and not entire string, characters after the 6th place are not needed. one of common string types is zero terminated. this means computer will treat sequence of characters as a string until it reaches position that is null (ASCII value 0).


    so you have

    test[]="XU756217802"


    which is 11 characters. actually you do not see that but there are additional characters after that (at least one) and the next character (at position 12) is a zero. this tells computer to look no further.


    so after execution of

    text[7]=0


    we replace value of 7th character to be null as well. but since 7 comes before 12, string will now only show first six characters and the variable will display as

    test[]="XU7562"


    and this is precisely part that you are looking for so normal comparison can be used. strings of different length cannot be same


    "ABC" is not the same as "ABCDE"

    but if we shorten "ABCDE" then we may have a match...

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • you have to pay attention to details.


    when specifying array name without index, your are addressing entire array.

    example:

    test[] = "hello world"


    when index is specified, you are addressing only specific element.

    example:

    test[6]="-"


    this changes content to "hello-world"


    test[5]=0

    this changes content to "hell"


    also it matters when and where you do that... if you are doing it before variable contains string value you will see no difference.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • your archive shows that variable is declared as TEXT[] not TEST[]. so you may be trying wrong spelling.


    also for any piece of code to do anything useful - it need to put it somewhere. a good place would be program file. i saw no trace of string comparison in your programs.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • SkyeFire

    Changed the title of the thread from “Kuka VisionTech hot to set output?” to “Kuka VisionTech how to set output?”.
  • your archive shows that variable is declared as TEXT[] not TEST[]. so you may be trying wrong spelling.


    also for any piece of code to do anything useful - it need to put it somewhere. a good place would be program file. i saw no trace of string comparison in your programs.

    yeah i have just text varible. Somehow test varible come with forum members.


    I have also 2 string varible too. You can see the kamera_kontrol .dat

    Totaly i have 3 string varible.


    I think im missing someting in code alignment.


    I understand all procedure.


    This is my original code block. Im trying to compare to string behind the my robot and changing the code there. Because camera mounted the robot.

    Somehow i get always 11 digit. This is make me sick.

  • Well, one brute-force way to do this would be to extract the substring. The trick relies on the fact that KRL doesn't really have a "string" variable type -- instead, the string functions like STRCOMP and STRFIND act on arrays of type CHAR.

    So:


    STRCOMP only works if both strings match in every character. So to find a substring inside a larger string, STRFIND probably works better.


    If you know, for example, that the substring you want to check is from the 3rd to the 9th characters of the large string, you could use STRFIND(3...). Or use the FOR loop method from 3 to 9 instead of 1 to 6.

Advertising from our partners