RoboDK Forum
Using Digital Inputs in Python Scripts- Printable Version

+- RoboDK Forum (//m.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//m.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//m.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Using Digital Inputs in Python Scripts (/Thread-Using-Digital-Inputs-in-Python-Scripts)



Using Digital Inputs in Python Scripts-aldomb-10-26-2021

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.

在一个不同的测试中,我发现在一个条件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: 224)



RE: Using Digital Inputs in Python Scripts-Albert-10-27-2021

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.