Overview
This is an example showing how you can use VBScript in DIAdem to implement interpolation and approximate a parameter from an input, specifically the angle of a shaft from a positional sensor.
Description
This example is based upon a rotating shaft which is being measured using a trigger tooth, with the number of times and timestamp of when this trigger passes a sensor being recorded, in this case there is only one trigger per full revolution. From this we can then calculate the approximate angle of the shaft at a certain point in time based upon the time between the triggers. If you have more than one trigger you can change the variable "NumberofTriggers" in the script to scale the data based on this.
To do this we need two channels, a voltage channel referenced to the number of samples, and a timestamp channel which maps the samples to a specific point in time. Firstly, before any analysis is done, your channel should be thresholded to give a uniform reference for the script to analyse.
To do this we first detect where all triggers occur in the data channel and place these into a temporary array. We then work out the number of samples and hence the amount of time(using the timestamp channel) between each trigger.
This allows us to work out the differential of angular displacement and from that the approximate value of angle over the set time between two triggers. We then iterate over the entire channel of data which allows us to buid up the approximate angle of the shaft over this timebase. The angle resets to 0 degrees after a full rotation.
Steps to Implement or Execute Code
Requirements
Software
DIAdem 2012
Hardware
None
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.