====== TADIn() ======
''variable = TADIn(Channel)''
| //variable// |Variable to store results. (No String or Single) |
| //channel// |AD channel number (0 to 15. This is the channel number, not the port number) |
This command is similar to [[:cubloc:adin:index|ADIn]], but returns the average of 10 values read
with [[:cubloc:adin:index|ADIn]]. When working under noisy environments, using
''TADIn'' could help in obtaining more precise results.
''TADIn'' is a pre-made function:
Function TADIn(num As Byte) As Integer
Dim ii As Integer, ta As Long
ta = 0
For ii = 0 To 9
ta = ta + ADIn(num)
Next
TADIn = ta / 10
End Function
The ''TADIn'' function cannot be used for the CB405RT's high resolution AD channels (See [[cubloc:hadin:index|HADIn]] and [[cubloc:hadin2:index|HADIn2]]), but the following implementation can be used as a substitute.
Function HTADIn(num As Byte) As Integer
Dim ii As Integer, ta As Long
ta = 0
For ii = 0 To 9
ta = ta + HADIn(num)
Next
HTADIn = ta / 10
End Function
[[cubloc:index#system_library:|Go CUBLOC home]]