I am using an Arduino UNO to read the voltage of two devices, aiming to synchronize them. I am using a digital pin of the Arduino to read voltage from Device A and an analog pin to read voltage from Device’s B Torque analog pin.
I measure time using a Real-Time Clock (Adafruit DS3231).
While writing the Arduino script's first draft, I connected a potentiometer to a 3.3 voltage source. By turning the control knob of the potentiometer, I created different analog voltage inputs simulating the behavior/readings of the Device's B analog Torque pin when the participant applies Torque. For example, when the control knob was turned all the way in one direction, 0 volts were going to the analog pin. I interpreted that as the participant was applying zero Torque in Device B. When the control knob was turned all the way in the other direction, 3.3 volts were going to the pin, and I interpreted that as the participant was applying max Torque in Device B.
During this process, everything looked good. The Arduino's recording time matched the recording time of Device A (Please see Figure 1).
Figure 1 shows that I recorded data from Device A for 20 (sec) during a 60 (sec) period, so I was expecting to see a 20 (sec) 'ON' window in the Arduino data (Panel A). Also, I was expecting that the time file of the Device A software would be 20 (sec) long (Panel B). Indeed, the Pane A. displays that the reading of the Arduino's digital pin was 20 (sec), the Pane B. displays that the readings from Device A software were 20 (sec), and the Panel C displays that the time series of the two devices are matched.
However, when I replaced the potentiometer with the Device B. The Device's A recording time does not match the recording time of Arduino's digital pin. This is mainly because the Arduino reads the Ultrasound as 'ON' earlier than Device'A software (left box) (Please see Figure 2).
Do you have any ideas why this is happening?
P.s. Please let me know if I have not provided enough information and you need more.