12.07.2015 Views

Using Hart in Excel - Borst Automation

Using Hart in Excel - Borst Automation

Using Hart in Excel - Borst Automation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Hart</strong> Driver DLL V 7.4, <strong>Us<strong>in</strong>g</strong> <strong>Hart</strong> with <strong>Excel</strong>, Walter <strong>Borst</strong>Example Description1 Gett<strong>in</strong>g StartedDouble click the file <strong>Us<strong>in</strong>g</strong><strong>Hart</strong>DLL.xlsm.<strong>Excel</strong> opens and appears with a button onone of the sheets. Press the button and theVisual Basic Editor will appear because theprogram was stopped at a breakpo<strong>in</strong>t.If strConnection.byError = SRV_SUCCESSFUL Then'Read Tag Descriptor DatehSrv = BHDrv_DoCommand(hDrv, _13, _DRV_WAIT, _byReqData(0), _0, _0, _ByVal strConnection.sUniqueId)BHDrv_FetchConfirmation hSrv, strConfirmationStopElseStopEnd IfThe program stops at this po<strong>in</strong>t because a connection to a device could not be established. If youconnect a real or a simulated device to the com port which was opened by'Open Com from Cell E2'Configuration will be defaultiComPort = Range("E2")Drv = BHDrv_OpenChannel(2)the software will reach the other Stop statement provid<strong>in</strong>g the Tag Name of the connected device.2 ModulesDLL.While the module <strong>Hart</strong>Test is conta<strong>in</strong><strong>in</strong>g the little test program the module<strong>Hart</strong>Interface conta<strong>in</strong>s the necessary structures and functions declarations.The follow<strong>in</strong>g is an example of the declaration of one of the functions <strong>in</strong> thePublic Declare Sub BHDrv_FetchConfirmation Lib "Ba<strong>Hart</strong>Drv74.dll" _(ByVal hService As Long, _strConfData As Any _)Version 7.4.0, Feb, 2nd, 2014© 1998-2014, <strong>Borst</strong> <strong>Automation</strong>, Walter <strong>Borst</strong>, Cuxhaven, DE Page 1 of 2


<strong>Hart</strong> Driver DLL V 7.4, <strong>Us<strong>in</strong>g</strong> <strong>Hart</strong> with <strong>Excel</strong>, Walter <strong>Borst</strong>Example DescriptionThe declaration of structures has to be done like the follow<strong>in</strong>g.Type T_strConfirmationbyCmd As Byte 'The <strong>Hart</strong> command which was servicedbyResp1 As Byte 'Command response codebyResp2 As Byte 'Device statusbyError As Byte 'Last errorbyUsedRetries As Byte 'Number of retries used for the servicebDeviceInBurstMode As Byte'Indicates if device is burst<strong>in</strong>giDuration As Integer 'Duration for the service <strong>in</strong> mslAppKey As Long 'A key provided by and returned to the'applicationusExtCmd As Integer 'Extended (16 Bit) commandbyReserved1 As BytebyDataLen As Byte 'Length of productive datasDataAs Str<strong>in</strong>g * 255 'Productive data <strong>in</strong> the responseEnd Type3 Contact<strong>Borst</strong> <strong>Automation</strong>Neue Reihe 33DE-27472 CuxhavenGERMANYVoice: +49 (0)4721 6985-100Fax: +49 (0)4721 6985-102Email: <strong>in</strong>fo@borst-automation.deHome: http://borst-automation.comVersion 7.4.0, Feb, 2nd, 2014© 1998-2014, <strong>Borst</strong> <strong>Automation</strong>, Walter <strong>Borst</strong>, Cuxhaven, DE Page 2 of 2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!