AXIOMTEK IRU152-I, IRU151-I Reference Manual

IRU152-I
Software Development Kit
Reference Manual
ii
Revision History
Version
Revised
Date
Author
Description
1.0
2018/12/05
Young
- 1st release
iii
How to Use This Document
This document is written to provide the information of the SDK and helps users implement their own applications
Chapter 1, “Basic Str uc ture” introduces the fundamental information for applying
the functions in this document.
Chapter 2, Function Descriptionintroduces the detailed information of the
functions provided by the SDK.
Appendix A, Error Code describes the meaning of the error code returned by
the functions.
Appendix B, Function Table shows all IRU152 function.
iv
Table of Contents
Revision History ............................................................................................ ii
How to Use This Document ........................................................................ iii
CHAPTER 1 Introduction ........................................................... 1
1.1 The Basic of the Programming ................................................. 1
1.2 Create a Receiver Data Example .............................................. 3
1.3 The Calibration Flow Chart ....................................................... 5
CHAPTER 2 Function Description ............................................ 7
2.1 Open_Device .............................................................................. 7
2.2 CloseDevice ................................................................................ 8
2.3 GetDevInfoEx .............................................................................. 9
2.4 EnAIReceiver ............................................................................ 10
2.5 DisAIReceiver ................................ ........................................... 11
2.6 ReadAIDataEx ........................................................................... 12
2.7 ReadAIVoltEx ............................................................................ 13
2.8 SetAITrigConfEx ....................................................................... 15
2.9 SetAIChannel ............................................................................ 16
2.10 SetAISampleRate ..................................................................... 17
2.11 SetAInputRange ....................................................................... 18
2.12 FactoryCalibratedRestore ....................................................... 19
2.13 ReadCaliFactors ....................................................................... 20
2.14 GetAISingleValueEx ................................................................. 21
2.15 GetAIinitConfEx ........................................................................ 23
2.16 SetAIinitConf ............................................................................ 24
2.17 AICalibrationEx ........................................................................ 25
2.18 RestoreAIConf .......................................................................... 27
2.19 GetAIDataLength ...................................................................... 28
2.20 GetDITrigConfEx ...................................................................... 29
2.21 ClearDITrigConf ........................................................................ 30
2.22 SetDITrigConf ........................................................................... 31
2.23 GetDILevelEx ............................................................................ 32
2.24 EnDIReceiver ............................................................................ 33
2.25 DisDIReceiver ................................ ........................................... 34
2.26 EnDICounterEx ......................................................................... 35
2.27 DisDICounterEx ........................................................................ 36
2.28 GetDICounterEx ....................................................................... 37
2.29 SetDICounterCompletedCallback ........................................... 38
2.30 SetDIStatusChangedCallback ................................................. 39
2.31 GetDOInitConfEx ...................................................................... 40
v
2.32 ClearDOInitConf ....................................................................... 41
2.33 SetDOInitConf ........................................................................... 42
2.34 SetDOStatus ............................................................................. 43
2.35 GetDOStatus ............................................................................. 44
2.36 EnDOPWM ................................................................................ 45
2.37 DisDOPWM ............................................................................... 46
2.38 GetDOPWMConf ....................................................................... 47
APPENDIX A Error Code .......................................................... 49
vi
This page is intentionally left blank.
IRU152-I Programmer Guidel
Introduction 1
CHAPTER 1
Introduction
This chapter introduces the information of the SDK.
1.1 The Basic of the Programming
To create an application with SDK, please follow the steps below.
Step 1 : Include IRU head file.
When user program a IRU application to call IRU API, user has to include "libiru.h" and "axiomtek_err.h" files.
"libiru.h" files is for API and control IRU device. and "axiomtek_err.h" files. Is error code respectively.
It can help user to analyze what problem is.
#include "libiru.h" #include "axiomtek_err.h"
Step 2 : Create a device
int ret; ret = Open_Device("IRU152");
if(ret != AXIO_OK) printf("Create Device Failure\n");
(Continue)
IRU152-I Programmer Guidel
2 Introduction
Step 3 : Get information from device via API
int i=0; char *pDevInfo; short length; (Continue) int modelidx = 1;
ret = GetDevInfo(modelidx, &pDevInfo, &length);
if(ret == AXIO_OK){
for(i=0;i<length;i++)
printf("%c", toascii( *(pDevInfo +i)));
printf("\n"); } else printf("Get Device info failure\n");
Step 4 : Close a device.
Close_Device();
Step 5 : The application can be closed
IRU152-I Programmer Guidel
Introduction 3
1.2 Create a Receiver Data Example
This example shows how to receive DI data. The sample is for a digital I/O receiver.
#define AXIO_OK 0x00
int channel = 1; int filter = 0 int trig = 2; int stop; int ret;
ret = Open_Device("IRU152"); if(ret != AXIO_OK){ printf("open IRU152 failure \n"); return; }
while(1) {
switch(stop){
case 0: ret = EnDIReceiver(channel, filter, trig); if(ret != AXIO_OK) printf("Enable DI Receiver failure \n"); break; case 1: ret = DisDIReceiver(channel); if(ret != AXIO_OK) printf("Enable DI Receiver failure \n"); break; case 2: printf("Exit \n"); break; }
IRU152-I Programmer Guidel
4 Introduction
if(stop == 2){ break; } } Close_Device();
IRU152-I Programmer Guidel
Introduction 5
1.3 The Calibration Flow Chart
IRU152-I Programmer Guidel
6 Introduction
This page is intentionally left blank.
IRU152-I Programmer Guidel
Function Description 7
CHAPTER 2
Function Description
This chapter describes the detail information of the SDK functions.
2.1 Open_Device
Description
Open the communication channel of I/O module.
Definition
int Open_Device (
char *devName
);
Parameters
*devName [in]: The name of target module. (IRU151/IR152)
Return value
AXIO_OK if successful. Other value represent the error. (See Error Code)
Example
int ret;
ret = Open_Device( IRU152);
if(ret != AXIO_OK)
printf (Open Device failure\n);
IRU152-I Programmer Guidel
8 Function Description
2.2 CloseDevice
Description
Close the communication channel of I/O module.
Definition
int Close_Device ();
Parameters
NULL
Return value
AXIO_OK if successful. Other value represent the error. (See Error Code)
Example
Int ret = 0; ret = Close_Device ();
IRU152-I Programmer Guidel
Function Description 9
2.3 GetDevInfoEx
Description
Get the device information.
Definition
int GetDevInfoEx(
int infoIndex, char *info, int *infoLen
);
Parameters
infoIndex [in]: This information index. 0x00 : Model Name 0x01 : Manufacture 0x02 : Firmware version
*info [out]: The information string. *infoLen [out]: The length of information string.
Return value
AXIO_OK if success, or other value represents the error. (See Error Code)
Example
int ret; int infoLen = 0; char info[128] = “”;
ret = GetDevInfo(0x00, info, &infoLen);
(Continue)
IRU152-I Programmer Guidel
10 Function Description
if (ret == AXIO_OK) { printf(“%s\n”, info); } else {
printf("Get Device info failure\n");
}
2.4 EnAIReceiver
Description
Enable the receiver of the selected AI receiver.
Definition
int EnAIReceiver (void);
Parameters
NULL
Return value
AXIO_OK if success, or other value represents the error. (See Error Code)
Example
int ret;
ret = EnAIReceiver ();
if(ret != AXIO_OK)
printf(Enable AI Receiver failure\n);
IRU152-I Programmer Guidel
Function Description 11
2.5 DisAIReceiver
Description
Disable the receiver of the selected AI channel.
Definition
int DisAIReceiver (void);
Parameters
NULL
Return value
AXIO_OK if success, or other value represents the error. (See Error Code)
Example
int ret;
ret = DisAIReceiver ();
if(ret != AXIO_OK)
printf(Disable AI Receiver failure\n);
Loading...
+ 38 hidden pages