05-11-2017 04:32 AM
I'm using a Ni usb6216 to acquire the position value from an rotary encoder. Since I'm new with labview I started from the encoder example " Counter - Read Encoder " given with the nidaqmx driver.
It works and I can read the position properly, but I now want to derivate the signal to obtain the rotation speed.
The point to point derivative block doesn't seem to work, cause it's output is still the position value divided by the "dt" value.
I don't know what's wrong, maybe it's some basic knowledge of lab view I'm missing.
05-11-2017 05:30 AM
Or just tell how else could I do the same thing
05-11-2017 07:45 AM
The main problem I notice is "units". Read carefully the Help for the dx/dt function, then check the units of each of your input wires. See if this makes a difference in what you get out.
Sometimes when you are unsure of how a LabVIEW function works, it helps to write a tiny "test" routine, which can take a whole 2 minutes to do, to test it out. For example, here's one I wrote (since I've never used this particular function myself, and wanted to see how it behaved) ...
Bob Schor
05-11-2017 09:39 AM
Another thought to consider: a numerical derivative on sampled data will tend to add "noise" to the result. If you care about both position and speed it's usually best to measure speed directly and calculate position rather than the other way around.
Provided your motion is unidirectional, you can configure your board's counter to do frequency measurement and get a direct measurement of speed. Just realize you'll lose any sign info for direction.
Position can be determined by keeping cumulative track of the sample # in the array of frequencies -- 1 sample per cycle of the encoder signal.
There would also be a way to use the 2nd counter to do quadrature position measurement that's synced to the freq measurement. That would give you a bit more position resolution and a good shot at decoding sign on your freq measurement. But I'd try the 1 counter method first as there are fewer configuration details to worry about.
-Kevin P