Announcement

Collapse
No announcement yet.

Analog Input Values

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Analog Input Values

    I'm hoping you will put out a version that can read the analog input values. I have temperature sensors on my Secu16 and read them with a script. I had this working since last year in a modified version of the open source by exposing GetAnalogInput. I believe I had to modify something from Int16 to Int32 to prevent errors in the plugin.

    I purchased a license since you had done so much work on the plugin. I had figured out the poll thread processor usage issue, gBusy not declared, the send_IR and the analog inputs, but you already had the PED issue worked out and did a lot more with the plugin.

    I use a script like this which worked fine.
    sub main
    dim v
    v = hs.PluginFunction("Applied Digital Ocelot", "", "GetAnalogInput", array(2,0))
    if v>10 and v<250 then hs.setdevicevalue "T1",round(100*v/256,1)
    End sub

    The plugin code I'm sure you have looks like this.
    Public Function GetAnalogInput(ByRef unit As Short, ByRef point As Short) As Short
    'Dim snd(7) As Byte
    Dim i As Short
    Dim rcv(6) As Byte
    Dim buf(256) As Byte
    On Error Resume Next
    If Not gIOEnabled Then Exit Function
    gbusy = 1
    SendToCPUXA(FrameGenerator.InitiateGetUnitParameters(point + 10))
    WaitForChar(gTimeOut, 3, 0)
    Wait(1)
    gbusy = 1
    SendToCPUXA(FrameGenerator.GetUnitParameters)
    If (WaitForChar(gTimeOut, 6 + 256 + 2, 42)) Then
    For i = 0 To 5
    rcv(i) = rbuffer(i)
    Next
    For i = 0 To 255
    buf(i) = rbuffer(i + 6)
    Next
    Status = ERR_NONE
    Else
    If gLogErrors Then
    hs.WriteLog(IFACE_OTHER, "Warning, Ocelot Plug-in, Timeout getting analog I/O")
    End If
    Status = ERR_SEND
    End If
    gbusy = 0
    GetAnalogInput = buf((unit - 1) * 2)
    End Function

    #2
    Nevermind - Found the solution

    I found the method. it works as well as it did before.

    Public Sub ReadInput(ByVal Parms As Object)
    Dim v As Int32
    Dim plugin = New HomeSeerAPI.PluginAccess(hs, "GTS CPUXA", "")
    Dim Parm(1) As Object
    Dim Unit As Byte = 2 ' Unit 2
    Dim pnum As Byte = 11 'Point 1 (+ 10)
    Parm(0) = Unit
    Parm(1) = pnum
    v = CInt(plugin.PluginFunction("GetParameter", Parm))
    If v > 10 And v < 250 Then
    hs.SetDeviceValue("T1", Math.Round(100 * v / 256, 1))
    hs.WriteLog("Ocelot", Math.Round(100 * v / 256, 1) & " Degrees")
    hs.WriteLog("Ocelot", Math.Round(v / 51, 2) & " Volts on input")
    End If
    End Sub

    Comment


      #3
      Hello twinch,
      Since response times can be long getting unit parameters via RS232, normally I write a CMax program to write analog values to variables. Then monitor the variables with the plugin. Same data, but a more reliable way to get it.

      I have Ocelots out in the field set up this way monitoring many different analog signals.

      Bruce

      Comment


        #4
        Using a variable works much better!
        Thank you.

        Comment

        Working...
        X