11-02-2021 11:21 AM
Hi,
I am have written a DAQ program to trigger a RC servo (works with PWM signal) with encoder angles as the input. I am comparing a theoretical angle with the encoder angle and telling the servo to rotate when that angle is reached. To monitor that the encoder has reached the angle and the servo starts rotating, there are two booleans. Theoretically, both the boolean should switch on at the same time. However, I observe that the boolean for the servo switches on some time later compared to the boolean which detects that the encoder angle has reached. This means that there is a delay between the two operations. Also, I observed that this delay is not consistent across different cases and it varies significantly. I don't want this delay as I want the servo to rotate as soon as the encoder angle is detected. The VI I am using is attached with this post.
Can someone please help out on how to correct this delay issue and reduce it?
Thanks
Abbishek
11-02-2021 11:35 AM
Hi Abbishek,
11-02-2021 11:51 AM
Hi Santosh,
Please find the VI attached in LabVIEW 2016 version.
Also, please find the connections made to the DAQ system attached with the mail. I am using USB-6341 DAQ system. The encoder is connected to Counter 0 while the servo connections are made to the Counter 1. The Encoder has 5 cables and they go into pins 96 (+5V), 86 (DGND), 81 (channel A), 85 (channel B) and 83 (Z index). Servo has 3 cables and they go into pins 96 (+5V), 94 (DGND) and 91 (signal).
Thank you
Abbishek
11-02-2021 03:06 PM - edited 11-02-2021 03:11 PM
Hi Abbishek,
it would help to cleanup your blockdiagram to follow the LabVIEW style guide. Really!
See this (partial) cleanup:

Atleast the wiring in the blockdiagram is the same kind of "horrible" as is the wiring on the DAQ box. 😄
11-03-2021 07:45 AM
Well, there's one very obvious reason for a delay that can vary from 0-25 msec. Is that what you're chasing?
Your lower loop must wait a minimum of 25 msec between times that it checks the boolean value. The indicator's local variable will be read at the very beginning of each 25 msec, but the indicator may change *at any unknown time* within a 25 msec interval. So the time between seeing the changes can easily vary from 0-25 msec due to this alone.
Beyond that, I really don't want to spend time interpreting the scrambled mess of code I see until you spend more time cleaning it up.
-Kevin P