Home
PAC SDK Standard API User Manual
Contents
1. int iSlot 1 short iChannel 2 float fValue BOOL iRet pac_GetPWMDuty hPort iSlot iChannel amp fValue uart_Close hPort C IntPtr hPort PACNET UART Open int iSlot 1 short iChannel 2 float fValue 0 bool iRet PACNET PWIM GetPWMDuty hPort iSlot iChannel ref fValue PACNET UART Close hPort Console WriteLine The duty value is fValue ToString Console ReadLine The example displays the following output to the console The duty value is 1 23 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 339 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 3 pac_SetPWMFrequency This function sets the frequency value for a specific channel Syntax C BOOL pac _SetPWMFrequency HANDLE port int slot short chindex unsigned long freq Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify the channel to set the frequency value freq in The frequency value to set to the PWM module PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 340 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the fun
2. PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 215 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 3 int iD TotalCh 8 int iLatchType 0 uint IDI_Latch_Value 0 bool iRet PACNET PAC O ReadDILatch hPort iSlot iDI_TotalCh iLatchType ref IDI_ Latch Value PACNET UART Close hPort Console WriteLine The DI latch value is IDI Latch_Value ToString Console ReadLine The example displays the following output to the console The DI latch value is 255 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 216 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 8 pac _ClearDlILatch This function clears the latch value of the DI module Syntax C BOOL pac_ClearDILatch HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If
3. C IntPtr hPort hPort PACNET UART Open int iSlot 1 short Status 0x01 bool iRet PACNET PWIV SetPWMStart hPort iSlot Status PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 353 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 10 pac_SetPWMSynChannel This function sets the PWM synchronization status for a specific channel Syntax C BOOL pac_SetPWMSynChannel HANDLE port int slot short chindex short enStatus Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify a channel to set the synchronization status config in 0 Disable the PWM synchronization 1 Enable the PWM synchronization PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 354 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 short mode 0 BOOL iRet pac_SetPWMSynChannel hPort iSlot
4. PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 264 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 3 int iValue new int 8 bool iRet PACNET PAC O ReadAIAllHex hPort iSlot iValue PACNET UART Close hPort for int i 0 i lt 8 i Console WriteLine The Al i ToString iValue i ToString Console ReadLine The example displays the following output to the console The Al O 3316 The Al 1 3 H The Al 7 0 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC _REMOTE_IO 0 255 which range is from O0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 265 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 21 pac _ReadCNT This function reads the counter values of the counter frequency modules Syntax C BOOL pac _ReadCNT HANDLE hPort int slot int iChannel DWORD ICounter_Value Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Defa
5. XP 8041 CE6 XP 8741 XP 8141 Atom CE6 XP 8741 Atom WP 88x1 WP 5141 OD XP 8741 CE6 XP 8741 Atom CE6 a o m o eme e a eee r e T Backplane It s RS232 interface used for accessing the I 87K module only COMO Backplane PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 443 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 1 XP 8041 XP 8041 CE6 COM4 T coms RS 232 RS 485 1 RS 232 COM1 COM2 RS 232 RS 232 IR COM3 m RS 485 1 v PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 444 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 2 XP 8341 XP 8741 XP 8341 CE6 XP 8741 CE6 COM4 COM5 RS 232 RS 485 a RS 232 A f J PE COM2 RS 232 n XP 8341 COM1 Slot 1 3 XP 8741 COM1 Slot 1 7 XP 8341 CE6 COM1 Slot 1 3 a i COM3 XP 8741 CE6 COM1 Slot 1 7 RS 485 vo PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 445 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 3 XP 8141 Atom XP 8141 Atom CE6 COM5 RS 232 COM4 RS 232 RS 485 COM2 RS 232 COM1 Slot 1 COM3 RS 485 o PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 446 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mai
6. 2 9 2 9 1 29 2 2 9 3 2 9 4 2 10 Misc API Error Handling API pac_GetBPTimerTimeTick_us pac _SetBPTimer pac SetBPTimerOut pac_SetBPTimerlnterruptPriority pac_KillBPTimer pac_GetLastError pac_SetLastError pac_GetErrorMessage pac_ClearLastError 2 10 1 AnsiString 2 10 2 WideString 2 10 3 pac_AnsiToWideString 2 10 4 pac_WideToAnsiString 2 10 5 pac_DoEvent pac_DoEvents Appendix A System Error Codes Appendix B API Comparison Appendix C What s New in PACSDK C 1 PACSDK dll modifications and updates Ale pac_EnableLED 2 Add I O WDT PowerOn Safe Value API for pure DIO modules 3 Add O accessing API functions for the Multi function modules 4 Add Misc API function for PACSDK 5 Add the reserved memory section for XPAC series 6 Using the new SDK PACSDK in a C program PAC Standard API Manual v1 0 2 Last Revised November 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Page 8 gt lt E mail service icpdas com 372 373 375 377 379 383 385 387 392 397 399 401 403 419 420 421 423 423 424 C 2 PACNET SDK modifications and UPCates ceccccccsceccccccsceccccccsceccccccscececcecces 1 API function classification 2 API functions modification 3 Enumerate the error codes 4 Using the new SDK PACNET in a C or VB net program 5 Show a tooltip for the classes of PACNET dIl C 3 Error code modifi
7. 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 3 Add I O accessing API functions for the Multi function modules The new PACSDK dIl provides the support of I O accessing functions including Write Read DIO AIO Read DI counter and I O WDT Power On and Safe value function for the Multi function DCON modules Refer to Note 2 regarding of the definition of Multi function modules These functions aren t supported for the previous SDK DCON_PC dll and XPACSDK dIl e pac _WriteAO_MF Note 5 e pac _WriteModulePowerOnValueAO_MF e pac _WriteModuleSafeValueAO_MF e pac_WriteDO_MF pac _ReadDIO_MF e pac _ReadDI_MF pac _ReadDO_ MF e pac _ReadDIO_DIBit_MF e pac _ReadDIO_DOBit_MF e pac _ReadDIBit_MF pac _ReadDOBit_MF e pac _ReadDICNT_MF e pac _ClearDICNT MF e pac _ReadModulePowerOnValueDO_MF e pac_WriteModulePowerOnValueDO_MF e pac _ReadModuleSafeValueDO_MF e pac _WriteModuleSafeValueDO_MF PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 421 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Notes 1 The functions pac_WriteDO pac_ReadDIO pac_ReadDI pac_ReadDO pac _ReadDIO_DIBit pac_ReadDIO_DOBit pac_ReadDIBit pac_ReadDOBit pac_ReadDICNT and pac_ClearDICNT which were supported in the previous SDK are used to read and write the DIO channels for pure DIO DCON modules which are defined as modules that only have DI DO
8. 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 1 short sStatus 0 unsigned long ulWDTtime 0 int iOverwrite 0 hPort uart_Open pac_GetModuleWDTConfig hPort iSlot amp sStatus amp ulWDTtime amp iOverwrite uart_Close hPort C f the module is 87k local IntPtr hPort int iSlot 1 short sStatus 0 int ulWDTtime 0 int Overwrite 0 hPort PACNET UART Open PACNET PAC O GetModuleWDTConfig hPort iSlot ref sStatus ref ulWDTtime ref iOverwrite PACNET UART Close hPort Console WriteLine Status sStatus ToString WDTTime ulWDTtime ToString Overwrite iOverwrite ToString Console ReadLine The example displays the following output to the console H Status 1 WDTTime 100 Overwrite 0 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 318 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 319 Copyright 2013 ICP DAS Co Ltd All Rights Reserve
9. Console WriteLine The DO value is do_value ToString Console ReadLine The example displays the following output to the console The DO value is 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 201 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 202 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 5 pac ReadDI pac ReadDI_MF This function reads the DI value of the DI module Syntax C for pac_ReadDI BOOL pac_ReadDI HANDLE hPort int slot int iDl TotalCh DWORD IDI_ Value C for pac _ReadDI_MF BOOL pac ReadDI MF HANDLE hPort int iSlot int iDl TotalCh DWORD IDI_Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 203 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot iSlot in The slot in which module is to receive the command Default is
10. PAC ERR_SRAM_INVALID_ TYPE defined in WinPacSDK h are modified as PAC_ERR_EEP_INVALID_ ADDRESS and PAC_ERR_MEMORY_INVALID_TYPE defined in PACSDK h e Error code PAC_ERR_MEMORY_ BASE 1 PAC_ERR_EEP_ACCESS_RESTRICTION Changed to PAC_ERR_EEP_INVALID_ADDRESS e Error code PAC_ERR_MEMORY_BASE 3 PAC_ERR_SRAM_INVALID_TYPE Changed to PAC_ERR_MEMORY_INVALID_TYPE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 434 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Add Basic PAC_ERR_MODULE_UNEXISTS PAC_ERR_BASE 7 PAC_ERR_INVALID _ SLOT NUMBER PAC_ERR_BASE 8 nterrupt PAC_ERR_INTR_BASE 0x13000 PAC_ERR_INTR_CREATE_EVENT FAILURE PAC_ERR_INTR_ BASE 1 UART PAC_ERR_UART_INTERNAL_BUFFER_OVERFLOW PAC_ERR_UART_BASE 9 0 PAC _ERR_IO DO CANNOT _OVERWRITE PAC_ERR_IO_BASE 10 PAC _ERR_IO AO CANNOT _OVERWRITE PAC_ERR_IO_BASE 11 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 435 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 For XPAC series Modify The error code PAC_ ERR_INTR_CRATE_EVENT_FAILURE defined in XPacSDK h is misspelled and it is corrected in PACSDK h as PAC_ERR_INTR_CREATE_EVENT_FAILURE nterrup e Error code PAC_ERR_INTR_BASE 1 PAC_ERR_INTR_CRATE_EVENT_FAILURE Changed to PAC_ERR_INTR_CREATE_EVENT_FAILURE Basic e PAC_ERR_MODULE_UNEXISTS Original Errorcode P
11. Y Y Y Y Y Y Y Y Y Y Y Y Y y Y Y Y Y Y Y Y Y Y y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y y Y Y Y Y Y Y Y Y Y Y Y lt lt lt lt pac_SetPWMStart pac_GetPWMSynChannel Y pac smewmsat J Y oY eT Y rr rr ysy pac_GetPWMDIOStatus pac sepwmputsecount Y y oy oy y vy y vy vy v fy pac sepwmputsecout Y yY y oy fo oy v vy fy v v fv Y Y Y Y Y Y Y Y Y Y Y Y lt lt lt lt PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 415 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Backplane Functions Functions Models XP 8000 XP 8000 Atom PC pac_setBPTimerTimetik ms Y y or y y _ pac SetBPTimer pac _SetBPTimerOut ra pac _SetBPTimerlInterruptPriority _ pac_KillBPTimer Y PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 416 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Error Handling Functions Functions Models XP 8000 XP 8000 Atom pac_GetLastError pyet or fe fe ye ef y fy fe fy fy pac_SetlastError poy oy y O paccettrrormessage Y Yy ov oy r vy _ paccleartasteror Y OY YP oy fF r doedoe d o de d o Misc Functions Functions Models XP 8000 XP 8000 Atom py Widestring o e e ee pac_AnsiToWidestring i ee eee moonen 0 0 o e ef
12. ac_ReadModulePowerOnValueAO_M g F pac_GetModuleWDTStatus PAC _10 GetModuleWDTStatus reads the host watchdog status of a module pac_GetModuleWDTConfig PAC _10 GetModulewDTConfig reads the host watchdog status of a module pac_SetModuleWDTConfig PAC _10 SetModulewDTConfig enables disables the host watchdog and sets the host watchdog timeout value of a module pac_ResetModuleWDT PAC 10 ResetModuleWDT resets the host watchdog status of a module pac_RefreshModuleWDT PAC _10 RefreshModuleWDT refreshes the watchdog PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 184 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_InitWoduleWDTInterrupt PAC 10 InitModulewDTinterrupt initializes and enables interrupt of a module watchdog pac_GetModuleWDTInterruptStatus PAC 10 GetModuleWDTinterruptStatus reads interrupt status of a module watchdog pac_SetModuleWDTInterruptStatus PAC _10 SetModuleWDTinterruptStatus enables disables interrupt of a module watchdog PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 185 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 1 pac _GetBit The function retrieves the value which is in specific bit Syntax C BOOL pac_GetBit int v int ndx Parameters V Which IO result wants to get bit ndx Specific bit to retrieve Return Value The value of the specific index
13. hPort uart_Open BYTE iSlot 1 int iChannel 2 short mode BOOL iRet pac_GetPWMSynChannel hPort iSlot iChannel amp mode uart_Close hPort C IntPtr hPort PACNET UART Open int iSlot 1 short iChannel 2 short mode 0 bool iRet PACNET PWIM GetPWMSynChannel hPort iSlot iChannel ref mode PACNET UART Close hPort Console WriteLine The return value is mode ToString Console ReadLine The example displays the following output to the console The return value is 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 357 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 12 pac_SyncPWMStart This function starts the PWM synchronization Syntax C BOOL pac _SyncPWMStart HANDLE port int slot short enStatus Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 enStatus in 0 Stops the PWM synchronization 1 Starts the PWM synchronization Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 358 Copyright 2013 ICP DAS Co Ltd All Rights Res
14. in Specifies the index of battery 1 means first battery 2 means second battery 3 means RTC battery For XPAC_Atom series only Return Value 1 means high voltage O means low voltage for XPAC series only Examples C int nBattery int index 1 nBattery pac_GetBatteryLevel index C int nBattery int index 1 nBattery PACNET Sys GetBatteryLevel index Console WriteLine The First battery level is nBattery ToString Console ReadLine The example displays the following output to the console The First battery level is 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 82 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 20 pac_EnableRetrigger This function determines the retrigger status Syntax C void pac EnableRetrigger BYTE iValues Parameters iValues in Specifies the retrigger value 0 255 unit 10 microsecond 0 means disable retrigger function Return Value This function has does not return any value Examples This function has no examples Remarks The retrigger mechanism is used when the below situation occurred If an interrupt is sent but not be serviced the retrigger function will send an interrupt again This operation will continue until the interrupt has been serviced PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 83 Copyright
15. module PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 271 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 0 int iOverflow BOOL iRet pac_ReadCNT_Overflow hPort iSlot iChannel amp iOverflow uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 0 int iOverflow BOOL iRet pac _ReadCNT_ Overflow 0 iSlot iChannel amp iOverflow PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 272 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 0 int iOverflow 0 bool iRet PACNET PAC O ReadCNTOverflow hPort iSlot iChannel ref iOverflow PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 273 Copyright 2013
16. 137 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Values A handle to the open COM port Nonzero indicates success If the function fails the return value is INVALID HANDLE_VALUE INVALID HANDLE_VALUE should be Oxffffffff in C C MFC INVALID HANDLE_VALUE should be 1 in NET To get extended error information call pac_GetLastError To get a generic description of the error call pac_GetErrorMessage The message resource is optional therefore if you call pac_GetErrorMessage it could fail Examples C HANDLE hOpen hOpen uart_ Open COM1 9600 N 8 1 C IntPtr hOpen hOpen PACNET UART Open COM1 9600 N 8 1 if hOpen ToString 1 Console WriteLine Open COM1 success else Console WriteLine Open COM 1 fail Console ReadLine The example displays the following output to the console if open successfully Open COM1 success Otherwise fe Open COM1 fail PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 138 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The uart_Open function does not open the specified COM port if the COM port has been opened Use I 811xW I 814xW series modules The COM port name is COM6 COM7 For example uart_Open COM6 9600 N 8 1 About how to set I 811xW I 814xW series modules Please refer to the manual
17. 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BOOL ret HANDLE hPort char buf 4 sprintf buf abcd hPort uart_Open COM2 9600 N 8 1 ret uart_ Send hPort buf uart_Close hPort C bool ret IntPtr hPort string buf buf abcd hPort PACNET UART Open COM1 9600 N 8 1 ret PACNET UART Send hPort PACNET M SC AnsiString buf PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 146 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The terminate characters is OxOD Refer to uart_SetTerminator function to change This function will call PurgeComm to clear serial COM port output buffer This function sends data with a terminate character OxOD For example Check sum is disabled The buf are five bytes ABCD 0x0 This function will send five bytes ABCD 0xOD PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 147 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 5 uart_RecvExt This function receives a string OxOD A OxOD character is assigned to terminate the string This function is not called when the checksum is enabled by using uart_EnableCheckSum function which includes the terminate character OxOD This function replaces uart_Recv The uart_Recv can cause the buffer overflow
18. 364 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short iChannel 2 long Icnt 1 BOOL iRet pac_SetPWMPulseCount hPort iSlot iChannel Icnt uart_Close hPort C IntPtr hPort hPort PACNET UART Open int iSlot 1 short iChannel 2 short Icnt 1 bool iRet PACNET PWIM SetPWMPulseCount hPort iSlot iChannel Icnt PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 365 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 16 pac_GetPWMPulseCount This function reads the PWM step value from a specific channel Syntax C BOOL pac GetPWMPulseCount HANDLE port int slot short chindex long cnt Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify a channel to read the PWM step value cnt out The PWM steps 0x0001 to OxFFFF When set to more than 1 step the PWM continuous mode will b
19. BOOL pac ReadAl HANDLE hPort int slot int iChannel int iAl_ TotalCh float fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 244 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the Al value from the channel IAl_ TotalCh in The total number of the Al channels of the Al module Value out The pointer to the Al value that is read back from the Al module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 245 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAl_ TotalCh 8 float fValue BOOL iRet pac_ReadAl hPort iSlot ichannel iAl_ TotalCh amp fValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iAL_ TotalCh 8 float fValue BOOL iRet pac_Re
20. C for pac_WriteModulePowerOnValueDO_MF BOOL pac_WriteModulePowerOnValueDO_MF HANDLE hPort int slot int iDO TotalCh unsigned long Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 285 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 IDO_TotalCh in The total number of DO channels of the DO modules Value in A 8 digit hexadecimal value where bit O corresponds to DOO bit 31 corresponds to DO31 etc When the bit is 1 it denotes that the digital output channel is on and O denotes that the digital output channel is off Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 286 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_WriteModulePowerOnValueDO Example 1 f the module is remote HANDLE hPort hPort uart_Open COM1 9600 N 8 1 int total channel 8 DWORD do_value 4 turn on the channel two BOOL ret pac_WriteModulePowerOnValueDO hPort PAC_REMOTE_1IO 1 total channel
21. Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 18 pac _GetBackplanelD This function retrieves the backplane ID of the XPAC Syntax C void pac GetBackplanelD LPSTR backplane version Parameters backplane_version out Retrieves the backplane ID Return Value This function has does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 79 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C char Backplane 32 pac_GetBackplanelD Backplane C string Backplane Backplane PACNET Sys GetBackplanelD Console WriteLine The Backplane ID is Backplane Console ReadLine The example displays the following output to the console The Backplane ID is 1 0 10 0 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 80 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 19 pac_GetBatteryLevel This function retrieves the battery status of the backplane and the RTC battery status of the CPU board This function supports the following series models XPAC Syntax C int pac GetBatteryLevel int nBattery PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 81 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters nBattery
22. IAO_ TotalCh in The total number of the AO channels of the AO module float fValue out The pointer to the AO value that is read back from the AO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 240 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadAO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue BOOL iRet pac _ReadAO hPort iSlot iChannel iAO TotalCh amp fValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue BOOL iRet pac_ReadAO 0 iSlot iChannel iAO_TotalCh amp fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 241 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadAO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue BOOL iRet pac_ReadAO_MF hPort iSlot iChannel iAO_TotalCh amp fValue uart_Close hPort C pac_ReadAO If the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 2 in
23. PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 186 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BYTE bit3 BYTE iSlot 2 int iDI_TotalCh 8 DWORD IDI_ Value HANDLE hPort hPort uart_Open BOOL iRet pac_ReadDI hPort iSlot iDI_ TotalCh amp IDI_ Value bit3 pac_GetBit IDI Value 3 uart_Close hPort C bool bit int index 3 byte iSlot 2 int iDI_ TotalCh 8 uint IDI Value 0 IntPtr hPort hPort PACNET UART Open Open COM1 data format 115200 N 8 1 bool iRet PACNET PAC O ReadDI hPort iSlot iDI_ TotalCh ref IDI_ Value bit PACNET PAC 0 GetBit int IDI_ Value index PACNET UART Close hPort Console ReadLine Remarks The function is used the same as v amp 1 lt lt index PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 187 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 2 pac _WriteDO pac_WriteDO_MF This function writes the DO values to DO modules Syntax C for pac _WriteDO BOOL pac_WriteDO HANDLE hPort int slot int iDO TotalCh DWORD IDO Value C for pac _WriteDO_ MF BOOL pac _WriteDO_MF HANDLE hPort int i AddrSlot int iDO_TotalCh DWORD IDO Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 188 Copyright 2013 ICP DAS Co Ltd All Rights Reser
24. PACNET UART Open COM4 9600 N 8 1 ret PACNET UART BinSend hPort PACNET MISC AnsiString AB 2 ret PACNET UART BinRecv hPort buf 2 PACNET UART Close hPort Console WriteLine PACNET MISC WideString buf Console ReadLine Remarks Note that this function is usually applied to communicate with the other device but not for ICPDAS DCON I 7000 8000 87K series modules PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 166 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 13 uart_BinSendCmd This function sends binary command and receive binary data with the fixed length This function is a combination of uart_BinSend and uart_BinRecv The operation for sending a command is the same as uart_BinSend The operation for receiving a response is the same as uart_BinRecv Syntax C bool uart BinSendCmd HANDLE hPort LPCSTR ByteCmd DWORD in_ Len LPSTR ByteResult DWORD out_ Len PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 167 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in Handle to the opened COM port ByteCmd in A pointer to a command in_Len in The length of the command string ByteResult out A pointer to a buffer that receives the data out Len in The length of the result string Return Value If the function succeeds the return value
25. The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the Al value from the channel IAl_ TotalCh in The total number of the Al channels of the Al module iValue out The pointer to the Al value that is read back from the Al module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 249 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAlL_ TotalCh 8 int iValue BOOL iRet pac_ReadAlHex hPort iSlot iChannel iAl_TotalCh amp iValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iAL_ TotalCh 8 int iValue BOOL iRet pac_ReadAlHex 0 iSlot iChannel iAl_TotalCh amp iValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 250 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART
26. do_value uart_ Close hPort Example 2 f the module is 87k local HANDLE hPort hPort uart_Open int total channel 8 DWORD do value 4 turn onthe channel two BOOL ret pac_WriteModulePowerOnValueDO hPort 1 total channel do_value uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 287 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModulePowerOnValueDO_MF Example 1 f the module is remote HANDLE hPort hPort uart_Open COM1 9600 N 8 1 int total_ channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteModulePowerOnValueDO_MF hPort PAC_REMOTE_IO 1 total_ channel do_value uart_Close hPort Example 2 f the module is 87k local HANDLE hPort hPort uart_Open int total channel 8 DWORD do value 4 turn onthe channel two BOOL ret pac_WriteModulePowerOnValueDO_ MF hPort 1 total channel do_ value uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 288 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModulePowerOnValueDO Example 1 f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total channel 8 uint do value 4 turn on the channel 2 int iRemoteAddr PACNET PAC O PAC REM
27. f the module is 8k local BYTE iSlot 1 int iChannel 0 BOOL iRet pac_ClearCNT 0 iSlot iChannel C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 0 bool iRet PACNET PAC O0 ClearCNT hPort iSlot iChannel PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 270 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 23 pac ReadCNTOverflow This function reads the counter overflow value of the counter frequency modules Syntax C BOOL pac _ReadCNTOverflow HANDLE hPort int slot int iChannel int iOverflow Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that reads the counter overflows value back from the counter frequency module iOverflow out The pointer to the counter overflow that is read back from the counter frequency
28. float fValue BOOL iRet pac_ReadModuleSafeValueAO_MF hPort iSlot iChannel iAO TotalCh amp fValue uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 302 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadModuleSafeValueAO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 0 bool iRet PACNET PAC O ReadModuleSafeValueAO hPort slot iChannel iAO_ TotalCh ref fValue PACNET UART Close hPort Console WriteLine The AO safe value is fValue ToString Console ReadLine The example displays the following output to the console The AO safe value is 5 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 303 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadModuleSafeValueAO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int iChannel 2 int iAO_TotalCh 8 float fValue O bool iRet PACNET PAC O ReadModuleSafeValueAO_MF hPort slot iChannel iAO_ TotalCh ref fValue PACNET UART Close hPort Console WriteLine The AO safe value is fValue ToString Console ReadLine The example displays the following output to the console The AO safe value is 5 Remarks The function can suppo
29. iSlot iDI_ TotalCh iDO_TotalCh iLatchType amp IDI_ Latch Value amp IDO_Latch_ Value un uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iD TotalCh 8 int iDO TotalCh 8 int iLatchType 0 DWORD IDI Latch_ Value DWORD IDO_ Latch Value BOOL iRet pac_ReadDIOLatch 0 iSlot iDI_ TotalCh iDO_ TotalCh iLatchType amp IDI_ Latch Value amp IDO Latch_Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 221 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iD TotalCh 8 int iDO_TotalCh 8 int iLatchType 0 uint IDI Latch Value 0 uint IDO_ Latch Value 0 bool iRet PACNET PAC O ReadDIOLatch hPort iSlot iDI TotalCh iDO _ TotalCh iLatchType ref IDI_Latch_ Value ref IDO Latch Value PACNET UART Close hPort Console WriteLine DI Latch IDI_Latch_ Value ToString DO Latch I1DO_Latch_Value ToString Console ReadLine The example displays the following output to the console f Dl Latch 240 DO Latch 240 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from 0 to 255 PAC Standard API Manual
30. in O Disable the PWM continuous mode pulse count mode 1 Enable the PWM continuous mode If the PWM continuous mode is enabled the step value for PWM will be automatically set to 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 344 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short iChannel 2 long mode 0 BOOL iRet pac_SetPWMMode hPort iSlot iChannel mode uart_Close hPort C IntPtr hPort hPort PACNET UART Open int iSlot 1 short iChannel 2 int mode 0 Disable the PWM continuous mode bool iRet PACNET PWIM SetPWMMode hPort iSlot iChannel mode PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 345 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 6 pac_GetPWMMode This function reads the continuous mode from a specific channel Syntax C BOOL pac _GetPWMMode HANDLE port int slot short chindex long mode Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the c
31. pac Getcurremmiretoy o PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 417 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Appendix C What s New in PACSDK PACSDK is the next version of XPACSDK and WinPACSDK It builds on the features of XPACSDK and WinPACSDK library by providing the following PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 418 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C 1 PACSDK dlIl modifications and updates The new PACSDK dIl provides support for two platforms one being designed for the WinPAC series ARM platforms and the other for the PC and XPAC series x86 platforms However there are a number of modifications and updates that are included in the new PACSDK which are listed below Note Compared to the previous WinPAC XPAC SDK these modification and updates need to be made to the previously implemented WinPAC XPAC programs so that it will work with the new SDK 1 pac_EnableLED The original pac_EnableLED bool bFlag function can be used only for the WinPAC series in the previous SDK and the original pac_EnableLED int pin bool bFlag function can be used only for the XPAC series in the previous SDK Consequently this API function cannot be integrated to the PACSDK dll because of the conflicting parameters As a result the function in PACSDK dll has been cha
32. pac_WriteDO CType 1 IntPtr 1 16 amp Hff End Sub End Class PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 32 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 Using PACNET dll PACNET dll is a net Compact framework SDK and PACNET dIl is not only used for CH program but also used for VB net program gt PACNET dIl the execution file should be put in the same directory of the PACNET dll The latest version of this library is located at CD root Xpac Atom SDK PACSDK Driver DOTNET in the companion CD http ftp icodas com pub cd xpac atom sdk pacsdk driver dotnet Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Tools Test Window Help Project Cth shittt H Web site Shift A lt File Ctr Project From Existing Code eave All Colts hatte Recent Files Recent Projects Exit PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 33 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 2 Select Windows Forms Application and name the project 1 In the Project Type column choose Other Languages gt Visual Basic gt Windows 2 Inthe Template column choose Windows Forms Application 3 Name your project 4 Click OK to create your new project New Project Pe Temp kis NET Framework 3 5 v E E Visual C Visual Studio installed templates Other
33. v1 0 2 Last Revised November 2013 Page 222 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 10 pac _ClearDIOLatch This function clears the latch values of DI and DO channels of the DIO module Syntax C BOOL pac_ClearDIOLatch HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 223 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_ Open BYTE iSlot 1 BOOL iRet pac_ClearDIOLatch hPort iSlot uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 BOOL iRet pac_ClearDIOLatch 0 iSlot C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 bool iRet PACNET PAC 0 ClearDIOLatch hPort iSlot PACNET UART Close hPort Remarks The function can support for Local or Remote When the modu
34. 1 int total_ channel 8 uint do_ value 0 bool ret PACNET PAC O ReadModulePowerOnValueDO_ MF hPort slot total channel ref do_value PACNET UART Close hPort Console WriteLine The DO power on value is do_value ToString Console ReadLine The example displays the following output to the console The DO power on value is 4 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 294 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 295 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 28 pac_WriteModuleSafeValueAO pac_WriteMo duleSafeValueAO_MF This function writes the AO safe value to the AO modules Syntax C BOOL pac_WriteModuleSafeValueAO HANDLE hPort int slot int iChannel int iAO_TotalCh float fValue C BOOL pac WriteModuleSafeValueAO MF HANDLE hPort int iAddrSlot int iChannel int iAO TotalCh float fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 296 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail se
35. 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModuleSafeValueDO Example 1 f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total channel 8 uintdo_value 4 turn onthe channel 2 int iRemoteAddr PACNET PAC O PAC REMOTE 10 1 bool ret PACNET PAC O WriteModuleSafeValueDO hPort iRemoteAddr total channel do_value PACNET UART Close hPort Example 2 f the module is 87k local IntPtr hPort1 hPort1 PACNET UART Open int total channel1 8 uint do value1 4 turn onthe channel 2 bool ret1 PACNET PAC O WriteModuleSafeValueDO hPort1 3 total_ channel do value1 PACNET UART Close hPort1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 278 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModuleSafeValueDO_MF Example 1 f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total channel 8 uint do value 4 turn on the channel 2 int iRemoteAddr PACNET PAC O PAC REMOTE 10 1 bool ret PACNET PAC 10 WriteModuleSafeValueDO_MEF hPort iRemoteAddr total_ channel do_ value PACNET UART Close hPort Example 2 f the module is 87k local IntPtr hPort1 hPort1 PACNET UART Open int total channel1 8 uint do value1 4 turn onthe ch
36. 2013 Page 88 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 2 pac _UnregisterSlotinterrupt This function unregisters slot interrupt service route and disables a hardware interrupt as specified by its interrupt identifier Syntax C BOOL pac UnregisterSlotinterrupt BYTE slot Parameters slot in Specifies the index of slot On the XPAC the index of slot starts from 1 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 89 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int slot 3 if slot is 3 int CALLBACK slot_callback_proc do something pac_InterruptDone slot return false if return true SDK will do pac_InterruptDone automatically else users should do pac_InterruptDone by themselves if needed if interrupt type is level trigger no matter return true or false needn t add pac_InterruptDone and it will work correctly void ClntrDlg OnButton1 pac RegisterSlotinterrupt slot slot callback proc pac_EnableSlotinterrupt slot true enable slot interrupt void ClntrDlg OnButton2 pac_EnableSlotinterrupt slot false disable slot interrupt pac_Unregister
37. 8000 Atom XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx A WP 5xxx only supports the memory type 1 EEPROM not type 0 SRAM Watchdog Functions Functions Models XP 8000 XP 8000 Atom PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 410 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com UART Functions Functions Models XP 8000 XP 8000 Atom PC jvartoren o YT eT Pf ff wnoose o SO OO lt lt lt lt lt ae lt lt lt lt lt lt lt PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 411 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com PAC_1O Functions Functions Models XP 8000 XP 8000 Atom PC pac_GetBit pac_WriteDO pac_WriteDO_MF pac_WriteDOBit pac_ReadDO pac_ReadDO_ MF pac_ReadDI pac_ReadDI_MF pac_ReadDIO pac_ReadDIO_MF pac_ReadDILatch pac_ClearDlLatch pac_ReadDIOLatch pac_ClearDIOLatch pac_ReadDICNT pac_ReadDICNT_MF pac_ClearDICNT pac_ClearDICNT_MF pac_WriteAO pac_WriteAO_MF pac_ReadAO pac_ReadAO_MF pac_ReadAl pac_ReadAlHex pac_ReadAIAIllExt pac_ReadAIAll pac_ReadAlAllHexExt pac_ReadAlAllHex gt O U or 3 5 Q D 2 o gt V D 5 oes lt N Last Revised November 2013 Page 412 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_ReadCNT y r pac
38. API consists of the following APIs and functional categories e System Information e Backplane Access e Interrupt e Memory Access e Watchdog UART Local I O PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 39 Remote I O Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 System Information API The system information functions and messages describe or change the system configuration settings and attributes PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 40 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the system information functions Functions Models XP 8000 XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx XP 8000 Atom lt pac_GetModuleName pac_GetRotarylD pac_GetSerialNumber pac_GetSDKVersion pac_ChangeSlot pac_CheckSDKVersion pac_ModuleExists pac_GetOSVersion Pac_GetCPUVersion Pac_EnableLEDs pac_GetModuleType pac _BuzzerBeep pac_GetBuzzerFreqDuty pac_SetBuzzerFreqDuty pac _StopBuzzer pac_GetDIPSwitch pac_GetSlotCount pac_GetBackplanelD pac_GetBatteryLevel pac_EnableRetrigger FEE EH FREE FEER EE HEHEHEH FEEFEE Ekker pac_GetMacAddress gt O U et 3 5 Q D 2 o gt V D 5 lt gt N Last Revised November 2013 Page 41 2 Co
39. Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 10 1 AnsiString This function converts a unicode string to an ANSI byte array Syntax C byte AnsiString string str Parameters Str in Points to the Unicode string to be converted Return Value Returns the ANSI byte array Examples C byte result new byte 32 IntPtr hPort PACNET UART Open COM1 115200 N 8 1 PACNET Sys ChangeSlot Convert ToByte 1 PACNET UART SendCmd hPort PACNET MISC AnsiString SOOM result string str PACNET MISC WideString result PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 395 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks In NET if we want to convert a Unicode string to ANSI or vice versa we should convert through byte array PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 396 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 10 2 WideString This function converts an ANSI byte array to a Unicode string Syntax C string WideString byte CharStr Parameters CharStr in Points to the ANSI byte array to be converted Return Value Returns the Unicode string Examples C byte result new byte 32 IntPtr hPort PACNET UART Open COM1 115200 N 8 1 PACNET Sys ChangeSlot Convert ToByte 1 PA
40. FALSE Examples C int CALLBACK TIMER Interrupt Function Add the user control code here return 0 Interrupt done Set timer1 with 200 microsecond interval pac SetBPTimerOut 200 300 TIMER PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 376 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 8 5 pac _SetBPTimerlnterruptPriority This function sets the priority for a real time thread of the backplane timer Syntax C BOOL pac SetBPTimerlnterruptPriority int type int nPriority Parameters type in Specify the backplane timer 0 Timerout 1 Timer 1 2 Timer 2 nPriority in Specify the priority to set for the thread This value can range from O through 255 with O as the highest priority Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 377 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int CALLBACK TIMER Interrupt Function Add the user control code here return 0 Interrupt done I Set timer1 with 200 microsecond interval pac SetBPTimer 1 200 TIMER Set the priority of timer 1 to 100 pac SetBPTimerlnterruptPriority 1 100 C static void Main string args PACNET
41. ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 24 pac_WriteModuleSafeValueDO pac_WriteMo duleSafeValueDO_MF This function writes the DO safe values to DO modules Syntax C for pac_WriteModuleSafeValueDO BOOL pac_WriteModuleSafeValueDO HANDLE hPort int slot int iDO_ TotalCh unsigned long Value C for pac_WriteModuleSafeValueDO_MF BOOL pac WriteModuleSafeValueDO_MF HANDLE hPort int slot int iDO TotalCh unsigned long Data PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 274 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 IDO_TotalCh in The total number of DO channels of the DO modules Value IData in A 8 digit hexadecimal value where bit O corresponds to DOO bit 31 corresponds to DO31 etc When the bit is 1 it denotes that the digital output channel is on and O denotes that the digital output channel is off Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 275 Copyright 2013 ICP DAS Co Ltd All Rights
42. Languages wa feb Vival Basic Ea Windows Koons Applicaton gel Class Library Poor okie az WEF Application myo WPF Browser Application i ins _ Smart Device T Console Application We Empty Project H Office ie Windows Service eve WPF Custom Conteol Library Database E WPF User Control Library tel Windows Fors Control Library Reporting Test My Templates WCF Workflow Search Online Templates gy Visual C W Other Project Types W Test Projects A project for creating an application with a Windows user interface NET Framework 35 Name Example Location DDoimng Browse olution Mame Example Create directory for solution PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 34 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 3 Add the PACNET dIl into the references of the project and then insert the code to complete your project Click Project gt Add Reference Choose PACNET dll from the list Click OK to add the reference oS oS Use the intellisSense feature to quickly select the function which you want to call 79 Example Microsoft isual Studio Sle File Edit Wiew Project Build Debug Data Tools Test Window Help Aas G9 OS De gt EE es PE EES Fomlvb Formal vb Design Start Page Bava SSS T m a Public Class Form olution Bxamp projec Al el Ex
43. Last Revised November 2013 Page 197 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 4 pac _ReadDO pac ReadDO_MF This function reads the DO value of the DO module Syntax C for pac _ReadDO BOOL pac _ReadDO HANDLE hPort int slot int iDO_ TotalCh DWORD IDO_ Value C for pac ReadDO_MF BOOL pac _ReadDO MF HANDLE hPort int iSlot int iDO_TotalCh DWORD IDO_ Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 198 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 IDO_TotalCh in The total number of DO channels of the DO modules IDO _ Value out The pointer of the DO value to read from the DO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 199 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadDO Example 1 f the module is 87k local HANDLE hPort hPort uart_Op
44. Reserved D lt E mail service icpdas com Examples C pac_WriteModuleSafeValueDO Example 1 f the module is remote HANDLE hPort hPort uart_Open COM2 9600 N 8 1 int total channel 8 DWORD do_ value 4 turn on the channel two BOOL ret pac_WriteModuleSafeValueDO hPort PAC REMOTE_1O 1 total channel do_ value uart_Close hPort Example 2 f the module is 87k local HANDLE hPort hPort uart_Open int total channel 8 DWORD do value 4 turn onthe channel two BOOL ret pac_WriteModuleSafeValueDO hPort 1 total_ channel do_value uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 276 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModuleSafeValueDO_MF Example 1 f the module is remote HANDLE hPort hPort uart_Open COM2 9600 N 8 1 int total_ channel 8 DWORD do value 4 turn on the channel two BOOL ret pac_WriteModuleSafeValueDO_MF hPort PAC _REMOTE_1O 1 total_ channel do_value uart_Close hPort Example 2 f the module is 87k local HANDLE hPort hPort uart_Open int total channel 8 DWORD do value 4 turn onthe channel two BOOL ret pac_WriteModuleSafeValueDO_MF hPort 1 total channel do_value uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 277 Copyright
45. WriteLine total channel n Console WriteLine Enter the number of DO s channel n strArray 1 Console ReadLine Console WriteLine DO s value n Console WriteLine Enter the value 1 is to turn on the DO channel Ois off n strArray 2 Console ReadLine bool err err PACNET PAC O WriteDO IntPtr Zero Convert Tolnt32 strArray 0 Convert TolInt32 strArray 1 Convert ToUInt32 strArray 2 if err false uint errorCode PACNET ErrHandling GetLastError Console WriteLine Write DO s Error PACNET ErrHandling GetErrorMessage errorCode The error code is errorCode ToString n else Console WriteLine Write DO sucessfully Console ReadLine PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 390 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The pac_GetErrorMessage function can be used to obtain error message strings for the XPac error codes returned by pac_GetLastError as shown in the following example TCHAR Buffer 32 pac_GetErrorMessage pac_GetLastError Buffer MessageBox NULL Buffer L Error MB_OK MB_ICONINFORMATION PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 391 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 9 4 pac_ClearLastError This function clears the last error code Syntax C void p
46. bas Copy PACSDK bas and PACSDK_vb dll to the application folder Click Project gt Add Module 3 Choose PACSDK bas from the list 4 Click OK to add the reference N e yy Progectl Microsoft Yisnal Basic design File Edit Vie Broject omat Debug Run Query Digam Tools Add Ins Window Help S n EE dd Form om y ia Nease Uwa eil aiam E E E aT Module HFL AgJ LA Loo We Add User Control w Project 1 Add Property Page Te Add User Document Add Web ls Add Data Report Add DHTML Page Add Data Environment Add File Cth Remove Formal Hi References Components Chlt T Project Properties Project Projecti ctl Projecti a Big pacalk pacalk bas PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 37 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com The following references illustrate how to develop the programs for XP 8000 and XP 8000 Atom step by step XP 8000 Refer to the chapter 4 on xp 8000 user manual for more details http ftp icodas com pub cd xp 8000 document user manual XP 8000 Atom Refer to the chapter 5 on xp 8000 Atom user manual for more details http ftp icodas com pub cd xpac atom document user_ manual PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 38 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 PAC API Functions The PACSDK
47. dll is a net Compact framework SDK and PACNET dIl is not only used for CH program but also used for VB net program gt PACNET dIl the execution file should be put in the same directory of the PACNET dll The latest version of this library is located at CD root Xpac Atom SDK PACSDK Driver DOTNET in the companion CD http ftp icodas com pub cd xp 8000 sdk pacsdk pacnet pacnet dll Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Tools Test Window Help Project Ctl shittt H Web site Shift A lt File Ctr Project From Existing Code eave All tlt hatte Recent Files Recent Projects Exit PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 26 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 2 Select Windows Forms Application and name the project 1 In the Project Type column choose Visual C gt Windows 2 Inthe Template column choose Windows Forms Application 3 Name your project 4 Click OK to create your new project Hew Project Project types Templates NET Framework 3 0 4 E Visual C Fisual Studio installed templates Windows oO Web fe Windows Forms Application E Clas Library ren Device ngt WEF Application WPF Browser Application E3 oe ee Console Application ce Empty Project Reporting i Windows Service d WPF Custom Control Library Test el WPF User Control Library ace Windows Forme Cont
48. iChannel mode uart_Close hPort C IntPtr hPort hPort PACNET UART Open int iSlot 1 short iChannel 2 short mode 0 Disable the PWM synchronization bool iRet PACNET P WIM SetPWMSynChannel hPort iSlot iChannel mode PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 355 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 11 pac_GetPWMSynChannel This function reads the PWM synchronization status ffom a specific channel Syntax C BOOL pac _GetPWMSynChanneli HANDLE port int slot short chindex short enStatus Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify a channel to read the synchronization status config out 0 The PWM synchronization status is disabled 1 The PWM synchronization status is enabled PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 356 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort
49. iLatchType DWORD IDI Latch Value DWORD IDO_Latch_ Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 219 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 IDL_TotalCh in The total number of the DI channels of the DIO module IDO_TotalCh in The total number of the DO channels of the DIO module iLatch lype in The type of the latch value read back 1 latched high status O latched low status IDI_Latch_ Value out The pointer to the DI latch value read back IDO_Latch_ Value out The pointer to the DO latch value read back Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 220 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_ Open BYTE iSlot 1 int iDl_ TotalCh 8 int iDO_TotalCh 8 int iLatchType 0 DWORD IDI_Latch_ Value DWORD IDO_Latch_ Value BOOL iRet pac_ReadDIOLatch hPort
50. in some situation Syntax C BOOL uart_RecvExt HANDLE hPort LPSTR buf DWORD in_Len Parameters hPort in Handle to the opened COM port buf out A pointer to a buffer that receives data in_Len in A pointer to a variable that specifies the size in bytes of the data in buffer pointed to by the buf parameter PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 148 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE If the function doesn t receive a character OxOD the other data still store to buf but the return value is FALSE Calling pac_GetLastError function will get an error code PAC_ERR_UART_READ_ TIMEOUT If this function to receive the actual data size is larger than the buffer length of buf it will return FALSE Calling pac_GetLastError function will get an error code PAC_ERR_UART_INTERNAL_BUFFER_OVERFLOW Examples C BOOL ret HANDLE hOpen char buf Length hOpen uart_Open COM1 9600 N 8 1 ret uart_RecvExt hOpen buf Length C bool ret IntPtr hOpen byte result new byte 64 hOpen PACNET UART Open COM3 9600 N 8 1 ret PACNET UART RecvExt hOpen result 64 if ret Console WriteLine PACNET MISC WideString result Console ReadLine PAC Standard API Manual
51. is True If the function fails the return value is False PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 168 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C bool ret HANDLE hPort char buf 2 char cmd 2 hPort uart_Open COM4 9600 N 8 1 cmd 0 0x41 cmd 1 0x42 ret uart_BinSendCmd hPort cmd 2 buf 2 uart_Close hPort C bool ret byte cmd new byte 2 IntPtr hPort byte buf new byte 2 cmd 0O 0x41 cmd 1 0x42 hPort PACNET UART Open COM4 9600 N 8 1 ret PACNET UART BinSendCmd hPort cmd 2 buf 2 PACNET UART Close hPort Remarks This function will call PurgeComm to clear serial COM port output and input buffer PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 169 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 14 uart GetLineStatus This function retrieves the modem control register values Syntax C BOOL uart_ GetLineStatus HANDLE hPort int pin Parameters hPort in Handle to the opened COM port pin in A variable specifies state of a pin of the COM port This parameter can be following values 0 define CTS 1 define DSR 2 define R 3 define CD Return Value TRUE indicates the state of the pin is ON False indicates OFF PAC Standard API Manual v1 0 2 Last R
52. is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 315 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 33 pac _ GetModuleWDTConfig This function reads the host watchdog status of a module Syntax C BOOL pac GetModuleWDTConfig HANDLE hPort int slot short enStatus unsigned long wdtTimeout int ifWDT Overwrite PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 316 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 enStatus out 1 the host watchdog is enabled 0 the host watchdog is disabled wat Timeout out The unit of return value is 100ms If WDT_Overwrite only for i 8k out 1 the host watchdog does overwrite 0 the host watchdog does not overwrite Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 317 Copyright
53. or DIO channels 2 In addition to provide support for the API functions described above the PACSDK also provides the support for the Multi function API that is used to read and write the DIO channels for the Multi function DCON modules which are defined as modules that mainly act as AlO or Counters but are equipped with DIO channels Such as the 87005W I 87016W I 87082W I 7016 I 7088 etc 3 The functions mentioned above i e pac_WriteDO pac_ReadDIO etc cannot be used to access Multi function DCON modules Only the pac_xxx_MF API allows access to Multi function DCON modules 4 In both the DCON_ PC dll and the XPACSDK dll PAC_IO API functions only support access to high profile I 87K I 8K series modules and I 7K series modules In the PACSDK dll the processing can be modified to send DCON commands without needing to determine the module name which means that a the new PAC_IO API functions can support access to the I 87K I 8K High profile and Low profile series modules 1 7K series modules l 8000 series modules units tM series modules and other OEM ODM DCON modules 5 The comparison table of pac_WriteAO pac_WriteAO_MF Functions and available modules are as following Since November 1 2012 pac_Write AO pac_WriteAOQ_MF I 87024W CW DW RW 87024 l 87026PW 87028CW UW I 87022 I 87026 l 7022 l 7024 8024R l 7021 I 7021P PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 422 Copyr
54. profile 87K series 811xW I 814xW series l 7000 series All the functions are based on standard COM port API functions in C CreateFile CloseHandle WriteFile ReadFile GetCommModemStatus Use these functions of this section to communicate with I 87K PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 130 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com XPAC COM1 For I 87K module in T O slot When a high profile I 87K is plugged in slot please call the function pac_ChangeSlot to change to the specific slot before doing other operations Please refer to demo 87k_Basic About I 87K commands DCON protocol please refer http ftp icodas com pub cd 8000cd napdos dcon io module 87k high profile modules h tm PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 131 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Although user can use UART API to set and read values for high profile I 87K series modules we provide a more convenient API to do it Please refer to Section 6 PAC_IO API Use these functions of this section to communicate with external devices by 811xW I 814xW serises modules XPAC Any serial devices connected with COM port I 7000 or I 87K4 5 8 9 PC The PC has no slots for plugging the high profile I 8K and I 87K series but the UART API on this section can also be
55. ret2 PACNET PAC O WriteDO_MF hPort2 1 total channel2 do_value2 PACNET UART Close hPort2 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If it is in remote the second parameter need use the macro PAC _REMOTE_IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 193 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 3 pac_WriteDOBit This function writes a single bit of value to the DO module that is only the channel corresponding to the bit is changed Syntax C BOOL pac WriteDOBit HANDLE hPort int slot int iDO TotalCh int iChannel int iBitValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 194 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The DO channel to be change IDO_TotalCh in The total number of DO channels of the DO modules iBitValue in 1 is to turn on the DO channel 0 is off Return Value If the functio
56. sets the hardware trigger for a specific channel Syntax C BOOL pac _SetPWMDITriggerConfig HANDLE port int slot short chindex short config Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify a channel to set the the hardware trigger config in 0 Disable the hardware trigger 1 Enable the trigger start 2 Enable the trigger stop PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 348 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short iChannel 2 short mode 0 BOOL iRet pac SetPWMDITriggerConfig hPort iSlot iChannel mode uart_Close hPort C IntPtr hPort hPort PACNET UART Open int iSlot 1 short iChannel 2 short mode 0 bool iRet PACNET P WIM SetPWMDITriggerConfig hPort iSlot iChannel mode PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 349 Copyright 2013 ICP DAS Co Ltd All Rights R
57. the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 217 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_ Open BYTE iSlot 1 BOOL iRet pac_ClearDILatch hPort iSlot uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 BOOL iRet pac_ClearDiLatch 0 iSlot C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 3 bool iRet PACNET PAC O ClearDILatch hPort iSlot PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1lO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 218 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 9 pac _ReadDIOLatch This function reads the latch values of the DI and DO channels of the DIO module Syntax C BOOL pac _ReadDIOLatch HANDLE hPort int slot int iD TotalCh int iDO TotalCh int
58. the buzzer PACNET Sys Buzzer BuzzerBeep 1 10000 Console ReadLine Press any key to stop the buzzer PACNET Sys Buzzer StopBuzzer PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 76 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 16 pac _GetDIPSwitch This function retrieves the dip switch on the XPAC AAA ROOUE Syntax C int pac_GetDIPSwitch Parameters This function has no parameters Return Value The return value specifies the dip switch Examples C int iDipSwitch C int iDipSwitch iDipSwitch PACNET Sys GetDIPSwitch Console WriteLine The DIP Switch value is iDipSwitch ToString Console ReadLine PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 77 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 17 pac _GetSlotCount This function retrieves the total number of the IO slot on the XPAC Syntax C int pac_GetSlotCount Parameters This function has no parameters Return Value The return value is the number of the IO slot Examples C int wSlot wSlot pac_GetSlotCount C int iSlot iSlot PACNET Sys GetSlotCount Console WriteLine The number of the I0 slot is iSlot ToString Console ReadLine PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 78
59. to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 262 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 20 pac _ReadAlAllHex This function reads all the Al values of all channels in 2 s complement mode of the Al module The function maybe causes the buffer overflow in some situation Syntax C BOOL pac ReadAIAllHex HANDLE hPort int slot int iValue Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iValuef out The array contains the Al values that read back from the Al module PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 263 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iValue 8 BOOL iRet pac_ReadAIAllHex hPort iSlot iValue uart_ Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iValue 8 BOOL iRet pac_ReadAIAllHex 0 iSlot iValue
60. use Dillmport you should add the namespace using Statement System Runtime InteropServices and then implement the function which you want to call Demonstrate an example of using pac_writeDO in NET project The function defined in PACSDK h file PAC_API BOOL pac_WriteDO HANDLE hPort int slot int iDO_TotalCh DWORD IDO Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 31 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com How to use in your NET project 1 Added this line in your project l lt Dillmport PACSDK dll EntryPoint pac_WriteDO gt _ Public Shared Function pac_WriteDO ByVal hPort As IntPtr ByVal slot As Integer ByVal l l l 3 Then you can use this function pac_WriteDO in your NET project Code Snippet Imports System Runtime lnteropServices Public Class Form1 Inherits Form lt Dillmport PACSDK dll EntryPoint pac_WriteDO gt _ Public Shared Function pac_WriteDO ByVal hPort As IntPtr ByVal slot As Integer ByVal iDO_TotalCh As Integer ByVal IDO_Value As Ulnteger As Boolean l I l I l l l I l I l l l I l I l l l I l I l l l I l l l l l I l I l l l I l I l l l End Function l l l l l l l l I l I l l l I l I l l l I l I l l l l l I l l l I l I l l l I l I l Private Sub Button1_Click ByVal sender As System Object ByVal e As System EventArgs Handles Button1 Click
61. used for the COM ports of PC To see more information please reference user manual Chapter 5 API and Demo Reference PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 132 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the UART functions Functions Models hd e1000 XP 8000 Atom PC nopen CY YT o oy jvarcose YL YT o oy sansene oY o oy lt lt lt lt lt lt lt lt x lt PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 133 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com UART Functions The following functions are used to retrieve or set the UART PACSDK Functions PACNET Functions Description sends out command string with or without null character under the consideration of the uart_BinSend UART BinSend command length receives the response string data with or without null character under the consideration uart_BinRecv UART BinRecv of receiving length uart_BinSendCmd UART BinSendCmd sends binary command and receive binary data with the fixed length uart_GetLineStatus UART GetLineStatus retrieves the modem control register values PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 134 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com l ret
62. v1 0 2 Last Revised November 2013 Page 149 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The terminate characters is OxOD Refer to uart_SetTerminator function to change For example a Check sum is disabled This function receives five bytes ABCD 0x0D The buf will be five bytes ABCD 0x0 b Check sum is enable This function receives four bytes ABCD The buf will be four bytes ABCD But the reurn value is 0 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 150 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 6 uart Recv This function retrieves data through the COM port which has been opened This function will receive a string OxOD Wait a character OxOD to mean the termination of a string And then if the checksum is enabled by the uart_EnableCheckSum function this function automatically checks the two checksum bytes to the string This function will provide a string without the last byte OxOD Syntax C BOOL uart Recv HANDLE hPort LPSTR buf Parameters hPort in Handle to the open COM port buf out A pointer to a buffer that receives data Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE If this function doesn t receive a characterOxOD the other data still store to buf but the r
63. value is 5 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 211 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadDIO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iD TotalCh 2 int iDO_ TotalCh 2 uint IDI_ Value O uint IDO_Value 0 bool iRet PACNET PAC O ReadDIO_MEF hPort iSlot iDI_ TotalCh iDO_TotalCh ref IDI_ Value ref IDO Value PACNET UART Close hPort Console WriteLine The DI value is IDL Value ToString The DO value is IDO_Value ToString Console ReadLine The example displays the following output to the console H The DI value is 2 The DO value is 1 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second Parameter need use the macro PAC_REMOTE_1O 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 212 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 7 pac _ReadDiLatch This function reads the DI latch value of the DI module Syntax C BOOL pac_ReadDILatch HANDLE hPort int slot int iDl TotalCh int iLatchType DWORD IDI_Latch_ Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 213 Copyrig
64. will not add new features Use the old SDK as following flowchart The VC project required to link WinPacSDK lib while building and the built executable file placed in the WinPAC series device must work with WinPacSDK dll VC Project Link gt C EXE ARM WinPacSDK lib PC WinPAC The C VB net project required to refer to WinPacNet dll while building and the built executable file placed in the WinPAC series device must work with WinPacNet dll and WinPacSDK dll C VB net 2 nde ain Project Refer to WinPacNet dll PC WinPAC PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 438 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com ii The users have used WinPAC series devices and their programs is based on the old SDK WinPacSDK dll working with the old DCON modules and multi function DCON modules on WinPAC device The new PACSDK dll provides pac_xxx_MF API functions that allow access to Multi function modules so the code must be updated in order to use the new PACSDK dll in the program Refer to How to document w6 10_How_to_update_to_PACSDK_library_from_WinPacSDK_library_EN pdf for more details iii The users have never used WinPAC series devices Their program will be based on the new SDK working with an old DCON module or a Multi function module Our API Manual give instructions for the PACSDK dll and the demo programs included on the shipp
65. 0 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 8 1 pac _GetBPTimerTimeTick_ms This function returns the number of milliseconds that have elapsed since the system was started excluding any time that the system was suspended Syntax C DWORD pac_GetBPTimerTimeTick ms void Parameters This function has no parameters Return Value The number of milliseconds indicates success Examples This function has no examples PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 371 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 8 2 pac _GetBPTimerTimeTick_us This function returns the number of microsecond that have elapsed since the system was started excluding any time that the system was suspended Syntax C DWORD pac_GetBPTimerTimeTick us void Parameters This function has no parameters Return Value The number of microseconds indicates success Examples This function has no examples PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 372 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 8 3 pac SetBPTimer This function creates a hardware timer with the specified time out value A time out value is specified and every time a time out occurs the system posts an interrupt signal to the system and pass the message to an ap
66. 0 2 Last Revised November 2013 Page 172 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 16 uart SetLineStatus This function sets the status of modem line Syntax C DWORD uart_SetLineStatus HANDLE hPort int pin int mode Parameters hPort in Handle to the open COM port pin in A variable specifies state of a pin of the COM port This parameter can be following values 1 define DTR 2 define RTS 3 define DTR RTS mode in 0O Disable Set the pin signal to be OFF 1 Enable Set the pin signal to be ON PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 173 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is nonzero If the function fails the return value is zero To get an error code call pac_GetLastError Examples C HANDLE hPort uart_Open COM5 9600 N 8 1 DTR pin on COM5 of XPAC HANDLE hPort uart_Open COM4 9600 N 8 1 DTR pin on COM4 of WinPAC uart_SetLineStatus hPort 1 1 set DTR to ON uart_Close hPort C IntPtr hPort PACNET UART Open COM5 9600 N 8 1 DTR pin on COMS5 of XPAC ntPtr hPort PACNET UART Open COM4 9600 N 8 1 DTR pin on COM4 of WinPAC PACNET UART SetLineStatus hPort 1 1 set DTR to ON PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revi
67. 0 2 Last Revised November 2013 Page 70 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_BuzzerBeep 1 100 C Beep 1 time for 1 second PACNET Sys Buzzer BuzzerBeep 1 1000 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 71 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 13 pac _GetBuzzerFreqDuty This function retrieves the frequency value and duty cycle value of the buzzer Syntax C void pac _GetBuzzerFreqDuty int freq int duty Parameters freq out The frequency of the sound ranging from 37 to 32767 hertz duty out The duty cycle of the sound Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 72 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int fq 0 int du 0 pac _GetBuzzerFreqDuty amp fq amp du C int fq 0 int du 0 PACNET Sys Buzzer GetBuzzerFreqDuty ref fq ref du Console WriteLine The frequency fq ToString The duration du ToString Console ReadLine The example displays the following output to the console The frequency 2000 The duration 50 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 73 Copyright 2013 ICP DAS Co Ltd
68. 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 258 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 19 pac _ReadAlAllHexExt This function reads all the Al values of all channels in 2 s complement mode of the Al module This function replaces pac_ReadAIlAllHex Syntax C BOOL pac ReadAlAllHex HANDLE hPort int slot int iValue DWORD Buff Len DWORD Channel PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 259 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iValue out The array contains the Al values that read back from the Al module Buff Len in A pointer to a variable that specifies the size of the buffer pointed to by the iValue Channel out The pointer to a variable that specifies the total available channel numberer of Al module This channel number is only valid if the return value is TRUE Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised Novemb
69. 00 Ox3FFF address of the EEPROM or to the last segment of the SRAM using the SDK version 2 0 1 0 or earlier the program may fail to write the data to the EEPROM or the SRAM using the PACSDK dll or PACNET dIl There are two ways to fix the problem 1 Modify the program so that the data is written to the O Ox1FFF address of the EEPROM or the O Ox6FFFF address of the SRAM 2 Ask for the previous SDK from ICPDAS PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 109 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 3 3 pac_WriteMemory This function stores data in the specified memory Syntax C BOOL pac _WriteMemory DWORD address LPBYTE lpBuffer DWORD dwLength int mem type PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 110 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters Address in Specifies the memory address where write from EEPROM O Ox1FFF 8KB for users Ox2000 0x3FFF 8KB is reserved for the system SRAM The size of the input range for the SRAM is only O Ox6FFFF 448KB with another 64KB of SRAM is reserved for use by the system loBuffer in A pointer to the buffer containing the data to be written to the memory dwLength in Number of characters to be written mem_type in Handle to a currently type memory 0 PAC_MEM_SRAM 1 PAC MEM EEPROM Return Va
70. 13 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadModulePowerOnValueDO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do value BOOL ret pac_ReadModulePowerOnValueDO hPort slot total channel amp do_ value uart_Close hPort C pac_ReadModulePowerOnValueDO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do_ value BOOL ret pac_ReadModulePowerOnValueDO_MF hPort slot total channel amp do_value uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 293 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadModulePowerOnValueDO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 8 uint do value 0 bool ret PACNET PAC 10 ReadModulePowerOnValueDO hPort slot total channel ref do_value PACNET UART Close hPort Console WriteLine The DO power on value is do_value ToString Console ReadLine The example displays the following output to the console The DO power on value is 4 C pac_ReadModulePowerOnValueDO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot
71. 2 1 1 pac _GetModuleName This function retrieves the name of the specified I O module plugged into the XPAC series devices Syntax C int pac _GetModuleName BYTE slot LPSTR strName Parameters Slot in Specifies the slot number to which I O module is plugged to XPAC series devices strName out A pointer to a buffer that receives the name of the specified I O module Return Value If the 8K I O module is undefined the return value is some other value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 45 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C byte slot 1 char strName 10 pac_GetModuleName slot strName C For this API there are two ways to get the module name First is called by reference and you should add key word ref The return value is Module type not Module name byte slot 1 string strName int ModuleType 0 ModuleType PACNET Sys GetModuleName slot ref strName Console WriteLine The Module Name on slot 1 is strName Another directly returns the module name slot 2 strName PACNET Sys GetModuleName slot Console WriteLine The Module Name on slot 2 is strName Console ReadLine The example displays the following output to the console The Module Name on slot 1 is 87061 The Module Name on slot 2 is 8017H PAC Standar
72. 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 Interrupt API The Interrupt functions provide the slot interrupt that may be used for counting timing detecting external events and sending and receiving data using the serial interface Interrupt Flow 0 Rising edge p Start _ Step 1 Set tigger type rogram Star aA oO pac_SetTriggerType Slot 1 1 Level trigger 2 Falling edge Step 2 Install user callback function pac_RegisterSlotInterrupt Slot f Step 3 Set interrupt priority pac_SetSlotInterruptPriority Slot Priority Step 4 Enable Interrupt pac_EnableSlotInterrupt Slot true int CALLBACK REO f return PAC_INTR_DONE pac_EnableSlotInterrupt gislot false pac_UnregisterSlotInterrupt BYTE slot pend PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 84 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the interrupt functions Functions Models XP 8000 XP 8000 Atom XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx lt pac_RegisterSlotInterrupt pac_UnregisterSlotInterrupt pac_EnableSlotInterrupt pac_SetSlotinterruptPriority pac_Interruptlnitialize pac_GetSlotInterruptEvent pac_SetSlotinterruptEvent pac_SetTriggerlType poy Ff e js aes yf ware Ff poy poy fe pac_GetSlotInterru
73. 6 is used for XPAC series PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 431 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Notes PACNET dIl has been developed using the Net CF V2 0 environment and can be used on all XPAC and WinPAC series devices PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 432 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 5 Show a tooltip for the classes of PACNET dIl When developing the programs in VS2005 VS2008 IDE typing a reference to a system class or namespace or roll over class the tooltips pop up on your cursor line giving not only the parameters and variables of methods but also some descriptions for these methods classes and namespaces Those description of tooltips are same on the PAC API manual Refer to the following figure Wold testi i 4 FAC_CALLBACK_FUNC ae Pac IG ae Pat Reg void testi i PACNET Svs Changes lot void Sys Changeslot byte slotho slotHo iS pecities the slot number PAC Standard API Manual v1 0 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved class PACNET BP Time Backplane tuner APT Last Revised November 2013 Page 433 gt lt E mail service icpdas com C 3 Error code modifications and updates 1 For WinPAC series Modify The error code PAC ERR_EEP_ACCESS RESTRICTION and
74. 8 BOOL iRet pac_ClearDICNT 0 iSlot iChannel iDI_ TotalCh C pac_ClearDICNT_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDI_ TotalCh 8 BOOL iRet pac_ClearDICNT_MF hPort iSlot iChannel iDI_ TotalCh uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 232 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ClearDICNT f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 3 int iChannel 2 int iDI_ TotalCh 8 bool iRet PACNET PAC 0 ClearDICNT hPort iSlot iChannel iDI_ TotalCh PACNET UART Close hPort C pac_ClearDICNT_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 0 int iDl_ TotalCh 2 bool iRet PACNET PAC 0 ClearDICNT_MF hPort iSlot iChannel iDI_ TotalCh PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 233 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 13 pac_WriteAO pac_WriteAO_MF This
75. AC_ERR_BASE 4 Changed to PAC_ERR_BASE 7 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 436 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Add Basic PAC_ERR_INVALID MAC PAC_ERR_BASE 4 PAC_ERR_INVALID_COMPORT_NUMBER PAC_ERR_BASE 5 PAC_ERR_ FUNCTION NOT SUPPORT PAC_ERR_BASE 6 PAC_ERR_INVALID _ SLOT NUMBER PAC_ERR_BASE 8 Memory Access PAC_ERR_NVRAM_INVALID_ ADDRESS PAC_ERR_MEMORY_ BASE 4 PAC_ERR_EEP_WRITE_PROTECT PAC_ERR_MEMORY_BASE 5 PAC_ERR_EEP_WRITE_FAIL PAC_ERR_ MEMORY _ BASE 6 PAC_ERR_EEP_READ FAIL PAC_ERR_ MEMORY _BASE 7 UART PAC_ERR_UART_INTERNAL_BUFFER_OVERFLOW PAC_ERR_UART_BASE 9 0 PAC_ERR_IO_DO_CANNOT_OVERWRITE PAC_ERR_IO_BASE 10 PAC_ERR_IO_AO_CANNOT_OVERWRITE PAC_ERR_IO_BASE 11 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 437 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Appendix D Using the Multi function DCON module 1 On WinPAC devices i The users have used WinPAC series devices and their programs is based on the old SDK WinPacSDK dll WinPacNet dll working with the old DCON modules Note 2 on WinPAC device and without using multi function DCON modules Note 1 The user s program can continue to use the old library without needing to be modified The Old SDK will continue to maintain Fix the bugs and released regularly but
76. All Rights Reserved D lt E mail service icpdas com 2 1 14 pac_SetBuzzerFreqDuty This function sets the frequency value and duty cycle value of the buzzer Syntax C void pac SetBuzzerFreqDuty int freq int duty Parameters freq out The frequency of the sound duty out The duty cycle of the sound Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 74 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int fq 500 int du 20 pac SetBuzzerFreqDuty fa du C Set Frequency 100 and Duty Cycle 20 int fq 100 int du 20 PACNET Sys Buzzer SetBuzzerFreqDuty fq du Remark The default frequency value is 2000 and the default duty cycle value is 50 in PACSDK dIl You can use the pac_SetBuzzerFreqDuty function to change the two parameters and the two values you changed will take effect until the end of the program PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 75 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 15 pac_StopBuzzer This function stops the buzzer Syntax C void pac StopBuzzer Parameters This function has no parameters Return Value This function does not return any value Examples C pac StopBuzzer C Demonstrate how to stop
77. C series reference of PACSDK dIl modifications and updates for more details The suite of the Registry API functions is placed in PACNET PAC_Reg class Add I O WDT PowerOn Safe Value API for pure DIO modules Refer to Add I O WDT PowerOn Safe Value API for pure DIO modules reference of PACSDK dll modifications and updates for more details The suite of the I O WDT PowerOn Safe Value API functions for pure DIO modules is placed in PACNET PAC_IO class Add I O WDT PowerOn Safe Value API for the Multi function modules Refer to Add I O WDT PowerOn Safe Value API for Multi function modules reference of PACSDK dll modifications and updates for more details The suite of the I O WDT PowerOn Safe Value API functions for Multi function modules is also placed in PACNET PAC_1O class Add Misc API function for PACSDK Refer to Add Misc API function for PACSDK reference of PACSDK dll modifications and updates for more details The suite of misc API function is placed in PACNET MISC class PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 428 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 3 Enumerate the error codes Add a function to enumerate all the error codes for PACSDK The code snippet is as follows The code is applicable to every C VB demo file uint ec PACNET ErrHandling pac_GetLastError MessageBox Show PACNET ErrCode ec ToString nE
78. CNET UART SendCmd hPort PACNET MISC AnsiString SOOM result string str PACNET MISC WideString result PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 397 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks In NET if we want to convert a Unicode string to ANSI or vice versa we should convert through byte array PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 398 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 10 3 pac_AnsiToWideString This function converts an ANSI string to a Unicode string Syntax C void pac AnsiToWideString LPCSTR astr LPWSTR wstr Parameters astr in Points to the ANSI string to be converted wstr out A pointer to a buffer location that receives the converted Unicode string Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 399 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C char ansiString 128 This is an ansi string TCHAR uniString 128 pac_AnsiToWideString ansiString uniString MessageBox NULL uniString NULL MB_OK The string This is an ansi string will show in the messagebox correctly C byte ansiString ASCIIEncoding ASCII GetBytes This is an ansi string string uniString u
79. Ch ref ICounter Value PACNET UART Close hPort Console WriteLine The counter value is Counter_Value ToString Console ReadLine The example displays the following output to the console The counter value is 10 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 228 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadDICNT_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 0 int iDI_ TotalCh 2 uint Counter_ Value 0 bool iRet PACNET PAC O ReadDICNT_MF hPort iSlot iChannel iDI TotalCh ref ICounter_ Value PACNET UART Close hPort Console WriteLine The counter value is Counter_Value ToString Console ReadLine The example displays the following output to the console The counter value is 13 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 229 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 12 pac _ClearDICNT pac_ClearDICNT_MF This function clears the counter value of the DI channel of the DI module Syntax C for pa
80. Ch 8 int iDO_ TotalCh 8 DWORD IDI Value DWORD IDO_ Value BOOL iRet pac_ReadDIO hPort iSlot iDI_ TotalCh iDO TotalCh amp IDI Value amp IDO_ Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iDl_ TotalCh 8 int iDO_ TotalCh 8 DWORD IDI_ Value DWORD IDO_ Value BOOL iRet pac_ReadDIO O iSlot iDI_ TotalCh iDO_TotalCh amp IDI_ Value amp IDO_ Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 210 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac ReadDIO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDI_ TotalCh 8 int iDO_TotalCh 8 DWORD IDI_ Value DWORD IDO_ Value BOOL iRet pac_ReadDIO hPort iSlot iDI_ TotalCh iDO_TotalCh amp IDI_ Value amp IDO Value uart_Close hPort C pac_ReadDIO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 3 int iDL TotalCh 8 int iDO_TotalCh 8 uint IDI Value 0 uint IDO_Value 0 bool iRet PACNET PAC O ReadDIO hPort iSlot iDI_ TotalCh iDO_ TotalCh ref IDI Value ref IDO Value PACNET UART Close hPort Console WriteLine The DI value is IDI Value ToString The DO value is IDO_Value ToString Console ReadLine The example displays the following output to the console The DI value is 5 The DO
81. Console WriteLine The return value is sStatus ToString Console ReadLine The example displays the following output to the console The return value is 0 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 330 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 39 pac_SetModuleWDtTInterruptStatus This function enables disables interrupt of a module watchdog Syntax C BOOL pac _SetModuleWDTInterruptStatus int slot short enStatus Parameters slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 enStatus in Interrupt status 1 Enabled 0 Disabled Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 331 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 int iSlot 1 short sStatus 0 pac_SetModuleWDTinterruptStatus iSlot sStatus C int iSlot 1 short sStatus 0 disabled PACNET PAC_ O0 SetModuleWDTInterruptStatus iSlot sStatus PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 332 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 PWM API
82. Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 8 4 pac_SetBPTimerOut This function creates a hardware timer with the specified time out value of high low wave The time out value of high low wave are specified and every time the time out of high wave and low wave occur the system posts an interrupt signal to the system and pass the message to an application defined callback function The timerout pin on each slot will be triggered while a timerout signal has been outputted The timeourput pin can be used to acquire the synchronized data on each slot Low wave time out gt Timerout Pin signal lt gt High wave time out Interrupt Signal Syntax C BOOL pac_ SetBPTimerOut unsigned int uHighElapse unsigned int uLOwElapse pac TIMEROUT CALLBACK FUNC f PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 375 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters UuHighElapse in Specify the elapsed time value for a high wave of the timerout signal as integer from 0 65535 in microseconds uLOwElapse in Specify the elapsed time value for a low wave of the timerout signal as integer from 0 65535 in microseconds Specify the address of the application supplied f callback function Return Value If the function succeeds the return value is TRUE If the function fails The return value is
83. Decide the check sum turning on or not Default is disabled Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 159 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com Examples C HANDLE hUart char result 32 hUart uart_Open uart_EnableCheckSum hUart true pac _ChangeSlot 1 uart_SendCmd hUart SOOM result C byte result new byte 32 IntPtr hPort PACNET UART Open COM1 115200 N 8 1 PACNET UART EnableCheckSum hPort true PACNET Sys ChangeSlot 1 PACNET UART SendCmd hPort PACNET MI SC AnsiString SOOM result Console WriteLine PACNET MISC WideString result Console ReadLine PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 160 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 10 uart_SetTerminator This function sets the terminate characters Syntax C void uart_SetTerminator HANDLE hPort LPCSTR szTerm Parameters hPort in Handle to the opened COM port szlerm in Pointer the terminate characters Default is CR Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 161 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C HANDLE hPort char resu
84. EPROM Syntax C void pac _EnableEEPROM BOOL bEnable Parameters bEnable in Specifies the mode of the EEPROM True To enable the writing for the EEPROM False To disable the writing for the EEPROM Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 113 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C define LENGTH 2 int ret DWORD address 0 BYTE Buffer LENGTH Buffer 0 OxAB Buffer 1 OxCD Int PAC_MEM_ EEPROM 1 pac_EnableEEPROM true ret pac_WriteMemory address Buffer LENGTH PAC_MEM_EEPROM pac_EnableEEPROM false C Demonstrate how to store the data in the EEPROM uint address 0 byte Buffer new byte 2 OxAB OxCD int PAC MEM EEPROM 1 PACNET Memory EnableEEPROM true PACNET Memory WriteMemory address Buffer uint Buffer Length PAC MEM_EEPROM PACNET Memory EnableEEPROM false Remarks Before writing EEPROM need turn on the EEPROM after writing EEPROM need turn off the EEPROM PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 114 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 Watchdog API Watchdog operations include basic management operations such as turning on and refreshing The following topics describe how you can operate watchdog progr
85. ETCF SDK WinPacNet dll and XPacNet dll files which means that NET CF programs linking to the PACNET dIl on a WinPAC device can be migrated to a XPAC device without needing to rewrite the code or rebuild the project and vice versa 1 API function classification All API functions for the WinPacNet dll or the XPacNet dll are placed in a single WinPacNet WinPAC xxx XPacNET XPac xxx class but the API functions for the PACNET dIl are classified as PACNET sys PACNET Memory and PACNET nterrupt etc The classifications applied to the API functions for the PACNET dIl as defined in the API user manual are as follows Classification in the API Manual 2 1 System Information API Sys 2 1 System Information API 2 2 Interrupt API 2 3 Memory Access API 2 4 Watchdog AP 2 6 PACIO API 2 7 PWM API PWM 2 8 Backplane Timer API 2 9 Error Handling API 2 10 Misc API PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 427 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 API functions modification LED control API function pac_EnableLED Refer to pac_EnableLED reference of PACSDK dIl modifications and updates for more details The modification in PACNET SDK XPacNet XPac pac_EnableLED pin bFlag function defined in XPacNet dll has been changed as PACNET Sys pac_EnableLEDs pin bFlag in PACNET dIl Add Registry API for XPAC series Refer to Add Registry API for XPA
86. Form class PACNET BP Timer lt 4 PAC_CALLBACE_ FUNC oe PAC IO ae PAC Reg Re PWM Tip You can add the the namespace using PACNET to your code and it can simplify object names Such as PAC_10 GetBit instead of PACNET PAC 0 GetBit PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 28 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 3 VB net Required library files The following DLL files are needed to include for developing a XPAC PC application or plug in gt PACSDK dIl How to create a program with new SDK using Visual Studio 2005 2008 VS2005 VS2008 1 Using DII Import Step 1 Create a new project by using Visual Studio 2005 2008 File Edit View Tools Test Window Help N Po 3 Project Ctl shitttN Open P o Web Site Shift Alt N File CthHN Project From Existing Code eave All Ctltshattte Recent Files Recent Projects Exit PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 29 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 2 Select Windows Forms Application and name the project 1 In the Project Type column choose Other Languages gt Visual Basic gt Windows 2 Inthe Template column choose Windows Forms Application 3 Name your project 4 Click OK to create your new project Hew Project A nee ienne NET Fra
87. GetBuzzerFreqDuty pac _SetBuzzerFreqDuty pac_StopBuzzer pac_GetDIPSwitch pac_GetSlotCount pac_GetBackplanelD pac_GetBatteryLevel pac_EnableRetrigger pac_RegisterSlotinterrupt pac_UnregisterSlotinterrupt pac_EnableSlotinterrupt pac_SetSlotInterruptPriority pac_Interruptlnitialize pac_GetSlotInterruptEvent pac_SetSlotInterruptEvent pac_SetTriggerlype pac_GetSlotInterruptID pac_InterruptDone pac _GetMemorySize pac_ReadMemory pac_WriteMemory pac_EnableEEPROM pac_EnableWatchDog 70 72 74 76 77 78 79 81 83 87 89 91 93 94 96 97 98 99 Last Revised November 2013 Page 4 gt lt E mail service icpdas com 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 2 5 UART API Pits Yl 2 5 2 23 3 2 5 4 239 2 5 6 2 5 7 2 5 8 2 3 9 2 5 10 2 5 11 2 912 2 93 13 2 5 14 2 95 15 2 5 16 2 6 PAC_IO API 2 6 1 2 6 2 2 6 3 2 6 4 PAC Standard API Manual v1 0 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved pac_DisableWatchDog pac_RefreshWatchDog pac_GetWatchDogState pac_GetWatchDogTime pac SetWatchDogTime uart_Open uart_Close uart_SendExt uart_Send uart_RecvExt uart_Recv uart_SendCmdExt uart_SetTimeOut uart_EnableCheckSum uart_SetTerminator uart_BinSend uart_BinRecv uart_BinSendCmd uart_GetLineStatus uart_GetDataSize uart_SetLineStatus pac_GetBit pac_WriteDO pac_WriteDO_MF pac_WriteD
88. IO BOOL pac_ReadDIO HANDLE hPort int slot int iDl TotalCh int iDO TotalCh DWORD IDI Value DWORD IDO_ Value C for pac_ReadDIO MF BOOL pac_ReadDIO MF HANDLE hPort int iAddrSlot int iDI_ TotalCh int iDO TotalCh DWORD IDI Value DWORD IDO_ Value PAC Standard API Manual v1 0 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised November 2013 Page 208 gt lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot iAddrSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iDI_TotalCh in The total number of DI channels of the DIO module IDO_TotalCh in The total number of DO channels of the DIO module IDI_ Value out The pointer to the value of DI read back IDO _ Value out The pointers to the value of DO read back Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 209 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadDIO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDl_ Total
89. If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError Examples This function has no examples PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 94 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks Default trigger type is level trigger For XP 8000 series only support level trigger type If you want to get the registered event handle please call this API pac_GetSlotInterruptEvent PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 95 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 6 pac _GetSlotinterruptEvent This function retrieves the slot event handle which registered by pac_InterruptInitialize Syntax C HANDLE pac_GetSlotIinterruptEvent BYTE slot Parameters slot in Specifies the index of slot to retrieve the event handle Return Value If the function succeeds return the event handles If the function fails the return value is NULL To get extended error information call pac_GetLastError Examples This function has no examples PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 96 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 7 pac_SetSlotinterruptEvent This function allows a device d
90. Last Revised November 2013 Page 123 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 4 pac _GetWatchDogState This function retrieves the watchdog state Syntax C BOOL pac _GetWatchDogState int wdt Parameters wat in Specifies the Watchdog type O Hardware watchdog PAC_WDT_HW 1 OS watchdog PAC_WDT_OS Return Value If the watchdog is turning on and the return value is TRUE Otherwise the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 124 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BOOL bState bState pac_GetWatchDogState PAC_WDT_OS C bool bState bState PACNET Sys W DT GetWatchDogState 1 Console WriteLine The state of the watchdog is bState ToString Console ReadLine f the watchdog is enabled the output to the console is as below The state of the watchdog is true f the watchdog is disabled the output to the console is as below H The state of the watchdog is false PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 125 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 5 pac_GetWatchDogTime This function retrieves the watchdog time Syntax C DWORD pac_GetWatchDogTime int wdt Parameters wat in Specifies the Watchdog t
91. O TotalCh float fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 300 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the AO value from the channel of the AO module IAO_ TotalCh in The total number of the AO channels of the AO module float fValue out The pointer to the AO safe value that is read back from the AO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 301 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadModuleSafeValueAO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue BOOL iRet pac_ReadModuleSafeValueAO hPort iSlot iChannel iAO TotalCh amp fValue uart_Close hPort C pac_ReadModuleSafeValueAO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8
92. OBit pac_ReadDO pac_ReadDO_ MF 120 122 124 126 142 145 148 151 153 156 159 161 163 165 167 170 172 194 198 Last Revised November 2013 Page 5 gt lt E mail service icpdas com 2 6 5 2 6 6 2 6 7 2 6 8 2 6 9 2 6 10 2 6 11 2 6 12 2 6 13 2 6 14 2 6 15 2 6 16 2 6 17 2 6 18 2 6 19 2 6 20 2 6 21 2 6 22 2 6 23 2 6 24 2 6 25 2 6 26 2 6 27 2 6 28 2 6 29 2 6 30 2 6 31 PAC Standard API Manual v1 0 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved pac_ReadDI pac_ReadDI_MF pac_ReadDIO pac_ReadDIO_MF pac_ReadDILatch pac_ClearDILatch pac _ReadDIOLatch pac_ClearDIOLatch pac_ReadDICNT pac_ReadDICNT_MF pac_ClearDICNT pac_ClearDICNT_MF pac_WriteAO pac_WriteAO_MF pac_ReadAO pac_ReadAO_ MF pac_ReadAl pac_ReadAlHex pac_ReadAIAIlExt pac_ReadAlAll pac_ReadAlAllHexExt pac_ReadAlAllHex pac _ReadCNT pac_ClearCNT pac_ReadCNTOverflow pac_WriteModuleSafeValueDO pac_WriteModuleSafeValueDO_MF pac_ReadModuleSafeValueDO pac_ReadModuleSafeValueDO_MF 203 208 213 217 219 223 225 230 234 239 244 248 252 256 259 263 266 269 271 274 280 pac_WriteModulePowerOnValueDO pac_WriteModulePowerOnValueDO_MF285 pac_ReadModulePowerOnValueDO pac_ReadModulePowerOnValueDO_MF 291 pac_WriteModuleSafeValueAO pac_WriteModuleSafeValueAO_MF pac_ReadModuleSafeValueAO pac_ReadMod
93. OOL err char strErr 32 memset buffer 0 4096 if atoi argv 3 0 printf The size of SRAM is d n pac_GetMemorySize atoi argv 3 err pac_ReadMemory atoi argv 1 buffer atoi argv 2 atoi argv 3 if err FALSE pac _GetErrorMessage pac_GetLastError strErr printf Read SRAM failure The error code is x n pac_GetLastError printf s strErr return O Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com printf s n buffer printf The size of EEPROM is d n pac_GetMemorySize atoi argv 3 err pac _ReadMemory atoi argv 1 buffer atoi argv 2 atoi argv 3 if err FALSE pac_GetErrorMessage pac_GetLastError strErr printf Read EEPROM failure The error code is x n pac_GetLastError printf s strErr return O I printf s n buffer return O PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 389 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C static void Main string args string strArray new string 3 Console WriteLine pac_WriteDO for 8000 modules n n Console WriteLine usage pac_WriteDO Slot total channel DO s value n n Console WriteLine Wwhere n Console WriteLine Slot n Console WriteLine Enter the number of slot for local modules n strArray O Console ReadLine Console
94. OTE_10O 1 bool ret PACNET PAC O WriteModulePowerOnValueDO hPort iRemoteAddr total channel do_value PACNET UART Close hPort Example 2 f the module is 87k local IntPtr hPort1 hPort1 PACNET UART Open int total channel1 8 uint do_value1 4 turn on the channel 2 bool ret1 PACNET PAC_ 0 WriteModulePowerOnValueDO hPort1 1 total channel1 do_valuei PACNET UART Close hPort1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 289 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModulePowerOnValueDO_MF Example 1 f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total_ channel 8 uint do_ value 1 turn on the channel 0 int iRemoteAddr PACNET PAC O PAC REMOTE_1O 1 bool ret PACNET PAC O WriteModulePowerOnValueDO_MF hPort iRemoteAddr total channel do_ value PACNET UART Close hPort Example 2 f the module is 87k local IntPtr hPort1 hPort1 PACNET UART Open int total channel1 8 uintdo_valuel 1 turn onthe channel 0 bool ret1 PACNET PAC_ 0 WriteModulePowerOnValueDO_ MF hPort1 1 total channel1 do_value1 PACNET UART Close hPort1 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second paramet
95. Open byte iSlot 3 int iChannel 0 int iAL_ TotalCh 8 int iValue 0 bool iRet PACNET PAC O ReadAlHex hPort iSlot iChannel iAl_ TotalCh ref iValue PACNET UART Close hPort Console WriteLine The Al value is iValue ToString Console ReadLine The example displays the following output to the console The Al value is 3319 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 251 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 17 pac_ReadAlAllExt This function reads all the Al values of all channels in engineering mode of the Al module This function replaces pac_ReadAIAll Syntax C BOOL pac_ReadAIAllExt HANDLE hPort int slot float fValue DWORD Buff_Len DWORD Channel PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 252 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO
96. Overwrite 0 hPort uart_Open pac SetModuleWDTConfig hPort iSlot sStatus ulWDTtime iOverwrite uart_Close hPort C f the module is 87k local IntPtr hPort int iSlot 1 short sStatus 0 int ulWDTtime 0 int Overwrite 0 hPort PACNET UART Open PACNET PAC_ O SetModuleWDTConfig hPort iSlot sStatus ulWDTtime iOverwrite PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 322 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 35 pac ResetModuleWDT This function resets the host watchdog status of a module Syntax C BOOL pac _ResetModuleWDT HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised N
97. PAC CALLBACK FUNC f new PACNET PAC_CALLBACK_FUNC myfunction Set timer1 with 200 microsecond interval PACNET BPTimer SetBPTimer 1 200 f Set the priority of timer 1 to 100 PACNET BPT imer SetBPTimerlinterruptPriority 1 100 static int myfunction Interrupt Function Add the user control code here return 0 Interrupt done PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 378 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 8 6 pac_KillBPTimer This function destroys the specified timer event identified by type set by an earlier call to pac _SetBPTimer Syntax C void pac_KillBPTimer int type Parameters type in Specify the timer O Timerout 1 Timer 1 1 microsecond timer 2 Timer 2 10 microsecond timer Return Value This function does not return any value Examples C Destroy the timer 1 pac_KillBPTimer 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 379 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 9 Error Handling API The error handling functions enable you to receive and display error information for your application PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 380 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following
98. PAC SDK Standard API User Manual Windows Based VC amp NET Version 1 0 2 November 2013 Service and usage information for XPAC 8000 XPAC 8000 Atom PC Written by Sean Edited by Amber Warranty All products manufactured by ICP DAS are under warranty regarding defective materials for a period of one year beginning from the date of delivery to the original purchaser Warning ICP DAS assumes no liability for any damage resulting from the use of this product ICP DAS reserves the right to change this manual at any time without notice The information furnished by ICP DAS is believed to be accurate and reliable However no responsibility is assumed by ICP DAS for its use not for any infringements of patents or other rights of third parties resulting from its use Copyright Copyright 2013 by ICP DAS Co Ltd All rights are reserved Trademark The names used for identification only may be registered trademarks of their respective companies Contact US If you have any problem please feel free to contact us You can count on us for quick response Email service icpdas com PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Contents CONTENTS inerci a E E 3 ADOUCNIS GUIE crearan E a E E A A 10 LGetinge Stan edanda a 14 1 1 Introducing the PACSDK ssesessesessssecssoecessesess
99. PACNET PAC O ReadAIAIlExt hPort iSlot fValue 8 ref channelnumber PACNET UART Close hPort for int i 0 i lt 8 i Console WriteLine The Al i ToString fValueli ToString Console ReadLine The example displays the following output to the console The Al 0 1 023 The Al 1 0 001 The Al 7 0 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 255 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 18 pac _ReadAlAIll This function reads all the Al values of all channels in engineering mode of the Al module The function maybe causes the buffer overflow in some situation Syntax C BOOL pac_ReadAIAIll HANDLE hPort int slot float fValue Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 fValue out The array contains the Al values that read back from the Al module Return Value If the function
100. PWM API only supports to operate I 7K I 87K PWM modules Before using the PWM API functions refer to the previous chapter PAC_IO Reference first for more details regarding of the slot definition in local and how to use remote I O module In developing C C program for I 7K I 87K PWM modules connected or plugged to on the the WinPAC XPAC series device in addition to link PACSDK lib and it needs to link PACSDK_PWM lib to the user s project Besides the built executable file placed in the WinPAC XPAC series device must work with PACSDK dll and PACSDK_PWM dll In developing net CF program the project only refer to PACNET dIl and the built executable file placed in the WinPAC XPAC series device only works with PACNET dll and PACSDK dll For more information about I 7K I 87K PWM modules that are compatible with the XPAC WinPAC series please refer to I 87K series http www icpdas com products PAC i 8000 8000 IO modules htm i87k PWM module such as 87088W module l 7K series 7000 selection html such as l 7088 The suit of the PWM API functions isn t applied to the I 8K PWM module PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 333 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the PWM functions Functions Models XP 8000 XP 8000 Atom PE pac_SetPWMMode pac_GetPWMMode p
101. SavePWMConfig hPort iSlot uart_Close hPort C IntPtr hPort hPort PACNET UART Open int iSlot 1 bool iRet PACNET PWIM SavePWMConfig hPort iSlot PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 361 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 14 pac_GetPWMDIOStatus This function reads the status of the PWM output port and the digital input port Syntax C BOOL pac _GetPWMD OStatus HANDLE port int slot unsigned char pwmBitArr unsigned char diBitArr Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 pwmBitArr out The array O corresponds to PWM channel 0 and the array 1 corresponds to PWM channel 1 etc When the array is 0 it denotes that the PWM is inactive and 1 denotes that the PWM is active diBitArr out The array O corresponds to DI channel 0 and the array 1 corresponds to DI channel 1 etc When the bit is O it denotes that the DI is inactive and 1 denotes that the DI is active PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 362 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value I
102. SlotInterrupt slot unregister slot interrupt PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 90 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 3 pac_EnableSlotinterrupt This function performs hardware operations necessary to enable the specified hardware interrupt Syntax C void pac_EnableSlotinterrupt BYTE slot BOOL bEnable Parameters slot in Specifies the index of slot to enable interrupt or disable bEnable in Specifies the Slot interrupt turning on or not Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 91 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int slot 3 if slot is 3 int CALLBACK slot_callback_proc do something pac_InterruptDone slot return true if return true SDK will do pac_InterruptDone automatically else users should do pac_InterruptDone by themselves if needed if interrupt type is level trigger no matter return true or false needn t add pac_InterruptDone and it will work correctly void CintrDlg OnButton1 pac_RegisterSlotinterrupt slot slot_callback_ proc pac_EnableSlotinterrupt slot true _ enable slot interrupt void ClntrDlg OnButton2 pac_EnableSlotinterrupt slot false _ disable slot interr
103. To get extended error information call pac_GetLastError Examples This function has no examples PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 99 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 10 pac_InterruptDone This function signals to the kernel that interrupt processing has been completed Syntax C void pac_ InterruptDone BYTE slot Parameters slot in Specifies the slot to clear trigger Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 100 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C HANDLE hintr BOOL bExit false BYTE slot 0 DWORD INTP_Thread PVOID pContext while bExit WaitForSingleObject hIntr INFINITE do something pac_InterruptDone slot pac _EnableSlotInterrupt slot false pac_SetSlotInterruptEvent slot NULL CloseHandle pac_GetSlotInterruptEvent slot return O void CinterruptDlg OnButton1 bExit true pac_Interruptlnitialize slot pac_EnableSlotinterrupt slot true hintr pac_GetSlotinterruptEvent slot CreateThread NULL O INTP_Thread amp slot 0 NULL PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 101 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 3 Memory A
104. Value out The pointer of the DO safe value to read from the DO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 281 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadModuleSafeValueDO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do value BOOL ret pac_ReadModuleSafeValueDO hPort slot total channel amp do_ value uart_Close hPort C pac_ReadModuleSafeValueDO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do_ value BOOL ret pac_ReadModuleSafeValueDO_MF hPort slot total_ channel amp do_ value uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 282 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadModuleSafeValueDO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total_ channel 8 uint do value 0 bool ret PACNET PAC O ReadModuleSafeValueDO hPort slot total channel ref do_value PACNET UART Close hPort Console WriteLine The DO safe value is do_value ToStri
105. Y Y pac GetMacaddress pac_ReBoot Pac_EnableLED pac_BackwardCompatible pac_GetEbootVersion pac_GetComMapping Beta testing Beta testing PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 408 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Interrupt Functions Functions Models XP 8000 XP 8000 Atom PC XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx pac Registersiotinterrust Y oY oy y pac Unregistersotinterupt Y o Yy o oY y y y vy _ jpac tnablesiotinterruot Y Y oY oY vy yy vy vy jpacinterruptiniiae Yo oY oY oY ror vy vy y pac Getslotinterupttvent Y Y oy jeac settrggerwpe Yo oY oy fF oY vy y vy y fpac Getslotinterupttd Y oY OY oY fT vy vy vy vy ia lt j lt lt Y Y Y poy fy Ee i Y Y Y Y Y Y Y Y Y Y lt j lt lt lt lt Se Nore fe erm rece pee x xi z ee ree mee cee ee cal ee me me kN kkk age e ie a ee a ME ee EE ec e ee reece ce E PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 409 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Memory Access Functions Functions Models XP 8000 XP
106. _ClearcNT oY eee pac_ReadCNTOverflow i teModuleSafeValueDO_MF cece ee pe fe fete Le Y Y Y Y Y Y Y Y Y Y Y dModuleSafeValueDO_MF anmannan c_WriteModulePowerOnValueDO_MF Fosmeennane _ReadModulePowerOnValueDO_MF meosmacow teModuleSafeValueAO_MF faeces al dModuleSafeValueAO_MF z e c_WriteModulePowerOnValueAO_MF Cee 1 ee _ReadModulePowerOnValueAO_MF pac_GetModuleWDTConfig PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 413 te ree BDE HL HH lt lt H ERE Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_InitModuleWOTinterrupt eS ee es pac GetModulewoTinterruptsiatus Y Y y y _ pac SetModulewOrinterruptstatus Y Yo r y _ pac GetModulelastoutpursource vy oy x v v PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 414 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com PWM Functions Functions Models hd ne 1010 0 XP 8000 Atom PC Y Y Y Y Y lt pac SetPWMFrequency pac _GetPWMFrequency _y pac_SetPWMMode Y Y pac cepwomode Yo oY oY yf r vy vy vy fy iy Y Y Y y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y i yf vy vy vy v a r S ee rir
107. _WriteAO hPort iSlot iChannel iAO_TotalCh fValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 5 BOOL iRet pac_WriteAO 0 iSlot iChannel iAO_TotalCh fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 236 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteAO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 5 BOOL iRet pac_WriteAO_ MEF hPort iSlot iChannel iAO_ TotalCh fValue uart_Close hPort C pac_WriteAO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 2 int iChannel 2 int iAO_TotalCh 4 float fValue 5 bool iRet PACNET PAC O WriteAO hPort iSlot iChannel iAO TotalCh fValue PACNET UART Close hPort PAC Standard API Manual v1 0 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised November 2013 Page 237 gt lt E mail service icpdas com C pac_WriteAO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iAO_ TotalCh 8 float fValue 5 bool iRet PACNET PAC O WriteAO_MF hPort iSlot iChannel iAO_TotalCh fValue PACNET UART Close hPort Remarks 1 The function can support
108. ac ClearLastError DWORD errno Parameters errno in Specify the last error code Return Value This function does not return any value Examples This function has no examples Remarks The pac_ClearLastError function clears the last error that is the application is treated as SUCCESS PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 392 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 10 Misc API Supported PACs The following list shows the supported PACs for each of the Misc functions Functions Models XP 8000 XP 8000 Atom WideString pac_AnsiloWideString pac_WideToAnsiString pac_DoEvent pac_DoEvents pac_GetCurrentDirectory pac_GetCurrentDirectoryW PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 393 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Misc Functions The following functions are used to do convertion PACSDK Functions PACNET Functions Description AnsiString MISC AnsiString converts a unicode string to an ANSI byte array WideString MISC WideString converts an ANSI byte array to a Unicode string pac_AnsiToWideString N A converts an ANSI string to a Unicode string pac_WideToAnsiString N A converts a Unicode string to an ANSI string pac_DoEvent pac_DoEvents MISC DoEvents handles all events PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 394
109. ac_SetPWMDlITriggerConfig pac_GetPWMDItTriggerConfig pac SetPWMsStart pac _GetPWMD OStatus Set Ne cece E E cece Feces eect mec coe reece Uf ec ecco eee lt lt lt lt lt PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 334 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com PWM Functions The following functions are used to retrieve or set the PWM PACSDK Functions PACNET Functions Description 2 7 1 pac_SetPWMDuty This function sets the duty cycle value for a specified channel Syntax C BOOL pac SetPWMDuty HANDLE port int slot short chindex float duty Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify the channel to set the duty cycle value duty in The duty cycle value to write to the PWM module PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 336 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int
110. adAl 0 iSlot iChannel iAl_ TotalCh amp fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 246 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 3 int iChannel 0 int iAL_ TotalCh 8 float fValue 0 bool iRet PACNET PAC O ReadAl hPort iSlot iChannel iAl_TotalCh ref fValue PACNET UART Close hPort Console WriteLine The Al value is fValue ToString Console ReadLine The example displays the following output to the console The Al value is 1 008 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 247 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 16 pac _ReadAlHex This function reads the 2 s complement mode Al value of the Al module Syntax C BOOL pac_ReadAlHex HANDLE hPort int slot int iChannel int iAl_ TotalCh int iValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 248 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in
111. ail service icpdas com F 8 VP 2xW1 COMO COM3 COM2 Slot 0 2 RS 232 RS 485 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 451 Copyright 2013 ICP DAS Co Ltd All Rights Reserved DX E mail service icpdas com
112. ammatically by using the watchdog functions PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 115 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the Watchdog functions Functions Models XP 8000 XP 8000 Atom pac_DisableWatchDog pac_RefreshWatchDog pac_GetWatchDogTime pac_SetWatchDogTime PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 116 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Watchdog Functions The following functions are used to retrieve or set the Watchdog PACSDK Functions PACNET Functions Description pac_EnableWatchDog Sys WDT EnableWatchDog starts a watchdog operation pac_DisableWatchDog Sys WDT DisableWatchDog stops a watchdog operation PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 117 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 1 pac_EnableWatchDog This function starts a watchdog operation Before you run the program which enabled watchdog you have to enable EWF for protecting the system disk Syntax C BOOL pac EnableWatchDog int wdt DWORD value Parameters wat in Specifies the name of watchdog O Hardware watchdog PAC_WDT_HW 1 OS watchdog PAC_WDT_OS value in Specifies the watchdog time Return Valu
113. ample E Ea My Project Cbs BF Timer 4 System Data ig Interrupt 42 System Data Datat ag Memory 42 System Deploymen Ae MISC 42 System Drawing oi PAC_CALLBACE FUNC 42 System Windows F e PAC_IO a 4D System Eml Ae PAC_Reg 3 o D System Eml Ling ig PWM E 9 bin E H g obj Form vb Tip You can add the the namespace Imports PACNET to your code and it can simplify object names Such as PAC_10 GetBit instead of PACNET PAC 0 GeitBit PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 35 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 4 Visual Basic 6 0 Required header and library files The following list lists the libraries or DLL files you will need to include to develop a XPAC PC application or plug in gt PACSDK_vb dll gt pacsdk bas How to create a program with new SDK using Visual Basic 6 0 Step 1 Create a new project by using Visual Basic 6 0 Hew Project ay Amn A detek ESE Active DLL fait T Ss te H YE Wizard Actved Activex Data Froject Manager Document DI Document Exe OK Cancel Don tshow this dialog in the future PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 36 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 2 Copy pacsdk bas and PACSDK_vb dll to the application folder and Include pacsdk
114. and change to the slot which the 87k modules plug in slot 1 PACNET Sys ChangeSlot slot Send SOOM DCON command by uart API to get the module name ret PACNET UART SendCmd hPort PACNET MISC AnsiString SOOM buf Console WriteLine The Module on slot 1 is PACNET MISC WideString buf Console ReadLine The example displays the following output to the console The Module Name on slot 1 is 87061 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 54 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks When you use uart APIs and the IO modules are located as slots you have to call pac_ChangeSlot to the specified slot for communicating with the module Besides other low level operations may use pac_ChangeSlot to change the slot If you just use PAC_IO APIs you needn t care about this PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 55 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 6 pac _CheckSDKVersion This function is used to compare the version number of the currently used PACSDK dll with the specified version number This function does not support all versions of XPACSDK Syntax C BOOL pac CheckSDKVersion DWORD version Parameters version in The version number of the PACSDK If the version number is 1 0 0 1 or previous this parameter must
115. annel 2 bool ret1 PACNET PAC O WriteModuleSafeValueDO_MF hPort1 3 total _channel1 do value1 PACNET UART Close hPort1 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_I0 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 279 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 25 pac _ReadModuleSafeValueDO pac_ReadMod uleSafeValueDO_MF This function reads the safe value of the DO modules Syntax C for pac_ReadModuleSafeValueDO BOOL pac _ReadModuleSafeValueDO HANDLE hPort int slot int iDO_TotalCh unsigned long IValue C for pac_ReadModuleSafeValueDO_ MEF BOOL pac ReadModuleSafeValueDO_ MF HANDLE hPort int slot int iDO TotalCh unsigned long IValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 280 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 IDO_TotalCh in The total number of DO channels of the DO modules
116. anual v1 0 2 Last Revised November 2013 Page 120 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac _DisableWatchDog PAC_WDT_ OS C Demonstrate how to disable the watchdog PACNET Sys WDT EnableWatchDog 1 10 First enable the OS watchdog Console WriteLine Press any key to disable the watchdog in 10 Seconds Console ReadLine PACNET Sys WDT DisableWatchDog 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 121 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 3 pac _RefreshWatchDog This function refreshes the watchdog Syntax C void pac RefreshWatchDog int wdt Parameters wat in Specifies the Watchdog type O Hardware watchdog PAC_WDT_HW 1 OS watchdog PAC_WDT_OS Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 122 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_RefreshWatchDog PAC_WDT_ OS C Demonstrate how to refresh the watchdog PACNET Sys WDT EnableWatchDog 1 10 First enable the OS watchdog while true Console WriteLine Press any key to refresh the watchdog in 10 Seconds Console ReadLine PACNET Sys WDT RefreshWatchDog 1 PAC Standard API Manual v1 0 2
117. ast Revised November 2013 Page 141 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 3 uart SendExt This function sends data as a string through the COM port which has been opened When the checksum is enabled by using uart_EnableCheckSum function the two bytes of the checksum is automatically added to the string and the character OxOD is added to the end of the string to terminate the string buf This function replaces the uart_Send function Syntax C BOOL uart_SendExt HANDLE hPort LPCSTR buf DWORD out_Len Parameters hPort in Handle to the opened COM port buf in A point to a buffer containing the data to be transmitted out Len in A pointer to a variable that specifies the size in bytes of the data in buffer pointed to by the buf parameter Return Value If the function succeeds the return value is TRUE otherwise FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 142 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BOOL ret HANDLE hOpen char buf Length sprintf buf abcd hOpen uart_ Open COM1 9600 N 8 1 ret uart SendExt hOpen buf Length uart_Close hPort C bool ret IntPtr hPort string buf buf abcd hPort PACNET UART Open COM1 9600 N 8 1 ret PACNET UART SendExt hPort PACNET MISC AnsiString buf uint buf Leng
118. atchdog type O Hardware watchdog PAC_WDT_HW 1 OS watchdog PAC_WDT_OS value in Specifies the watchdog time PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 128 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value This function does not return any value Examples C DWORD dwtTime 1000 pac SetWatchDogTime PAC_WDT_OS dwTime C Set the OS watchdog time 10 seconds uint uTime 10 int PAC_WDT_OS 1 PACNET Sys WDT SetWatchDogTime PAC_WDT_OS uTime Remarks The same as the pac_EnableWatchDog function The unit of the parameter value for OS watchdog is second In addition the value cannot be zero for XPAC series only The value of the parameter value for hardware watchdog is limited to the range of 0 63 unit A unit is about 0 5 seconds 0 means the shortest timeout otherwise 63 is longest and it takes about 30 second PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 129 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 UART API Uart operations include basic management operations such as opening sending receiving and closing The following topics describe how you can operate uart programmatically using the uart functions Remarks We provide several COM port functions uart_Send uart_Recv to communicate with ICPDAS modules High
119. be 0x01000001 Return Value If the specified version number is eailer than the currently used PACSDK dll the return value is TRUE If the specified version number is later than the currently used PACSDK dll the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 56 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Added this API in the begin of your application BOOL bVersion bVersion pac_CheckSDKVersion 0x01000001 if your application should use newer than version 1 0 0 1 if bVersion MessageBox The XPacSDK dIl version is wrong display some warning and close the application C Added this API in the begin of your application bool bVersion bVersion PACNET Sys CheckSDKVersion 0x01000001 if your application should use newer than version 1 0 0 1 if bVersion Console WriteLine The PACSDK dll version is wrong display some warning and close the application Console ReadLine f the version of the currently used PACSDK dll is not 1 0 0 1 or earlier the output to the console is as below H The PACSDK dll version is wrong PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 57 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 7 pac _ModuleExists This functions specifies whether the local IO modul
120. below wes2 011 03 how_to set_up multi_port_modules_tc pdf Use I 87K series modules Only use COM1 to communicate with l 87K series modules Please refer to Sec 5 UART API PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 139 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 2 uart Close This function closes the COM port which has been opened Syntax C BOOL uart_ Close HANDLE hPort Parameters hPort in The handle to the opened COM port to close Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 140 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BOOL ret HANDLE hOpen hOpen uart_Open COM1 9600 N 8 1 ret uart_Close hOpen C bool ret IntPtr hOpen hOpen PACNET UART Open COM1 9600 N 8 1 ret PACNET UART Close hOpen if ret Console WriteLine Close COM1 success else Console WriteLine Close COM1 fail Console ReadLine The example displays the following output to the console if close successfully ff Close COM1 success Otherwise ry Close COM 1 fail Remarks The function for a specified COM port should not be used after it has been closed PAC Standard API Manual v1 0 2 L
121. cSDK dll XPacNet dll working with the old DCON modules Note 2 on XPAC device and without using multi function DCON modules Note 1 The user s program can continue to use the old library without needing to be modified The Old SDK will continue to maintain Fix the bugs and released regularly but will not add new features Use the old SDK as following flowchart The VC project required to link XPacSDK lib while building and the built executable file placed in the XPAC series device must work with XPacSDK dll VC Project Link C EXE ARM XPacSDK lib The C VB net project required to refer to XPacNet dll while building and the built executable file placed in the XPAC series device must work with XPacNet dll and XPacSDK dil CH VB net ne rer Project Refer to XPacNet dll XPacSDK dll XPacSDK dll ee an one PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 441 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com ii The users have used XPAC series devices and their programs is based on the old SDK XPacSDK dll working with the old DCON modules and multi function DCON modules on XPAC device The new PACSDK dll provides pac_xxx_MF API functions that allow access to Multi function modules so the code must be updated in order to use the new PACSDK dIl in the program iii The users have never used XPAC series devices Their progra
122. c_ClearDICNT BOOL pac_ClearDICNT HANDLE hPort int slot int iChannel int iD TotalCh C for pac_ClearDICNT_MF BOOL pac ClearDICNT_MF HANDLE hPort int iAddrSlot int iChannel int iDI TotalCh PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 230 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot iAddrSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that the counter value belongs IDL_TotalCh in Total number of the DI channels of the DI module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 231 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ClearDICNT Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iD TotalCh 8 BOOL iRet pac_ClearDICNT hPort iSlot iChannel iDI_TotalCh uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iDI_ TotalCh
123. cations and updates s esessesessesessssecsesecescecescecesoecesseceseececee 1 For WinPAC series 2 For XPAC series Appendix D Using the Multi function DCON module ccscsecsccscescees 1 On WinPAC devices 2 On XPAC devices Appendix F Comparison of Defined Slots and COM Ports cscsscsscseeees Fs XP 8041 XP 3041 CE6 risiini F 2 XP 8341 XP 8741 XP 8341 CEG XP 8741 CEG cssscossscesscnssccssccsccecccesscesseuees F 3 XP 8141 Atom XP 8141 AtOM CEG csscsscsscsscesceccecceccescecceccecceccecceccececscescess F 4 XP 8341 Atom XP 8741 Atom XP 8341 Atom CE6 XP 8741 Atom CE6 c00 Fo WV POUT sccacesotesvecscedanaawiasvssabaeuungswianyaeiianpdeuaawses E domsuse tus daeste cousmsenees F 6 WP 84x1 WP 88x1 siieisiats cos cunsicins bebentaadewaieseuabsctossassanveboheateceveseuesene sues dactcavabelasters F Z WP 5141 WP 5141 0D as socaccnsssesiansasieaevaaienagsasesacdaeerniaisansvenssaasenacesseceedadssanaasenaiens F8 VIPEZKVV E vndenisseavs cand cocaeenaragsnccaaneeeeseuapensoeancennas ease danesaneudeneopanse aa PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 9 427 428 429 430 433 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com About this Guide This manual is intended for software developers who want to integrate XPAC PC functionality into their applications What Models and PC OS are co
124. ccess API The memory access functions provide the memory management that may be used for reading writing EEPROM or SRAM or mounting ummounting MicroSD PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 102 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the memory access functions Functions Models hd ne 101010 XP 8000 Atom XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x pac SDMount pac _SDOnside pac SDUnmount A WP 5xxx only supports the memory type 1 EEPROM not type 0 SRAM PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 103 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com WP 5xxx VP 25Wx VP 23Wx Memory Access Functions The following functions are used to retrieve or set the memory PACSDK Functions PACNET Functions Description pac_GetMemorySize Memory GetMemorySize retrieves the size of the specified memory pac_GetRotarylD Memory ReadMemory retrieves the position number of the rotary switch pac_WriteMemory Memory WriteMemory stores data in the specified memory pac_EnableEEPROM Memory EnableEEPROM retrieves the version number of the current PACSDK dIl PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 104 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas c
125. contact ICP DAS Customer Support in one of the following ways Visit the ICP DAS Storage Manager technical support Web site at http www icpdas com fag faq htm gt Submit a problem management record PMR electronically from our Web site at http www icodas com sevices contact customerservice htm gt Send e mail to service icpdas com PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 12 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Revision History The table below shows the revision history Revision Date Description PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 13 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 Getting Started This chapter provides a guided tour that describes the steps needed to know download copy and configure of the basic procedures for user working with the PACSDK for the first time 1 1 Introducing the PACSDK PACSDK are software development kits that contain header files libraries documentation and tools required to develop applications for XPAC series and PC PACSDK has replaced XPACSDK and DCON_PC ICP DAS has released a new SDK PACSDK which merged and replaced the XPACSDK and DCON_ PC XPACSDK DCON PC y PAC SDK The XPACSDK and DCON_PC have been unified and renamed PACSDK The new PACSDK dll provides support x86 platforms for th
126. ction succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short iChannel 2 unsigned long ulfreq 1 BOOL iRet pac_SetPWMFrequency hPort iSlot iChannel ulfreq uart_Close hPort C IntPtr hPort hPort PACNET UART Open int iSlot 1 short iChannel 2 uint ulfreq 1 bool iRet PACNET P WIM SetPWMFrequency hPort iSlot iChannel ulfreq PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 341 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 4 pac_GetPWMFrequency This function reads the frequency value for a specific channel Syntax C BOOL pac GetPWM Frequency HANDLE port int slot short chindex unsigned long freq Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify the channel to get the frequency value freq in The frequency value to read from the PWM module PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 342 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail ser
127. d D lt E mail service icpdas com 2 6 34 pac SetModuleWDTConfig This function enables disables the host watchdog and sets the host watchdog timeout value of a module Syntax C BOOL pac SetModuleWDTStatus HANDLE hPort int slot short enStatus unsigned long wdtTimeout int ifWDT Overwrite PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 320 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 enStatus in 1 the host watchdog is enabled 0 the host watchdog is disabled wat Timeout in The unit of return value is 100ms If WDT_Overwrite only for i 8k in 1 the host watchdog does overwrite 0 the host watchdog does not overwrite Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 321 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 1 short sStatus 0 unsigned long ulWDTtime 0 int i
128. d API Manual v1 0 2 Last Revised November 2013 Page 46 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 2 pac_GetRotarylD This function retrieves the position number of the rotary switch Syntax C int pac_GetRotarylD Parameters This function has no parameters Return Value If the function succeeds the return value is the position number of the rotary switch If the function fails the return value is invalid value To get extended error information call pac_GetLastError PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 47 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int RotarylD RotaryID pac_GetRotarylD C int RotarylD RotarylD PACNET Sys GetRotarylID Console WriteLine The Rotary ID is RotaryID ToString Console ReadLine The example displays the following output to the console The Rotary ID is 0 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 48 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 3 pac_GetSerialNumber This function retrieves the serial number of the XPAC hardware ID Syntax C void pac GetSerialNumber LPSTR SerialNumber Parameters SerialNumber out The serial number of the XPAC hardware ID Return Value This function does not r
129. dDI_MF pac _ReadDIO pac_ReadDIO_MF PAC_10 ReadDIO reads the DI and the DO values of the DIO module PAC_10 ReadDIO_MF pac _ReadDICNT pac_ReadDICNT_ MF PAC _lO ReadDICNT reads the counts of the DI channels of the DI module PAC_10 ReadDICNT_MF pac_ClearDICNT pac_ClearDICNT_MF PAC_1O ClearDICNT clears the counter value of the DI channel of the DI module PAC_1O ClearDICNT_MF pac_WriteAO pac_WriteAO_MF PAC _1O WriteAO writes the AO value to the AO modules PAC_lO WriteAO_MF pac_ReadAO pac_ReadAO_MF PAC 10 ReadAO reads the AO value of the AO module pac_ReadAl PAC 10 ReadAl reads the engineering mode Al value of the Al module pac_ReadAlHex PAC 1O ReadAlHex reads the 2 s complement mode Al value of the Al module pac_ReadAIAllExt PAC 10 ReadAIAIlExt reads all the Al values of all channels in engineering mode of the Al pean remem a et teneteene et pac_ReadAIAll PAC IO ReadAlAll reads all the Al values of all channels in engineering mode of the Al p module pac_ReadAlAllHexExt PAC 1O ReadAIAllHexExt reads all the Al values of all channels in 2 s complement mode of the pean peemmwanee limi en pac_ReadAlAllHex PAC 10 ReadAIAllHex reads all the Al values of all channels in 2 s complement mode of the pea penne mau herein pac_ReadCNT PAC 10 ReadCNT reads the counter values of the counter frequency modules pac_ClearCNT PAC 10 ClearCNT clears the counter values of the counter frequency modules pac_ReadCNTOverflow PAC 10 ReadCNTOve
130. des are defined as DWORD values If you are defining an error code ensure that your error code does not conflict with any PacSDK defined error codes We recommend that your error code should be greater than 0x20000 For more information about the definition of error codes please refer to pac_GetLastError in this document PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 386 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 9 3 pac GetErrorMessage This function retrieves a message string Syntax C void pac GetErrorMessage DWORD dwMessagelD LPTSTR lpBuffer Parameters dwMessagel D in Specify the 32 bit message identifier for the requested message loBuffer out A pointer to a buffer that receives the error message Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 387 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int main int argc char argv if argc lt 3 printf usage ReadMemory address dwLength mem_type n n printf where n printf address n printf the memory address where read from n printf dwLength n printf number of characters to be read n printf mem_type n printf 0 SRAM n printf 1 EEPROM n else BYTE buffer 4096 B
131. dule with 16 DI channels and 16 DO channels PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 68 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int iDIO_ Slot 1 int Type 0 Type pac_GetModuleType iDIO_ Slot if Type Oxe2 Type O0xc2 The module is DIO module C byte slot 1 int ModuleType 0 ModuleType PACNET Sys GetModuleType slot if ModuleType 0xCO Console WriteLine The module is an 3000W module with 16 DO channels else Console WriteLine The module type value is Convert ToString ModuleType 16 Console ReadLine f an 1 8000W module with 16 DO channels plugged into slot 1 the output to the console is as below Ds The module is an l 8000W module with 16 DO channels Else output the module type to the console as below The module type value is 40 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 69 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 12 pac_BuzzerBeep This function generates simple tones on the speaker Syntax C void pac BuzzerBeep WORD count DWORD milliseconds Parameters count in Specifies the number of beeps milliseconds in Specifies the duration of the sound measured in milliseconds Return Value This function does not return any value PAC Standard API Manual v1
132. e If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 118 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C DWORD second 10 bool ret ret pac_EnableWatchDog PAC_WDT_OS second C Enable the OS watchdog and set the reset time 10 seconds int PAC_WDT_OS 1 uint second 10 bool ret_err ret_err PACNET Sys WDT EnableWatchDog PAC_WDT_OS second Remarks The unit of the parameter value for OS watchdog is second In addition the value cannot be zero for XPAC series only The value of the parameter value for hardware watchdog is limited to the range of 0 63 unit A unit is about 0 5 seconds 0 means the shortest timeout otherwise 63 is longest and it takes about 30 seconds PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 119 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 2 pac_DisableWatchDog This function stops a watchdog operation Syntax C void pac DisableWatchDog int wdt Parameters wat in Specifies the Watchdog type O Hardware watchdog PAC_WDT_HW 1 OS watchdog PAC_WDT_OS Return Value This function does not return any value PAC Standard API M
133. e XPAC series and PC PACSDK dll x86 is linked to C programs for the XPAC series to replace the previous SDK XPACSDK dll and for the PC to replace the previous SDK DCON_PC dll The PACNET dIl is used for Net CF programs C VB for both the XPAC series and PC to replace the previous SDKs XPacNet dll and DCON_PC_DotNet dll PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 14 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com New Previous SDK files comparison items XPACSDK Library DCON_PC Library PACSDKLibrary Development header files XPacSDK h DCON_Fun h PACSDK h Development library files XPacSDK lib DCON_PC lib PACSDK lib Target device Native DLL files XPacSDK dll DCON_PC dll PACSDK dll Target device NET CF DLL files XpacNet dll DCON_PC_DotNet dll PACNET dll Benefits of the unified SDK include Easily migrates custom PC programs to the XPAC series Easily migrates custom XPAC programs to the PC A suite of PACSDK APIs is almost same as the previous SDK KPACSDK dll but there are some modifications and updates Refer to the Appendix C for more details PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 15 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 2 Copying the PACSDK Users just need through a simple action that copies the PACSDK dll to a specified folder and then they can use the PACSDK library
134. e automatically set to disabled PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 366 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short iChannel 2 long Icnt BOOL iRet pac_GetPWMPulseCount hPort iSlot iChannel amp lcnt uart_Close hPort C IntPtr hPort PACNET UART Open int iSlot 1 short iChannel 2 int Icnt O bool iRet PACNET PWIM GetPWMPulseCount hPort iSlot iChannel ref Icnt PACNET UART Close hPort Console WriteLine The return value is Icnt ToString Console ReadLine The example displays the following output to the console The return value is 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 367 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 8 Backplane Timer API Backplane timer API supports to hardware timer including timerout timer1 timer2 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 368 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the backplane timer
135. e exist in the XPAC or not Syntax C BOOL pac _ModuleExists HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open Because the API only uses for local modules this parameter must be 0 Slot in The slot in which module is to check exists or not Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 0 2 Last Revised November 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C if you want to check a module which is in the slot 5 BOOL bExist bExist pac_ModuleExists 0 5 if bExist MessageBox The module exist else MessageBox The module unexist C Check if a module exists in the slot 5 of the XPAC bool bExist IntPtr hPort PACNET UART Open 0 bExist PACNET Sys ModuleExists hPort 5 if bExist Console WriteLine A module exists in the slot 5 of the XPAC else Console WriteLine No module exists in the slot 5 of the XPAC Console ReadLine f there isa local module in the slot 5 of a XPAC the output to the console is as below A module exists in the slot 5 of the XPAC Else the output to the console is as below I No module exists in the slot 5 of the XPAC PAC Standard API Ma
136. e hOpen PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 157 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks CTO_READ_TOTAL_TIMEOUT A constant used to calculate the total time out period for read operations in milliseconds A value of zero for the CTO_READ_TOTAL_TIMEOUT indicates that total time outs are not used for read operations CTO_WRITE_TOTAL_TIMEOUT A constant used to calculate the total time out period for write operations in milliseconds A value of zero for the CTO_WRITE_TOTAL_TIMEOUT indicates that total time outs are not used for write operations CTO_READ_RETRY_TIMEOUT A constant used to calculate the time out period for read operations in system tick count CTO_TIMEOUT_ALL A constant used to calculate the total time out period for write and read operations in milliseconds A value of zero for the CTO_TIMEOUT_ ALL indicates that total time outs are not used for write and read operations PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 158 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 9 uart_EnableCheckSum This function turns on the check sum or not Add two checksum bytes to the end of the data which is used to produce checksum Syntax C void uart_EnableCheckSum HANDLE hPort BOOL bEnable Parameters hPort in Handle to the opened COM port bEnable in
137. ecessecesoecesseceseecesseoeceeoesssoesssoeoe 14 1 2 Copying the PACSDK iaeviciricsinciece Gideon atiiade a a aE nae tedeedactueds Aidsuledicetvacsnte dus 16 1 3 Setting up the Development Environment ccccscscsccscsceccccccsceccccccscsceececs 18 1 3 1 C C based on Visual Studio 19 1 3 2 Visual C 22 1 3 3 VB net 29 1 3 4 Visual Basic 6 0 36 Z PAG API FUNRCTONS a yiciccstcocencareccsitidecvenecesetcavtuovincavaccsdeedcaceneemncataaweeuteseesseit 39 2 1 System Information API sisssesssssceassacciesscsutoncscssntarcewessetepnetansacubennteinatevesansiianes 40 2 1 1 pac_GetModuleName 45 2 1 2 pac_GetRotaryID 47 2 1 3 pac_GetSerialNumber 49 2 1 4 pac _GetSDKVersion 51 2 1 5 pac_ChangesSlot 53 2 1 6 pac_CheckSDKVersion 56 2 1 7 pac_ModuleExists 58 2 1 8 pac _GetOSVersion 61 2 1 9 Pac _GetCPUVersion 63 2 1 10 Pac_EnableLEDs 65 2 1 11 pac_GetModuleType 67 PAC Standard API Manual v1 0 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Last Revised November 2013 Page 3 2 14 12 2143 2 1 14 2 1 15 2 1 16 Z AAS 2 1 18 2119 2 1 20 2 2 Interrupt API 2 2 1 2 22 OS i 2 2 4 2 2 2 2 6 2 2 7 2 2 8 2 2 9 2 2 10 2 3 Memory Access API 2 3 1 2 3 2 23 2 3 4 2 4 Watchdog API 2 4 1 PAC Standard API Manual v1 0 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved pac_BuzzerBeep pac_
138. ection because of the definition of the parameters and Return Value of this pair of functions are the same The functions used to access the pure DIO DCON modules cannot be used to access Multi function DCON modules The function will return 0x14003 meaning of Uart response error if use the function to acccess Multi function DCON modules and vice versa PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 178 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Supported PACs The following list shows the supported PACs for each of the PAC_IO functions Functions Models XP 8000 XP 8000 Atom PC pac_GetBit pac_WriteDO pac_WriteDO_MF pac_WriteDOBit pac_ReadDO pac_ReadDO_ MF pac_ReadDI pac_ReadDI_ MF pac_ReadDIO pac_ReadDIO_MF pac_ReadDILatch pac_ClearDlLatch pac_ReadDIOLatch pac_ClearDIOLatch pac_ReadDICNT pac_ReadDICNT_MF pac_ClearDICNT pac_ClearDICNT_MF pac_WriteAO pac_WriteAO_MF pac_ReadAO pac_ReadAO_MF pac_ReadAl pac_ReadAlHex pac_ReadAlAllExt pac_ReadAIAll PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 179 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com peacciearcnt OY pac_WriteModuleSafeValueDO pac_Wri y teModuleSafeValueDO_MF i ES pac_WriteModulePowerOnValueDO pa Y Y Y Y Y Y Y Y Y Y c_WriteModulePowerOnValueDO_MF pac_ReadModulePowerOnValueDO pac Y Y Y Y Y Y _ReadModulePowerOnVal
139. ed CD FTP are linked with the new PACSDK dIl so users should refer to the demo programs and follow the API instructions when developing new programs based on the new PACSDK dll rather than those for the WinPACSDK Use the new SDK as following flowchart The VC project required to link PACSDK lib while building and the built executable file placed in the WinPAC series device must work with PACSDK dll VC Project Link C EXE ARM PACSDK dll PACSDK lib PC WinPAC The C VB net project required to refer to PACNET dIl while building and the built executable file placed in the WinPAC series device must work with PACNET dll and PACSDK dll CH VB net ease eee Project Link PACNET dll PC WinPAC PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 439 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Notes 1 Multi function DCON modules are defined as modules that mainly act as AIO or Counters but are equipped with DIO channels Such as the I 87005W I 87016W I 87082W I 7016 I 7088 etc 2 Old DCON module definition Non multi function DCON modules are defined as Old DCON modules PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 440 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 On XPAC devices i The users have used XPAC series devices and their programs is based on the old SDK XPa
140. en BYTE slot 1 int total_ channel 8 DWORD do value BOOL ret pac_ReadDO hPort slot total channel amp do_value uart_Close hPort Example 2 f the module is 8k local BYTE slot 1 int total channel 8 DWORD do_ value BOOL ret pac_ReadDO O slot total _ channel amp do_value C pac ReadDO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE slot 1 int total channel 8 DWORD do_ value BOOL ret pac_ReadDO_MBF hPort slot total channel amp do_value uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 200 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadDO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 2 int total_ channel 16 uint do value 0 bool ret PACNET PAC O ReadDO hPort slot total channel ref do_value PACNET UART Close hPort Console WriteLine The DO value is do value ToString Console ReadLine The example displays the following output to the console Js The DO value is 4 C pac_ReadDO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total channel 2 uint do value 0 bool ret PACNET PAC O ReadDO_MEF hPort slot total channel ref do_value PACNET UART Close hPort
141. en PACNET UART Open COM1 115200 N 8 1 cmd PACNET MISC AnsiString buf ret PACNET UART SendCmdExt hOpen cmd 64 result 64 if ret Console WriteLine Console ReadLine Remarks This function calls PurgeComm to clear serial COM port input and output buffer Refer to Remarks of uart_SendExt uart_RecvExt for more details PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 155 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 8 uart_SetTimeOut This function sets the time out timer Syntax C void uart_SetTimeOut HANDLE hPort DWORD msec int ctoType Parameters hPort in Handle to the opened COM port msec in Millisecond to the timer cto Type in Specifies the timer type of time out as following O CTO_TIMEOUT_ALL 1 CTO_READ_RETRY_TIMEOUT 2 CTO_READ_TOTAL_TIMEOUT 3 CTO_WRITE_TOTAL_TIMEOUT Return Value This function has does not return a value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 156 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C HANDLE hOpen DWORD mes hOpen uart_Open COM1 9600 N 8 1 mes 300 uart_SetTimeOut hOpen mes CTO_TIMEOUT_ALL uart_Close hOpen C IntPtr hOpen uint MSC hOpen PACNET UART Open COM1 9600 N 8 1 msc 300 PACNET UART SetTimeOut hOpen msc 0 PACNET UART Clos
142. er need use the macro PAC_REMOTE_1IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 290 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 27 pac _ReadModulePowerOnValueDO pac_Rea dModulePowerOnValueDO_MF This function reads the power on value of the DO modules Syntax C for pac_ReadModulePowerOnValueDO BOOL pac _ReadModulePowerOnValueDO HANDLE hPort int slot int iDO_TotalCh unsigned long IValue C for pac_ReadModulePowerOnValueDO_ MF BOOL pac ReadModulePowerOnValueDO_ MF HANDLE hPort int slot int iDO TotalCh unsigned long IValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 291 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 IDO_TotalCh in The total number of DO channels of the DO modules Value out The pointer of the DO power on value to read from the DO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 292 Copyright 20
143. er 2013 Page 260 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iValue 8 int ichannelnumber 0 BOOL iRet pac_ReadAlAllHexExt hPort iSlot iValue 8 amp ichannelnumber uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int ichannelnumber 0 int iValue 8 BOOL iRet pac_ReadAIAllHexExt 0 iSlot iValue 8 amp ichannelnumber PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 261 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 3 int ichannelnumber 0 int iValue new int 8 bool iRet PACNET PAC O ReadAIAllHexExt hPort iSlot iValue 8 ref ichannelnumber PACNET UART Close hPort for int i 0 i lt 8 i Console WriteLine The Al i ToString iValue i ToString Console ReadLine The example displays the following output to the console The Al 0O 3316 The Al 1 3 The Al 7 0 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O
144. ersion retrieving PacSDK version PacNET PACNET Sys GetPacNetVersion retrieving PacNET version Console WriteLine The PacSDK dll version is PacSDK Console WriteLine The PacNET dll version is PacNET Console ReadLine The example displays the following output to the console The PacSDK dll version is 4 2 3 6 H The PacNET dll version is 2 1 0 3 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 52 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 5 pac_ChangeSlot This function handles the slot of the XPAC from one to another Syntax C void pac ChangeSlot BYTE slotNo Parameters slotNo in Specifies the slot number which the 87K module plug in Return Value This function does not return a value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 53 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BYTE slot HANDLE hPort BOOL ret char buf Length hPort uart_Open pac_ChangeSlot slot Change to the slot which the 87k modules plug in ret uart_SendCmd hPort SOOM buf SOOM ask the device name C This example demonstrates how to change slot if you want to use the uart API byte slot IntPtr hPort bool ret byte buf new byte 10 hPort PACNET UART Open Assign the slot number
145. erved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short Status 0 BOOL iRet pac_SyncPWMStart hPort iSlot Status uart_Close hPort C IntPtr hPort hPort PACNET UART Open int iSlot 1 short Status 0 Stops the PWM synchronization bool iRet PACNET PWIM SyncPWMStart hPort iSlot Status PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 359 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 13 pac_SavePWMConfig This function saves the PWM configuration Syntax C BOOL pac_SavePWMConfig HANDLE port int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 360 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 BOOL iRet pac_
146. eserved D lt E mail service icpdas com 2 7 8 pac _GetPWMDITriggerConfig This function reads the hardware trigger from a specific port Syntax C BOOL pac _GetPWMDITriggerConfig HANDLE port int slot short chindex short config Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify a channel to read the hardware trigger config out 0 The hardware trigger disabled 1 The hardware trigger start is enabled 2 The hardware trigger stop is enabled PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 350 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short iChannel 2 short mode BOOL iRet pac_GetPWMDITriggerConfig hPort iSlot iChannel amp mode uart_Close hPort C IntPtr hPort PACNET UART Open int iSlot 1 short iChannel 2 short mode 0 bool iRet PACNET PWIM GetPWMDITriggerConfig hPort iSlot iChannel ref mode PACNET UART Close hPort Console Wr
147. eturn a value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 49 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt lt E mail service icpdas com Examples C char SN 32 pac_GetSerialNumber SN C string SN SN PACNET Sys GetSerialNumber Console WriteLine The Serial Number is SN Console ReadLine The example displays the following output to the console The Serial Number is 01 38 11 79 14 00 00 2F Remarks If the retrieved value is null means the function executes failure or the device is not valid product PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 50 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 4 pac_GetSDKVersion This function retrieves the version number of the current PACSDK dIll Syntax C void pac_GetSDKVersion LPSTR sdk_ version Parameters sdk_version out The version number of the PACSDK Return Value This function does not return a value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 51 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C char SDK 32 pac_GetSDKVersion SDK C n net ths API is different with VC And there are two API pac_GetPacSDKVersion and pac GetPacNetVersion string PacSDK string PacNET PacSDK PACNET Sys GetPacSDKV
148. eturn value is 0 Calling pac_GetLastError function will get an error code pac ERR uart READ TIMEOUT PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 151 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BOOL ret HANDLE hPort char buf 10 hPort uart_ Open COM2 9600 N 8 1 ret uart_Recv hPort buf uart_Close hPort C bool ret IntPtr hPort byte result new byte 64 hPort PACNET UART Open COM3 9600 N 8 1 ret PACNET UART Recv hPort result if ret Console WriteLine PACNET MISC WideString result Console ReadLine PACNET UART Close hPort Remarks The terminate characters is OxOD Refer to uart_SetTerminator function to change For example a Check sum is disabled This function receives five bytes ABCD 0x0D The buf will be five bytes ABCD 0x0 b Check sum is enabled This function receives four bytes ABCD The buf will be four bytes ABCD But the reurn value is 0 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 152 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 7 uart_SendCmdExt This function sends commands through the COM port which has been opened This function is a combination of uart_SendExt and uart_RecveExt The operation for sending a command is the same as uart_ SendExt The operation for receiv
149. evised November 2013 Page 170 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C HANDLE hPort uart_Open COM5 115200 N 8 1 BOOL ret uart_ GetLineStatus hPort DSR _ the pin DSR for example if ret printf The status of DSR is ON n else printf The status of DSR is OFF n uart_Close hPort C IntPtr hPort PACNET UART Open COM4 115200 N 8 1 the pin DSR for example uint ret PACNET UART GetLineStatus hPort PACNET UART DSR if ret 1 Console WriteLine The status of DSR is ON else Console WriteLine The status of DSR is OFF Console ReadLine PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 171 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 15 uart_GetDataSize This function retrieves the number of bytes received by the serial provider but not yet read by a uart_Recv operation or of user data remaining to transmitted for write operations Syntax C BOOL uart_GetDataSize HANDLE hPort int data_type Parameters hPort in Handle to the opened COM port data_type in A value specifies to retrieve in or out buffer This parameter can be following values O define IN DATA 1 define OUT DATA Return Value The number of bytes in out buffer but not yet read write PAC Standard API Manual v1
150. f the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 unsigned char pwm 32 unsigned char di 32 BOOL iRet pac_GetPWMDIOStatus hPort iSlot pwm di uart_Close hPort C IntPtr hPort hPort PACNET UART Open int iSlot 1 byte pwm new byte 32 byte di new byte 32 bool iRet PACNET P WIM GetPWMD1IOStatus hPort iSlot pwm di PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 363 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 15 pac_SetPWMPulseCount This function sets the PWM step value for a specific channel Syntax C BOOL pac _SetPWMPulseCount HANDLE port int slot short chindex long cnt Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify the channel to set the PWM step value cnt in The PWM steps 0x0001 to OxFFFF When set to more than 1 step the PWM continuous mode will be automatically set to disabled PAC Standard API Manual v1 0 2 Last Revised November 2013 Page
151. for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from 0 to 255 2 The comparison table of pac_WriteAO pac_WriteAO_MEF Functions and available modules are as following Since November 1 2012 pac_Write AO pac_WriteAOQ_MF I 87024W CW DW RW 87024 I 87026PW 87028CW UW I 87022 I 87026 l 7022 l 7024 8024R PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 238 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 14 pac _ReadAO pac ReadAO_MF This function reads the AO value of the AO module Syntax C BOOL pac _ReadAO HANDLE hPort int slot int iChannel int iAO TotalCh float fValue C BOOL pac _ReadAO MF HANDLE hPort int slot int iChannel int iAO_TotalCh float fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 239 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the AO value from the channel
152. function writes the AO value to the AO modules Syntax C for pac_WriteAO BOOL pac_WriteAO HANDLE hPort int slot int iChannel int iAO TotalCh float fValue C for pac_WriteAO_MF BOOL pac _WriteAO_MF HANDLE hPort int iAddrSlot int iChannel int iAO_TotalCh float fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 234 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot iAddrSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that is written the AO value to IAO_ TotalCh in The total number of the AO channels of the AO module float fValue in The AO value to write to the AO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 235 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_WriteAO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 5 BOOL iRet pac
153. functions Functions Models XP 8000 XP 8000 Atom pac_GetBPTimerTimeTick_ms Poy fy pac_GetBPTimerTimeTick_us pac SetBPTimer pac SetBPTimerOut pac _SetBPTimerlnterruptPriority pac_KillBPTimer PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 369 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Backplane Timer Functions The following functions are used to retrieve or set the backplane timer PACSDK Functions PACNET Functions Description l l l l returns the number of milliseconds that have elapsed since the system was pac_GetBPTimerTimeTick_ms BPTimer GetBPTimerTimeTick_ms started excluding any time that the system was suspended l l l l l returns the number of microsecond that have elapsed since the system was pac_GetBPTimerTimeTick_us BPTimer GetBPTimerTimeTick_us started excluding any time that the system was suspended pac_SetBPTimer BPTimer SetBPTimer creates a hardware timer with the specified time out value pac_SetBPTimerOut BPTimer SetBPTimerOut creates a hardware timer with the specified time out value of high low wave pac_SetBPTimerlInterruptPriority BPTimer SetBPTimerInterruptPriority sets the priority for a real time thread of the backplane timer destroys the specified timer event identified by type set by an earlier call to pac_KillBPTimer BPTimer KillBPTimer pac _SetBPTimer PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 37
154. g ansiString Console ReadLine The string This is a unicode string will show the console mode correctly Remarks The maximum size of the string buffer is 2 kbytes PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 402 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 10 5 pac DoEvent pac_DoEvents This function handles all events When you run a Windows Form it creates the new form which then waits for events to handle Each time the form handles an event it processes all the code associated with that event All other events wait in the queue While your code handles the event your application does not respond If you Call pac_DoEvents in your code your application can handle the other events Syntax C void pac DoEvent C void pac DoEvents Parameters This function has no parameters Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 403 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int counter 0 char buf 10 bFlag true while bFlag pac_DoEvents sprintf buf d counter SetDlgltemText IDC_EDIT1 buf counter PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 404 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpda
155. ge 425 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com The flowchart for a C program that is now calling the new SDK PACSDK dIl is as follows C EXE ARM PACSDK dIl ARM Project Built as Linked with Code C EXE x86 PACSDK dIl x86 The benefits of using the new SDK A program applied to WinPAC series modules and the other program applied to XPAC series modules are functionally identical because using the same header file and the API functions and error code on the library are exactly the same the source code can be shared for two programs The Project with the shared source code can be built as two different platform executable programs selecting the different Platform settings in the development environment while build the project The results of the above are Project is built as an ARM based executable program which runs with the ARM based PaCSDK dll and it s also built as an x86 based executable program which runs with x86 based PaCSDK dIl PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 426 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C 2 PACNET SDK modifications and updates The NET Compact Framework environment allows multiple high level languages C VB to be used on different platforms without needing to be rewritten for specific architectures The new PACNET dll replaces the previous N
156. ght 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModuleSafeValueAO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int iChannel 2 int iAO_ TotalCh 8 float fValue 5 bool iRet PACNET PAC O0 WriteModuleSafeValueAO hPort slot iChannel iAO_TotalCh fValue PACNET UART Close hPort C pac_WriteModuleSafeValueAO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int iChannel 2 int iAO_ TotalCh 8 float fValue 5 bool iRet PACNET PAC 0 WriteModuleSafeValueAO_MF hPort slot iChannel iAO_ TotalCh fValue PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 299 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 29 pac _ReadModuleSafeValueAO pac_ReadMod uleSafeValueAO_MF This function reads the AO safe value of the AO module Syntax C BOOL pac _ReadModuleSafeValueAO HANDLE hPort int slot int iChannel int iAO_TotalCh float fValue C BOOL pac ReadModuleSafeValueAO MF HANDLE hPort int slot int iChannel int iA
157. h used for both WinPAC or ViewPAC series program and XPacSDK h used for the XPAC series program are must be replaced by PACSDK h e Replace the previous library file by PACSDK lib WinpacSDK lib WinPAC or ViewPAC series XPacSDK lib XPAC series Changed as PACSDK lib WinPacSDK lib used for WinPAC or ViewPAC series and XPacSDK lib used for XPAC series are replaced by PACSDK lib PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 424 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com The original flowchart for a C program that is calling the previous SDK is illustrated below Project A roject C EXE ARM WinPacSDK dll Code Built as Linked with Project B C EXE x86 XPacSDK dll Code Even if Project A applied to WinPAC series modules and Project B applied to XPAC series modules are functionally identical The source code using the previous SDK cannot be exactly the same because of using the different header file and the few function names and error code defined in the previous SDK are different So Project A and Project B are regarded as separate programs cannot share the source code The results of the above are Project A is built as an ARM based executable program and it must be run with WinPacSDK dll Project B is built as an x86 based executable program and it must be run with XPacSDK dll PAC Standard API Manual v1 0 2 Last Revised November 2013 Pa
158. hannel of the AO module IAO_ TotalCh in The total number of the AO channels of the AO module float fValue out The pointer to the AO power on value that is read back from the AO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 310 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadModulePowerOnValueAO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue BOOL iRet pac_ReadModulePowerOnValueAO hPort iSlot icChannel iAO_TotalCh amp fValue uart_Close hPort C pac_ReadModulePowerOnValueAO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue BOOL iRet pac_ReadModulePowerOnValueAO_MF hPort iSlot iChannel iAO_ TotalCh amp fValue uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 311 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadModulePowerOnValueAO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 0 boo
159. hdog status of a module Syntax C BOOL pac _GetModuleWDTStatus HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function succeeds and the host watchdog is enabled the return value is TRUE If the function fails or the host watchdog is disabled the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 314 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot O bool bStatus 0 hPort uart_Open bStatus pac_GetModuleWDTStatus hPort iSlot uart_Close hPort C f the module is 87k local IntPtr hPort int iSlot 1 hPort PACNET UART Open bool bStatus PACNET PAC 0 GetModuleWDTStatus hPort iSlot PACNET UART Close hPort Console WriteLine The return value is bStatus ToString Console ReadLine The example displays the following output to the console ry The return value is True Remarks The function can support for Local or Remote When the module is local the second Parameter s range
160. ht 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_ REMOTE_IO 0 255 IDIL_TotalCh in The total number of the DI channels of the DI module iLatch lype in Specify the latch type to read latch value back 1 latched high status O latched low status IDI_Latch_ Value out The pointer to the latch value read back from the DI module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 214 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iDl_ TotalCh 8 int iLatchType 0 DWORD IDI _Latch_ Value BOOL iRet pac_ReadDILatch hPort iSlot iDI_ TotalCh iLatchType amp IDI_Latch_ Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iDI_ TotalCh 8 int iLatchType 0 DWORD IDI_Latch_ Value BOOL iRet pac_ReadDILatch 0 iSlot iDI_ TotalCh iLatchType amp IDI_ Latch Value
161. iSlot 1 short iChannel 2 float fValue 1 23 BOOL iRet pac_SetPWMbDuty hPort iSlot iChannel fValue uart_Close hPort C IntPtr hPort hPort PACNET UART Open int iSlot 1 short iChannel 2 float fValue 1 23F bool iRet PACNET PWIM SetPWMDuty hPort iSlot iChannel fValue PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 337 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 2 pac_GetPWMDuty This function reads the duty cycle value for a specific channel Syntax C BOOL pac GetPWMDuty HANDLE port int slot short chindex float duty Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Get the duty cycle value from the channel duty out The duty cycle value to read from the PWM module PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 338 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open
162. ight 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 4 Add Misc API function for PACSDK The new PACSDK dIl provides 2 miscellaneous API functions below e pac_GetCurrentDirectory pac_GetCurrentDirectoryW Add the reserved memory section for XPAC series In order to reserve some memory sections of EEPROM and SRAM for the use by the system the reserved section of the pac_ReadMemory and pac_WriteMemory function must be changed The reserved section is same with the WinPAC SDK The definition of the items included in the reserved section is EEPROM O Ox1FFF 8KB for users Ox2000 0x3FFF 8KB is reserved for the system SRAM The size of the input range for the SRAM is only O Ox6FFFF 448KB with another 64KB of SRAM is reserved for use by the system In the previous XPAC SDK XPacSDK dll all memory space O Ox3FFF 16KB of EEPROM is available for the use by the user and all memory space 0 0x80000 512KB of SRAM is available for the use by the user PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 423 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 6 Using the new SDK PACSDK in a C program To use the new PACSDK in a C based program some code needs to be changed in the program Replace the previous header file by PACSDK h include WinPacSDK h include XPacSDK h Changed as include PACSDK h WinPacSDK
163. ing a response is the same as uart_RecvExt This function replaces uart_SendCmd The uart_SendCmd can cause the buffer overflow in some situation Syntax C BOOL uart_SendCmdExt HANDLE hPort LPCSTR cmd DWORD out Len LPSTR szResult DWORD in_Len PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 153 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in Handle to the opened COM port cmd in A pointer to a command out Len in A pointer to a variable that specifies the size in bytes of the data pointed to by the cmd parameter szResult out A pointer to a buffer that receives data in_Len in A pointer to a variable that specifies the size in bytes of the data in buffer pointed to by the szResult parameter Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 154 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C BOOL ret HANDLE hOpen char buf Length hOpen uart_Open COM1 9600 N 8 1 ret uart_SendCmdExt hOpen SOOM 4 buf Length SOOM ask the device name uart_Close hPort C bool ret IntPtr hOpen string buf SOOM read module name byte cmd new byte 64 byte result new byte 64 hOp
164. ing up the Development Environment Both the XPAC series an PC support Visual Studio 2005 2008 2010 and Visual Studio 6 0 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 18 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 1 C C based on Visual Studio Required header and library files The following list lists the libraries header files or DLL files you will need to include to develop a XPAC PC application or plug in gt PACSDK h gt PACSDK Iib How to create a program with new SDK using Visual Studio 2005 2008 VS2005 VS2008 Step 1 Create a new project by using Visual Studio 2005 2008 Edit View Toole Test Window Help Project Ctl hit H Web site hift A lH File Ctl Project From Existing Code eave All Colt stuttts Recent Files Recent Projects Exit PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 19 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 2 Select Windows Forms Application Hew Project Pion Temphis NET Framework 3 5 sE E E Visual C Visual Studio i 1 nnal Other Languages ae o E Visual Basic 7d Class Library Visual C ATL cle z E E Pals E x cou Greneral n MFZ a amart Device n Test ale My Templates Other Project Types Test Projects aiseach Online Templates Mane Enere O O Location Dong OO i D solutio
165. iteLine The return value is mode ToString Console ReadLine The example displays the following output to the console The return value is 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 351 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 9 pac_SetPWMStart This function sets the status of the PWM output port Syntax C BOOL pac _SetPWMStart HANDLE port int slot short enStatus Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 enStatus in Bit O corresponds to PWM channel O and bit 1 corresponds to PWM channel 1 etc When the bit is 0 it denotes that the PWM output port is off and 1 denotes that the PWM output port is on Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 352 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short Status 0x01 BOOL iRet pac_SetPWMStart hPort iSlot Status uart_Close hPort
166. k The function is only applied to the XP 8000 Atom series PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 65 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac EnableLEDs 0 TRUE C Turn on the L1 LED PACNET Sys EnableLEDs 0 true Turn off the L2 LED PACNET Sys EnableLEDs 1 false PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 66 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 11 pac_GetModuleType This function retrieves the type of I O modules which plugged into the XPAC series devices Syntax C int pac _GetModuleType BYTE slot Parameters slot in Specifies the slot number where the I O module is plugged into PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 67 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value For XPAC Series The following table shows the defined values VELTE Description ooo No module existed 0x80 Genernal l 8000W module 0x81 I 8000RW module R version Provide PowerOn and Safe value OxE3 Il 8000W module with 32 DI channels OxEO Il 8000W module with 32 DO channels OxC3 Il 8000W module with 16 DI channels OxCO Il 8000W module with 16 DO channels OxC2 3000W module with 8 DI channels and 8 DO channels 0x40 No module defined I 8000W mo
167. l service icpdas com F 4 XP 8341 Atom XP 8741 Atom XP 8341 Atom CE6 XP 8741 Atom CE6 COM4 COM5 RS 232 RS 485 W W pa R E RS 232 c COM2 RS 232 XP 8341 Atom COM1 Slot 1 3 XP 8741 Atom COM1 Slot 1 7 XP 8341 Atom CE6 COM1 Slot 1 3 XP 8741 Atom CE6 COM1 Slot 1 3 COM3 m RS 485 n PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 447 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 5 WP 81x1 o COM2 D RS 485 GHD THD 7 COM1 R _ RS 232 a ERE A E a a E E d COMO Slot 0 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 448 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 6 WP 84x1 WP 88x1 COM3 COM4 RS 232 RS 485 RS 232 a COM1 f RS 232 i WP 84x1 COMO Slot 0 3 WP 88x1 COMO Slot 0 7 7 T COM2 D l PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 449 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com F 7 WP 5141 WP 5141 OD ofa tu babi bs fi a8 i E E ap AE a a a A o eba SB eS Sse Peo 29 BE L JLILJ COM1 COM2 COM3 RS 232 RS 485 RS 232 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 450 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E m
168. l iRet PACNET PAC O ReadModulePowerOnValueAO hPort slot iChannel iAO_ TotalCh ref fValue PACNET UART Close hPort Console WriteLine The AO power on value is fValue ToString Console ReadLine The example displays the following output to the console The AO power on value is 5 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 312 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadModulePowerOnValueAO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int iChannel 2 int iAO_TotalCh 8 float fValue O bool iRet PACNET PAC O ReadModulePowerOnValueAO_MEF hPort slot iChannel iAO_ TotalCh ref fValue PACNET UART Close hPort Console WriteLine The AO power on value is fValue ToString Console ReadLine The example displays the following output to the console The AO power on value is 5 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 313 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 32 pac_GetModuleWDTStatus This function reads the host watc
169. le is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 224 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 11 pac_ReadDICNT pac_ReadDICNT_MF This function reads the counts of the DI channels of the DI module Syntax C for pac _ReadDICNT BOOL pac _ReadDICNT HANDLE hPort int slot int iChannel int iD _ TotalCh DWORD ICounter_ Value C for pac_ReadDICNT_MF BOOL pac _ReadDICNT_MF HANDLE hPort int iAddrSlot int iChannel int iDI TotalCh DWORD ICounter Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 225 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local O if the module is 8k modules in local Slot iAddrSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that the counter value belongs IDL_TotalCh in Total number of the DI channels of the DI module Counter_ Value out The pointer to the counter value Return Value If the function succeeds the
170. list shows the supported PACs for each of the error handling functions Functions Models XP 8000 XP 8000 Atom PC pac_GetLastError y pac_Settast rror pac_GetErrorMessage pac_CleartastError PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 381 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Error Functions The following functions are used to retrieve or set the error code PACSDK Functions PACNET Functions Description pac_GetLastError ErrHandling GetLastError last error code value pac_SetLastError ErrHandling SetLastError sets the last error code pac_GetErrorMessage ErrHandling GetErrorMessage retrieves a message string pac_ClearLastError ErrHandling ClearLastError clears the last error code PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 382 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 9 1 pac_GetLastError This function retrieves the calling thread s last error code value Syntax C DWORD pac_GetLastError Parameters This function has no parameters Return Value The Return Value section of each function page notes the conditions under which the function sets the last error code Examples This function has no examples PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 383 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service ic
171. local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 IDIL_TotalCh in The total channels of the DI module IDI_ Value out The pointer to DI value to read back Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 204 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadDI Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 2 int iDl_ TotalCh 8 DWORD IDI_ Value BOOL iRet pac_ReadDI hPort iSlot iDI_ TotalCh amp IDI_ Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 2 int iDL_ TotalCh 8 DWORD IDI_ Value BOOL iRet pac_ReadDI 0 iSlot iDI_ TotalCh amp IDI_ Value C pac_ReadDI_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 2 int iDL_ TotalCh 8 DWORD IDI Value BOOL iRet pac_ReadDI_MF hPort iSlot iDI_TotalCh amp IDI_ Value uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 205 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadDI f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 3 int iDL T
172. lt 32 hPort uart_Open Open COM1 data format 115200 N 8 1 uart_SetTerminator hPort r pac_ChangeSlot 1 An I 87K module is in slot 1 uart SendCmd hPort SOOM result SOOM ask the device name DCON uart_Close hPort C byte result new byte 32 IntPtr hPort PACNET UART Open Open COM1 data format 115200 N 8 1 PACNET UART SetTerminator hPort PACNET MISC AnsiString r PACNET Sys ChangeSlot 1 An 87K module is in slot 1 SOOM ask the device name DCON PACNET UART SendCmd hPort PACNET MISC AnsiString SOOM result Console WriteLine PACNET M ISC WideString result Console ReadLine PACNET UART Close hPort Remarks This function relates to uart_Send uart_Recv uart_SendCmd PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 162 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 11 uart_BinSend Send out the command string by fix length which is controlled by the Parameter in Len The difference between this function and uart_Send is that uart_BinSend terminates the sending process by the string length in_Len instead of the character CR Carry return Therefore this function sends out command string with or without null character under the consideration of the command length Besides because of this function without any error checking mechanism Checksum CRC LRC etc user
173. lue If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 111 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com Examples C define LENGTH 2 bool ret DWORD address 0 BYTE Buffer LENGTH Buffer O 10 Buffer 1 20 ret pac_WriteMemory address Buffer LENGTH PAC_MEM_SRAM C Demonstrate how to store data 10 and 20 in the address 0 1 of SRAM uint address 0 byte Buffer new byte 2 10 20 int PAC_MEM_SRAM 0 PACNET Memory WriteMemory address Buffer 2 PAC_MEM_SRAM Remarks If an older program is coded to write data to the 0x2000 Ox3FFF address of the EEPROM or to the last segment of the SRAM using the SDK version 2 0 1 0 or earlier the program may fail to write the data to the EEPROM or the SRAM using the PACSDK dll or PACNET dIl There are two ways to fix the problem 1 Modify the program so that the data is writhen to the 0 0x1FFF address of the EEPROM or the O Ox6FFFF address of the SRAM 2 Ask for the previous SDK from ICPDAS PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 112 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 3 4 pac _EnableEEPROM This function sets the states of the E
174. m will be based on the new SDK working with an old DCON module or a Multi function module Our API Manual give instructions for the PACSDK dll and the demo programs included on the shipped CD FTP are linked with the new PACSDK dIl so users should refer to the demo programs and follow the API instructions when developing new programs based on the new PACSDK dIl rather than those for the XPACSDK Use the new SDK as following flowchart The VC project required to link PACSDK lib while building and the built executable file placed in the XPAC series device must work with PACSDK dll VC Project Link 2 gt C EXE ARM PACSDK lib The C VB net project required to refer to PACNET dIl while building and the built executable file placed in the XPAC series device must work with PACNET dIl and PACSDK dIl C VB net as Project Link PACNET dIl PACSDK dll PACNET dll in XPAC PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 442 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Appendix F Comparison of Defined Slots and COM Ports Each PAC has its own definition and corresponding communication ports and slots whose parameters are defined as below As a result apply the corresponding slot and COM port number on the API functions in writing programs XP 8341 XP 8341 Atom WP 84x1 WP 5141 XP 8041 XP 8341 CE6 XP 8141 Atom XP 8341 Atom CE6 WP 81x1 VP 2xW1
175. maximal efficiency For more information about expansion modules that are compatible with the XPAC WinPAC series please refer to I 8K I 87K series http www icodas com products PAC i 8000 8000 IO modules htm I 7K series http www icodas com tw product solutions remote_ io rs 485 i 7000 amp m 7000 i 7000 i ntroduction html I 8K units http www icodas com tw product solutions pac ipac ipac introduction html tM series http www icodas com products Remote lO tm series introduction htm PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 177 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com API functions for theMulti function DCON modules PAC_IO API has provided 2 types functions One type which includes pac_WriteDO pac_ReadDIO pac_ReadDIl pac_ReadDO pac_ReadDIO_DIBit pac ReadDIO_DOBIit pac_ReadDIBit pac _ReadDOBit pac _ReadDICNT and pac_ClearDICNT functions is used to access the pure DIO DCON modules which are defeind as modules that only has DI DO or DIO channels The other type which includes pac_WriteDO_MF pac_ReadDIO_MF and pac_ReadDI_ MF etc functions is used to access the Multi function DCON modules which are defined as modules that mainly act as AlO or Counters but are equipped with DIO channels Such as the I 87005W I 87016W I 87082W I 7016 I 7088 etc The instructions of two fucntions i e pac_WriteDO and pac_WriteDO_MF are placed on the same s
176. mework 3 5 EE E Vimal C isual Studio installed templates Other Languages 0 B Visual Basic TA Windows Forme Applicaton gel Class Library Windows eal WPF Application Fe WPF Browser Application ied Device SM Console Application mE Empty Project q Office l Windows Service eve WPF Custom Control Library C Database ae WPF User Control Library tel Windows Forme Contool Library Reporting Test My Templates WF Workflow n eearch Online Templates H Visual C Other Project Types Test Projects A project for creating an application with a Windows user interface NET Framework 3 5 Name SUE Information Location polutan Hame SUE Information Create directory for solution PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 30 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 3 Add a button control to the Windows form 1 Open the form 2 Inthe Toolbox click the Button control and drag it to your form 3 Double click the button on the form to create a Click event Toolbox i Office Ribbon Controls Excel Controls Dialog Editor All Windows Forms Pointer Sp Background Worker 7H BindingMavigator tA BindingSource Checkbox E4 CheckedListhox S ColorDialoz fe ComboBox fe ContextMenuStrip TE Datalrrid Y iew ai DataSet Te Date TimePicker te DirectoryEntry wl Step 4 In order to
177. module is remote please use the macro PAC_REMOTE_IO 0 255 fValue out The array contains the Al values that read back from the Al module Buff Len in A pointer to a variable that specifies the size of the buffer pointed to by the fvalue Channel out The pointer to a variable that specifies the total available channel numberer of Al module This channel number is only valid if the return value is TRUE Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 253 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int ichannelnumber 0 hPort uart_Open BYTE iSlot 1 float fValue 8 BOOL iRet pac_ ReadAlAllExt hPort iSlot fValue 8 amp ichannelnumber uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int ichannelnumber 0 float fValue 8 BOOL iRet pac_ ReadAIAIlExt 0 iSlot fValue 8 amp ichannelnumber PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 254 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort int channelnumber 0 hPort PACNET UART Open byte iSlot 3 float fValue new float 8 bool iRet
178. n Name lt Enter_names sid Create directory for solution Step 3 Copy PACSDK h to the application folder and include it 1 Copy PACSDK h to the application folder 2 Add include PACSDK h include stdatx h include Form h include PACSDK A PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 20 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 4 Copy PACSDK ib to the application folder and Include it 1 Copy PACSDK lib to the application folder 2 Open the project s Property Page dialog box 3 Click the Linker folder 4 Click the Input property page 5 Inthe right pane type the PACSDK lib in the Additional Dependencies item Sample Property Pages Configuration Active Debug Platform Active W7in32 E Common Properties Additional Dependencies PACSDE lib a Configuration Properties lenore All Default Libraries No General lenore Specific Lin Dehn ere snore Specific Library CA Module Definition File Linker Add Module to Assembly ae Embed Managed Resource File Manifest File Force Symbol References Debugging Delay Loaded DLLs e bysten Assembly Link Resource ptimization Embedded IDL n Advanced i Command Line H Manifest Tool Resources W Managed Resources H EML Document Generator H Browse Information Build Events W Custom Build Step Additional Dependencies specifies addito
179. n succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 195 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDO_TotalCh 8 int iBitValue 1 BOOL ret pac_WriteDOBit hPort iSlot iDO_TotalCh iChannel iBitValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iDO_TotalCh 8 int iBitValue 1 BOOL ret pac_WriteDOBit 0 iSlot iDO TotalCh iChannel iBitValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 196 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 2 int iChannel 2 int iDO_TotalCh 16 int iBitValue 1 bool ret PACNET PAC O WriteDOBit hPort iSlot iDO_TotalCh iChannel iBitValue PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2
180. nal items to add to the link line fex kemel 2 lib configuration specific RUA PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 21 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 2 Visual C Required library files The following DLL files are needed to include for developing a XPAC PC application or plug in gt PACSDK dIl How to create a program with new SDK using Visual Studio 2005 2008 VS2005 VS2008 1 Using DII Import Step 1 Create a new project by using Visual Studio 2005 2008 1 Start Visual Studio NET 2 Click gt File gt New gt Project Edit View Tools Test Window Help Project Cth hitt Web Site hift Alt File Ct Project From Existing Code eave All Ctltshittts Recent Files Recent Projects Exit PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 22 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 2 Select Windows Forms Application and name the project 1 2 2 4 In the Project Type column choose Visual C gt Windows In the Template column choose Windows Forms Application Name your project Click OK to create your new project New Project a Ed Project types Templates NET Frmework3 5 G E Visual Studio installed templates m Windows Forms Application ict Class Library i smart Device Ei WPF Application Pay WPF Brow
181. nction is applied to receive the fix length response The length of the receiving response is controlled by the Parameter in_Len The difference between this function and uart_Recv is that uart_BinRecv terminates the receiving process by the string length in _Len instead of the character CR Carry return Therefore this function receives the response string data with or without null character under the consideration of receiving length Besides because of this function without any error checking mechanism checksum CRC LRC etc users have to remove the error checking information from the raw data by themselves if communication checking system is used Syntax C bool uart BinRecv HANDLE hPort LPSTR buf DWORD in_Len Parameters hPort in Handle to the open COM port buf out A pointer to a buffer that receives the data in_Len in The length of result string PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 165 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is True If the function fails the return value is False Examples C bool ret HANDLE hPort char buf 2 hPort uart_ Open COM4 9600 N 8 1 ret uart_BinSend hPort AB 2 ret uart_BinRecv hPort buf 2 uart_Close hPort C bool ret IntPtr hPort byte buf new byte 100 hPort
182. ng Console ReadLine The example displays the following output to the console The DO safe value is 4 C pac_ReadModuleSafeValueDO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int total_ channel 8 uint do_ value 0 bool ret PACNET PAC O ReadModuleSafeValueDO_MF hPort slot total_ channel ref do value PACNET UART Close hPort Console WriteLine The DO safe value is do_value ToString Console ReadLine The example displays the following output to the console ry The DO safe value is 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 283 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 284 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 26 pac_WriteModulePowerOnValueDO pac_Wri teModulePowerOnValueDO_MF This function writes the DO power on values to DO modules Syntax C for pac_WriteModulePowerOnValueDO BOOL pac_WriteModulePowerOnValueDO HANDLE hPort int slot int iDO_TotalCh unsigned long IValue
183. nged pac_EnableLED bool bFlag is been reserved and a new API function has been added pac_EnableLEDs int pin BOOL bFlag PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 419 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 Add I O WDT PowerOn Safe Value API for pure DIO modules The new PACSDK dll provides the support of I O WDT Power On and Safe value functions for pure DIO DCON modules Refer to Note 1 These functions aren t supported for the previous SDK DCON_PC dll and XPacSDK dll pac _GetModuleLastOutputSource pac _GetModuleWDTStatus e pac _GetModuleWDTConfig pac _SetModuleWDTConfig e pac _ResetModuleWDT e pac_RefreshModuleWDT e pac_InitModuleWDTInterrupt e pac _SetModuleWDTInterruptStatus pac _GetModuleWDTInterruptStatus e pac _ReadModuleSafeValueDO e pac_WriteModuleSafeValueDO e pac _ReadModuleSafeValueAO e pac_WriteModuleSafeValueAO pac _ReadModulePowerOnValueDO e pac_WriteModulePowerOnValueDO e pac _ReadModulePowerOnValueAO e pac_WriteModulePowerOnValueAO Notes 1 The each of API function is used for the DCON module which is provided with Power ON or Safe value function 2 7K I 87K series modules provided with Power ON or Safe Value function can support the API functions above I 8K series module provide the functions is only I 8041RW PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 420 Copyright
184. niString PACNET MISC WideString ansiString Console WriteLine uniString Console ReadLine The example displays the following output to the console This is an ansi string Remarks The maximum size of the string buffer is 2 Kbytes PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 400 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 10 4 pac_WideToAnsiString This function converts a Unicode string to an ANSI string Syntax C void pac WideToAnsiString LPCWSTR wstr LPSTR astr C void pac _ WideStringToAnsi const TCHAR wstr LPSTR astr Parameters wsir in Points to the Unicode string to be converted astr in A pointer to a buffer location that receives the converted ANSI string Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 401 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C TCHAR uniString 128 TEXT This is a unicode string char ansiString 128 pac _WideStringToAnsi uniString ansiString printf s ansiString The string This is a unicode string will show the console mode correctly C string uniString This is a unicode string byte ansiString new byte 128 ansiString PACNET MISC AnsiString uniString Console WriteLine Encoding ASCIl GetStrin
185. nnel 8 uint do value 4 turn on the channel2 int iRemoteAddr PACNET PAC O PAC REMOTE_10O 1 bool ret PACNET PAC O WriteDO hPort iRemoteAddr total_ channel do_ value PACNET UART Close hPort Example 2 f the module is 87k in local IntPtr hPort2 hPort2 PACNET UART Open Open COM1 data format 115200 N 8 1 int total _ channel2 8 uint do _value2 4 turn on the channel2 bool ret2 PACNET PAC O0 WriteDO hPort2 2 total_ channel2 do_value2 PACNET UART Close hPort2 Example 3 f the module is 8k local int total channel3 8 uint do_value3 4 turn on the channel2 bool ret3 PACNET PAC 0 WriteDO IntPtr O 3 total channel3 do_value3 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 192 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteDO_ MF Example 1 f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total channel 8 uint do value 2 turn onthe channel1 int iRemoteAddr PACNET PAC O PAC REMOTE_1O 1 bool ret PACNET PAC 10 WriteDO_ MF hPort iRemoteAddr total_ channel do_value PACNET UART Close hPort Example 2 f the module is 87k local IntPtr hPort2 hPort2 PACNET UART Open Open COM1 data format 115200 N 8 1 int total_ channel2 2 uint do value2 2 turn onthe channel1l bool
186. nual v1 0 2 Last Revised November 2013 Page 59 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks When you have ever sended a command to a local module on the slot and an error happened you can add the Pac_ModuleExists function into your program before sending command to the module By this way You can quickly check whether a module correctly exists in the slot and save the waiting time for the timeout if a module does not exist The API does not apply to a remote module PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 60 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 8 pac _GetOSVersion This function retrieves the version number of the XPAC current operating system OS Syntax C void pac GetOSVersion LPSTR os version Parameters os_version out The version number of the XPAC OS Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 61 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C char OS 32 pac _GetOSVersion OS C string OS OS PACNET Sys GetOSVersion Console WriteLine The XPAC OS version is v OS Console ReadLine The example displays the following output to the console The XPAC OS version is v1 0 3 0 PAC Standa
187. om 2 3 1 pac _GetMemorySize This function retrieves the size of the specified memory Syntax C DWORD pac_GetMemorySize int mem_type Parameters mem_type in Handle to a currently type memory 0 PAC_MEM_SRAM 1 PAC MEM_ EEPROM Return Value The return value specifies the memory size PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 105 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C DWORD mem_ size mem_size pac _GetMemorySize PAC_MEM_SRAM C uint mem_size int PAC_MEM_SRAM 0 int PAC_MEM EEPROM 1 mem_size PACNET Memory GetMemorySize PAC_MEM_SRAM Console WriteLine The SRAM size is mem_size ToString mem_size PACNET Viemory GetMemorySize PAC_ MEM EEPROM Console WriteLine The EEPROM size is mem_size ToString Console ReadLine The example displays the following output to the console The SRAM size is 524288 H The EEPROM size is 16384 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 106 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 3 2 pac _ReadMemory This function retrieves data from the specified memory Syntax C BOOL pac_ReadMemory DWORD address LPBYTE lpBuffer DWORD dwLength int mem type PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 107 Copy
188. ommand Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify a channel to read the continuous mode mode out 0 Disable the PWM continuous mode pulse count mode 1 Enable the PWM continuous mode If the PWM continuous mode is enabled the step value for PWM will be automatically set to 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 346 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short iChannel 2 long mode BOOL iRet pac_GetPWMMode hPort iSlot iChannel amp mode uart_Close hPort C IntPtr hPort PACNET UART Open int iSlot 1 short iChannel 2 int mode 0 bool iRet PACNET PWIM GetPWMMode hPort iSlot iChannel ref mode PACNET UART Close hPort Console WriteLine The mode value is mode ToString Console ReadLine The example displays the following output to the console The mode value is 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 347 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 7 pac SetPWMDITriggerConfig This function
189. otalCh 8 uint IDI Value O bool iRet PACNET PAC O ReadDI hPort iSlot iDI_ TotalCh ref IDI_ Value PACNET UART Close hPort Console WriteLine The DI value is IDI_Value ToString Console ReadLine The example displays the following output to the console Js The DI value is 5 C pac_ReadDI_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iD TotalCh 2 uint IDI_ Value 0 bool iRet PACNET PAC O ReadDI_MF hPort iSlot iDI_ TotalCh ref IDI_ Value PACNET UART Close hPort Console WriteLine The DI value is IDI_Value ToString Console ReadLine The example displays the following output to the console The DI value is 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 206 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1IO 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 207 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 6 pac ReadDIO pac ReadDIO_ MF This function reads the DI and the DO values of the DIO module Syntax C for pac ReadD
190. ovember 2013 Page 323 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 1 hPort uart_Open pac_ResetModuleWDT hPort iSlot uart_Close hPort C f the module is 87k local IntPtr hPort int iSlot 1 hPort PACNET UART Open PACNET PAC_ O ResetModuleWDT hPort iSlot PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 324 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 36 pac RefreshModuleWDT This function refresh the host watchdog of a module Syntax C BOOL pac_RefreshModuleWDT HANDLE hPort int slot Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 Return Value If the function succeeds the return value is TRUE If the function fails the return value i
191. pServices and then implement the function which you want to call Demonstrate an example of using pac_writeDO in NET project The function defined in PACSDK h file PAC_API BOOL pac_WriteDO HANDLE hPort int slot int iDO_TotalCh DWORD l IDO_Value PAC Standard API Manual v1 0 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved Last Revised November 2013 Page 24 gt lt E mail service icpdas com How to use in your NET project 1 Added this line in your project i e i l DIllmport PACSDK dll EntryPoint pac_WriteDO i public extern static bool pac_WriteDO IntPtr hPort int slot int iDO_TotalCh uint IDO_ Value 3 Then you can use this function pac_WriteDO in your NET project Code Snippet using System Windows Forms using System Runtime InteropServices l l l l l l Namespace l i public partial class Form1 Form i l O Dlllmport PACSDK dll EntryPoint pac_WriteDO l public extern static bool pac_WriteDO IntPtr hPort int slot int iDO_TotalCh uint IDO_Value l l public Form1 l l InitializeComponent l private void button1_Click object sender EventArgs e i l pac_WriteDO IntPtr 1 1 16 Oxff i i l a l L PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 25 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 Using PACNET dll PACNET
192. pdas com Remarks You should call the pac_GetLastError function immediately when a function s return value indicates that such a call will return useful data That is because some functions call pac_SetLastError O when they succeed wiping out the error code set by the most recently failed function For an example please refer to pac_GetErrorMessage in this chapter To obtain an error string for XPAC error codes use the pac_GetErrorMessage function For a complete list of error codes see Appendix A System Error Code The following table lists the system error codes ranges for each function reference Error Type Explanation Range PAC_ERR_SUCCESS 0400000 PAC_ERR_UNKNOWN 0x00001 Interrupt Ox13000 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 384 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 9 2 pac_SetLastError This function sets the last error code Syntax C void pac SetLastError DWORD errno Parameters errno in Specify the last error code Return Value This function does not return any value Examples This function has no examples PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 385 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks Applications can optionally retrieve the value set by this function by using the pac_GetLastError function The error co
193. plication defined callback function Syntax C BOOL pac SetBPTimer int type unsigned int uElapse PAC TIMEROUT CALLBACK FUNC f Parameters type in Specify the type of the timer 1 Timer 1 1 microsecond timer 2 Timer 2 10 microsecond timer Others Not applicable uElapse in Specify the elapsed time Timer 1 A value of a timerout signal as integer from 0 65535 in 1 microsecond Timer 2 A value for a timerout signal as integer from0 65535 in 10 microseconds Specify the address of the application supplied f callback function PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 373 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C int CALLBACK TIMER Interrupt Function Add the user control code here return 0 Interrupt done Set timer1 with 200 microsecond interval pac SetBPTimer 1 200 TIMER C static void Main string args PACNET PAC_CALLBACK_ FUNC f new PACNET PAC CALLBACK FUNC myfunction Set timer1 with 200 microsecond interval PACNET BPTimer SetBPTimer 1 200 f static int myfunction Interrupt Function Add the user control code here return 0 Interrupt done PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 374
194. ptID pacinterruptdone Y y o YP r drr fp Pf lt lt lt lt lt lt lt lt PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 85 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Interrupt Functions The following functions are used to retrieve or set the slot interrupt PACSDK Functions PACNET Functions Description pac_RegisterSlotInterrupt Interrupt RegisterSlotInterrupt registers the slot interrupt service route after turning on the slot interrupt Interrupt UnregisterSlotinterrupt unregisters slot interrupt service route and disables a hardware interrupt as specified pac_UnregisterSlotinterrupt by its interrupt identifier pac_EnableSlotinterrupt Interrupt EnableSlotinterrupt performs hardware operations necessary to enable the specified hardware interrupt pac_SetSlotinterruptPriority Interrupt SetSlotInterruptPriority sets the priority for a real time thread on a thread by thread basis a Interrupt Interruptinitialize initializes a slot interrupt with the kernel This initialization allows the slot to register pac_Interruptlnitialize an event and enable the interrupt PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 86 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 1 pac_RegisterSlotinterrupt This function registers the slot interrupt service route after t
195. pyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Pac_EnableLED pac_BackwardCompatible pac_GetEbootVersion pac_RegistryHotPlug Beta testing pac_UnregistryHotPlug Beta testing PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 42 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com System Information Functions The following functions are used to retrieve or set system information PACSDK Functions PACNET Functions Description Sys CheckSDKVersion is used to compare the version number of the currently used PACSDK dIl with the pac_CheckSDKVersion specified version number PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 43 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_GetDIPSwitch Sys GetDIPSwitch retrieves the dip switch on the XPAC pac_GetSlotCount Sys GetSlotCount retrieves the total number of the IO slot on the XPAC pac_GetBackplanelD Sys GetBackplanelD retrieves the backplane ID of the XPAC pac_GetBatteryLevel Sys GetBatteryLevel retrieves the battery status of the backplane and the RTC battery status of the CPU board pac_EnableRetrigger Sys EnableRetrigger determines the retrigger status PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 44 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com
196. rd API Manual v1 0 2 Last Revised November 2013 Page 62 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 9 Pac GetCPUVersion This function retrieves the version number of the XPAC CPU board Syntax C void pac GetCPUVersion LPSTR cpu_version Parameters cou_version out The version number of the XPAC CPU board Return Value This function does not return any value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 63 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com Examples C char CPU 32 pac_GetCPUVersion CPU C string CPU PACNET Sys GetCPUVersion Console WriteLine The XPAC CPU board version isv CPU Console ReadLine The example displays the following output to the console The XPAC CPU board version is v1 0 15 0 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 64 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 1 10 Pac_EnableLEDs PWR RUN LI L2 This function sets the state of the specified LED Syntax C void pac EnableLEDs INT pin BOOL bFlag Parameters pin Specifies the user programmable LED 0 L1LED 1 L2 LED bFlag Specifies the mode of the LED True Turn on the LED False Turn off the LED Return Value This function does not return any value Remar
197. return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 226 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_ReadDICNT Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDl_ TotalCh 8 DWORD I Counter_ Value BOOL iRet pac _ReadDICNT hPort iSlot iChannel iDI_ TotalCh amp lCounter_Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 2 int iDI_TotalCh 8 DWORD ICounter Value BOOL iRet pac_ReadDICNT O iSlot iChannel iDI_TotalCh amp lCounter_ Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 227 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadDICNT_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iDI_ TotalCh 8 DWORD Counter _ Value BOOL iRet pac _ReadDICNT MF hPort iSlot iChannel iDI_ TotalCh amp lCounter_Value uart_Close hPort C pac_ReadDICNT f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 2 int iDl TotalCh 8 uint Counter_ Value 0 bool iRet PACNET PAC O ReadDICNT hPort iSlot iChannel iDI Total
198. rflow reads the counter overflow value of the counter frequency modules pac_WriteModuleSafeValueDO pa PAC_IO WriteModuleSafeValueDO writes the DO safe values to DO modules c_WriteModuleSafeValueDO_MF pac jo WriteModuleSafeValueDO_MF pac_ReadModuleSafeValueDO pac_R PAC_lO ReadModuleSafeValueDO reads the safe value of the DO modules eadModuleSateValueDO_MF PAC _10 ReadModuleSafeValueDO_ MF PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 183 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_WriteModulePowerOnValueDO PAC_lO WriteModulePowerOnValueDO writes the DO power on values to DO modules pac_WriteModulePowerOnValueDO_ pac 10 WriteModulePowerOnValueDO MIF ME pac_ReadModulePowerOnValueDO p PAC_IlO ReadModulePowerOnValueDO reads the power on value of the DO modules ac_ReadModulePowerOnValueDO_M PAC_1O0 ReadModulePowerOnValueDO _ F MF pac_WriteModuleSafeValueAO pac_ PAC 10 WriteModuleSafeValueAO writes the AO safe value to the AO modules WriteModuleSafeValueAO_MF pac_ReadModuleSafeValueAO pac_R PAC 10 ReadModuleSafeValueAO reads the AO safe value of the AO module eadModuleSafeValueAO_MF g pac_WriteModulePowerOnValueAO p PAC 10 WriteModulePowerOnValueAO Writes the AO power on value to the AO modules ac_WriteModulePowerOnValueAO_M g F pac_ReadModulePowerOnValueAO p PAC 10 ReadModulePowerOnValueAO reads the AO power on value of the AO module
199. rieves the number of bytes received by the serial provider but not yet read by a uart_GetDatasSize UART GetDataSize 7 uart_Recv operation or of user data remaining to transmitted for write operations uart_SetLineStatus UART SetLineStatus sets the status of modem line PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 135 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 1 uart Open This function opens the COM port and specifies the baud rate parity bits data bits and stop bits Syntax C HANDLE uart Open LPCSTR ConnectionString PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 136 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters connectionString in Specifies the COM port baud rate parity bits data bits and stop bits The default setting is COM1 115200 N 8 1 The format of ConnectionString is as follows com_port baud_rate parity_bits data_bits stop_bits Warning there is no blank space between each parameter Com_ port XPAC COM1 COM 2 WinPAC COMO COM1 baud_rate 1200 2400 4800 9600 19200 38400 57600 115200 parity_ bits N NOPARITY O ODDPARITY E EVENPARITY M MARKPARITY S SPACEPARITY Data_bits 5 6 7 8 Stop_ bits 1 ONESTOPBIT 2 TWOSTOPBITS 1 5 ONESSTOPBITS PAC Standard API Manual v1 0 2 Last Revised November 2013 Page
200. right 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Parameters address in Specifies the memory address where read from EEPROM O Ox1FFF 8KB for users Ox2000 0x3FFF 8KB is reserved for the system SRAM The size of the input range for the SRAM is only O Ox6FFFF 448KB with another 64KB of SRAM is reserved for use by the system loBuffer out Receives the memory data dwLength in Number of characters to be read mem_type in Handle to a currently type memory 0 PAC_MEM_SRAM 1 PAC MEM EEPROM Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 108 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C define LENGTH 2 bool ret DWORD address 0 BYTE Buffer LENGTH ret pac_ReadMemory address Buffer LENGTH PAC_MEM_SRAM C uint address 0 the memory address where read from byte Buffer new byte 2 PACNET Memory ReadMemory address Buffer 2 0 Console WriteLine Buffer 0 Buffer O Buffer 1 Buffer 1 Console ReadLine The example displays the following output to the console Buffer 0 37 Buffer 1 38 Remarks If an older program is coded to write data to the 0x20
201. river to assign the slot event handle Syntax C void pac SetSlotinterruptEvent BYTE slot HANDLE hEvent Parameters slot in Specifies the index of slot to assign the event handle hEvent in Event to be signaled Return Value This function does not return any value Examples This function has no examples PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 97 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 8 pac SetTriggerType This function assigns the pulse trigger type for separate slot Syntax C void pac SetTriggerType BYTE slot int iType Parameters iType in Specifies the pulse trigger type O Rising edge trigger default 1 Level trigger 2 Falling edge trigger Return Value This function does not return any value Examples This function has no examples Remarks For XP 8000 series only support level trigger type PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 98 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 9 pac _GetSlotinterruptiD This function retrieves the ID of the slot interrupt Syntax C DWORD pac_GetSlotInterrupt D BYTE Slot Parameters slot in Specifies the slot Return Value If the function succeeds the return value is the ID of the slot interrupt If the function fails the return value is FALSE
202. rol Library WCE Workflow Hy Templates Other Languages E Other Project Types E Seach Online Templates Test Projects i A project for creating an application with a Windows Forme user interface NET Framework 3 0 Name Lesion sotnion Nane JEE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 27 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 3 Add the PACNET dIl into the references of the project and then insert the code to complete your project 1 Click Project gt Add Reference 2 Choose PACNET dIl from the list 3 Click OK to add the reference 4 Use the intellisense feature to quickly select the function which you want to call Forml cs Forml cs Desien Start Page x Solution Explorer Solution Wi F Xx e WindowsFornss pplication For s Eee ea Es a TTS gel Solution WindowsFormsApplication2 using system Collections Generic c Pintors Forms pyar atone H Sa Properties using System Companenthlodel D E Bafecoos using System Data O PACNET using system Drawing E e ess ry using system Text 42 System Data using System Windows Forms Le fd System Deployment 42 System Drawing Enamespace VVindowsFormsApplicatianz 4 System Windows Forne i ee AO System onal public partial class Formi Form fe FS Forml cs a Program cs public
203. rror Code Ox ec ToString X The sample code is used to show the error code number and its enumerated definition If the last error code 0x10001 is happened on the user s program The message box with PAC_ERR_UNKNOWN Error Code 0x10001 caption will be shown PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 429 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 4 Using the new SDK PACNET in a C or VB net program To use the new PACNET in a C or VB net program some code needs to be changed in the program In a C program e Modify the code for using XPAC series devices using XPacNET to using PACNET using XPacNet Changed as using PACNET e Modify the code for using WinPAC series devices using WinPacNet to using PACNET using WinPacNet Changed as using PACNET In a VB net program e Modify the code for using XPAC series devices Imports XPacNET to Imports PACNET Imports XpacNet Changed as Imports PACNET e Modify the code for using WinPAC series devices Imports WinPacNet to Imports PACNET Imports WinPacNet Changed as Imports PACNET PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 430 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com With the previous NETCF library WinPacNet dll or XPacNet dll the flowchart was as follow
204. rt for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 304 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 30 pac_WriteModulePowerOnValueAO pac_Wri teModulePowerOnValueAOQ_MF This function writes the AO power on value to the AO modules Syntax C BOOL pac_WriteModulePowerOnValueAO HANDLE hPort int slot int iChannel int iAO_TotalCh float fValue C BOOL pac WriteModulePowerOnValueAO_MEF HANDLE hPort int iAddrSlot int iChannel int iAO TotalCh float fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 305 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot iAddrSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that is written the AO value to IAO_ TotalCh in The total number of the AO channels of the AO module float fValue in Contain the AO value to write to the AO module Return Value If the function succeeds the re
205. rvice icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot iAddrSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that is written the AO value to IAO_ TotalCh in The total number of the AO channels of the AO module fValue in The AO value to write to the AO module Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 297 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_WriteModuleSafeValueAO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 5 BOOL iRet pac_WriteModuleSafeValueAO hPort iSlot iChannel iAO_TotalCh fValue uart_Close hPort C pac_WriteModuleSafeValueAO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 5 BOOL iRet pac_WriteModuleSafeValueAO_MEF hPort iSlot iChannel iAO_TotalCh fValue uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 298 Copyri
206. s Project A net EXE WinPAC WinPacNet dll WinPacSDK dll Code Built as Linked with And Project B net EXE XPAC XPacNet dll XPacSDK dll Code Project A applied to WinPAC series modules and Project B applied to XPAC series modules are functionally identical but the source code cannot be exactly the same because of using the different NET CF library and few function name and error code are different So Project A and Project B are regarded as separate programs no relevance Project A for WinPAC series is built as an executable program which must be run with WinPacNet dll and WinPacSDK dll Project B for XPAC is built as an executable program which must be run with XpacNet dll and XPacSDK dll With the new NETCF library PACNET dIl and the flowchart becomes PACSDK dll ARM PACNET dll Project Code Built as Linked with And PACSDK dll x86 The benefits of using the new SDK A program applied to WinPAC series modules and the other program applied to XPAC series modules are functionally identical because of using the same NET CF library and the API functions and error code on the library are exactly the same the source code can be shared for two programs One shared source code can be built as an executable programs and link the same NET CF library PACNET dIl The only change is that links different platform native SDK PACSDK dll ARM is used on WinPAC series and PACSDK dIl x8
207. s FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 325 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort int iSlot 1 hPort uart_Open pac_RefreshModuleWDT hPort iSlot uart_Close hPort C f the module is 87k local IntPtr hPort int iSlot 1 hPort PACNET UART Open PACNET PAC_ O RefreshModuleWDT hPort iSlot PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 326 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com 2 6 37 pac_InitModuleWDTInterrupt This function initializes and enables interrupt of a module watchdog This function only supports for 8KRW modules l 80xxRW Syntax C BOOL pac RefreshModuleWDT int slot PAC CALLBACK_FUNC f Parameters slot in The slot in which module is to receive the command Default is local it in A call back function Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual
208. s com Appendix A System Error Codes This following table provides a list of system error code There are turned by the pac_GetLastError function when many functions fail To retrieve the description text for the error in your application use the pac_GetErrorMessage function Error Code Error Message PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 405 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 406 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Appendix B API Comparison The following tables give a brief summary of the capabilities of each API function where Y means supported and means unsupported System Information Functions XP 8000 XP 8000 Atom Functions Models XP 8000 CE6 XP 8000 Atom CE6 WP 8x4x WP 8x3x WP 8x5x WP 5xxx VP 25Wx VP 23Wx lt pac_GetModuleName pac _GetRotarylD pac_GetSerialNumber pac_GetSDKVersion pac_ChangeSlot pac_CheckSDKVersion pac_ModuleExists pac_GetOSVersion Pac_GetCPUVersion Pac_EnableLEDs pac_GetModuleType pac BuzzerBeep pac_GetBuzzerFreqDuty pac_SetBuzzerFreqDuty pac _StopBuzzer pac_GetDIPSwitch PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 407 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac EnableRetrigger
209. s have to add the error checking information to the raw data by themselves if communication checking system is required Syntax C BOOL uart_BinSend HANDLE hPort LPCSTR buf DWORD in_ Len Parameters hPort in Handle to the opened COM port buf in A point to a buffer containing the data to be transmitted in_Len in The length of result string PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 163 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C bool ret HANDLE hPort char buf 2 buf 0 0x41 buf 1 0x42 hPort uart_ Open COM4 9600 N 8 1 ret uart_BinSend hPort buf 2 uart_ Close hPort C bool ret IntPtr hPort string buf AB hPort PACNET UART Open COM3 9600 N 8 1 ret PACNET UART BinSend hPort PACNET M SC AnsiString buf 2 PACNET UART Close hPort Remarks Note that this function is usually applied to communicate with the other device but not for ICPDAS DCON I 7000 8000 87K series modules This function will call PurgeComm to clear serial COM port output buffer PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 164 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 12 uart_BinRecv This fu
210. sed November 2013 Page 174 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 PAC_IO API PAC_IO API supports to operate IO modules which can be divided into the following parts Local IO in slot In the local mode the slot range is from 1 to 7 and it s the same as the iSlot as follow hPort uart_Open iClear DO pac _WriteDO hPort i on in on i PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 175 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remote If the module is in the remote mode the address need call a macro PAC_REMOTE_IO And its range is from O to 255 For example as follow Write DO value to remote module HANDLE hPort uart_Open ConnectionString if thPort AfxMessageBox _T Open Com Error pac_WriteDO hPort PAC_REMOTE_I0 iAddr m_iDOCHs 1D0_Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 176 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com In PACSDK dll modify the processing to send the DCON commands without determining the module name the new PAC_IO API functions can support to access the I 87K I 8K High profile and Low profile I 7K 8000 units tM series and etc DCON modules You also need to know the expansion capacities in order to choose the best expansion module for achieving
211. ser Application f ee Console Application cs Empty Project Reporting ca Windows Service t WEF Custom Control Library i Test il WPF User Control Library ey Windows Forme Control Library WCF Workflow Hy Templates H Other Languages e H Other Project Types isearch Online Templates H Test Projects A project for creating an application with a Windows Forme v r interface NET Framework 35 Name WindowsFormss WindowsFormsApplicationd 0000 ee solution Name WindowsFormsd pp WindowsFornsA pplication ication 0 v Create directory for solution PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 23 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Step 3 Add a button control to the Windows form 1 Open the form 2 Inthe Toolbox click the Button control and drag it to your form 3 Double click the button on the form to create a Click event Toolbox Office Ribbon Controls A Formi cs Design Start Page ie Excel Controls Dialog Editor AU Windows Forms lp Pointer T Background Worker oH Binding ayigator E D BindingSounce Checkbox Checked Listhiox S ColorDialog je ComboBox fEl ContextMenuStrip i DataGridView ai DataSet Date Time Picker Formi Step 4 In order to use Dillmport you should add the namespace using Statement System Runtime Intero
212. succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 256 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 float fValue 8 BOOL iRet pac_ReadAIAll hPort iSlot fValue uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 float fValue 8 BOOL iRet pac_ReadAIAll 0 iSlot fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 257 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 3 float fValue new float 8 bool iRet PACNET PAC O ReadAIAll hPort iSlot fValue PACNET UART Close hPort for int i 0 i lt 8 i Console WriteLine The Al i ToString fValue i ToString Console ReadLine The example displays the following output to the console The Al O 1 015 The Al 1 0 001 H The Al 7 0 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from
213. t 1 int iChannel 2 int iAO_ TotalCh 8 float fValue 5 bool iRet PACNET PAC 0O WriteModulePowerOnValueAO_MF hPort slot iChannel iAO_TotalCh fValue PACNET UART Close hPort Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_1O 0 255 which range is from 0 to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 308 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 31 pac _ReadModulePowerOnValueAO pac_Rea dModulePowerOnValueAO_MF This function reads the AO power on value of the AO module Syntax C BOOL pac_ReadModulePowerOnValueAO HANDLE hPort int slot int iChannel int iAO_TotalCh float fValue C BOOL pac ReadModulePowerOnValueAO_ MF HANDLE hPort int slot int iChannel int iAO TotalCh float fValue PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 309 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in Read the AO value from the c
214. t iChannel 2 int iAO_ TotalCh 4 float fValue 0 bool iRet PACNET PAC O ReadAO hPort iSlot iChannel iAO_TotalCh ref fValue PACNET UART Close hPort Console WriteLine The AO value is fValue ToString Console ReadLine The example displays the following output to the console The AO value is 5 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 242 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_ReadAO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 0 int iAO_TotalCh 2 float fValue 0 bool iRet PACNET PAC O ReadAO hPort iSlot iChannel iAO_TotalCh ref fValue PACNET UART Close hPort Console WriteLine The AO value is fValue ToString Console ReadLine The example displays the following output to the console The AO value is 5 Remarks The function can support for Local or Remote When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 243 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 15 pac_ReadAl This function reads the engineering mode Al value of the Al module Syntax C
215. te When the module is local the second Parameter s range is from 1 to 7 for XPAC series If remote the second parameter need use the macro PAC_REMOTE_IO 0 255 which range is from O to 255 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 268 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 22 pac_ClearCNT This function clears the counter values of the counter frequency modules Syntax C BOOL pac_ClearCNT HANDLE hPort int slot int iChannel Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local iSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that clears the counter value back from the counter frequency modules Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 269 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 0 BOOL iRet pac_ClearCNT hPort iSlot iChannel uart_Close hPort Example 2
216. th PACNET UART Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 143 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Remarks The terminate characters is OxOD Refer to uart_SetTerminator function to change This function will call PurgeComm to clear serial COM port output buffer This function sends data with a terminate character OxOD For example Check sum is disabled The buf are five bytes ABCD 0x0 This function will send five bytes ABCD 0xOD PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 144 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 5 4 uart Send This function sends data through the COM port which have been opened This function will send a string If the checksum is enabled by the uart_EnableCheckSum function this function automatically adds the two checksum bytes to the string And then the end of sending string is further added OxOD to mean the termination of the string buf Syntax C BOOL uart_Send HANDLE hPort LPCSTR buf Parameters hPort in Handle to the opened COM port buf in A point to a buffer containing the data to be transmitted Return Value If the function succeeds the return value is TRUE If the function fails the return value is FLASE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 145 Copyright
217. to develop the applications for the XPAC series and PC To download and copy the new PACSDK to a specified folder 1 Get the latest version of PACSDK library The latest version of the installation package from FTP site listed as following FTP http ftp icodas com pub cd xp 8000 sdk pacsdk http ftp icodas com pub cd xpac atom sdk pacsdk 2 Copy the PACSDK dll to the Windows system directory and copy the corresponding PACSDK library to the application folder for reference The default location of Windows system directory for XPAC and PC is listed as below XPAC series C WINDOWS On 32 bit Windows the path is C WINDOWS System32 On 64 bit Windows the path is C WINDOWS SysWow64 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 16 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com To Update the XPACSDK to PACSDK In XPAC series Please download and install the software XP 8000_Toolkit_Setup exe to update The latest version of the installation package from FTP site listed as following FTP http ftp icodas com pub cd xp 8000 sdk install http ftp icodas com pub cd xpac atom sdk install In PC Directly download and copy the new PACSDK library to replace XPacSDK library on users program PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 17 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 1 3 Sett
218. total channel do_value uart_Close hPort Example 2 f the module is 87k local HANDLE hPort hPort uart_Open int total channel 8 DWORD do value 4 turn onthe channel two BOOL ret pac_WriteDO hPort 1 total channel do_value uart_Close hPort Example 3 f the module is 8k remote int total channel 8 DWORD do value 4 turn onthe channel two BOOL ret pac_WriteDO 0 1 total_ channel do_value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 190 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteDO_MF Example 1 f the module is remote HANDLE hPort hPort uart_Open COM2 9600 N 8 1 int total_ channel 8 DWORD do value 4 turn on the channel two BOOL ret pac _WriteDO_MF hPort PAC _REMOTE_10O 1 total channel do_value uart_Close hPort Example 2 f the module is 87k local HANDLE hPort hPort uart_Open int total channel 8 DWORD do value 4 turn onthe channel two BOOL ret pac_WriteDO_MF hPort 1 total channel do_value uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 191 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteDO Example 1 f the module is remote IntPtr hPort hPort PACNET UART Open COM1 9600 N 8 1 int total_ cha
219. turn value is TRUE If the function fails the return value is FALSE PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 306 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_WriteModulePowerOnValueAO Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 5 BOOL iRet pac_WriteModulePowerOnValueAO hPort iSlot iChannel iAO_TotalCh fValue uart_Close hPort C pac_WriteModulePowerOnValueAO_MF Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 2 int iAO_TotalCh 8 float fValue 5 BOOL iRet pac_WriteModulePowerOnValueAOQ_MF hPort iSlot iChannel iAO_TotalCh fValue uart_Close hPort PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 307 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C pac_WriteModulePowerOnValueAO f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slot 1 int iChannel 2 int iAO_ TotalCh 8 float fValue 5 bool iRet PACNET PAC_ O WriteModulePowerOnValueAO hPort slot iChannel iAO_ TotalCh fValue PACNET UART Close hPort C pac_WriteModulePowerOnValueAO_MF f the module is 87k local IntPtr hPort hPort PACNET UART Open byte slo
220. ueDO_MF pac_WriteModuleSafeValueAO pac_Wri Y Y Y Y Y Y Y Y Y Y teModuleSafeValueAO_MF Ea Y lt lt lt lt a EA dModuleSafeValueAO_MF c_WriteModulePowerOnValueAO_MF _ReadModulePowerOnValueAO_MF pac_GetModuleWDTConfig pac_SetModuleWDTConfig pac_ResetModuleWDT PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 180 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com pac_RefreshModuleWDT Y GS pac_InitWioduleWDTinterrupt Y es ee pac_GetModuleWDtTInterruptStatus 2 pac_SetModuleWDTInterruptStatus ey x of pac_GetModuleLastOutputSource Loo PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 181 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com PAC_1O Functions The following functions are used to retrieve or set the IO modules PACSDK Functions PACNET Functions Description pac_GetBit PAC 10 GetBit retrieves the value which is in specific bit pac_WriteDO pac_WriteDO_ MF PAC _10 WriteDO writes the DO values to DO modules PAC_10 WriteDO_MEF pac_WriteDOBit PAC IO WriteDOBit writes a single bit of value to the DO module that is only the channel corresponding to the bit is changed pac_ReadDO pac_ReadDO_MF PAC_10 ReadDO reads the DO value of the DO module PAC _10 ReadDO_MF pac_ReadDI pac_ReadDI_ MF PAC _10 ReadDI reads the DI value of the DI module PAC _lO Rea
221. uleSafeValueAO_MF 296 300 pac_WriteModulePowerOnValueAO pac_WriteModulePowerOnValueAO_MF305 pac_ReadModulePowerOnValueAO pac_ReadModulePowerOnValueAO_ MF 309 Last Revised November 2013 Page 6 gt lt E mail service icpdas com 2 7 2 8 2 6 32 2 0 33 2 6 34 2 6 35 2 6 36 2 6 37 2 6 38 2 6 39 2 7 1 2 7 2 Zits 2 7 4 Lid 3D 2 7 6 Zid A 2 7 8 2 7 9 2 7 10 2 7 11 2 7 12 2 7 13 2 7 14 any Eta ls 2 7 16 2 8 1 PAC Standard API Manual v1 0 2 Copyright 2013 ICP DAS Co Ltd All Rights Reserved PWM API Backplane Timer API pac_GetModuleWDTStatus pac_GetModuleWDTConfig pac_SetModuleWDTConfig pac_ResetModuleWDT pac_RefreshModuleWDT pac_InitWoduleWDTInterrupt pac_GetModuleWDtTInterruptStatus pac _SetModuleWDTInterruptStatus pac_SetPWMDuty pac_GetPWMDuty pac SetPWMFrequency pac_GetPWMFrequency pac SetPWMMode pac _GetPWMMode pac SetPWMDItTriggerConfig pac_GetPWMDItTriggerConfig pac_SetPWMsStart pac _SetPWMSynChannel pac_GetPWMSynChannel pac_SyncPWWMStart pac SavePWMConfig pac _GetPWMDlIOStatus pac _SetPWMPulseCount pac_GetPWMPulseCount pac_GetBPTimerTimeTick_ms Last Revised November 2013 314 316 320 323 325 327 329 331 338 340 342 344 346 348 350 352 354 356 358 360 362 364 366 Page gt lt E mail service icpdas com 2 8 2 2 8 3 2 8 4 2 8 5 2 8 6
222. ult is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 iChannel in The channel that reads the counter value back from the counter frequency module ICounter_Value out The pointer to the counter value that reads back from the counter frequency module PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 266 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open BYTE iSlot 1 int iChannel 0 DWORD Counter_ Value BOOL iRet pac_ReadCNT hPort iSlot iChannel amp lCounter_ Value uart_Close hPort Example 2 f the module is 8k local BYTE iSlot 1 int iChannel 0 DWORD ICounter_ Value BOOL iRet pac_ReadCNT O iSlot iChannel amp lCounter_ Value PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 267 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com C f the module is 87k local IntPtr hPort hPort PACNET UART Open byte iSlot 1 int iChannel 0 uint Counter_Value 0 bool iRet PACNET PAC O ReadCNT hPort iSlot iChannel ref Counter_Value PACNET UART Close hPort Remarks The function can support for Local or Remo
223. upt pac_UnregisterSlotInterrupt slot unregister slot interrupt I Remarks Default trigger type is level trigger For XP 8000 series only support level trigger type PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 92 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 4 pac_SetSlotinterruptPriority This function sets the priority for a real time thread on a thread by thread basis Syntax C BOOL pac_SetSlotinterruptPriority BYTE slot int nPriority Parameters slot in Specifies the index of slot to set priority nPriority in Specifies the priority to set for the thread This value can range from O through 255 with O as the highest priority Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError Examples This function has no examples PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 93 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 2 5 pac_Interruptinitialize This function initializes a slot interrupt with the kernel This initialization allows the slot to register an event and enable the interrupt Syntax C BOOL pac Interruptinitialize BYTE slot Parameters slot in Specify the index of slot to initialize Return Value
224. urning on the slot interrupt Syntax C BOOL pac_RegisterSlotinterrupt BYTE slot PAC CALLBACK FUNC f Parameters slot in Specifies the index of slot On the XPAC the index of slot starts from 1 A call back function Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE To get extended error information call pac_GetLastError PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 87 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C int slot 3 if slot is 3 int CALLBACK slot_callback_proc do something return true if return true SDK will do pac_InterruptDone automatically else users should do pac_InterruptDone by themselves if needed if interrupt type is level trigger no matter return true or false needn t add pac_InterruptDone and it will work correctly I void CintrDlg OnButton1 pac_RegisterSlotinterrupt slot slot_callback proc pac_EnableSlotinterrupt slot true enable slot interrupt void ClntrDlg OnButton2 pac_EnableSlotinterrupt slot false disable slot interrupt pac_UnregisterSlotInterrupt slot unregister slot interrupt Remarks for XPAC series only Default trigger type is level trigger For XPAC series only support level trigger type PAC Standard API Manual v1 0 2 Last Revised November
225. v1 0 2 Last Revised November 2013 Page 327 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 int CALLBACK slot_callback proc do something return true int iSlot 1 pac_InitModuleWDTInterrupt iSlot slot_callback_proc C static public int slot_callback_proc do something return O static void Main string args int iSlot 1 PACNET PAC_ O InitModuleWDTInterrupt iSlot slot_callback_proc PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 328 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 6 38 pac_GetModuleWDtTInterruptStatus This function reads interrupt status of a module watchdog This function only supports for 8KRW modules Il 80xxRW Syntax C short pac GetModuleWDTInterruptStatus int slot Parameters slot in The slot in which module is to receive the command Default is local Return Value Interrupt status 1 Enabled 0 Disabled PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 329 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C Example 1 int iSlot 1 short sStatus 0 sStatus pac_GetModuleWDtTinterruptStatus iSlot C int iSlot 1 short sStatus 0 sStatus PACNET PAC O GetModuleWDTInterruptStatus iSlot
226. ved D lt E mail service icpdas com Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local 0 if the module is 8k modules in local slot iAddrSlot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 IDO_TotalCh in The total number of DO channels of the DO modules iDO Value in A 8 digit hexadecimal value where bit O corresponds to DOO bit 31 corresponds to DO31 etc When the bit is 1 it denotes that the digital output channel is on and O denotes that the digital output channel is off Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Remarks The definition of the parameters and Return Value of pac_WriteDO and pac_WriteDO_MF functions are the same The different is that pac_WriteDO is applied to the pure DIO DCON modules and pac_WriteDO_MCF is applied to the Multi function DCON modules PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 189 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com Examples C pac_WriteDO Example 1 f the module is remote HANDLE hPort hPort uart_Open COM2 9600 N 8 1 int total channel 8 DWORD do_value 4 turn on the channel two BOOL ret pac_WriteDO hPort PAC REMOTE_ O 1
227. vered in this Manual The following PAC models and PC OS are covered in this manual XPAC family for x86 platform series XP 8000 series XP 8041 Windows Embedded Standard 2009 XPAC with 0 I O slot XP 8341 Windows Embedded Standard 2009 XPAC with 3 I O slots XP 8741 Windows Embedded Standard 2009 XPAC with 7 I O slots XP 8000 Atom series XP 8141 Atom Windows Embedded Standard 2009 XPAC with 1 I O slot XP 8341 Atom Windows Embedded Standard 2009 XPAC with 3 I O slots XP 8741 Atom Windows Embedded Standard 2009 XPAC with 7 I O slots Supported Windows OS for PC Operation System Windows XP Windows 7 Windows 8 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 10 Copyright 2013 ICP DAS Co Ltd All Rights Reserved lt E mail service icpdas com Related Information For additional information about your PAC that can be obtained from CD or by downloading the latest version from ICP DAS web site XPAC family for x86 series XP 8000 Series CD XP 8000 Document http www icpdas com products PAC xpac download xpac_wes download documents h tm XP 8000 Atom Series CD XPAC ATOM Document http www icpdas com products PAC xpac download atom wes download documents Atm PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 11 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com How to contact us For support for this or any ICP DAS product you can
228. vice icpdas com Return Value If the function succeeds the return value is TRUE If the function fails the return value is FALSE Examples C Example 1 f the module is 87k local HANDLE hPort hPort uart_Open int iSlot 1 short iChannel 2 unsigned long ulfreq BOOL iRet pac_GetPWMFrequency hPort iSlot iChannel amp ulfreq uart_Close hPort C IntPtr hPort PACNET UART Open int iSlot 1 short iChannel 2 uint ulfreg 0 bool iRet PACNET PWIM GetPWMFrequency hPort iSlot iChannel ref ulfreq PACNET UART Close hPort Console WriteLine The frequency value is ulfreq ToString Console ReadLine The example displays the following output to the console The frequency value is 1 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 343 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 7 5 pac _SetPWMMode This function sets the continuous mode for a specific channel Syntax C BOOL pac _SetPWMMode HANDLE port int slot short chindex long mode Parameters hPort in The serial port HANDLE opened by uart_Open if the module is 87k modules in local slot in The slot in which module is to receive the command Default is local If the IO module is remote please use the macro PAC_REMOTE_IO 0 255 chindex in Specify a channel to set the continuous mode mode
229. ype O Hardware watchdog PAC_WDT_HW 1 OS watchdog PAC_WDT_OS Return Value The return value is the watchdog time which has been assigned by pac_EnableWatchDog or pac_SetWatchDogTime For OS watchdog the unit of the return value is second and for hardware watchdog the return value is between 0 63 PAC Standard API Manual v1 0 2 Last Revised November 2013 Copyright 2013 ICP DAS Co Ltd All Rights Reserved gt lt E mail service icpdas com Examples C DWORD dwtTime dwTime pac GetWatchDogTime PAC_WDT_OS C uint uTime uTime PACNET Sys W DT GetWatchDogTime 1 Console WriteLine The watchdog time is uTime ToString Console ReadLine The example displays the following output to the console The watchdog time is 10 PAC Standard API Manual v1 0 2 Last Revised November 2013 Page 127 Copyright 2013 ICP DAS Co Ltd All Rights Reserved D lt E mail service icpdas com 2 4 6 pac _SetWatchDogTime This function starts a watchdog operation The unit of the parameter value for OS watchdog is second In addition the value cannot be zero The value of the parameter value for hardware watchdog is limited to the range of 0 63 unit A unit is about 0 5 seconds 0 means the shortest timeout otherwise 63 is longest and it takes about 30 seconds Syntax C BOOL pac_ SetWatchDogTime int wat DWORD value Parameters wat in Specifies the W
Download Pdf Manuals
Related Search
Related Contents
IPhone 3020 取扱説明書 - Y!mobile(ワイモバイル) Manual em PDF Uniden UDRC14 surveillance camera MODEL 4192A LF IMPEDANCE ANALYZER LO + DESTACADO Sirius Satellite Radio SIR-ALP10T User's Manual Mise en service - LEVEL TRANSMITTER 8189 Origin Storage 128GB MLC SATA 2.5" Copyright © All rights reserved.
Failed to retrieve file