From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate the derivative of an array using measurement studio?

Hi I am using a counter task to read the position from a rotary encoder. I would like to calculate the angular speed (let's not consider here all the constants like Pi etc). Using the differentiate function  (NationalInstruments.Analysis.Dsp.SignalProcessing.Differentiate) i obtain a result that is clearly uncorrect (e.g. when the encoder stops the value doesn't go to 0 but remains constant). What am I doing wrong? I attach a few lines of code

Imports NationalInstruments.Analysis.Dsp.SignalProcessing
(...)
'this is the position vector
contatore = myCICounterReader.ReadMultiSampleDouble(SamplesToRead)
'this should be the speed vector
velocita = Differentiate(contatore,SamplingInterval, 0, 0)

tkx
nunzio
0 Kudos
Message 1 of 2
(3,779 Views)

Hello Nunzio,

sorry for the late reply. Have you verified that the data included into contatore array are the ones you're expecting so the velocita array will contain zero values? The function call

Differentiate(contatore,SamplingInterval, 0, 0)

seems correct, try to replace contatore input with a known array and then check if everything works correctly.

Best regards,

Fabio

Fabio M.
NI
Principal Engineer
0 Kudos
Message 2 of 2
(3,733 Views)