Need some help in Robotstudio with an inductive sensor

  • Hi!


    I have this lab where I am given 4 parallell random size metal plates and I need to sort them according to size.


    I am given in the beginning an inductive sensor, which I am going to use to detect and measure the length of each piece.


    So I make a nice path that runs through the pieces and I write some code in a TRAP to record the point of one edge of the a metal piece when the sensor goes high and record the other position when the sensor goes low.

    The plan is to subtract and find the length. It goes well for the first piece, but when the sensor goes to the next metal piece it just applies the position values of the first piece and so on for the rest of the pieces.


    I suspect the problem lies with my TRAP routine and that I should use IDelete/IEnable/Iwatch or smth to deactivate the TRAP? Or can you suggest something that works?


    Thanks in advance!

  • A search would be more appropriate. You can use two different rorbtargets to store the found positions, and then use the Dist() function to tell you the length.

    What do you mean by "search" that would be more appopriate?



    By the way, thanks for the Distance function, i did not know it existed :smiling_face:

  • Look up SearchL in the Instructions, functions and datatypes manual.

    Thanks for the advice! I finally could finish the lab and learned a couple of nice things too. i used the Distance function, which worked like a charm and SearchL led me to discover SearchC also and they were great ideas for my other lab! :grinning_squinting_face:

Advertising from our partners