Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Digital Inputs in Python Scripts
#1
Using: RoboDK v5.2.5 (64 bit), Windows 10, UR5 (in this example)/UR5e/UR10 robots, Python.

I've included a video in this post as an aid to explain my confusions. My primary focus is making use of a Digital Input (3) on the UR5. It is just a switch that I am manually pressing and letting go of. It seems like the Python script is just ignoring the Digital Input state. At first I thought it just wasn't coming through, but I used ShowMessage() function to produce some feedback on that Bool and it is registering.

Side confusion: why is it that the function ShowMessage() ignores my "False" input for the popup argument? It just goes ahead and shows me the pop up regardless.

In a different test, I found that in a conditional IF statement, using getDI() doesn't work as I thought it would. Basically, it will ignore whether or not the input is active/on/true/1 and allow any code that's under the "not true"/(!= 1)... regardless of the actual getDI() value, whether its 1 or 0. What is the proper way to make use of and implement getDI()?



.mp4   RoboDK_DigitalInput.mp4 (Size: 1.07 MB / Downloads: 23)
   
#2
You should convert the digital input to an int. You are retrieving the number as a string. Example:
Code:
DigitalInput = int(robot.getDI(3))
print(DigitalInput)

Also, you are not using RoboDK's ShowMessage. You should call ShowMessage on the RDK object to see the behavior you expect from the Robolink class (display the message in the status bar):

Code:
RDK.ShowMessage("Message to Display in the RoboDK status bar", False)
You can also use print("Your message") to debug output in the console.
  




Users browsing this thread:
1 Guest(s)