Attribute VB_Name = "Module1"

Public gOut(6) As Variant
Public gClockMultiplier As Variant
Public gQueUpdate As Boolean
'Public gAA As Boolean
Public gReceive As Variant



Public Function gComputeTd(DT As Double) As Double
Dim Td As Double
Td = (DT * Form1.txtClockFrequency * gClockMultiplier) - 1
gComputeTd = Round(Td)
Debug.Print "Td after rounding is "; gComputeTd
End Function

'The returned value, gComputeDT is in units of microhertz
Public Function gComputeDT(Td As Double) As Double
gComputeDT = (Td + 1) / (Form1.txtClockFrequency * gClockMultiplier)
End Function

Public Function gComputeFcommand(Fout As Double)
'Debug.Print txtClockFrequency; gClockMultiplier
gComputeFcommand = (Fout * 28.1474976710656 * 10) / (Form1.txtClockFrequency * gClockMultiplier)
gComputeFcommand = Format(gComputeFcommand, "##0.0###########")
End Function

Public Function gComputeFout(Fcommand As Double)
gComputeFout = (Fcommand * Form1.txtClockFrequency * gClockMultiplier) / (28.1474976710656 * 10)
gComputeFout = Format(gComputeFout, "##0.0###########")
End Function

'Returns clock frequency in hertz
Public Function gGetClockFreq()
gGetClockFreq = Form1.txtClockFrequency * 10 ^ 6
End Function
