Universal Robots Forum

Generating a square signal

Hello there,

I am trying to send a square digital signal from a UR3 to an Arduino board, but I am encountering issues when optimizing the duty cycle, because the robot is quite unstable.
Here is the set up:

  • One output (tool DO0) goes from the UR to Arduino.
  • In between the UR and Arduino, there is a optocoupler to transform the signal from 24 to 5V.
  • The Arduino generates also the same square signal, but it’s connected only to the oscilloscope.
  • For testing: the other output (tool DO1) is connected to an oscilloscope. Both signals (DO0 and DO1) stream the same square signal. Additionally, the oscilloscope also measures what the Arduino receives from the optocoupler the other square signal.

The result:

  • Top: the square signal from DO1 has a falling time of 12 ms. This is measured directly on the robot.
  • Bottom: what the Arduino receives and streams. The yellow square signal is the digital input that the Arduino receives from the optocoupler and the blue is a square signal generated from Arduino with an actual active cycle of 25.
  • Comparing the graphs, the robot should generate a square signal similar to what the Arduino shows. However, it generates the yellow signal, which has an active cycle way shorter than it should.

The code on the robot side:

def writeTest():
   testSend = False
   TEST_PERIOD = 0.025
   while True:
      testSend = not testSend
# main

So here are my questions:

  • Why does the voltage drop before the active cycle is completed? Should it not drop after the first 25ms, when the code sets the signal to 0?
  • If tool DO1 is directly connected to the oscilloscope, then the optocoupler and intermediate hardware has no role on the falling time?
  • Is there any way to short this falling time or to move it to the inactive cycle?