20 1 februar

33
Hardware-Description Februar USB-WATCHDOG-STICK 2011

Upload: others

Post on 02-Nov-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Hardware-Description

Februar

USB-WATCHDOG-STICK

2011

INDEX

Index | 2Seite

1. Introduction 5

1.1. General remarks 5

1.2. Customer satisfaction 5

1.3. Customer response 5

2. Hardware description 7

2.1. Overview screen 8

2.2. Technical data 9

2.3. Pin assignment DSUB-9 connector 10

2.4. Control LED 10

3. Software 12

3.1. Using our products 12

123.1.1. Access via graphical applications 123.1.2. Access via the DELIB driver library 123.1.3. Access via protocol 133.1.4. Access via provided test programs

3.2. DELIB driver library 14

143.2.1. Overview 143.2.1.1. Program under diverse operating systems

153.2.1.2. Program with diverse programming languages

153.2.1.3. Program independent of the interface

153.2.1.4. SDK-Kit for Programmer

163.2.2. Supported operating systems 163.2.3. Supported programming languages 173.2.4. Installation DELIB driver library 193.2.5. DELIB Configuration Utility

3.3. Test programs 20

203.3.1. Watchdog Demo

4. DELIB API reference 22

INDEX

Index | 3Seite

4.1. Management functions 22

224.1.1. DapiOpenModule 234.1.2. DapiCloseModule

4.2. Error handling 24

244.2.1. DapiGetLastError 254.2.2. DapiGetLastErrorText

4.3. Watchdog functions 26

264.3.1. DapiWatchdogEnable 274.3.2. DapiWatchdogDisable 284.3.3. DapiWatchdogRetrigger

4.4. Example program 29

5. Appendix 32

5.1. Revisions 32

5.2. Copyrights and trademarks 33

I

Introduction |Seite 4

Introduction

Introduction |Seite 5

1. Introduction

1.1. General remarks

First of all, we would like to congratulate you to the purchase of a high qualityDEDITEC product.

Our products are being developed by our engineers according to qualityrequirements of high standard. Already during design and development we takecare that our products have -besides quality- a long availability and an optimalflexibility.

Modular design

The modular design of our products reduces the time and the cost ofdevelopment. Therefor we can offer you high quality products at a competitiveprice.

Availability

Because of the modular design of our products, we have to redesign only amodule instead of the whole product, in case a specific component is no longeravailable.

1.2. Customer satisfaction

Our philosophy: a content customer will come again. Therefor customersatisfaction is in first place for us.

If by any chance, you are not content with the performance of our product,please contact us by phone or mail immediately.

We take care of the problem.

1.3. Customer response

Our best products are co-developments together with our customers. Thereforwe are thankful for comments and suggestions.

II

Hardware description |Seite 6

Hardware description

Hardware description |Seite 7

2. Hardware description

The electronic, which is taken in an USB stick case, cares for the monitoringwith watchdog functions. The used micro controller is scanned in periodicintervals by the PC via the USB bus.

If a timeout occurs, the watchdog will switch independently both relays with aprocedure, which is specified by the user.

In case of a timeout, the relays, if correspondingly wired, are able to e.g. resetthe PC, an external SMS modem can send warnings or a connected horn canalarm.

The provided test program and a configuration tool facilitate a simple start.

Hardware description |Seite 8

2.1. Overview screen

Hardware description |Seite 9

2.2. Technical data

USB stick output modul with USB 2.0 / USB 1.1 interface

Micro controller monitoring

10ms to 10h timeout time adjustable

Windows Watchdog API

2 Relays for switching procedures

Connection cable (ca 1,8m) with DSUB-9 connector

Dimensions: 84,5 * 21 * 12,5 / 9,5 mm (without cable)

Hardware description |Seite 10

2.3. Pin assignment DSUB-9 connector

Pin Description

3 & 7 Relay 1

2 & 6 Relay 2

1, 4, 5, 8, 9 NC

2.4. Control LED

The LED on the watchdog stick displays following status:

Description LED Flash Sequence

Watchdog Disabled LED permanent on (turns shortly off by PC access )

Watchdog Enabled 1*on + long pause

Watchdog Retrigger 1*on + long pause

Watchdog Timeout 2*short on + long pause

III

Software |Seite 11

Software

Software |Seite 12

3. Software

3.1. Using our products

3.1.1. Access via graphical applications

We provide driverinterfaces e.g. for LabVIEW and ProfiLab. The DELIB driverlibrary is the basis, which can be directly activated by ProfiLAB.

For LabVIEW, we provide a simple driver connection with examples!

3.1.2. Access via the DELIB driver library

In the appendix, you can find the complete function reference for the integrationof our API-functions in your software. In addition we provide examples for thefollowing programming languages:

C

C++

C#

Delphi

VisualBasic

VB.NET

MS-Office

3.1.3. Access via protocol

