VibratingWire (Vibrating Wire Sensors)
This instruction is used to measure vibrating wire sensors. It can be programmed so that only the vibrating wire is measured, or with the use of optional parameters, a thermistor temperature measurement can be returned in degrees C or as resistance in Ohms.
NOTE: A time slicing conflict will occur if a measurement instruction is included in the main scan when running the VibratingWire() instruction. To avoid the conflict, measurement instructions can be run in a SlowSequence().
Syntax
VibratingWire ( VWDest, VWReps, VWUChan, BeginFreq, EndFreq, VWExOpt, VWAmpThreshold, “DiagFName”, Therm_fN1 [optional], Therm_A [optional], Therm_B [optional], Therm_C [optional] )

Below are two example programs that demonstrate requesting a sensor diagnostic file with the DiagFname parameter of the VibratingWire instruction:
Example #1:
Use “” (empty quotes) for DiagFname parameter and trigger diagnostic file write manually
'Declare Constants
Const reps = 1 'Number of VW sensors
Const VW_OUTPUTS = 6 'Frequency, amplitude, signal to noise ratio, noise frequency, decay ratio, thermistor
Const num_meas = VW_OUTPUTS
Const Bfreq = 1000
Const Efreq = 3000
Const Exopt = 2
Const AmpTh = 0.01
'Steinhart-Hart coefficients for thermistor
Const ThermA = 1.028444E-3
Const ThermB = 2.392435E-4
Const ThermC = 1.562216E-7
'Declare Public variables
Public VW(reps,num_meas)
'Use Table Monitor to assign a file name to the _VW_VW_File field in the Public table. When entering the file name, include the directory name. E.g., CPU:VWField.
'Once the file is written to the specified drive, the Public field will be reset to blank. If the field is not reset, then the file was not written.
BeginProg
Scan(10,sec,0,0)
VibratingWire(VW,1,U1,Bfreq,Efreq,Exopt,AmpTh,"",60) 'Empty quotes for DiagFName parameter.
NextScan
EndProg
Example #2:
Use a conditional statement to programatically trigger writing a diagnostic file to a card.
'Declare Cosntants
Const reps = 1 'Number of VW sensors
Const VW_OUTPUTS = 6 'Frequency, amplitude, signal to noise ratio, noise frequency, decay ratio, thermistor
Const num_meas = VW_OUTPUTS
Const Bfreq = 1000
Const Efreq = 3000
Const Exopt = 2
Const AmpTh = 0.01
'Steinhart-Hart coefficients for thermistor'Main Program
Const ThermA = 1.028444E-3
Const ThermB = 2.392435E-4
Const ThermC = 1.562216E-7
'Declare Public variables
Public VW(reps,num_meas)
Public VWFile as String * 64 'Use variable for DiagfFname parameter
Public FileIndex as Long 'counter for diagnostic file writes
BeginProg
Scan(10,sec,0,0)
VibratingWire(VW,1,U1,Bfreq,Efreq,Exopt,AmpTh,VWFile,60) 'String variable for DiagFName parameter
If VW(1) > 4000 Then 'Write a diagnostic file to card if frequency > 4000 Hz
FileIndex = FileIndex += 1 'counter to append to file name so files are not overwritten
VWFile = "CRD:Data_File_" & FileIndex
EndIf
NextScan
EndProg
Remarks
The coil of the sensor is used to excite the wire element, the resulting wire motion is analyzed, and a frequency value is returned. Diagnostic values for each measurement can be stored in a file for subsequent analysis. This instruction includes the option to measure a thermistor within the instruction. If control over settling time, excitation, voltage range, and noise cancellation is desired for the thermistor measurement, use the separate Thermistor instruction.
NOTE: The VibratingWire instruction does a 4096 point FFT and therefore requires 4*4096 or 16384 bytes of memory for every vibrating wire measurement. Hence large scan buffers (e.g. > 200) in PipelineMode may lead to out of memory errors.
Parameters
VWDest
A variable in which to store the results of the measurement. This parameter will be a two dimensional array if reps are > 1. It must be large enough to accommodate 6 values with the thermistor measurement or 5 without. The order of the returned data is:
Dest(1) = Frequency in Hz
Dest(2) = Amplitude in mV RMS
Dest(3)= Signal to noise ratio
Dest(4)= Noise Frequency
Dest(5)= Decay ratio
Dest(6) = Thermistor (only present if Therm_fN1 optional parameter is present)
If optional parameters A, B, and C are used, the thermistor value will be in units of degrees C; otherwise, it will be resistance in Ohms.
Type: Variable Array
VWReps
The number of sensors to measure (vibrating wire with or without thermistor). If the thermistor is measured it must occupy the pair of channels adjacent (and higher in number) to the vibrating wire connection. With Reps the order in which the measurements will be made are vibrating wire, thermistor, vibrating wire, thermistor, and so forth. If the thermistor is not measured, the Therm_f(N1) optional parameter should be set to 0.
Type: Constant
VWUChan
The first channel to be measured with this instruction. It must be an odd numbered universal terminal. Note that if the thermistor measurement is made with this instruction, then the subsequent odd numbered terminal in the list below is used for that measurement and is thus unavailable for a vibrating wire or other measurement.
Code | Description |
---|---|
U1 | Universal terminal 1 |
U3 | Universal terminal 3 |
U5 | Universal terminal 5 |
U7 | Universal terminal 7 |
U9 | Universal terminal 9 |
U11 | Universal terminal 11 |
Type: Constant
BeginFreq (Starting Frequency)
The starting frequency to use for the vibrating wire measurement (Hz). The minimum value that can be entered is 100.
Refer to the specifications of the vibrating wire sensor for recommended BeginFreq and EndFreq values (typical sweep range is 450 to 6000).
NOTE: Using a variable for BeginFreq will force the program to run in sequential mode.
Type: Constant or Variable
EndFreq (Ending Frequency)
The ending frequency to use for the vibrating wire measurement (Hz). The maximum value that can be entered is 6500.
Refer to the specifications of the vibrating wire sensor for recommended BeginFreq and EndFreq values (typical sweep range is 450 to 6000).
NOTE: Using a variable for EndFreq will force the program to run in sequential mode.
Type: Constant or Variable
VWExOpt
The excitation voltage to apply to the vibrating wire. Valid options are 1 (5 V peak-to-peak), 2 (12 V peak-to-peak), or 3 (2V peak-to-peak). A drop-down list is available to choose one of these options.
Type: Constant
VWAmpThreshold
Used to define a minimum value, in millivolts, for the amplitude of the signal. If an amplitude of less than the threshold is returned, NAN will be stored for the frequency measurement (Dest(1)). If you are unsure of what to enter for this parameter, start with a value of 0.01.
Type: Constant
“DiagFName”
A Public string variable or string constant that is used to trigger the creation of a vibrating wire sensor diagnostic file (.vw). This parameter cannot be left blank.
By default, the DiagFName parameter is set to empty quotes (""). With this default, the data logger automatically assigns a default string name for the parameter: _VW_VW_File.
Users can define their own variable or constant name with a Public string variable, or a Public string constant. For example:
Public DiagFile as String
or
Const FName = DiagFile
The DiagFName will always be visible in the Public table. Entering a file name in the DiagFName field triggers the generation of a diagnostic report.
You can enter the file name manually or programmatically using conditional statements in a CRBasic program.
-
Manually Triggering: For details on how to manually trigger a diagnostic report, see Manually triggering a VW diagnostic report.
-
Programmatically Triggering: To trigger the report programmatically, specify an event condition or time to initiate the file write. For example:
Example Condition Trigger:
If VW(1) > 4000Then 'Write diagnostic file to a card if frequency > 4000 Hz
VWFile = "CRD:Diag_File" 'The file generated will be named Diag_File.vw
EndIf
Example Time Trigger:
If IfTime (1430,1440,Min) Then'Write diagnostic file to the CPU each night, 10 min before midnight
Name = "CPU:Diag_File"
EndIf
After the diagnostic file is successfully written, the DiagFName field is cleared. When a new file name is specified, a new diagnostic report will be generated.
NOTE: If the file was not written successfully, the file name is not cleared.
See example program #2 for a complete program.
As with manual file triggering, the resulting diagnostic file can be retrieved either through File Control or by removing the storage card. The file can then be viewed using the Device Configuration Utility in VW Offline Analysis mode.
Type: String Variable or String Constant
Optional Parameters
Therm_fN1
If present, the thermistor is measured and returned in Dest(6). The parameter is used to specify the frequency in Hz rejected by the summing of multiple 97.35 kHz samples. If the thermistor is not measured the Therm_f(N1) optional parameter should be set to 0.
Option | Description |
---|---|
15000 | Performs a 0.0667 millisecond integration (for fast measurements) |
60 (or _60Hz) | Performs a 16.67 millisecond integration (filters 60 Hz noise) |
50 (or _50Hz) | Performs a 20 millisecond integration (filters 50 Hz noise) |
Type: Constant
Therm_A, Therm_B, Therm_C
Optional parameters used to enter the Steinhart-Hart thermistor coefficients. If one is present they must all be specified. When these coefficients are entered, the thermistor value will be returned as degrees C. If the coefficients are not entered, the result will be returned as resistance in Ohms.
Note that for the VibratingWire instruction, Therm_fN1must be specified in order for the thermistor to be measured.
Type: Constant