Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

setting up public varibles when transcribing code for use with MUX AM 16/32. alias use?


Shanks.J Nov 16, 2021 10:54 PM

my sensor suite is expanding and i am now planning to us and am 16/32 to measure serveral sensors including 3 vibrating wires.

before the expantion 3 vibrating wires are measure with the cr6 and the following varibale set ups:

'VW1

Public VW1_Sensor_Change

Public VW1_Freq, VW1_Digits, VW1_Eng_Units, VW1_Temp

Public VW1_Set_Zero As Boolean

'VW2

Public VW2_Sensor_Change

Public VW2_Freq, VW2_Digits, VW2_Eng_Units, VW2_Temp

Public VW2_Set_Zero As Boolean

'VW2

Public VW3_Sensor_Change

Public VW3_Freq, VW3_Digits, VW3_Eng_Units, VW3_Temp

Public VW3_Set_Zero As Boolean

 

'Dimmed Variables

'VW1

Dim VW1_Dest(6)

Dim VW1_C

Dim VW1_Install__Eng_Units

Dim VW1_Install_Temp

Dim VW1_Temp_Corr

Dim VW1_K

'VW2

Dim VW2_Dest(6)

Dim VW2_C

Dim VW2_Install__Eng_Units

Dim VW2_Install_Temp

Dim VW2_Temp_Corr

Dim VW2_K

'VW3

Dim VW3_Dest(6)

Dim VW3_C

Dim VW3_Install__Eng_Units

Dim VW3_Install_Temp

Dim VW3_Temp_Corr

Dim VW3_K

now that i must use the MUX the varible have to be read with:

'Vibrating Wire

Public VW(3,6)

ie 3 sensors with 2 readings each (frequency and temp)

question: how to expand the limited variables of the mux variables above, into the larger set up i was formally using. is this with a set of alias?


Shanks.J Nov 17, 2021 11:34 PM

solution:

'CR6 Datalogger


'Wiring Schedule

'#################Wiring#######################

'Datalogger Provisioning
'U1 -
'U2 -
'U3 -
'U4 -
'U5 -
'U6 -
'U7 -
'U8 -
'U9 - Vibrating Wire Coil + link
'U10 - Vibrating Wire Coil - link
'U11 - Vibrating Wire Thermistor link
'U12 - Vibrating Wire Thermistor link
'C1 - AM16/32B Enable (RES)
'C2 - AM16/32B Stepping (CLK)
'C3 - SDI12 Weather Sensor
'C4 - Not Used
'==============================================
'*********************NOTE*********************
' U5 & U9 are all connected to Com Odd H
' U6 & U10 are all connected to Com Odd L
'U3, U7 & U11 are all connected to Com Even H
'U4, U8 & U12 are all connected to Com Even L
'==============================================

'Multiplexer AM16/32B - 4x16 mode (used 2x32 labels in list for identification only)


'19H - Vibrating Wire 1 Coil + red
'19L - Vibrating Wire 1 Coil - black
'20H - Vibrating Wire 1 Thermistor green
'20L - Vibrating Wire 1 Thermistor white
'21H - Vibrating Wire 2 Coil +
'21L - Vibrating Wire 2 Coil -
'22H - Vibrating Wire 2 Thermistor
'22L - Vibrating Wire 2 Thermistor
'23H - Vibrating Wire 3 Coil +
'23L - Vibrating Wire 3 Coil -
'24H - Vibrating Wire 3 Thermistor
'24L - Vibrating Wire 3 Thermistor
'25H -
==

'################# Variables #################

'Declare Public Variables
Public PTemp,
Public Batt_volt(2)

'Vibrating Wire
Public VW1_Eng_Units
Public VW2_Eng_Units
Public VW3_Eng_Units
Public VW1_Sensor_Change
Public VW2_Sensor_Change
Public VW3_Sensor_Change
Public VW(3,6)
Public VW1_Set_Zero As Boolean
Public VW2_Set_Zero As Boolean
Public VW3_Set_Zero As Boolean
Public VW1_Digits
Public VW2_Digits
Public VW3_Digits

'Dimmed Variables
'VW1
Dim VW1_C
Dim VW1_Install__Eng_Units
Dim VW1_Install_Temp
Dim VW1_Temp_Corr
Dim VW1_K
'VW2
Dim VW2_C
Dim VW2_Install__Eng_Units
Dim VW2_Install_Temp
Dim VW2_Temp_Corr
Dim VW2_K
'VW3
Dim VW3_C
Dim VW3_Install__Eng_Units
Dim VW3_Install_Temp
Dim VW3_Temp_Corr
Dim VW3_K

'Declare Private Variables
Dim i

Alias VW(1,1) = VW1_Freq
Alias VW(1,2) = VW1_Amp
Alias VW(1,3) = VW1_SN_Ratio
Alias VW(1,4) = VW1_Noise_Freq
Alias VW(1,5) = VW1_Decay_Ratio
Alias VW(1,6) = VW1_Temp

Alias VW(2,1) = VW2_Freq
Alias VW(2,2) = VW2_Amp
Alias VW(2,3) = VW2_SN_Ratio
Alias VW(2,4) = VW2_Noise_Freq
Alias VW(2,5) = VW2_Decay_Ratio
Alias VW(2,6) = VW2_Temp

Alias VW(3,1) = VW3_Freq
Alias VW(3,2) = VW3_Amp
Alias VW(3,3) = VW3_SN_Ratio
Alias VW(3,4) = VW3_Noise_Freq
Alias VW(3,5) = VW3_Decay_Ratio
Alias VW(3,6) = VW3_Temp