The protocol for the activation of our products is open source. So you are ableto use our products on systems without Windows or Linux.

Software |Seite 13

3.1.4. Access via provided test programs

We provide simple handling test programs for the most important functions ofour products. These will be installed automatically by the installation of theDELIB driver library.

So you can test directly e.g. relays or you can check the voltage of an A/Dconverter.

Software |Seite 14

3.2. DELIB driver library

3.2.1. Overview

The following figure explains the structure of the DELIB driver library

The DELIB driver library allows an uniform response of DEDITEC hardware withparticular consideration of the following viewpoints:

Independent of operating system

Independent of programming language

Independent of the product

3.2.1.1. Program under diverse operating systems

The DELIB driver library allows an uniform response of our products on diverseoperating systems.

We has made sure, that all of our products can be responded by a fewcommands.Whatever which operating system you use. - Therefore the DELIB cares!

Software |Seite 15

3.2.1.2. Program with diverse programming languages

We provide uniform commands to create own applications. This will be solvedby the DELIB driver library.

You choose the programming language!

It can be simply developed applications under C++, C, Visual Basic, Delphi orLabVIEW®.

3.2.1.3. Program independent of the interface

Write your application independent of the interface !

Program an application for an USB product of us. - Also, it will work with anethernet or RS-232 product of us !

3.2.1.4. SDK-Kit for Programmer

Integrate the DELIB in your application. On demand you receive an installationscript for free, which allows you, to integrate the DELIB installation in yourapplication.

Software |Seite 16

3.2.2. Supported operating systems

Our products support the following operating systems:

Windows 7

Windows Vista

Windows XP

Windows 2000

Linux

3.2.3. Supported programming languages

Our products are responsive via the following programming languages:

C

C++

C#

Delphi

VisualBasic

VB.NET

MS-Office

Software |Seite 17

3.2.4. Installation DELIB driver library

DELIB stands for DEDITEC Library and contains the necessary libraries for themodules in the programming languages C, Delphi and Visual Basic.

Insert the DEDITEC driver CD into the drive and start „delib_install.exe“. The

DELIB driver library is also available on http://www.deditec.en/delib

Click on „Install“.

Software |Seite 18

The drivers will be installed.

The DELIB driver library is now installed. Press „Close“ to finish the installation.

You can configure your module with the „DELIB Configuration Utility“ (see

next chapter). This is only necessary, if more than one module is present.

Software |Seite 19

3.2.5. DELIB Configuration Utility

Start the “DELIB Configuration Utility” as follows:

Start Programs DEDITEC DELIB DELIB Configuration Utility.

The „DELIB Configuration Utility“ is a program to configure and subdivide

identical USB-modules in the system. This is only necessary if more than onemodule is present.

Software |Seite 20

3.3. Test programs

3.3.1. Watchdog Demo

Start "Watchdog Demo" as follows:

Programme -> DEDITEC -> DELIB -> Watchdog Demo

This screenshot shows a test of the watchdog stick. The configuration of themodule is shown on the upper left side.

IV

DELIB API reference |Seite 21

DELIB API reference

DELIB API reference |Seite 22

4. DELIB API reference

4.1. Management functions

4.1.1. DapiOpenModule

Description

This function opens a particular module.

Definition

ULONG DapiOpenModule(ULONG moduleID, ULONG nr);

Parameters

moduleID=Specifies the module, which is to be opened (see delib.h)

nr=Indicates No of module which is to be opened.

nr=0 -> 1. module

nr=1 -> 2. module

Return value

handle=handle to the corresponding module

handle=0 -> Module was not found

Remarks

The handle returned by this function is needed to identify the module for allother functions.

Example program

// USB-Modul öffnenhandle = DapiOpenModule(RO_USB1, 0);printf("handle = %x\n", handle);if (handle==0){// USB Modul wurde nicht gefundenprintf("Modul konnte nicht geöffnet werden\n");return;}

DELIB API reference |Seite 23

4.1.2. DapiCloseModule

Description

This command closes an opened module.

Definition

ULONG DapiCloseModule(ULONG handle);

Parameters

handle=This is the handle of an opened module

Return value

none

Example program

// Close the moduleDapiCloseModule(handle);

DELIB API reference |Seite 24

4.2. Error handling

4.2.1. DapiGetLastError

Description

This function returns the last registered error.

Definition

ULONG DapiGetLastError();

Parameters

None

Return value

Error code

0=no error. (see delib.h)

Example program

ULONG error;error=DapiGetLastError();if(error==0) return FALSE;printf("ERROR = %d", error);

DELIB API reference |Seite 25

4.2.2. DapiGetLastErrorText

Description

This function reads the text of the last registered error.

Definition

extern ULONG __stdcall DapiGetLastErrorText(unsigned char * msg, unsigned longmsg_length);

Parameters

msg = text buffer

msg_length = length of the buffer

