Discussion

Left ArrowBack to discussions page
agiakosagiakos Posts: 13 Apprentice
edited February 7 in Troubleshooting
Hello Community,

I made a small program to check my MODBUS connection. It seems like I can not read the register value or detect changes.
My code stucks here even when I change the register value from zero to 500. Is my approach/coding wrong?

Edit: I was able to make it work with the function modbus_get_status_signal("register name",false)


Comments

  • LoïcLoïc Posts: 16 Apprentice
    First, in the MODBUS configuration, you want to read the register 128 so it's a robot's input. It needs to be a "Register Input" and not a "Register Output".

    Then, you should put the line "var_1:=read_port_register(128)" in a thread to make it works (don't forget to put a "wait 0.01s").
    With your actual code, you only read once the register concerned, when the blue cursor pass on it so if it's not at the value 500 at this time, you'll wait forever. Putting it in a thread, you'll read it "continuously".

    I don't know if then it will works but you can start changing this.
  • agiakosagiakos Posts: 13 Apprentice
    Loïc said:
    First, in the MODBUS configuration, you want to read the register 128 so it's a robot's input. It needs to be a "Register Input" and not a "Register Output".

    Then, you should put the line "var_1:=read_port_register(128)" in a thread to make it works (don't forget to put a "wait 0.01s").
    With your actual code, you only read once the register concerned, when the blue cursor pass on it so if it's not at the value 500 at this time, you'll wait forever. Putting it in a thread, you'll read it "continuously".

    I don't know if then it will works but you can start changing this.
    Loïc you mean that I need to put the line "var_1:=read_port_register(128)" inside the moveL and after that line the wait command?
  • LoïcLoïc Posts: 16 Apprentice
    No, your code should look like this :



    The Thread function will run like an infinite loop which will check the status of your port.
  • agiakosagiakos Posts: 13 Apprentice
    edited February 7
    sorry i just had a syntax error,thank you for the help
  • LoïcLoïc Posts: 16 Apprentice
    You're welcome
  • matthewd92matthewd92 Posts: 623Founding Pro, Tactile Sensor Beta Testers Handy
    You actually don't need a thread for this to work.  Instead of assigning it to a variable you simply put it in the wait statement like the image below



    When this code executes it will wait for the register to become 500, then execute the popup, wait again for it to be 1000, execute the popup, etc.

    Like this



    We use this whenever we need to synchronize activities or motion between robots in a cell.
  • agiakosagiakos Posts: 13 Apprentice
    edited February 13
    thank you @matthewd92

    I would like to sent the wrist3 position through a modbus register but I do not know how to do it.
    I thought to try the command get_actual_tcp_pose() , but the register reads only one value. 
    Do I have to read the value of register 275 and get the position in rads?
  • matthewd92matthewd92 Posts: 623Founding Pro, Tactile Sensor Beta Testers Handy
    Songet actual TCP pose will return the coordinates of the TCP as a pose giving the x,y,z coordinates in meters and the rotation of the TCP in radians as rx,ry and rz. 

    If you want to have a register of the actual joint rotation create a modbus client to IP address 127.0.0.1 and then connect an input register to port port 275. This will now hold the value of the wrist 3 in milliradians. You would need to multiply by 1000 to get radians. 
Sign In or Register to comment.
Left ArrowBack to discussions page