usb-relais-8 / optoin-8 - deditechardware description |seite 18 2.3.4. pin assignment 2.3.4.1. pin...
TRANSCRIPT
Hardware-Description
Oktober
USB-RELAIS-8 / OPTOIN-8
2020
INDEX
Index | 2Seite
1. Introduction 7
1.1. General remarks 7
1.2. Customer satisfaction 7
1.3. Customer response 7
2. Hardware description 9
2.1. Quick installation 9
92.1.1. Step 1 - Installation of the software and driver 92.1.2. Step 2 - Connecting of the module 92.1.3. Step 3 - Testing the connection and the module
2.2. USB-RELAIS-8 10
102.2.1. Technical data 112.2.2. Product pictures 122.2.3. Overview screen 132.2.4. Pin assignment 132.2.4.1. Pin assignment J1
132.2.4.2. Pin assignment J2
142.2.5. Outputs 142.2.5.1. Relay outputs
142.2.5.2. Timeout protection
14
2.2.5.3. Visual control of the outputs (depends ofmodule)
2.3. USB-OPTOIN-8 15
152.3.1. Technical data 162.3.2. Product pictures 172.3.3. Overview screen 182.3.4. Pin assignment 182.3.4.1. Pin assignment J1
182.3.4.2. Pin assignment J2
192.3.5. Inputs 192.3.5.1. Registering short input pulses
192.3.5.2. Galvanically decouppled through optocouplers
192.3.5.3. Visual control of the inputs (depends of module)
INDEX
Index | 3Seite
3. Firmware update 22
3.1. DEDITEC Flasher 22
4. Software 26
4.1. Using our products 26
264.1.1. Access via graphical applications 264.1.2. Access via the DELIB driver library 264.1.3. Access via protocol 274.1.4. Access via provided test programs
4.2. DELIB driver library 28
284.2.1. Overview 284.2.1.1. Program under diverse operating systems
294.2.1.2. Program with diverse programming languages
294.2.1.3. Program independent of the interface
294.2.1.4. SDK-Kit for Programmer
304.2.2. Supported operating systems 304.2.3. Supported programming languages 314.2.4. Installation DELIB driver library 354.2.5. DELIB Configuration Utility
4.3. Integration of the DELIB 36
364.3.1. Integration of the delib.h in Visual-C/C++ 394.3.2. Integration of the delib.cs in Visual-C# 404.3.3. Integration of the delib.cs in Visual-C# unter Windows 64bit 444.3.4. Integration of the delib.pas in Delphi 454.3.5. Integration of the delib.bas in Visual Basic 464.3.6. Integration of the delib.vb in VB.NET 474.3.7. Integration of the delib.bas in MS-Office (VBA) 494.3.8. Integration of the delib.dll in LabVIEW 494.3.8.1. Integration of the delib.dll in LabVIEW
584.3.8.2. Usage of the VIs in LabVIEW
4.4. Test programs 60
604.4.1. Digital Input-Output Demo
4.5. DELIB CLI (command-line interface) 61
634.5.1. Customisation for USB-Modules (only Linux)
INDEX
Index | 4Seite
644.5.2. Customisation for RO-ETH-Modules (only Linux) 654.5.3. DELIB CLI samples
5. DELIB API reference 70
5.1. Management functions 70
705.1.1. DapiOpenModule 715.1.2. DapiCloseModule 725.1.3. DapiGetDELIBVersion 735.1.4. DapiSpecialCMDGetModuleConfig 755.1.5. DapiOpenModuleEx
5.2. Error handling 76
765.2.1. DapiGetLastError 775.2.2. DapiGetLastErrorText
5.3. Reading Digital inputs 78
785.3.1. DapiDIGet1 795.3.2. DapiDIGet8 805.3.3. DapiDIGet16 815.3.4. DapiDIGet32 825.3.5. DapiDIGet64 835.3.6. DapiDIGetFF32 845.3.7. DapiDIGetCounter 855.3.8. DapiSpecialCounterLatchAll 865.3.9. DapiSpecialCounterLatchAllWithReset 875.3.10. Dapi_Special_DI_FF_Filter_Value_Get 885.3.11. Dapi_Special_DI_FF_Filter_Value_Set
5.4. Setting Digital outputs 89
895.4.1. DapiDOSet1_WithTimer 905.4.2. DapiDOSet1 915.4.3. DapiDOSet8 925.4.4. DapiDOSet16 935.4.5. DapiDOSet32 945.4.6. DapiDOSet64 955.4.7. DapiDOReadback32 965.4.8. DapiDOReadback64
5.5. Example program 97
INDEX
Index | 5Seite
6. Appendix 100
6.1. Revisions 100
6.2. Copyrights and trademarks 101
I
Introduction |Seite 6
Introduction
Introduction |Seite 7
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 of development.Therefor we can offer you high quality products at a competitive price.
Availability
Because of the modular design of our products, we have to redesign only a moduleinstead of the whole product, in case a specific component is no longer available.
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, pleasecontact 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. Therefor weare thankful for comments and suggestions.
II
Hardware description |Seite 8
Hardware description
Hardware description |Seite 9
2. Hardware description
2.1. Quick installation
2.1.1. Step 1 - Installation of the software and driver
Now install the driver DELIB library with the file "delib_install.exe" from the suppliedDEDITEC-Driver CD.
These can be found in the "\zip\DELIB\delib_install.exe" on the DEDITEC-DriverCD.
Note: On our website www.deditec.de you can always find the latest DELIB driverversion.
2.1.2. Step 2 - Connecting of the module
Connect your PC via USB cable to the USB connector of the module.
After about 20 seconds, the module is detected by the driver and can now betested and operated.
2.1.3. Step 3 - Testing the connection and the module
In the Start menu, see "Start -> All Programs -> DEDITEC -> DELIB -> SamplePrograms" you will find some example programs to test your module.
Hardware description |Seite 10
2.2. USB-RELAIS-8
2.2.1. Technical data
Interface USB 2.0 / USB 1.1
Power Supply +5V (power supply occurs over USB bus) 8x Relais outputs (36V, 1A, 15W)
max. switching voltage: 36V DC
max. switching current: 1A
max. switching power: 15W
max. transport current: 1,25A
Isolation (coil / contact): 1500V DC
contact resistance: 150mW
switching time: 0,5 ms
fall time: 0,1 ms
Outputs Selectable timeout-protection, if the module is not longer adressedGalvanically isolated using relaysControl-LED LED for 5V power supply Dimensions 77 mm x 67,5 mm x 55 mm (L x W x H) Operating temperature 10°C .. 50°C
Produktspezifische Daten:
Product Connection Activity-LED Case
USB-RELAIS-8 screwable terminal block 1 for each output Yes
USB-RELAIS-8_A screwable - -
USB-RELAIS-8_B screwable terminal block 1 for each output -
Hardware description |Seite 11
2.2.2. Product pictures
USB-RELAIS-8
USB-RELAIS-8_A
USB-RELAIS-8_B
Hardware description |Seite 12
2.2.3. Overview screen
Hardware description |Seite 13
2.2.4. Pin assignment
2.2.4.1. Pin assignment J1
Pin Description
1 Output Channel 1
2 Output Channel 1
3 Output Channel 2
4 Output Channel 2
5 Output Channel 3
6 Output Channel 3
7 Output Channel 4
8 Output Channel 4
2.2.4.2. Pin assignment J2
Pin Description
9 Output Channel 5
10 Output Channel 5
11 Output Channel 6
12 Output Channel 6
13 Output Channel 7
14 Output Channel 7
15 Output Channel 8
16 Output Channel 8
Hardware description |Seite 14
2.2.5. Outputs
2.2.5.1. Relay outputs
The relays are able to switch voltages up to 36V. The max. current is 1A at a max.power of 15W.
Additionally, the relays provide a safe electrical isolation of the module to theconnected equipment.
2.2.5.2. Timeout protection
The timeout-protection gives the possibility to switch-off automatically the outputsto prevent damage. This takes place, if in a predefined time frame anycommunication with the module was possible. Reasons could be cable disruption,PC-crash and so on. This way damage control, surcharge of connected equipmentand risk of accidents can be avoided.
2.2.5.3. Visual control of the outputs (depends of module)
The state of each output is directly signalized by a separate LED. This simplifies todetect and rectify wiring errors, because the signals on the cables are directlyobservable.
Note: Only available for the USB-RELAIS-8 and USB-RELAIS-8_B module
Hardware description |Seite 15
2.3. USB-OPTOIN-8
2.3.1. Technical data
USB-Interface (USB 1.1 / USB 2.0)
Power supply: +5V (supply occurs over USB bus)
8 opto-coupler inputs
24V AC switching voltage (optional 15V, 12V and 5V are available)
16 Bit-Counter for each input
Detection of pulses between two selection cycles
Galvanically isolated using opto-couplers
Variable input voltage range min 5V, max 30V AC (standard: 15-30V)
Logging of impulses between 2 read out cycles
Control-LED LED for 5V power supply Dimensions: 77 x 67,5 x 55 mm (L x W x H)
Operating temperature: 10°C .. 50°C
Produktspezifische Daten:
Product Connection Activity-LED Case
USB-OPTOIN-8 screwable terminal block 1 for each input Yes
USB-OPTOIN-8_A screwable - -
USB-OPTOIN-8_B screwable terminal block 1 for each input -
Hardware description |Seite 16
2.3.2. Product pictures
USB-OPTOIN-8
USB-OPTOIN-8_A
USB-OPTOIN-8_B
Hardware description |Seite 17
2.3.3. Overview screen
Hardware description |Seite 18
2.3.4. Pin assignment
2.3.4.1. Pin assignment J1
Pin Description
1 Input Channel 1 +
2 Input Channel 1 -
3 Input Channel 2 +
4 Input Channel 2 -
5 Input Channel 3 +
6 Input Channel 3 -
7 Input Channel 4 +
8 Input Channel 4 -
2.3.4.2. Pin assignment J2
Pin Description
9 Input Channel 5 +
10 Input Channel 5 -
11 Input Channel 6 +
12 Input Channel 6 -
13 Input Channel 7 +
14 Input Channel 7 -
15 Input Channel 8 +
16 Input Channel 8 -
Hardware description |Seite 19
2.3.5. Inputs
2.3.5.1. Registering short input pulses
Short input pulses between to read-out cycles are registered through an additionallogic and can be separately read-out.
2.3.5.2. Galvanically decouppled through optocouplers
AC input opto-couplers provide a galvanic isolation of the module towards theconnected equipment. They also provide a safe connection to the module forreverse currents and high voltage peaks.
2.3.5.3. Visual control of the inputs (depends of module)
The state of each input is directly signalized by a separate LED. This simplifies todetect and rectify wiring errors, because the signals on the cables are directlyobservable.
Note: Only available for the USB-RELAIS-8 and USB-RELAIS-8_B module
Hardware description |Seite 20
III
Firmware update |Seite 21
Firmware update
Firmware update |Seite 22
3. Firmware update
3.1. DEDITEC Flasher
You can find the latest firmware version for your DEDITEC product always at thedownload section of our homepage.
( -> http://www.deditec.de/en/module/downloads/firmware-updates.html )
Approach after download
Unzip the ZIP archive
Start the program deditec-flasher.exe
The following application will be opened:
You can find a detailed description of the available commands on the followingpage.
Firmware update |Seite 23
1. Select the Interface of the module of the RO-Series
Command (Key) Interface
U USB-Interface
S Serial Interface (RS-232 / RS-485)
C CAN-Interface
E Ethernet-Interface
V USB2-Interface
Note:
1) The current selected interface will be displayed in the last line (Selected Device= USB)
2) Press key Q to flash "non-RO-Series-products" (USB-Mini-Sticks, USB-Logi-500, ..)
3) In order to flash products of the RO-CAN-Series, you have to connect themodule with your PC via the CAN/SER adapter.
2. Additional options
Command (Key) Description
D Flasher runs in DEBUG mode
Therefore, additional information will be displays
P Reads the current firmware of connected DEDITECproducts
3. Select the module which you want to flash (RO-Series only)
Command (Key) Description
M Flash the RO-Interface module
A Flash all AD16, AD16-DA4, DA4 or AD16_ISO submodules
B Flash all DA2_ISO sub modules
G Flash all STEPPER2 sub modules
H Flash all O8-R8 or M16 sub modules
I Flash all PT100 sub modules
J Flash all CNT8 or CNT/IGR sub modules
Z Scan the module for available sub modules
Firmware update |Seite 24
After successful update procedure, the message FLASH-OK! appears.
IV
Software |Seite 25
Software
Software |Seite 26
4. Software
4.1. Using our products
4.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!
4.1.2. Access via the DELIB driver library
In the appendix, you can find the complete function reference for the integration ofour API-functions in your software. In addition we provide examples for thefollowing programming languages:
C
C++
C#
Delphi
VisualBasic
VB.NET
MS-Office
4.1.3. Access via protocol
The protocol for the activation of our products is open source. So you are able touse our products on systems without Windows or Linux.
Software |Seite 27
4.1.4. Access via provided test programs
We provide simple handling test programs for the most important functions of ourproducts. These will be installed automatically by the installation of the DELIBdriver library.
So you can test directly e.g. relays or you can check the voltage of an A/Dconverter.
Software |Seite 28
4.2. DELIB driver library
4.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
4.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 few commands.Whatever which operating system you use. - Therefore the DELIB cares!
Software |Seite 29
4.2.1.2. Program with diverse programming languages
We provide uniform commands to create own applications. This will be solved bythe DELIB driver library.
You choose the programming language!
It can be simply developed applications under C++, C, Visual Basic, Delphi orLabVIEW®.
4.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 !
4.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 30
4.2.2. Supported operating systems
Our products support the following operating systems:
Windows 7
Windows Vista
Windows XP
Windows 2000
Linux
4.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 31
4.2.4. Installation DELIB driver library
Start screen of the DELIB installer
Software |Seite 32
Insert the DEDITEC driver CD into the drive and start „delib_install.exe“. TheDELIB driver library is also available on http://www.deditec.en/delib
Software |Seite 33
Click on „Install“.
Software |Seite 34
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 nextchapter). This is only necessary, if more than one module is present.
Software |Seite 35
4.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 subdivideidentical USB-modules in the system. This is only necessary if more than onemodule is present.
Software |Seite 36
4.3. Integration of the DELIB
4.3.1. Integration of the delib.h in Visual-C/C++
Description of the DELIB integration in Visual-C/C++
The DELIB Installation defines environment variables to facilitate links to theDELIB-include and DELIB-lib directory.
DELIB_LIB = C:\Programs\DEDITEC\DELIB\lib
DELIB_INCLUDE = C:\Programs\DEDITEC\DELIB\include
Start Visual-C/C++ and open via menu "Projekt -> Einstellungen"
Software |Seite 37
DELIB.H entry in the Visual-C/C++ Project configurations
Under the tab "C/C++" choose the "Kategorie" Präprozessor and enter on"Zusätzliche Include Verzeichnisse" "$(DELIB_INCLUDE)".
Software |Seite 38
DELIB.LIB entry in the Visual-C/C++ Project configurations
Under the tab "Linker" extend the existing line in "Zusätzliche IncludeVerzeichnisse" with the ending "$(DELIB_LIB)\delib.lib"
Software |Seite 39
4.3.2. Integration of the delib.cs in Visual-C#
Description of the DELIB integration in Visual-C#
You can find the needed files for Visual-C# in the directory C:\Programme\DEDITEC\DELIB\Include\delib.cs. Start Visual-C# and open viamenu "Projekt -> Vorhandes Element hinzufügen" in the directory C:\Programme\DEDITEC\DELIB\Include\ the file "delib.cs" to import.
Add the following reference in your program:using DeLib;
Software |Seite 40
4.3.3. Integration of the delib.cs in Visual-C# unter Windows 64bit
Program sample for the DELIB driver library under Windows 64 Bit
In the following sections there is a description how to compile the project as "x86"
Show all settings
Open the options via menue "Extras -> Optionen"
Check “Alle Einstellungen anzeigen"
Software |Seite 41
Check under "Projekte und Projektmappen" "Erweiterte Buildkonfigurationenanzeigen".
Software |Seite 42
The Configuration Manager
Open the configuration manager via "Any CPU -> Konfigurations-Manager...".
In the configuration manager select under der column "Plattform" "Any CPU ->Neu...".
Under "Neue Plattform" select "x86".
Software |Seite 43
Start debugging
You can start the debugging as normal via the "Start-Button". Note that the toolbarcombobox for Platform Configuration now lists both "x86" and "AnyCPU" and has"x86" selected
Software |Seite 44
4.3.4. Integration of the delib.pas in Delphi
Description of the "delib.pas" integration in Delphi
You can find the needed files for Delphi in the directory C:\Programme\DEDITEC\DELIB\include\delib.pas.
Start Delphi and open via menu "Projekt -> dem Projekt hinzufügen" the file "delib.pas" to import.
Software |Seite 45
4.3.5. Integration of the delib.bas in Visual Basic
Description of the "delib.bas" integration in Visual Basic
You can find the needed files for VB in the directory C:\Programme\DEDITEC\DELIB\include\delib.bas.
Start Visual Basic and open via menu "Projekt -> Datei hinzufügen..." the file"delibi.bas" to import.
Software |Seite 46
4.3.6. Integration of the delib.vb in VB.NET
Description of the DELIB integration in VB.NET
You can find the needed files for VB.NET in the directory C:\Programme\DEDITEC\DELIB\Include\delib.vb. Start VB.NET and open via menu"Projekt -> Vorhandes Element hinzufügen" in the directory C:\Programme\DEDITEC\DELIB\Include\ the file "delib.vb" to import.
Software |Seite 47
4.3.7. Integration of the delib.bas in MS-Office (VBA)
Description of the "delib.bas" integration in Visual Basic for Applications
You can find the needed files for VBA in the directory C:\Programme\DEDITEC\DELIB\include\delib.bas.
Start Microsoft Excel and open via menu "Extras -> Makro -> Visual Basic Editor".
Software |Seite 48
Creation of UserForm
Create a new UserForm via menu "Einfügen -> UserForm". In the top left-handcorner of the project manager right click on "UserForm -> Datei importieren". Openin the directory C:\Programme\DEDITEC\DELIB\include the file "delib.bas" toimport.
Software |Seite 49
4.3.8. Integration of the delib.dll in LabVIEW
4.3.8.1. Integration of the delib.dll in LabVIEW
The LabVIEW-Sampleprogram "Deditec_Modul_Control.vi" is not a EXE-File andyou need to execute this file the LabVIEW development environment.
Description of the delib.dll integration in LabVIEW Version 11
- You can find the needed files for LabVIEW in the directorys
"C:\Windows\System32\delib.dll" and "C:\Programme\DEDITEC\DELIB\include\ delib.h"
- Start LabVIEW and open the menu "Tools -> Import -> DLL ..."
Software |Seite 50
- Choose the option "create VIs for DLL" and press continue
Software |Seite 51
- In the next window, choose the path to the delib.h and delib.dll and press continue
Software |Seite 52
- Press continue again
- The Header-File will now be analized. Afterwards press continue.
Software |Seite 53
- Follow the instructions and configurate the name and the saving location for theVIs.
Software |Seite 54
- In the new window choose "Easy error correction" in the drop-down menu andpress continue.
Software |Seite 55
- VIs which are working with 64-bit values must be edited. The display must bechanged from "unsigned long" to "unsigned quad".
- The following VIs must be edited:
-> DapiCNT48CounterGet48 (function return)
-> DapiDIGet64 (function return)
-> DapiDOSet64 (data)
-> DapiDOReadBack64 (function return)
Software |Seite 56
- In addition for some VIs you need to change the elementype to "numeric".
- The following VIs must be edited:
-> DapiWriteLongLong (value)
-> DapiReadLongLong (function return)
- Afterwards press continue.
Software |Seite 57
- You recive a summary of the executed steps.
- Press continue
- The VIs will now be created and are ready to use.
Software |Seite 58
4.3.8.2. Usage of the VIs in LabVIEW
Some functions of the DELIB-library are expecting a string as a parameter value.
This example shows how to use such functions in LabVIEW.
We will use the A/D converter function which is used to set the voltage range as anexample.
The definition of this function is:void DapiADSetMode(ULONG handle, ULONG ch, ULONG mode);
The voltage ranges for this function are already defined in the DELIB-library.
Example code in C/C++:DapiADSetMode(handle, 0, ADDA_MODE_UNIPOL_5V);
This code can also be written like this:DapiADSetMode(handle, 0, 1);
In the delib.h file can you read the hexadecimal values to determine the modes.The hex values must be convertet to decimal.
After the installation of the DELIB-library, the delib.h file is located in the followingdirectory: C:\Programs\Deditec\DELIB\Include\delib.h
Software |Seite 59
The function could look like this in LabVIEW:
The channel and mode are passed as unsigned long
Software |Seite 60
4.4. Test programs
4.4.1. Digital Input-Output Demo
Start “Digital Input-Output Demo” as follows:
Start Programme DEDITEC DELIB Digital Input-Output Demo.
Software |Seite 61
4.5. DELIB CLI (command-line interface)
In some programming languages (like PHP), you can't include DLLs, therefore isan extra console command, which you can directly call out of the program (withappropriate parameters). You can find this command after installation of the DELIBdriverlibrary in the directory C:\Programme\DEDITEC\DELIB\Programs\Console.
You can find the DELIB CLI Command for Windows after Installation of the DELIBdriverlibrary in the directory C:\Programme\DEDITEC\DELIB\programs\cli\ .
The DELIB CLI Command for Linux is located in the directory "/deditec-cli/, afterunzipping the ZIP-Archiv "delib-linux-cli".
Definition (Windows)
delib_cli command channel [value | unit ["nounit"] ]
Definition for USB-Module (Linux)
sudo delib-cli-usb command channel [value | unit ["nounit"] ]
Definition for RO-ETH-Module (Linux)
delib-cli-eth command channel [value | unit ["nounit"] ]
Note: The parameters are separated by spaces.
These commands and parameters are not case sensitive.
Parameter
command channel value unit nounit
di1 0, 1, 2, ...
- hex nounitdi8
0, 8, 16, ...di16
di24
do1 0, 1, 2, ... 0/1 (1-bit command)
- -do8
0, 8, 16, ...8-bit value
(Bit 0 for channel 1, Bit1 for channel 2, ...)do16 16-bit value
do24 24-bit value
ai 0, 1, 2, ... - hex, volt, mA nounit
ao 0, 1, 2, ...
integer or hexadecimal number
(starting with 0x).
For an integer a V for Volt, mA formilli Ampere can be attached.
- -
Software |Seite 62
Return-value
Read state of the inputs (in combination with command = di, di8, di16, di32 andai).
Read state of the inputs as hexadecimal (in combination with command = di, di8,di16, di32 and ai and unit "hex")
Voltage of the input (in combination with unit "volt" and command "ai")
Current of the input (in combination with unit "mA" and command "ai")
Software |Seite 63
4.5.1. Customisation for USB-Modules (only Linux)
In order to access the right module under Linux via DELIB CLI, you have to set themodule id at the command "DapiOpenModule". Therefore you can find in thedirectory "/deditec-cli/source" the file "delib_cli_open_module_usb.c" afterunzipping the ZIP archive.
By default, the program "delib-cli-usb" (see source code) tries to open a RO-USBmodule. If the module is not found, it will try to open an USB-Mini-Stick, and so on...
Since this causes unnecessary error-messages, you can simply remark notneeded entries.
#include "../../delib-sources/delib/delib.h"
ULONG handle;
ULONG delib_cli_open_module(){
handle = DapiOpenModule(RO_USB, 0);if(handle==0){
handle = DapiOpenModule(USB_MINI_STICK, 0);}if(handle==0){
handle = DapiOpenModule(USB_RELAIS_8, 0);}if(handle==0){
handle = DapiOpenModule(USB_OPTOIN_8_RELAIS_8, 0);}if(handle==0){
handle = DapiOpenModule(USB_OPTOIN_16_RELAIS_16, 0);}if(handle==0){
handle = DapiOpenModule(USB_OPTOIN_32_RELAIS_32, 0);}
return handle;}
Note:
The project "delib-cli-usb" has to recompiled after each modification. Therefore,you can find in the directory "/deditec-cli/", the shell script "compile_delib_cli_usb.sh", with which you can compile the project under Linux.
Software |Seite 64
4.5.2. Customisation for RO-ETH-Modules (only Linux)
In order to access a RO-ETH module under Linux, you have to set IP address of themodule. Therefore you can find in the directory "/deditec-cli/source" the file"delib_cli_open_module_eth.c" after unzipping the ZIP archive.
You have to modify following entry:
#include "../../delib-sources/delib/delib.h"
extern char global_ip_addr[];ULONG handle;
ULONG delib_cli_open_module(){
sprintf(global_ip_addr, "192.168.1.11"); // Set the IP address of the RO-ETHmodule here
handle = DapiOpenModule(RO_ETH,0);
return handle;}
Note:
The project "delib-cli-eth" has to recompiled after each modification. Therefore,you can find in the directory "/deditec-cli/", the shell script "compile_delib_cli_eth.sh", with which you can compile the project under Linux.
Software |Seite 65
4.5.3. DELIB CLI samples
Digital Outputs
Windowsdelib_cli DO1 17 1-> digital output 18 will be switched on
delib_cli DO1 3 0-> digital output 4 will be switched on
delib_cli DO8 0 255-> digital outputs 1-8 will be switched on
delib_cli DO16 0 0-> digital outputs 1-16 will be switched off
delib_cli DO16 16 65535-> digital outputs 17-32 will be switched on
delib_cli DO32 0 4294967295-> digital outputs 1-32 will be switched on
Linuxsudo delib_cli _usb DO1 17 1-> digital output 18 of an USB-Module will be switched on
delib_cli _eth DO1 3 0-> digital output 18 of a RO-ETH-Module will be switched off
Software |Seite 66
Digitale Inputs
Windowsdelib_cli DI1 3Example of a return value: 1 -> reads the state of digital input 4
delib_cli DI8 0 hexExample of a return value: 0xFF-> reads the state of digital input 4 as hexadecimal
delib_cli DI16 0 hexExample of a return value: 0xFFFF-> reads the state of digital inputs 1-16 as hexadecimal
delib_cli DI32 0 hexExample of a return value: 0xFFFFFFFF-> reads the state of digital inputs 1-32 as hexadecimal
Alternatively you can append the argument "nounit"delib_cli DI8 0 hex nounitExample of a return value: FF-> reads the state of digital inputs 1-8 as hexadecimal
Linuxsudo delib_cli _usb DI1 3Example of a return value: 1-> reads the state of digital input 4 of an USB-Module
delib_cli_eth DI8 0 hexExample of a return value: 0xFF-> reads the state of digital input 1-8 of a RO-ETH-Module as hexadecimal
Software |Seite 67
Analog Outputs
Windowsdelib_cli AO 7 4711->analog output 8 will be set to the decimal value 4711
delib_cli AO 6 0x4711->analog output 7 will be set to the hexadecimal value 0x4711
delib_cli AO 7 3.7V-> the voltage of analog output 8 will be set to 3,7 Volt (the comma "," and the dot "." can be used for decimal separation)
delib_cli AO 7 13.3mA-> the current of analog output 8 will be set to 13,3 mA (the comma "," and the dot "." can be used for decimal separation)
Linuxsudo delib_cli_usb AO 7 4711-> analog output 8 of an USB-Module will be set to the decimal value 4711
delib_cli_eth AO 6 0x4711-> analog output 7 of a RO-ETH-Module will be set to the hexadecimal value 0x4711
Software |Seite 68
Analog Inputs
Windowsdelib_cli AI 2Example of a return value: 1234-> reads the value of analog input 3 as decimal
delib_cli AI 2 hexExample of a return value: 0x1FA-> reads the value of analog input 3 as hexadecimal
delib_cli AI 2 VExample of a return value: 12.500000V-> reads the voltage of analog input 3 as point number
delib_cli AI 2 mAExample of a return value: 20.551600mA-> reads the current of analog input 3 as point number
Alternatively you can append the argument "nounit"
delib_cli AI 3 hex nounitExample of a return value: 1FA-> reads the value of analog input 4 as hexadecimal
delib_cli AI 3 V nounitExample of a return value: 12.500000-> reads the voltage of analog input 4 as point number
delib_cli AI 3 mA nounitExample of a return value: 20.551600-> reads the current of analog input 4 as point number
Linuxsudo delib_cli_usb AI 2Example of a return value: 1234-> reads the value of analog input 3 of an USB-Module as decimal
delib_cli_eth AI 2 hexExample of a return value: 0x1FA-> reads the value of analog input 3 of an RO-ETH-Module as hexadecimal
V
DELIB API reference |Seite 69
DELIB API reference
DELIB API reference |Seite 70
5. DELIB API reference
5.1. Management functions
5.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 all otherfunctions.
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 71
5.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 72
5.1.3. DapiGetDELIBVersion
Description
This function returns the installed DELIB version.
Definition
ULONG DapiGetDELIBVersion(ULONG mode, ULONG par);
Parameters
mode=Mode, with which the version is readout (must be 0).
par=This parameter is not defined (must be 0).
Return value
version=Version number of the installed DELIB version [hex].
Example program
version = DapiGetDELIBVersion(0, 0);//Bei installierter Version 1.32 ist version = 132(hex)
DELIB API reference |Seite 73
5.1.4. DapiSpecialCMDGetModuleConfig
Description
This command returns the hardware equipment (number of in-/output channels) ofthe module.
Definition
ULONG DapiSpecialCommand(ULONG handle,DAPI_SPECIAL_CMD_GET_MODULE_CONFIG, par, 0, 0);
Parameters
handle=This is the handle of an open module.
Get number of digital input channels
par=DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_DI
Get number of digital output channels
par=DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_DO
Get number of digital in-/output channels
par=DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_DX
Get number of analog input channels
par=DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_AD
Get number of analog output channels
par=DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_DA
Get number of stepper channels
par=DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_STEPPER
DELIB API reference |Seite 74
Return value
Get number of digital input channels
return=Number of digital input channels
Get number of digital output channels
return=Number of digital output channels
Get number of digital in-/output channels
return=Number of digital in-/output channels
Get number of analog input channels
return=Number of analog input channels
Get number of analog output channels
return=Number of analog output channels
Get number of stepper channels
return=Number of stepper channels
Example program
ret=DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_GET_MODULE_CONFIG,DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_DI, 0, 0);//Gibt die Anzahl der digitalen Eingangskanäle zurückret=DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_GET_MODULE_CONFIG,DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_DO, 0, 0);//Gibt die Anzahl der digitalen Ausgangskanäle zurückret=DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_GET_MODULE_CONFIG,DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_DX, 0, 0);//Gibt die Anzahl der digitalen Ein-/Ausgangskanäle zurückret=DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_GET_MODULE_CONFIG,DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_AD, 0, 0);//Gibt die Anzahl der analogen Eingangskanäle zurückret=DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_GET_MODULE_CONFIG,DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_DA, 0, 0);//Gibt die Anzahl der analogen Ausgangskanäle zurückret=DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_GET_MODULE_CONFIG,DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_STEPPER, 0, 0);//Gibt die Anzahl der Stepperkanäle zurück
DELIB API reference |Seite 75
5.1.5. DapiOpenModuleEx
Description
This function opens a specific RO-ETH-module.The particularity of this commandis, that parameters like IP-address and portnumber can be specified.
Definition
ULONG DapiOpenModuleEx(ULONG moduleID, ULONG nr, unsigned char*exbuffer);
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
exbuffer=buffer for IP-adresse and port
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 all otherfunctions.
Currently, this command is only supported by our RO-ETH-Series.
Example program
// Open ETH-Module with parameter
DAPI_OPENMODULEEX_STRUCT open_buffer;
strcpy((char*) open_buffer.address, "192.168.1.10");open_buffer.portno = 0;
handle = DapiOpenModuleEx(RO_ETH, 0, (unsigned char*) &open_buffer);printf("Module handle = %x\n", handle);
DELIB API reference |Seite 76
5.2. Error handling
5.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 77
5.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 78
5.3. Reading Digital inputs
5.3.1. DapiDIGet1
Description
This command reads a single digit input.
Definition
ULONG DapiDIGet1(ULONG handle, ULONG ch);
Parameters
handle=This is the handle of an opened module.
ch=Specifies the number of input that is to be read (0 ..).
Return value
State of the input (0 / 1).
DELIB API reference |Seite 79
5.3.2. DapiDIGet8
Description
This command reads 8 digital inputs simultaneously.
Definition
ULONG DapiDIGet8(ULONG handle, ULONG ch);
Parameters
handle=This is the handle of an opened module.
ch=Specifies the number of the input, from which it begins to read from (0, 8, 16,24, 32, ..)
Return value
State of the read inputs.
DELIB API reference |Seite 80
5.3.3. DapiDIGet16
Description
This command reads 16 digital inputs simultaneously.
Definition
ULONG DapiDIGet16(ULONG handle, ULONG ch);
Parameters
handle=This is the handle of an opened module.
ch=Specifies the number of the input, from which it begins to read from (0, 16, 32,..)
Return value
State of the read inputs.
DELIB API reference |Seite 81
5.3.4. DapiDIGet32
Description
This command reads 32 digital inputs simultaneously.
Definition
ULONG DapiDIGet32(ULONG handle, ULONG ch);
Parameters
handle=This is the handle of an opened module.
ch=Specifies the number of the input, from which it begins to read from (0, 32, 64,..)
Return value
State of the read inputs.
Example program
unsigned long data;// ----------------------------------------------------// Einen Wert von den Eingängen lesen (Eingang 1-31)data = (unsigned long) DapiDIGet32(handle, 0);// Chan Start = 0printf("Eingang 0-31 : 0x%x\n", data);printf("Taste für weiter\n");getch();// ----------------------------------------------------// Einen Wert von den Eingängen lesen (Eingang 32-64)data = (unsigned long) DapiDIGet32(handle, 32);// Chan Start = 32printf("Eingang 32-64 : 0x%x\n", data);printf("Taste für weiter\n");getch();
DELIB API reference |Seite 82
5.3.5. DapiDIGet64
Description
This command reads 64 digital inputs simultaneously.
Definition
ULONGLONG DapiDIGet64(ULONG handle, ULONG ch);
Parameters
handle=This is the handle of an opened module.
ch=Specifies the number of the input,from which it begins to read from (0, 64, ..)
Return value
State of the read inputs.
DELIB API reference |Seite 83
5.3.6. DapiDIGetFF32
Description
This command reads the flip-flops from the inputs and resets them. (Input statechange).
Definition
ULONG DapiDIGetFF32(ULONG handle, ULONG ch);
Parameters
handle=This is the handle of an opened module .
ch=Specifies the number of the input, from which it begins to read from (0, 32, ..)
Return value
State of 32 input change states
DELIB API reference |Seite 84
5.3.7. DapiDIGetCounter
Description
This command reads the counter of a digital input
Definition
ULONG DapiDIGetCounter(ULONG handle, ULONG ch, ULONG mode);
Parameters
handle=This is the handle of an opened module.
ch=Specifies the digital input,from which the counter will be read.
mode=0 (Normal counter function)
mode=DAPI_CNT_MODE_READ_WITH_RESET (Reading and resetting thecounter)
mode=DAPI_CNT_MODE_READ_LATCHED (Reading the latched counter)
Return value
Value of the counter.
Example program
value = DapiDIGetCounter(handle, 0 ,0);// Reading counter of DI Chan 0
value = DapiDIGetCounter(handle, 1 ,0);// Reading counter of DI Chan 1
value = DapiDIGetCounter(handle, 8 ,0);// Reading counter of DI Chan 8
value = DapiDIGetCounter(handle, 0 ,DAPI_CNT_MODE_READ_WITH_RESET);// Reading AND resetting counter of DI Chan 0
value = DapiDIGetCounter(handle, 1, DAPI_CNT_MODE_READ_LATCHED);// Reading the latched counter of DI Chan 1
DELIB API reference |Seite 85
5.3.8. DapiSpecialCounterLatchAll
Description
This command saves the counters of all digital inputs simultaneously into atemporary storage (latch).
So, after that, the counter of the latch can be read successively.
Here, the speciality is, that it is possible to "freeze" simultaneously the counter andthe frozen counter (latch) can be read one by one.
Definition
void DapiSpecialCommand(ULONG handle, DAPI_SPECIAL_CMD_COUNTER,DAPI_SPECIAL_COUNTER_LATCH_ALL, 0, 0);
Parameters
None
Example program
DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_COUNTER,DAPI_SPECIAL_COUNTER_LATCH_ALL, 0, 0);
DELIB API reference |Seite 86
5.3.9. DapiSpecialCounterLatchAllWithReset
Description
This command saves the counters of all digital inputs simultaneously into atemporary storage (latch).
In addition, the counters of the digital inputs will be reset.
Definition
void DapiSpecialCommand(ULONG handle, DAPI_SPECIAL_CMD_COUNTER,DAPI_SPECIAL_COUNTER_LATCH_ALL_WITH_RESET, 0, 0);
Parameters
None
Example program
DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_COUNTER,DAPI_SPECIAL_COUNTER_LATCH_ALL_WITH_RESET, 0, 0);
DELIB API reference |Seite 87
5.3.10. Dapi_Special_DI_FF_Filter_Value_Get
Description
This command returns the filter [ms], in which time interval the digital inputs aresampled.
Definition
ULONG DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_DI,DAPI_SPECIAL_DI_FF_FILTER_VALUE_GET, 0, 0);
Parameters
handle=This is the handle of an opened module.
Return value
Time [ms]
Example program
value = DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_DI,DAPI_SPECIAL_DI_FF_FILTER_VALUE_GET, 0, 0);//Gibt das Zeitintervall zum Abtasten der digitalen Eingangskanäle zurück.
DELIB API reference |Seite 88
5.3.11. Dapi_Special_DI_FF_Filter_Value_Set
Description
This command sets a filter [ms], in which time interval the digital inputs aresampled.
Definition
void DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_DI,DAPI_SPECIAL_DI_FF_FILTER_VALUE_SET, ULONG time_ms, 0);
Parameters
handle=This is the handle of an opened module.
time_ms=time interval [ms], in which digital inputs are sampled.
Return value
None
Remarks
This command only supports pulse durations between 5ms and 255ms.
If no time is set, the default value (100ms) will be used.
Example program
DapiSpecialCommand(handle, DAPI_SPECIAL_CMD_DI,DAPI_SPECIAL_DI_FF_FILTER_VALUE_SET, 5, 0);// Setzt das Zeitintervall auf 5msDapiSpecialCommand(handle, DAPI_SPECIAL_CMD_DI,DAPI_SPECIAL_DI_FF_FILTER_VALUE_SET, 150, 0);// Setzt das Zeitintervall auf 150ms
DELIB API reference |Seite 89
5.4. Setting Digital outputs
5.4.1. DapiDOSet1_WithTimer
Description
This function sets a digital output (ch) to a value (data - 0 or 1) for a specified timein msec.
Definition
void DapiDOSet1_WithTimer(ULONG handle, ULONG ch, ULONG data, ULONGtime_ms);
Parameters
handle=This is the handle of an opened module
ch=Specifies the number of the output, from which it begins to write to (0, 32, 64, ..)
data=Specifies the data values, to write to the outputs
time_ms=Specifies the time, in which an output is set [ms]
Return value
None
Remarks
This function is only supported by our RO-O8-R8 module.
This function will lose its validity, if it is overwritten with other values.
If you want to deactivate this function, you will have to overwrite it with time_ms=0.
Example program
DapiDOSet1_WithTimer(handle, 2, 1, 1000);//Setting channel 2 for 1000msec to 1
DELIB API reference |Seite 90
5.4.2. DapiDOSet1
Description
This is the command to set a single output.
Definition
void DapiDOSet1(ULONG handle, ULONG ch, ULONG data);
Parameters
handle=This is the handle of an opened module
ch=Specifies the number of the output to be set to (0 ..)
data=Specifies the data value that is to be written (0 / 1)
Return value
None
DELIB API reference |Seite 91
5.4.3. DapiDOSet8
Description
This command sets 8 digital outputs simultaneously.
Definition
void DapiDOSet8(ULONG handle, ULONG ch, ULONG data);
Parameters
handle=This is the handle of an opened module
ch=Specifies the number of the output, from which it begins to write to (0, 8, 16, 24,32, ..)
data=Specifies the data values, to write to the outputs
Return value
None
DELIB API reference |Seite 92
5.4.4. DapiDOSet16
Description
This command sets 16 digital outputs simultaneously.
Definition
void DapiDOSet16(ULONG handle, ULONG ch, ULONG data);
Parameters
handle=This is the handle of an opened module
ch=Specifies the number of the output, from which it begins to write to (0, 16, 32, ..)
data=Specifies the data values, to write to the outputs
Return value
None
DELIB API reference |Seite 93
5.4.5. DapiDOSet32
Description
This command sets 32 digital outputs simultaneously.
Definition
void DapiDOSet32(ULONG handle, ULONG ch, ULONG data);
Parameters
handle=This is the handle of an opened module
ch=Specifies the number of the output, from which it begins to write to (0, 32, 64, ..)
data=Specifies the data values, to write to the outputs
Return value
None
Example program
// Einen Wert auf die Ausgänge schreibendata = 0x0000ff00; // Ausgänge 9-16 werden auf 1 gesetztDapiDOSet32(handle, 0, data); // Chan Start = 0printf("Schreibe auf Ausgänge Daten=0x%x\n", data);printf("Taste für weiter\n");getch();// ----------------------------------------------------// Einen Wert auf die Ausgänge schreibendata = 0x80000000; // Ausgang 32 wird auf 1 gesetztDapiDOSet32(handle, 0, data); // Chan Start = 0printf("Schreibe auf Ausgänge Daten=0x%x\n", data);printf("Taste für weiter\n");getch();// ----------------------------------------------------// Einen Wert auf die Ausgänge schreibendata = 0x80000000; // Ausgang 64 wird auf 1 gesetztDapiDOSet32(handle, 32, data); // Chan Start = 32printf("Schreibe auf Ausgänge Daten=0x%x\n", data);printf("Taste für weiter\n");getch();
DELIB API reference |Seite 94
5.4.6. DapiDOSet64
Description
This command is to set 64 digital outputs.
Definition
void DapiDOSet64(ULONG handle, ULONG ch, ULONG data);
Parameters
handle=This is the handle of an opened module
ch=Specifies the number of the output, from which it begins to write to (0, 64, ..)
data=Specifies the data values, to write to the outputs
Return value
None
DELIB API reference |Seite 95
5.4.7. DapiDOReadback32
Description
This command reads back the 32 digital outputs.
Definition
ULONG DapiDOReadback32(ULONG handle, ULONG ch);
Parameters
handle=This is the handle of an opened module
ch=Specifies the number of the input, from which it begins to read from (0, 32, ..)
Return value
Status of 32 outputs.
DELIB API reference |Seite 96
5.4.8. DapiDOReadback64
Description
This command reads back the 64 digital outputs.
Definition
ULONGLONG DapiDOReadback64(ULONG handle, ULONG ch);
Parameters
handle=This is the handle of an opened module
ch=Specifies the number of the input, from which it begins to read from (0, 64, ..)
Return value
Status of 64 outputs.
DELIB API reference |Seite 97
5.5. Example program
// ****************************************************************************// ****************************************************************************// ****************************************************************************// ****************************************************************************// ****************************************************************************//// (c) DEDITEC GmbH, 2009//// web: http://www.deditec.de//// mail: [email protected]//////// dtapi_prog_beispiel_input_output.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 data;unsigned long anz;unsigned long i;unsigned long chan;// ----------------------------------------------------// USB-Modul öffnenhandle = DapiOpenModule(USB_Interface8,0);printf("USB_Interface8 handle = %x\n", handle);if (handle==0){// USB Modul wurde nicht gefundenprintf("Modul konnte nicht geöffnet werden\n");printf("TASTE für weiter\n");getch();
DELIB API reference |Seite 98
return;}// Zum Testen - ein Ping senden// ----------------------------------------------------printf("PING\n");anz=10;for(i=0;i!=anz;++i){data=DapiPing(handle, i);if(i==data){// OKprintf(".");}else{// No answerprintf("E");}}printf("\n");
// ----------------------------------------------------// Einen Wert auf die Ausgänge schreibendata = 255;DapiWriteByte(handle, 0, data);printf("Schreibe auf Adresse=0 daten=0x%x\n", data);// ----------------------------------------------------// Einen Wert auf die Ausgänge schreibendata = 255;DapiWriteByte(handle, 1, data);printf("Schreibe auf Adresse=0 daten=0x%x\n", data);// ----------------------------------------------------// Einen Wert auf die Ausgänge schreibendata = 255;DapiWriteByte(handle, 2, data);printf("Schreibe auf Adresse=2 daten=0x%x\n", data);// ----------------------------------------------------// Einen Wert von den Eingängen lesendata = (unsigned long) DapiReadByte(handle, 0);printf("Gelesene Daten = 0x%x\n", data);// ----------------------------------------------------// Einen A/D Wert lesenchan=11; // read chan. 11data = DapiReadWord(handle, 0xff010000 + chan*2);printf("Adress=%x, ret=%x volt=%f\n", chan, data, ((float) data) / 1024*5);//Bei 5 Volt Ref// ----------------------------------------------------// Modul wieder schliessenDapiCloseModule(handle);printf("TASTE für weiter\n");getch();return ;}
VI
Appendix |Seite 99
Appendix
Appendix |Seite 100
6. Appendix
6.1. Revisions
Rev 2.00 First DEDITEC issue
Rev 2.01 Added chapter "Firmware update" and "Integration of theDELIB"
Rev 2.02 Added index
Appendix |Seite 101
6.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.