Config.dat Signal Declaration (Joining Numbers)

  • Hi,


    We have two sets of 4 inputs, creating two 4 bit binary values that allows us to select a value of up to 9 on each dial. This is to give us the ability to have double figure values.


    e.g. dial 1 set to 2 (0100) dial 2 set to 8 (0001). I wish to combine these values to give the value 28.


    normally in config.dat i would use $IN[1] TO $IN[16] to give a decimal value from binary inputs. however because the each dial only goes up to 9, this is not possible.


    I could probably do something in the SPS but this is for a tool ID and if the SPS is stopped it, the tool id may be incorrect.


    Is there a way to achieve what i want?


    Thanks!


    KSS 8.3

  • don't use config dat. just create function such as TOOL_ID.SRC


    DEFFCT INT Tool_ID() SIGNAL X1 $IN[1201] TO $IN[1204] ; low nibble SIGNAL X10 $IN[1205] TO $IN[1208] ; high nibble RETURN X10*10 + X1 ENDFCT


    then call it as needed


    Code
    IF Tool_ID()==28 THEN
    
    
    
    
    ENDIF


    or


    Code
    Tool = Tool_ID()

    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

  • signal is just a substitute name for I/O

    you can use $IN[643] in your code but who the heck is going to remember that that input is really called...

    and when you get to command like


    WAIT FOR $IN[643]

    guess what message is displayed?


    so you make a signal with proper name that matches KRL naming conventions, for example


    SIGNAL Gripper_Closed $IN[643]


    after that you can still use $IN[643] in your programs but... why would you?

    you may replace


    WAIT FOR $IN[643]


    with

    WAIT FOR Gripper_Closed


    which is much more readable and additionally - a user friendly message is displayed.


    SIGNAL also allows you to group up to 32bits of input or outputs into single variable.


    SIGNAL parts_produced $OUT[333] TO $OUT[349]


    then you can send signal to some PLC or whatever by using


    parts_produced = 1234


    how and where signal is declared will affect scope and life of the signal - same rules as for variables.

    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

  • and there are more advantages...


    for example your input gets busted for some reason.

    no problem you think, we can just wire the signal to next available IO such as $IN[647]

    but rather than search through each and every program and replacing $IN[643] with $IN[647], if you already used signal, you just need to make change in one place.


    this same principle allows you to deploy and run same programs on different robots (robots with different IO configuration). you just need to customize one file where signals are declared....

    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

  • DEFFCT INT Tool_ID()

    SIGNAL X1 $IN[1201] TO $IN[1204] ; low nibble

    SIGNAL X10 $IN[1205] TO $IN[1208] ; high nibble

    RETURN X10*10 + X1

    ENDFCT



    i just copied what you write earlier to help you understand what i would like to say :D

    So.. i would like to use a HMI PLC, where the data change if the operator enter the values. example:

    The operator says i would like to produce 300x500 exp wooden planks. After that he will produce 600x1000, so the values should change.


    The question is how to change the return line to be variable?

  • not sure i understand... above example is for specific use where user had two 4-bit values (BCD).

    4bit value can be used for numbers 0-15 but in BCD only 0-9 is used. with two such digits one can represent range 00-99.


    but what you are mentioning here are values in great excess of that range. if signal is in BDC format you would need additional digits.

    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

  • Yes, thats what i would like to know. So this is the format what should i use?


    DEF example()


    SIGNAL X1 $IN[80] TO $IN[84]

    SIGNAL X10 $IN[85] TO $IN[88]

    SIGNAL X100 $IN[89] TO $IN[93]

    SIGNAL X1000 $IN[94] TO $IN[98]

    RETURN X1000*1000+X100*100+X10*10+X1


    END


    -> back to the main program


    IF example()=> 500 THEN


    PTP P1...

    ...

    ...


    else

    ...


    ENDIF

  • Thanks! And one more question. If i use these names: X1,X10,X100... should i declare this in DAT file?( I mean Decl INT X1 or something?) Or as you said earlier i just gave a name to a signal in src.

  • Earlier i made a mistake...sorry...


    It's.. DEFFCT


    SIGNAL X1 $IN[80] TO $IN[84]

    SIGNAL X10 $IN[85] TO $IN[88]

    SIGNAL X100 $IN[89] TO $IN[93]

    SIGNAL X1000 $IN[94] TO $IN[98]


    RETURN X1000*1000+X100*100+X10*10+X1


    ENDFCT


    How can i move it to the $config.dat if the description says i have to use DEFFCT?


    Can you explain me please like an example how can i declare signal X1 in dat??


    i know how to declare int, bool, real etc., but i don't know how to decl this if the description says what i wrote earlier.

  • just transfer signals from DEFFCT to $CONFIG.DAT

    simplest way is to copy and paste. then you can come back to DEFFCT and remove or comment out originals (or even leave them there if you really want to)


    SIGNAL X1 $IN[80] TO $IN[84]

    SIGNAL X10 $IN[85] TO $IN[88]

    SIGNAL X100 $IN[89] TO $IN[93]

    SIGNAL X1000 $IN[94] TO $IN[98]

    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

  • Hello guys:)

    Here we go again.. :)
    I didn't have time to deal with this, so this is the time when i would like to use signals.
    panic mode i thing there was a little missunderstanding between us, i think i didn't express myself well.

    So i would like to use PGNO_TYPE = 1 (binary coded integer)

    Cause as i know this is the best method in KRC2 to transfer data. Or can i send data pack somehow?



    in field:

    The operator would like to produce 1500 x 500 material. The robot will dose to assembly. Every workpeace will grab by a vaccuum gripper in the center. So the robot will has a zero point and will go 250mm in x and 750 mm in y. This is the center of the material.

    The operator will type these parameters in the HMI. (length - width)


    Question:


    To stay on the example.
    1500:
    Signal x1: 0000

    Signal x10: 0000

    Signal x100: 0101

    signal x1000: 0001


    I hope everything good until this.:)
    The question is how the robot know that which $IN is the binar value 1?
    So stay on the exmaple: 1500.

    0, 0 don't care because there are no IN switching.

    5 at the hundredth place value.

    It is 0101 with $IN[124] TO $IN[127].

    How should we see this, which inputs will switch on and how will know the robot which one is the 20

    or 21 or 22 or 23 ?

    $IN[124]= 0

    $IN[125]= 1

    $IN[126]= 0

    $IN[127]= 1


    And firstly should we declare somehow to know the robot which is the 20 ... etc.?


    I hope you understand what i would like to ask and i hope i can help somebody else too with these questions.


    Thanks to read this and thanks for your help in advance!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now