Jump to content

ADR2200


Recommended Posts

Im trying to write and receive commands from the ADR2200 by ontrak with autoit (serial connection) and move the info from it to a text file and then write to it from a text file... any Ideas?? (Im trying not to buy any large development platforms if i can help it.)

:D

Link to comment
Share on other sites

Im trying to write and receive commands from the ADR2200 by ontrak with autoit (serial connection) and move the info from it to a text file and then write to it from a text file... any Ideas?? (Im trying not to buy any large development platforms if i can help it.)

:D

Can't imagine it takes much of a development platform to drive a simple relay board. Googled up some VBS examples and JAVA code for it in no time. I don't claim to be knowledgable on it myself, but others have made it plain that translation from VBS to AutoIT is not a big deal. Search this forum for more on accessing the COM ports and you are on your way. :D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 17 years later...

I know this question was asked many, many years ago. But after recent frustration in dealing with this box, here is the script I wrote to communicate with the Ontrak ADU200. Just copy AduHid.dll to the same folder and run.

;Tested with ONTRAK ADU200
Global $DisplayMsgBox=''
;global $DisplayMsgBox='1'
Global $dll = DllOpen( "AduHid.DLL" )
Global $iHandle=0

_TestAduDevice()


Func _TestAduDevice()
   $iHandle=_OpenAduDevice(1)
   ConsoleWrite(Number($iHandle)&@CRLF)
   if @error then ConsoleWrite('','','failed open'&@CRLF)

   _WriteAduDevice($iHandle,'SK0',0,500)

sleep(500)
   _WriteAduDevice($iHandle,'RK0',0,500)

   _WriteAduDevice($iHandle,'SPK1011',0,500) ;Binary Output Relay Set 1011
   _WriteAduDevice($iHandle,'RPK',0,500) ; Read Relay Bits
   $ret=(_ReadAduDevice($iHandle,'RPK',0,500))
   ConsoleWrite('Relay Binary Bits Set to: '&($ret)&@CRLF)
sleep(500)
   ;_WriteAduDevice($iHandle,'RC0',0,500) ; Clear Switch 0 Counter
  ; sleep(1000)

   _WriteAduDevice($iHandle,'RPA',0,500) ; Read input Switch Bits
   $ret=(_ReadAduDevice($iHandle,'RPA',0,500))
   ConsoleWrite('Input Switch Bits Set to: '&($ret)&@CRLF)
sleep(500)

   _WriteAduDevice($iHandle,'RE0',0,500) ; Read Switch 0 Count
   $ret=(_ReadAduDevice($iHandle,'RE0',0,500))
   ConsoleWrite(Number($ret)&@CRLF)

   _WriteAduDevice($iHandle,'DB2',0,500) ; Set Debounce to 100ms
   _WriteAduDevice($iHandle,'DB',0,500) ; Read Debounce setting
   $ret=(_ReadAduDevice($iHandle,'DB',0,500))
   ConsoleWrite('Debounce Set to: '&($ret)&@CRLF)

   _WriteAduDevice($iHandle,'WD3',0,500) ; Set Watchdog Timeout to 1min
   _WriteAduDevice($iHandle,'WD',0,500) ; Read Watchdog Timeout setting
   $ret=(_ReadAduDevice($iHandle,'WD',0,500))
   ConsoleWrite('Watchdog Timeout Set to: '&($ret)&@CRLF)
   _WriteAduDevice($iHandle,'WD0',0,500) ; Set Watchdog Timeout OFF

   _CloseAduDevice($iHandle)

   DllClose( $dll )
EndFunc

Func _OpenAduDevice($aduHandle)
    Local $ret
    $ret = DllCall( $dll, 'long','OpenAduDevice','long', 500 )
    if @error then ConsoleWrite('failed open'&@CRLF)
    If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $ret[0])
    return $ret[0]
 EndFunc

Func _CloseAduDevice($aduHandle)
    Local $ret
    $ret = DllCall( $dll, 'long','CloseAduDevice','long', $aduHandle )
    if @error then ConsoleWrite('failed close'&@CRLF)
    If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $ret[0])
    return $ret[0]
 EndFunc

Func _WriteAduDevice($aduHandle,$lpBuffer,$lBytesWritten,$iTimeout)
    Local $ret
   $lNumberOfBytesToWrite=StringLen($lpBuffer)
   $ret = DllCall( $dll, 'long','WriteAduDevice','long', $aduHandle, 'str',$lpBuffer, 'long',$lNumberOfBytesToWrite, 'long', $lBytesWritten, 'long', $iTimeout )
    if @error then ConsoleWrite('failed write'&@CRLF)
    If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $ret[0])
    return $ret[0]
 EndFunc

Func _ReadAduDevice($aduHandle,$sResponse,$iBytesRead,$iTimeout)
    Local $ret
   $ret = DllCall( $dll, 'long','ReadAduDevice','long', $aduHandle, 'str',$sResponse,'str',7, 'long',$iBytesRead, 'long', $iTimeout )
    if @error then ConsoleWrite('failed read'&@CRLF)
    If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $ret[0])
    return $ret[2]
 EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...