02-10-2021 02:36 PM
After have decent results without the sensor and shift registers I added the sensor back in.
Back to POOR results.
02-10-2021 04:01 PM
But in this picture, you put the subVI back in!
Shift registers vs. feedback nodes will have very little difference in performance. It seems quite obvious to me the difference is due to what ever is going on inside that "sensor subVI" that is making the loop iteration take longer.
What is your actual goal here?
You talk about counting pulses, but the pictures you've shown really don't tell the story of even how you are losing pulses. It seems you are just trying to collect and array of counts.
The counter is counting every pulse. Even if the counter jumps from 100 to 105 from one iteration in the next, you still counted the 5 pulses. Your loop just isn't iterating fast enough for you to be able to see ....each ... and... every.... single.... pulse get added into the pulse counter as they occur. But they still got counted.
02-11-2021 10:29 AM
The actual goal here is to save a displacement reading every encoder pulse. By doing so I will eliminate the effects of speed changes. If the motor that is turning the wheel in the future is accelerating or decelerating it will have no spacing effect on the total scan.
Attached is my latest test code showing VERY slow data flow from my sensor.
Even if I replace the array with a chart or have no chart nor array the baud rate is still 568.
Pretty slow device.
I will try a different sensor manufacturer in a bit.
02-11-2021 10:34 AM
I would not call that baud rate. Baud rate pertains to the actual speed of the serial communication. Your measurement is just how many samples per second you are getting.
That VI basically proves the problem is with that subVI. There is no way that subVI can execute fast enough to get that loop to iterate as fast as the pulses are coming in. I'm not saying that there is a problem with the subVI. Just that the instrument you are using and its communication method have no way of executing as fast you want them to.
02-11-2021 10:52 AM
Can't you do sparse sampling instead? For the difference in the counter value you can actually tell how many pulses you missed, so you know where you are, even if there are gaps.
02-11-2021 12:08 PM
First things first. The "right way" to do this is to use the encoder as an external sample clock that drives an analog acquisition task. (Perhaps it would also drive a position measurement task, depending on overall needs).
Given what you've shared so far however, it doesn't sound like that's a feasible option for your laser displacement sensor driver. So you'll probably need to choose between using different equipment that supports the "right way", or settle for making a non-ideal method the "least wrong" that you can.
If there's no means to force hardware-timing correlation between the laser displacement values and your encoder, then you're stuck with imperfect software-timing correlation. The only good news there is that you can probably stick with your simple software-timed counter query since you're already in the imperfect realm of software timing.
How to *best* correlate that with the data you get from the mfgr's driver depends predominantly on that driver, which no one here knows anything about. About the only advice I can give is that careful attention to dataflow on your part will tend to help preserve that "least wrong" correlation instead of making it worse.
-Kevin P