'################# Constants ################# - set these as per the sensor cal cert or manual
'generic VW
Const T_A = 1.4051e-3
Const T_B = 2.369e-4
Const T_C = 1.019e-7
Const K_M = 0.000376
Const K_B = 0.328
'VW1 (SN:2129518)
Const VW1_A = 1.7854e-6
Const VW1_B = 0.6242
Const VW1_G = 0.6400
'VW2 (SN:2129519)
Const VW2_A = 2.6922e-7
Const VW2_B = 0.6104
Const VW2_G = 0.6128
'VW3 _test
Const VW3_A = 2.6922e-7
Const VW3_B = 0.6104
Const VW3_G = 0.6128


'################# Data Tables #################

DataTable(Table1,True,-1) 'Set table size to # of records, or -1 to autoallocate.
DataInterval (0,10,Min,10)
'VW1
Sample (1,VW1_Eng_Units,IEEE4)
Sample (1,VW1_Temp,IEEE4)
Sample (1,VW1_Sensor_Change,IEEE4)
'VW2
Sample (1,VW2_Eng_Units,IEEE4)
Sample (1,VW2_Temp,IEEE4)
Sample (1,VW2_Sensor_Change,IEEE4)
'VW3
Sample (1,VW3_Eng_Units,IEEE4)
Sample (1,VW3_Temp,IEEE4)
Sample (1,VW3_Sensor_Change,IEEE4)

'system
Minimum (1,Batt_volt,FP2,False,False)
Sample (1,PTemp,FP2)

EndTable

'################# Main Program #################

BeginProg
Scan (60,Sec,0,0)

'System
PanelTemp (PTemp,50)
Battery (Batt_volt)

'Measurements
'### mux ###
PortSet (C1,1) 'Enable Mux

'step though 1-9
' For i = 1 to 9
' PulsePort (C2,35000) 'Step through Mux inputs
'Delay (0,35,mSec) 'Delay to provide a gap between pulses
'Next i

'MEASURE VIBRATING WIRES
'Vibrating Wire Sensors (the VibratingWire instrucion does not like indexing of the co-efficients for some reason)
For i = 1 To 3
PulsePort (C2,35000) 'Step through Mux inputs
If i = 1 Then VibratingWire (VW(i,1),1,U9,450 ,6000 ,1,0.01,"Diag1",50,T_A,T_B,T_C)
If i = 2 Then VibratingWire (VW(i,1),1,U9,450 ,6000 ,1,0.01,"Diag2",50,T_A,T_B,T_C)
If i = 3 Then VibratingWire (VW(i,1),1,U9,450 ,6000 ,1,0.01,"Diag3",50,T_A,T_B,T_C)
Next i

PortSet (C1,0) ' Disble & Reset Mux

'VW1 Convert Freq to Digits
VW1_Digits = (VW1_Freq^2) / 1000
VW2_Digits = (VW2_Freq^2) / 1000
VW3_Digits = (VW3_Freq^2) / 1000
'VW1 Calculate Engineering Units
VW1_Eng_Units = (VW1_Digits^2) * VW1_A + VW1_Digits * VW1_B + VW1_C
VW2_Eng_Units = (VW2_Digits^2) * VW2_A + VW2_Digits * VW2_B + VW2_C
VW3_Eng_Units = (VW2_Digits^2) * VW3_A + VW3_Digits * VW3_B + VW3_C

'VW1 Calculate & Apply Temperature Compensation
'VW1
VW1_K = ((VW1_Digits * K_M) - K_B) * VW1_G
VW1_Temp_Corr = (VW1_Temp - VW1_Install_Temp) * VW1_K
VW1_Eng_Units = VW1_Eng_Units + VW1_Temp_Corr
'vw2
VW2_K = ((VW2_Digits * K_M) - K_B) * VW2_G
VW2_Temp_Corr = (VW2_Temp - VW2_Install_Temp) * VW2_K
VW2_Eng_Units = VW2_Eng_Units + VW2_Temp_Corr
'VW3
VW3_K = ((VW3_Digits * K_M) - K_B) * VW2_G
VW3_Temp_Corr = (VW3_Temp - VW3_Install_Temp) * VW3_K
VW3_Eng_Units = VW3_Eng_Units + VW3_Temp_Corr
'Calculate Movement
VW1_Sensor_Change = VW1_Eng_Units - VW1_Install__Eng_Units
VW2_Sensor_Change = VW2_Eng_Units - VW2_Install__Eng_Units
VW3_Sensor_Change = VW3_Eng_Units - VW3_Install__Eng_Units

'vw zeros
'VW1 Set Zero (installation) Point
If VW1_Set_Zero = True Then
VW1_C = ((VW1_Digits^2) * VW1_A + VW1_Digits * VW1_B) * -1
VW1_Install_Temp = VW1_Temp
VW1_Install__Eng_Units = VW1_Eng_Units
VW1_Set_Zero = False
EndIf
'VW2 Set Zero (installation) Point
If VW2_Set_Zero = True Then
VW2_C = ((VW2_Digits^2) * VW2_A + VW2_Digits * VW2_B) * -1
VW2_Install_Temp = VW2_Temp
VW2_Install__Eng_Units = VW2_Eng_Units
VW2_Set_Zero = False
EndIf
'VW3 Set Zero (installation) Point
If VW3_Set_Zero = True Then
VW3_C = ((VW3_Digits^2) * VW3_A + VW3_Digits * VW3_B) * -1
VW3_Install_Temp = VW3_Temp
VW3_Install__Eng_Units = VW3_Eng_Units
VW3_Set_Zero = False
EndIf

'Call Output Tables
CallTable Table1
NextScan


EndProg

Log in or register to post/reply in the forum.