Example program

BOOL IsError (){ if (DapiGetLastError () != DAPI_ERR_NONE)

{ unsigned char msg[500];

DapiGetLastErrorText((unsigned char*) msg, sizeof(msg)); printf ("Error Code = %x * Message = %s\n", 0, msg); return TRUE;}

return FALSE;}

DELIB API reference |Seite 26

4.3. Watchdog functions

4.3.1. DapiWatchdogEnable

Description

This function enables the watchdog.

Definition

void DapiWatchdogEnable(ULONG handle);

Parameters

handle=This is the handle of an opened module.

Return values

None

Example program

DapiWatchdogEnable(handle);//Watchdog enabled

DELIB API reference |Seite 27

4.3.2. DapiWatchdogDisable

Description

This function disables the watchdog.

Definition

void DapiWatchdogDisable(ULONG handle);

Parameters

handle=This is the handle of an opened module.

Return values

None

Example program

DapiWatchdogDisable(handle);//Watchdog disabled

DELIB API reference |Seite 28

4.3.3. DapiWatchdogRetrigger

Description

This function retriggers the watchdog timer.

Definition

void DapiWatchdogRetrigger(ULONG handle);

Parameters

handle=This is the handle of an opened module.

Return values

None

Example program

DapiWatchdogDisable(handle);//Watchdog timer retriggered

DELIB API reference |Seite 29

4.4. Example program

// ****************************************************************************

// ****************************************************************************

// ****************************************************************************

// ****************************************************************************

// ****************************************************************************

//

// (c) DEDITEC GmbH, 2011

//

// Samples for USB-WATCHDOG

//

// vc-usb-watchdog-sample.cpp

//

//

// ****************************************************************************

// ****************************************************************************

// ****************************************************************************

// ****************************************************************************

// ****************************************************************************

//

//

// Folgende Bibliotheken beim Linken mit einbinden: delib.lib

// Dies bitte in den Projekteinstellungen (Projekt/Einstellungen/Linker(Objekt-

Bibliothek-Module) .. letzter Eintrag konfigurieren

#include <windows.h>

#include <stdio.h>

#include "conio.h"

#include "delib.h"

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

void main(void)

{

unsigned long handle;

unsigned long wd_status, wd_timeout, wd_counter;

// ----------------------------------------------------

// USB-Modul öffnen

handle = DapiOpenModule(USB_WATCHDOG,0);

printf("handle = %x\n", handle);

if (handle==0)

{

// USB Modul wurde nicht gefunden

printf("Modul konnte nicht geöffnet werden\n");

printf("TASTE für weiter\n");

getch();

return;

DELIB API reference |Seite 30

}

// ----------------------------------------------------

// activate watchdog

DapiWatchdogEnable(handle);

printf("watchdog is activated\n");

printf("Taste für weiter\n");

getch();

// ----------------------------------------------------

// activate watchdog

DapiWatchdogDisable(handle);

printf("watchdog is deactivated\n");

printf("Taste für weiter\n");

getch();

// ----------------------------------------------------

// activate watchdog + retrigger

DapiWatchdogEnable(handle);

DapiWatchdogRetrigger(handle);

printf("watchdog is enabled+retriggered\n");

wd_status=0;

while(!kbhit() && wd_status!=2)

{

wd_status = DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_WATCHDOG,

DAPI_SPECIAL_WATCHDOG_GET_STATUS, 0, 0);

wd_counter = DapiSpecialCommand(handle,

DAPI_SPECIAL_CMD_WATCHDOG, DAPI_SPECIAL_WATCHDOG_GET_WD_COUNTER_MSEC, 0, 0);

wd_timeout = DapiSpecialCommand(handle,

DAPI_SPECIAL_CMD_WATCHDOG, DAPI_SPECIAL_WATCHDOG_GET_TIMEOUT_MSEC, 0, 0);

printf("WD-Status=%d * WD-Timeout=%dms * WD-Counter = %dms\n",

wd_status, wd_timeout, wd_counter);

}

if(wd_status==2)

{

printf("status=2 -> Watchdog TIMEOUT !!!!\n");

}

printf("Taste für weiter\n");

getch();

// ----------------------------------------------------

// Modul wieder schliessen

DapiCloseModule(handle);

printf("TASTE für weiter\n");

getch();

return ;

}

V

Appendix |Seite 31

Appendix

Appendix |Seite 32

5. Appendix

5.1. Revisions

Rev 2.00 First issue

Appendix |Seite 33

5.2. Copyrights and trademarks

Linux is registered trade-mark of Linus Torvalds.

Windows CE is registered trade-mark of Microsoft Corporation.

USB is registered trade-mark of USB Implementers Forum Inc.

LabVIEW is registered trade-mark of National Instruments.

Intel is registered trade-mark of Intel Corporation

AMD is registered trade-mark of Advanced Micro Devices, Inc.