Home

- Literature Library

image

Contents

1. Module Name Description Class Mi Type 1746 104 2 Input 100 120 V ac 2 Output RLY 0 8 0 1746 108 4 Input 100 120 V ac 4 Output RLY 0 11 0 1746 1012 6 Input 100 120 V ac 6 Output RLY 0 15 0 1746 INT4 4 thermocouples isolated 1 35 15 1746sc INOAVI Spectrum Controls 4 Analog Outputs 35 19 1746sc INIAVI Spectrum Controls 4 Analog Inputs 35 20 1746sc INOAI Spectrum Controls 4 Analog Outputs 35 21 1146sc INI4l Spectrum Controls 4 Analog Inputs 35 22 1746 NI4 4 Channel Analog Input 44 1 1746 NI8 8 Analog Inputs 35 26 1746 NI8 8 Analog Inputs 3 127 26 1746 NIOAI Analog Comb 2 In amp 2 Current Out 1 32 1 1746 NIO4V Analog Comb 2 In amp 2 Voltage Out 32 2 1746 HO41 Fast Analog Comb 2 In amp 2 Current Out 32 24 1746 HO4V Fast Analog Comb 2 In amp 2 Voltage Out 32 18 1746 N041 4 Channel Analog Current Output 54 1 1746 N04V 4 Channel Analog Voltage Output 54 2 1746 NT4 4 Channel Thermocouple Input Module 35 10 1746sc NT8 Spectrum Controls 4 Analog inputs isolated 35 33 1746 NR4 4 Channel RTD Resistance Input Module 35 13 1746 HSCE High Speed Counter Encoder 3 127 5 1746 HS Single Axis Motion Controller 1 33 3 1746 HSRV SLC Servo Single AX MC 3 101 14 1746 HSTP1 Stepper Controller Module 1 35 12 1746 BAS13 BASIC Module 5 01 Configuration 35 6 1746 BAS2 BASIC Module 5 02 Configuration 4 131 6 1746 05 Synchronized Axes
2. OCEXTERR See appendix A for error codes Return Value Name Value Description SUCCESS 0 extended error information was read successfully ERR_OCACCESS 2 handle does not have access to scanner Publication 1747 UM002A US P June 2000 Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle OCEXTERR exterr char msg int retcode Should already have called OC GetExtendedError to obtain exterr retcode OC ExtendedErrorMsg Handle amp exterr amp msg printf ERROR sNn msg Library of Routines 6 17 0C_GetBatteryStatus OC_GetBatteryStatus gets the current state of the battery of the scanner Syntax int OC_GetBatteryStatus HANDLE handle BYTE batstate Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner batstate If batstate IS BATTERY_GOOD battery voltage is good BATTERY LOW battery voltage has dropped below a reliable level Description The battery provides backup power for the host retentive data dual port RAM Return Value Name Value Description SUCCESS 0 battery state was read successfully ERR OCACCESS 2 handle does not have access to scanner ERR OCINIT 5 scanner has not been initialized see OC InitScanner Considerations Supported in the
3. Syntax int OC_SetUserLEDState HANDLE handle int lednum int state Parameters Parameter Description handle Must be a valid handle returned from OC_OpenScanner lednum Must be a value from 1 to 4 which corresponds to LED1 LED2 LED3 and LED4 ledstate If ledstate IS LED_OFF LED is off LED_RED_SOLID LED is on red solid LED_GREEN_SOLID LED is on green solid LED_RED_FLASH LED is on red flashing LED1 and LED2 only LED_GREEN_FLASH LED is on green flashing LED1 and LED2 only Description The application can use the four user LEDs for any purpose Return Value Name Value Description SUCCESS 0 LED was updated successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCPARAM 8 parameter contains invalid value Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC_SetUserLEDState Handle 1 LED_GREEN_SOLID Publication 1747 UM002A US P June 2000 6 66 Library of Routines OC_SetupPowerFail Action OC_SetupPowerFailAction registers the action to be taken when a power fail interrupt is received from the scanner Syntax int OC SetupPoverFailAction HANDLE handle BYTE bufptr WORD offset WORD length void callback Parameters Parameter Description handle Must be a valid handle returned from OC_OpenScanner
4. QO SDO p p EE Publication 1747 UM002A US P June 2000 SlotCfg contains information about each slot in the racks The 1746 I O PCI Interface supports as many as 31 slots numbered 0 to 30 Slot 0 is the adapter slot left slot of rack 1 and is invalid for scanner functions Each slot is described by the structure OCSLOTCFG mix Module 1 0 Mix value type Module Type InputSize number of inputs in bytes OutputSize number of outputs in bytes MOSize size of MO file in words MiSize size of M1 file in words GSize size of G file in words GData pointer to array of length GSize Name pointer to module name string You can specify a module by name or by mix and type You only specify G data if the module uses G files such as the 1747 SN If the Name pointer is NULL OC_CreatelOConfiguration uses mix and type to identify the module See page 4 for the mix and type values OC_CreatelOConfiguration supplies the InputSize OutputSize MOSize M1Size Gsize and Name fields If Name points to a string containing a valid module name the module name identifies the module OC CreatelOConfiguration supplies the mix type InputSize OutputSize MOSize MISize and Gsize fields Initialize empty slots and slot O with a mix value of OxFF and a type value of OxFF If the module is not in the internal database OC_CreatelOConfiguration doesn t alter the OCSLOTCFG To support m
5. CPATH D MSVC15 Location of Microsoft tools CC CPATH bin cl compiler LINK S CPATH NbinNlink linker MAKE CPATH bin nmake make utility Path to API Library and Include file Publication 1747 UM002A US P June 2000 2 6 Using the API Note Modify the following path to correspond to your environment APILIB ocapil lib Path to Open Controller API library APIINC Path to Open Controller API include file Options CFLAGS c nologo G3 W3 AL Oi D Gx I S APIINC LFLAGS MAP A NOI PACKC sample exe sample obj APILIB samplem mak LINK LFLAGS sample obj exe map S APILIB nul def clean del exe del obj del map rebuild MAKE f samplem mak clean MAKE f samplem mak c obj CC S CFLAGS c sample obj sample c APIINC ocapi h samplem mak Sample Windows NT MAKE file for Microsoft compilers The following sample file shows how to use a Microsoft MAKE file The bold headings indicate the statements you need to modify for your environment Abstract sample application Environment Microsoft Windows N1 Microsoft Visual C KAKKKAKAKKAK KA KKK KA KKK KKK KKK KA K KA KA K KA KKK KKK KKK KK KKK KA KOKA KKK KKK KA ko ko KKK KKK Title Makefile for Open Controller NT API Sample This file is used by the Microsoft NMake utility to build the 1747 OCE Open Controller 4 0 c Copyright All
6. iocfg SlotCfg 6 mix 35 iocfg SlotCfg 6 type 6 Slot 6 has 1746 BAS module or iocfg SlotCfg 6 name module name Use name instead Add additional module information to match the physical I O configuration retcode OC CreatelOConfiguration amp iocfg Use OC DownloadlOConfiguration to download the information OC DemandinputScan forces the scanner to immediately perform an input scan Syntax int OC DemandInputScan HANDLE handle int mode Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode IS OCVVAIT OC DemandinputScan waits for the input scan to be completed before returning to the caller OCNOWAIT OC DemandinputScan returns immediately Description If an I O scan is in progress when this function is called the input scan is performed after the current scan has completed Publication 1747 UM002A US P June 2000 6 8 Library of Routines The scanner updates the input image vvith data read from the modules Use OC Readinputimage to read data from the input image Return Value Name Value Description SUCCESS 0 demand input request was successful ERR_OCACCESS 2 handle does not have access to scanner ERR_OCRESPONSE 10 scanner did not respond to request ERR_OCSCANCFG 14 scanner has not been configured Considerations Supported in the DOS API libra
7. JES TYPE DEFINITIONS HA KKKKKKKKKKKKKKKKKKKAKKKAKKAKAKAKKAKKAKAKKKAK typedef unsigned char BYTE 8 bit unsigned value typedef unsigned short WORD 16 bit unsigned value typedef unsigned long DWORD 32 bit unsigned value typedef unsigned short HANDLE access token for scanner kk kk ke eee See See ke e ke e e S S S S S S KKK KA S amp M amp M amp A M X ike kek STRUCTURES BECKY KKRKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK ensure structures are byte aligned ifdef BORLANDC pragma option al endif _BORLANDC ifdef _MSC_VER pragma pack 1 endif MSC VER JAKKKAKKKAKKKA KKK KKKAKKKA IK kk A OK Structure Name OCINIT Description AA A Passed to OC InitScanner function to specify size of dual port RAM available for 1 0 and host partitions Publication 1747 UM002A US P June 2000 C 6 Header File dual port RAM partition sizes for output image input image and host retentive data KARA RRA RARA RRA KKKAKKKAKKKAKKKKKKAKKKKKKKKKKKKKKKKKKJ typedef struct tagOCINIT WORD OutputImageSize size in bytes WORD Input ImageSize size in bytes WORD HostRetentiveDataSize size in bytes OCINIT PARRA RIA RARA RARA RRA RRA RR RRA RRA RAR RRA RRA kk RAR k k k Structure Name OCSLOTCFG Description Configuration information for a module The mix and x type codes together form a unique id
8. Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC OpenScanner sHandle 0 O if OC OpenScanner amp Handle 0xC800 IRQ11 SUCCESS printf Scanner could not be opened n OC_PetHostWatchdog increments the host to scanner watchdog register of the scanner Syntax void OC_PetHostWatchdog HANDLE handle Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner Description OC PetHostWatchdog must be called at time intervals less than the timeout value specified in the OC SetHostWatchdog function Return Value Name Value Description SUCCESS 0 watchdog was updated successfully ERR OCACCESS 2 handle does not have access to scanner Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle retcode OC PetHostWatchdog Handle Publication 1747 UM002A US P June 2000 6 44 Library of Routines OC PollScanner OC PollScanner reads module 1 0 interrupt discrete input interrupt and end of scan notification messages from the scanner Syntax int OC PollScanner HANDLE handle int MsgFilter MSGBUF msgbuf Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner MsgFilter If MsgFilter Is OCMSG_DIINT OCMSG_IOINT OCMSG_EOS OC_PollSc
9. Publication 1747 UM002A US P June 2000 If no I O forces are in the force files OC EnableForces does not enable forces and instead returns an error All forces are disabled by default Library of Routines 6 13 Return Value Name Value Description SUCCESS 0 forces were updated successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCNOFORCES 15 no forces installed scanner cannot enable forces ERR_OCPARAM 8 parameter contains invalid value ERR_OCRESPONSE 10 scanner did not respond to request ERR_OCSCANCFG 14 scanner has not been configured Considerations OC EnableSlot Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode Use OC SetForces to configure forcing information first He retcode OC EnableForces Handle FORCE ENABLE OC EnableSlot enables fine tuning of the I O scanning process Syntax int OC EnableSlot HANDLE handle int slotnum int state Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner slotnum Must contain a valid slot number state If state IS SLOT_ENABLE the module is released from its reset state and is included in the 1 0 scan SLOT DISABLE the module is no longer included in the 1 0 scan and any outputs remain at their last state Publication 1747 UM002A US P June 20
10. Syntax int OC_GetExtendedError HANDLE handle OCEXTERR buf Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner buf Contains the extended error information If no extended error information is available the error code field of buf will be 0 Description The extended error information is written during Scan mode or its configuration An API function that determines that the scanner has responded with an error returns an error code of ERR_OCEXTERR OC_GetExtendedError retrieves the extended error information written by the scanner and removes the error from the scanner The library buffers extended errors in a queue The queue can hold as many as 5 extended errors at one time If the queue is full when a new extended error is received from the scanner the oldest extended error is lost and ERR_OCOVERRUN is returned The host application must call this function periodically to remove existing extended errors from the buffer The OCEXTERR structure is defined as define OCERRDATASIZE3 number of bytes of error data typedef struct tagOCEXTERR BYTE ErrorCode Extended error code BYTE SlotNum Associated slot number BYTE ErrorData OCERRDATASIZE Error code data OCEXTERR See appendix A for error codes Return Value Value
11. These values are passed to the OC SetHostWatchdog function 7 7 define WATCHDOG IGNORE 0 Host watchdog is disabled define WATCHDOG_IDLE 1 Scanner with change to Idle mode on host wdog timeout define WATCHDOG_RESET 2 Scanner will issue a system reset on host wdog timeout KKKKK Reset Cause KKKKK These values are returned by the OC GetResetCause function Le KA define RESET NOT HOST WD 0 Reset was not caused by the host watchdog define RESET HOST WD 1 Reset was caused by the host watchdog Ki Module I O Int Modes These values are passed to the OC SetModuleInterrupt function Ki pe Ef define IOINT_ENABLE 1 Enable module interrupt define IOINT DISABLE 0 Disable module interrupt define IOINT ACK XL Acknowledge module interrupt Output Update Modes These values are passed to the OC SetOutputUpdateMode function JE i define OUTUPD_NEVER 0 Never scan outputs xf define OUTUPD CHANGE 1 Only scan outputs when output image chages define OUTUPD ALWAYS 2 Scan outputs every scan DNA f Input Update Modes These values are passed to the OC SetInputUpdateMode function define INUPD_NEVER 0 Never scan outputs define INUPD ALWAYS E Scan outputs every scan f EndOfScan Modes These values are passed to the OC EnableEOSNotify function ERA LE E
12. x x x x x x x x x x x x x x x x x x x x x x x x x x x x Entry point main Description This program resets initializes the front panel svitch position It lights User LED 1 input module Arguments none External effects none Return value 0 if no errors wer ncount red 1 if errors Access Public Entry point of the PCI I O bus interface API sample application and autoconfigures the scanner It displays the scanner firmware and hardware versions and reads inputs from a 32 pt discrete and writes data to the MO file on a BAS module Notes main Creat int int int int ter i slots BASslot int IB32slot int fRecreatelOcfg OCINIT ocpart BYTE Status OCVERSIONINFO verinfo BYTE swpos WORD wData wLen BYTE temp BASslot IB32slot fRecreatelOcfg 0 0 Open the scanner if SUCCESS printf nERROR OC_OpenScann rc OC OpenScann r fail r amp OChandle d d n Ioexit 1 an itf i long _beginthread t rror handling thread el mrrornaven Ec C 0 NULL printf NnERROR beginthread terror Event failed An KAKAKAKAKAKAKAKKKKKKKKKKKKKKKKKKKKKKAKKKAKKKAKKKAKAKAKAKAKAKAKKKKKKKKKKJ Access the scanner Publication 1747 UM002A US P June 2000 3 14 Developing Applications
13. BYTE Rack2Size number of slots in Rack 2 Publication 1747 UM002A US P June 2000 6 22 Library of Routines BYTE Rack3Size number of slots in Rack 3 OCSLOTCFG slotCfg OCMAXSLOT configuration for each slot OCIOCFG Return Value Name Value Description SUCCESS 0 1 0 configuration was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner ERR_OCRESPONSE 10 scanner did not respond to request OC GetLastFaultCause Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle OCIOCFG iocfg int retcode retcode OC GetlIOConfiguration Handle amp iocfg Use OC DownloadlOConfiguration to download the information OC GetLastFaultCause retrieves the cause of the last fault Syntax int OC GetLastFaultCause HANDLE handle BYTE FaultCode int SlotNum Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner FaultCode Points to the address that contains the fault cause If the value returned in FaultCode is 0 the scanner has not received any faults since it has been reset SlotNum Slot number that caused the fault Publication 1747 UM002A US P June 2000 Library of Routines 6 23 Description When the scanner faults
14. Description SUCCESS 0 extended error information was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCOVERRUN 16 an error message has been discarded Publication 1747 UM002A US P June 2000 6 20 Library of Routines OC Getinputimage UpdateCounter Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle OCEXTERR exterr int retcode retcode OC_GetExtendedError Handle amp exterr OC GetinputimageUpdateCounter reads the value of the input image update counter from the scanner and places it into count Syntax int OC_GetInputImageUpdateCounter HANDLE handle BYTE count Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner count Contains the value of the input image update counter Description The input image update counter is incremented by the scanner after each input scan The input image update counter is only incremented if the scanner is in Scan mode input scans are enabled and inputs are present Use the counter to determine whether a change occurred the value of the counter is not important It is possible to configure a system with no inputs in this case the input image update counter would not be incremented Return Value Name Value Description SUCCESS 0 input image update counter
15. OC SetScanMode OChandle SCAN RUN printf nERROR OC SetScanMode failed d n rc Ioexit 1 Turn on User LED 1 if SUCCESS rc OC SetUserLEDState OChandle 1 LED GREEN SOLID printf NnERROR OC SetUserLEDState failed d n rc Ioexit 1 Read word 0 of IB32 module if IB32slot 0 if SUCCESS rc OC ReadinputImage OChandle NULL IB32slot 0 1 amp wData printf nERROR OC_ReadInputImage failed d n rc Ioexit 1 Scan 1 0 Write the data read to word 2 of BAS module MO file wLen 1 if BASslot 0 if SUCCESS rc OC NriteModuleFile OChandle FILTYP MO amp wData BASslot 2 wLen printf NnERROR OC WriteModuleFile failed d n rc Ioexit 1 PR Close the scanner befor xiting OC_CloseScanner OChandle return 0 end main Publication 1747 UM002A US P June 2000 Developing Applications 3 17 Handling Interrupt Messages Handling Errors Modules that communicate via discrete input interrupts or module interrupts require special attention The API buffers these interrupts internally until they are extracted via OC PollScanner The internal message buffer can hold as many as 5 messages If the message buffer is full the oldest message in the buffer is overwritten by the next message Interrupts vvill be missed if OC PollScanner is not called by the application more often than interrupts ar
16. Solid green The scanner is scanning 170 None Flashing red An 170 fault has occurred Check software to identify fault condition Solid red scanner internal fault has Power system off and back on occurred If the problem persists service may be required Off The adapter is not powered up Turn on power Publication 1747 UM002A US P June 2000 1 8 Overview Installing the DOS API Installing the Windows NT API Publication 1747 UM002A US P June 2000 To install the DOS API copy the following files to a directory you create The sample code files are optional but they show how to use the API functions This file Contains ocapil lib API functions that you link to your application ocapi h API header file that contains APl referenced structures sample c Sample application program calling the API functions sampleb mak Sample make file for the Borland C compiler samplem mak Sample make file for the Microsoft C compiler To install the Windows NT APT use the setup utility TIP It is recommended that you exit all applications before starting the setup process Copy the contents of the API diskette to a temporary directory on the open controllerys disk drive This step is not necessary if a local diskette drive is connected The device driver file is OCdriver sys Select Run from the startup menu then select the setup exe program from the temporary directory Click on OK to execute the
17. Supported in the DOS API library and the Windows NT API library Example OCIOCFG iocfg int retcode Either OC CreatelOConfiguration or OC GetIOConfiguration vere called previously to fill in iocfg structure retcode OC WritelOConfigFile amp iocfg RACK1 CFG OC WriteModuleFile writes a data file to a module Syntax int OC WriteModuleFile HANDLE handle BYTE ftype WORD mfile int slotnum WORD offset WORD len Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner ftype Defines the module type as FILTYP MO MO file FILTYP M1 M1 file FILTYP G G file mfile Buffer file that contains data read from the module at slotnum The data in m ile is written to the module starting at word offset This function does not write data past the end of the module file for the slot slotnum Must be a valid slot number offset Must be valid word number within module file len Number of words written from the module located at slotnum on the scanner into the buffer mfile Description This function accesses an internal data file of the selected module I O scanning is blocked while this access takes place Publication 1747 UM002A US P June 2000 6 78 Library of Routines Return Value Name Value Description SUCCESS 0 file was read successfully ERR_OCACC
18. define EOSMSG_ENABLE 0 Enable end of scan notification messages define EOSMSG_DISABLE 1 Disable end of scan notification messages KKK Wait Flags KKKKK define OCNOWAIT 0 Return without waiting for operation to complete define OCWAIT 1 Wait for operation to complete before returning Publication 1747 UM002A US P June 2000 Je Module File Types KARRE These values are passed to the OC WriteModuleFile functions define FILTYP_G define FILTYP_MO define FILTYP M1 0x05 Module G file 0x08 Module MO file 0x09 Module M1 file T O Configuration Definitions tdefine OCMAXSLOT define OCEMPTYTYPE define OCEMPTYMIX define OCNILDTYPE define OCSTSFILEWSIZE define OCRTCSRAMSIZE define OCSEGMENTSIZELIMIT 0x1A00 Header File C 5 and OC ReadModuleFile 4 e i d a 31 Maximum number of slots slot 0 is reserved for PCIL OxFF Mix and type codes for empty slots and slot 0 OxFF OxFF Wildcard type code matches any module type 25 Status file size in words 0x1000 size of real time clock SRAM Message callback return values define OCNOQUEUE define OCQUEUE BS 0 Device Type Definitions f Returned by OC GetDeviceInfo define OCDEVTYPE_OC 1 1747 PCIL define OCDEVTYPE PCIS 2 1747 PCIS KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
19. v uoce ASA 2 2 Windows NT Considerations 2 3 To lsto LIS jau j vj U vd e Die de 2 4 Sample DOS MAKE file for Borland compilers 2 4 Sample DOS MAKE file for Microsoft compilers 2 5 Sample Windows NT MAKE file for Microsoft compilers 2 6 Sample Windows NT MAKE file for Borland compilers 2 8 Chapter 3 a pe kek KA TN RA de t 3 1 How the API Functions Are Organized 3 1 Programming Sequence 3 1 Access the scanner nia aos 3 2 Initialize the scanner eqe ia pinte deg PETES ss 3 2 Configure the scanner s ence etd a dinde etes 3 3 Control scanner operation xix eee los 3 4 Seam Org ana Seed AN dra ROG KE EES 3 4 Programming Example for DOS Vito ane ge pet 3 5 Programming Example for Windows NT 3 11 Handling Interrupt Messages 3 17 Handling Errors we rta q n toe PE ES 3 17 Determining Partition Sizes for Shared Memory 3 18 Publication 1747 UM002A US P June 2000 Table of Contents ii Using the API Structures Configuring 1 0 Modules Library of Routines Publication 1747 UM002A US P June 2000 Chapter 4 Introduction a pire DEDE er eed ER 4 1 API StEUCt fesan v veil ac as ex w LER dl oe US 4 1 Chapter 5 Introductorio pend wp YN Ee OX NE SDN Ex 5 1 CONTOUR L O 65 sep doe td nie en pm RS 5 1 Usine M0 M1 Files and G Files oa qc se E qoe e bee ec 5 3 MOM DIES sp e a SAA SS 5 3 OS aa aeu Dd A Beh u
20. BYTE OC GetSwitchPosition HANDLE BYTE OC GetUserJumperState HANDLE BYTE OC SetHostWatchdog HANDLE int WORD OC PetHostWatchdog HANDLE OC GetScannerWatchdogCount HANDLE BYTE OC GetResetCause HANDLE int OC WriteHostRetentiveData HANDLE BYTE WORD WORD OC ReadHostRetentiveData HANDLE BYTE WORD WORD OC GetVersionInfo HANDLE OCVERSIONINFO OC GetExtendedError HANDLE OCEXTERR l OC CalculateCRC BYTE WORD WORD OC ErrorMsg int char d OC ExtendedErrorMsg HANDLE OCEXTERR char OC GetMeasuredScanTime HANDLE WORD WORD OC WritelOConfigFile OCIOCFG char OC ReadIOConfigFile OCIOCFG char OC ReadRECSRAM BYTE WORD WORD OC WriteRtcSRAM BYTE WORD WORD OC SetupPowerFailAction HANDLE BYTE WORD WORD void void OC SetInputUpdateMode HANDLE int OC DemandInputScan HANDLE int OC SetupMessageCallback HANDLE int int void OC GetDeviceInfo HANDLE OCDEVICEINFO OCAPI H Publication 1747 UM002A US P June 2000 C 10 Header File Windows NT Header File JAKKKKAKKKKAKKKK KKK KKAKKKAKKKKKKAKKKAKKKKKKAKKKAKKKKKKKAKKKAKKAKKKAKKKKKKAK Title Abstract Contains definitions structures 1746 1 0 PCI Interface API library header file and function templates for all functions defined in the Open Controller API This file is distributed as part of the API Environmen
21. Description 0x00 Download error invalid directory file pointer block 0x01 Download error change to Idle mode failed 0x02 Download error configuration file CRC failed byte 1 contains the file number 0x03 Download error directory CRC failed 0x04 Download error input or output image exceeds partition allocation byte 1 contains 0 for output image 1 for input Publication 1747 UM002A US P June 2000 A 4 Error Codes Publication 1747 UM002A US P June 2000 The third byte of the Error Code Data provides details about the Subsystem Error Codes Error Code Description 0x01 Rack configuration verify error 0x02 DII configuration error 0x03 1 0 error occurred while updating slot enables Ox06 1 0 error occurred while polling for PINT 0x07 Bad module mode change attempted 0x08 Slot error occurred during mode change 0x09 Source of module interrupt not found Ox0A Corrupted directory file detected when going to run mode Ox0C 1 0 error occurred while servicing module interrupt Ox0D Module interrupt from disabled slot OxOE Interrupting module requested unsupported service OxOF 1 0 error while performing input scan 0x10 1 0 error while performing output scan 0x11 Verified read or write error If the extended error code is an internal scanner error OxFO the slot number is set to O and the first byte of the Error Code Data contains the source of the error The table belo
22. Reset the scanner printf AnResetting the scanner if SUCCESS rc OC_ResetScanner OChandle OCWAIT printf NnERROR OC ResetScanner failed d n rc Ioexit 1 Initialize the scanner Check scanner status register if SUCCESS rc OC_GetScannerStatus OChandle amp status printf AnERROR OC GetScannerStatus failed d n rc Toexit 1 if status SCANSTS INIT printf AnERROR POST failure detected d n status Ioexit 1 Initialize the DPR partitions ocpart Output ImageSize 0x800 ocpart InputImageSize 0x800 ocpart HostRetentiveDataSize 0 if SUCCESS rc OC InitScanner OChandle amp ocpart printf NnERROR OC InitScanner failed d n rc Ioexit 1 Display software hardware versions if SUCCESS rc OC GetVersionInfo OChandle amp verinfo printf NnERROR OC GetVersionInfo failed d n rc Ioexit 1 printf nOC API Series 02d Revision 02d 7 verinfo APISeries verinfo APIRevision printf NnoCdriver Series 02d Revision 02d 7 verinfo OCdriverSeries verinfo OCdriverRevision printf nOC Scanner Firmware Series 02d Revision 02d verinfo ScannerFirmwareSeries verinfo ScannerFirmwareRevision printf An0C Hardware Series 02d Revision 02d n verinfo OCHardwareSeries verinfo OCHardwareRevision Read switch position i
23. comparison is satisfied When the total number of counts equals the DII preset value an interrupt will be generated This word is applied upon detection of the DII reconfigure bit 11 10 and at the end of each 1 0 scan status DII accumulator The DII accumulator contains the number of count transitions that have occurred see word 17 When a count occurs and the accumulator is greater than or equal to the preset value a DII interrupt is generated status Scanner firmware series This word indicates the scanner firmware series number The series and revision numbers are used to identify versions of firmware 20 status Scanner firmware revision This word indicates the scanner firmware revision number The series and revision numbers are used to identify versions of firmware status 1746 1 0 PCI Interface hardware series This word indicates the 1746 1 0 PCI Interface hardware series number The series and revision numbers are used to identify versions of firmware 22 status 1746 1 0 PCI Interface hardware revision This word indicates the 1746 1 0 PCI Interface hardware revision number The series and revision numbers are used to identify versions of firmware 23 status Scanner RAM size This word indicates the size of RAM in 16 bit K words For example a value of 64 indicates 64K words or 128K bytes 24 status Scanner flash ROM size This word indicates the size of flash
24. mode Publication 1747 UM002A US P June 2000 6 60 Library of Routines 0G SetModulelnterrupt OC SetModuleInterrupt enables disables or acknowledges the module interrupt for the slot s1otnum on the scanner Syntax int OC SetModuleInterrupt HANDLE handle int slotnum int mode Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner slotnum Must be a valid slot number mode If mode Is IOINT_ DISABLE the module interrupt is disabled default IOINT ENABLE the module interrupt is enabled IOINT_ACK the module interrupt is acknowledged Description When a module interrupt is received the scanner generates a module interrupt message that the host application can read by calling the OC_PollScanner function After retrieving the module interrupt message the host application should immediately acknowledge the module interrupt and then service the module interrupt message The module interrupt must be acknowledged before another can be received from that module Return Value Name Value Description SUCCESS 0 module interrupt was processed successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCPARAM 8 parameter contains invalid value ERR_OCRESPONSE 10 scanner did not respond to request ERR_OCSCANCFG 14 scanner has not been configured ERR_OCSLOT 12 slot number is invalid Considerations Supported in the DOS
25. see your user manual for your compiler If you plan to use a programming language other than C make sure the programming language follows the appropriate calling convention Pascal for the DOS API Win32 _stdcall for Windows NT After you write your application use your compiler to link to ocapil lib DOS or ocapi lib Windows NT The follow pages offer sample MAKE files for DOS and Windows NT systems on Microsoft and Borland compilers Sample DOS MAKE file for Borland compilers The following sample file shows how to use a Borland MAKE file The bold headings indicate the statements you need to modify for your environment Kk ck Ck ck ck Ck ck ck Ck ck KA KKK KA KKK KKK KKK KA K KA KA K KA KKK KKK KA KKK KKK KKK KKK KKK KKK KKK KKK KKK Title Makefile for Open Controller API Sample Abstract This file is used by the Borland MAKE utility to build the sample application Environment 1747 OCE Open Controller MS DOS Borland C C Compiler 16 bit kk ck Ck ck ck Ck ck ck kk Ck Sk KKK KA KKK KKK KKK KA K KA KA K KA KKK KKK KKK KA KKK KKK KA KKK KAKAO KA kc ko kc KAKKK Paths to Tools Note Modify the following paths to correspond to your environment CPATH D BC5 Location of Borland tools CC CPATH bin Bcc compiler LINK CPATH bin TLink linker MAKE CPATH bin Make make utility Path to API Library and Include file Note Modify the following path to correspond
26. the interrupt MsgData 3 highbyte of count of matches that generated the interrupt MsglD 0CMSG_EOS_DMDIN MsgData 0 number of scans that occurred since the last MsglD 0CMSG EOS DMDOUT MsglD OC EOS end of scan message of this type was read Separate queues hold messages received from each source The host application must call OC PollScanner periodically to read messages from each enabled source to prevent messages from being discarded If a message queue is full when a new message is received the oldest message is discarded and the next call to OC PollScanner results in a return value of ERR OCOVERRUN The queue can hold as many as five messages Return Value Name Value Description SUCCESS 0 scanner was polled successfully ERR OCACCESS 2 handle does not have access to scanner ERR OCOVERRUN 16 a message has been discarded Considerations Supported in the DOS API library and the Windows NT API library Publication 1747 UM002A US P June 2000 6 46 Library of Routines 0C_ReadHostRetentive Data Example HANDLE Handle MSGBUF msgbuf int retcode retcode OC PollScanner Handle OCMSG ANY amp msgbuf Check msgbuf MsgID for what message is available OC_ReadHostRetentiveData reads the host retentive data partition of the scanner Syntax e int OC_ReadHostRetentiveData HANDLE handle BYTI buf WORD offset WORD len Pa
27. then OCcfg SlotCfg i mix 131 make it class 4 OCcfg SlotCfg i Name NULL remove name so that OC CreatelOConfiguration will key off mix type fRecreatelOcfg 1 BASslot 1 check for IB32 modules if OCcfg SlotCfg i mix IB32slot 1 if we converted a Class 1 BAS module to Class 4 recreate the 10 configuration to insure we get the MO and M1 file sizes if fRecreatelOcfg 1 if SUCCESS rc OC_CreatelO0Configuration 0Ccfg printf nERROR OC CreatelOConfiguration failed d n rc Ioexit 1 Publication 1747 UM002A US P June 2000 3 16 Developing Applications Download the configuration to the scanner if SUCCESS rc OC DownloadlIOConfiguration OChandle 0Ccfg printf nERROR OC DownloadIOConfiguration failed dWMn rc Configure the scanner Toexit 1 Set output update mode to always if SUCCESS rc OC SetOutputUpdateMode OChandle OUTUPD ALWAYS printf nERROR OC SetOutputUpdateMode failed Sd n rc Ioexit 1 Set scan time to Sms LE SUCCESS rc periodic scan mode OC_SetScanTime OChandle l SCAN_PERIODIC 20 Control scanner operation printf nERROR OC_SetScanTime failed d n rc Ioexit 1 Goto Scan Mode if SUCCESS rc
28. 0x55AA outputdata 1 0xAA55 retcode OC WriteOutputImage Handle NULL 6 O0 2 outputdata OC WriteSRAM wires data to the battery backed user memory Syntax int OC WriteSRAM HANDLE Handle BYTE bufptr DWORD offset DWORD length Description The battery backed memory may be used to store important data that needs to be preserved in the event of a power failure The size of the available memory in bytes may be obtained using OC GetDeviceInfo IMPORTANT Lis recommended that the integrity of data stored in the user memory be verified by some means The OC CalculateCRC function may be used to generate a 16 bit CRC that may be used for this purpose handle must be a valid handle returned from OC OpenScanner bufptr points to the data to be written offset specifies the offset within the memroy to begin writing length specifiies the number of bytes to be written If offset length points past the end of the memory no bytes will be written and ERR_OCPRAM will be returned Return Value Library of Routines 6 81 Name Description SUCCESS data was written successfully ERR_OCACCESS handle does not have access to scanner ERR_OCPARAM offset length points past the end of the memory Considerations Supported in the Windows NT API library only Example Byte buf 100 buffer of important data Word crc HANDLE handle Save 100 bytes of OC_WriteSRAM handle Cal
29. API library and the Windows NT API library Publication 1747 UM002A US P June 2000 Library of Routines 6 61 OC SetOutputUpdate Mode Example HANDLE Handle int retcode retcode OC SetModuleInterrupt Handle 6 IOINT ENABLE Slot 6 module now enabled to generate module interrupts Use OC PollScanner to check for Module Interrupt messages OC SetOutputUpdateMode controls how the scanner updates real outputs from the Output Image Syntax int OC SetOutputUpdateMode HANDLE handle int mode Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode Is OUTUPD_NEVER the scanner does not write outputs from the output image unless explicitly requested by the OC DemandOutputScan function OUTUPD CHANGE the scanner writes outputs only when the scanner output image is written via OC WriteOutputlmage but does not continuously update outputs from the output image every scan OUTUPD ALWAYS the scanner continuously updates outputs from the output image on every scan By default the output update mode is OUTUPD NEVER A change in status of the output update mode will take effect at the start of the next scan Description This function does not affect input image scanning Setting the output update mode to OUTUPD NEVER allows the host application to read the input image and perform logic to determine the
30. E AAA Publication 1747 UM002A US P June 2000 3 6 Developing Applications INCLUDE FILES Xj tinclude ocapi h tinclude lt stdio h gt tinclude lt dos h gt tinclude lt time h gt tinclude lt conio h gt include lt string h gt MODULE WIDE GLOBAL VARIABLES EL HANDLE Handle Software ID to scanner device OCIOCFG OCcfg Chassis I O config data structure FUNCTION PROTOTYPES E void loexit int MAIN PROGRAM w void main int retcode Return code from API calls int i int slots int input_slot input_found 0 int output_slot output_found 0 OCINIT ocpart BYTE status OCVERSIONINFO verinfo BYTE SWpos WORD wData ei A Open the scanner Access the scanner retcode OC OpenScanner Handle 0 0 if retcode SUCCESS printf XnERROR OC OpenScanner failed d n retcode Ioexit 1 Publication 1747 UM002A US P June 2000 table Developing Applications j Reset the scanner x printf Anin Going to reset OC takes 6 seconds to complete Mn retcode OC ResetScanner Handle OCWAIT if retcode SUCCESS printf XnERROR OC ResetScanner failed d n retcode Ioexit 1 Check scanner status register retcode OC GetScannerStatus
31. EN 61131 2 see the appropriate sections in this publication as well as the Allen Bradley publication Industrial Automation Wiring and Grounding Guidelines For Noise Immunity publication 1770 4 1 This equipment is classified as open equipment and must be mounted in an enclosure during operation to provide safety protection Who Should Use this Manual Terminology Reference Material Preface Use this manual if you are responsible for developing control applications using the 1746 I O PCI Interface API application programming interface software or Open Controller API software in an MS DOS or Windows NT environment This manual documents the 1746 I O PCI Interface API and Open Controller API software packages for DOS and Windows NT The APIs use most of the same calls Differences are noted as appropriate Throughout the language of this document we refer to the 1746 I O PCI Interface card 1747 PCIS as the scanner and the 1747 PCIL chassis interface module as the adapter We also refer to the open controller 1747 OCF as a scanner There are two versions of the PCI Bus Interface Card 1747 PCIS has a 256k memory capacity and the 1747 PCIS2 has a 1M capacity The following books might be useful as you develop your 1746 I O PCI Interface applications This document Written by Has this ISBN number PC System Architecture Series PCI System Architecture MindShare Inc ISBN 0 201 40993 3 Addison Wesley Publi
32. GetScannerStatus ERR OCREINIT 4 scanner has already been initialized ERR OCRESPONSE 10 scanner did not respond to request Publication 1747 UM002A US P June 2000 Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle OCINIT Scaninit int retcode Library of Routines 6 41 OC OpenScanner scaninit InputImageSize 128 64 words for input image scaninit OutputImageSize 128 64 words for output image ur Scaninit HostRetentiveDataSize 500 256 words for host data area retcode OC InitScanner Handle amp scaninit OC OpenScanner acquires access to the scanner device and sets a unique ID that the application uses to access the scanner in subsequent functions Syntax DOS int OC OpenScanner HANDLE handle 0 0 OCE only int OC OpenScanner HANDLE handle WORD segaddr BYTE irqnum NT int OC OpenScanner HANDLE handle IMPORTANT The two argument values of zero are ignored by the DOS API function They are a carryover from the Open Controller API Description This function must be called before any of the other scanner access functions can be used After OC OpenScanner has been called ATTENTION OC_CloseScanner must be called before exiting the application segaddr defines the segment address of the scanner s shared memory in the host processor s memory map segaddr must contain
33. I O configuration utility ioconfig exe allows an I O configuration data file to be created and saved to disk The application configures the scanner by downloading information about the installed rack sizes and module types Call the OC_GetlOConfiguration function to get the current I O configuration or use OC_CreatelOConfiguration to build an VO configuration Both of these functions return a valid I O configuration that can be downloaded to the scanner The scanner will not go to Scan mode until the OC DownloadIOConfiguration function sends the configuration information The scanner checks the downloaded I O configuration against the installed modules when the application attempts to set the scanner to Scan mode The scanner returns an extended error if the I O configuration is not valid and the scanner will fault The OC CreatelOConfiguration function requires a structure containing rack sizes and module types or module names The Structure is Rack1Size number of slots in rack1 4 7 10 Rack2Size number of slots in rack2 0 4 7 10 Rack3Size number of slots in rack3 0 4 7 10 OCSLOTCFGSlotCfg 31 slot information Initialize the three rack size variables with the total number of slots in each rack If rack 2 or rack 3 is not installed set the size to 0 Publication 1747 UM002A US P June 2000 5 2 Configuring 1 0 Modules struct BY BY BY BY NOR WOR WOR WOR words char OCSLOTCFG
34. KC KKAKKKAKKKKKKKAKKKAKKKKKKKKKKKKKJ Publication 1747 UM002A US P June 2000 Header File C 7 typedef struct tagFORCEDATA BYTE SlotNum slot number WORD WordOffset offset to word to force BYTE IOType selects force inputs or outputs WORD ForceMask bits set to 1 are forced 0 removes forces WORD ForceVal selects force state of bits set to 1 in ForceMask FORCEDATA JAKKKKKKKAKKKKKKAKKKAKKKA KKK K KKK K KKK KKAKKKA ko Kk k KKKAKKKKKKKKKK Structure Name DII_CFG Description Passed to OC ConfigureDII ii Configures a discrete input interrupt for a module KAKKKAKKKAKKKA KKK KKKAKKKA k k Ck k KKK k KKK k k ck ck k ck ckckck ck kckok sk k ko k sk oe ke ke x x typedef struct tagDII CFG BYTE SlotNum slot number BYTE IOIncludeMask declare which Discrete Inputs can cause interrupts BYTE IOEdgeType select required transition of each discrete input WORD PresetCount set the number of transitions required to cause interrupt DII CFG JAKKKKKKKAKKKKA kk kk KKK KKK KA CK kk KKK AA Structure Name STSFILE Description x Scanner status file x KAKKKAKKKAKKKA KKK KKKAK KKK KKK KKKAK KKK KKK KKKAKKKKKKKKKKKKKKKKKKJ typedef struct tagSTSFILE WORD wWordNum OCSTSFILEWSIZE STSFILE JAKKKKKKKAKKKKKKAKKKAKKKA CK kk AS Structure Name MSGBUF Description Returned by OC PollScanner MsgID i
35. KKK KKKAKKKAKKKAKKKKKKAKKKAKKKAKAKKKKKKKKAK Structure Name OCDEVICEINFO x Description x x Returned by OC GetDeviceInfo Information regarding the scanner device KAKKKKAKKAKKKAKKKAKKKKAKKKK Kk KC KKAKKKAKKKKKKKAKKKAKKKKKKKKKKKKK A typedef struct tagOCDEVICEINFO WORD ScannerType OC PCIS etc WORD ScannerIrq Interrupt El DWORD ScannerMemory Memory window physical address EJ WORD Controllo PCIS control register 1 0 address DWORD SRAM_Size Always 0 for DOS El OCDEVICEINFO return packing alignment to command line option ifdef _ BORLANDC fpragma option a endif BORLANDC 7 ifdef MSC VER pragma pack endif _MSC_VER JAKKKKAKKKKKKAKKKAKKKAKKKAKKKAKKKKKKKKK ae FUNCTION PROTOTYPES EN A A int pascal OC OpenScanner HANDLE WORD BYTE Publication 1747 UM002A US P June 2000 int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca void pasc int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pasca int pas
36. OC SetHostWatchdog HANDLE handle int mode WORD delay Library of Routines 6 57 Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode IS WATCHDOG_IGNORE The host to scanner watchdog is disabled default WATCHDOG IDLE A watchdog timeout causes the scanner to fault The status LED is set to flashing red the 1 0 is reset I O scanning stops and internal scanner error of OxOB is set and the major error code is set to 0x40 Use OC ClearFault before the scanner can be set to Scan mode WATCHDOG RESET A watchdog timeout forces a hard reset of the controller and scanner If the mode is WATCHDOG RESET the control application must disable this watchdog before exiting If this watchdog is not disabled the controller and scanner experience hard resets once the timeout delay has expired The WATCHDOG RESET mode is not available on the 1747 PCIS and will return ERR OCNOTSUPP delay Specifies the watchdog timeout in multiples of 100ms and can have any value from 1 100ms to 65535 6553 5s Description Once the Host Watchdog is enabled the host application must call OC PetHostWatchdog more often than the time specified as the watchdog timeout If the host application does not call OC PetHostWatchdog for a time longer than the watchdog timeout then the action specified by mode is performed Return Value Return Value Name Valu
37. On the 1747 PCIS only the jumper for the IMPORTANT IMPORTANT battery backup dual port memory is disabled by default You must switch the jumper to enable the battery backup feature The 1747 OCF dual port is NOT battery backed Your application the code you develop using the APD uses the dual port memory to communicate with the scanner to handle control functions on the 1746 backplane such as e scanner commands and responses e battery and scanner status e scan rate frequency and timing e I O image counters priority messages and interrupts semaphores to ensure data integrity software generated watchdogs control of the 4 user definable LEDs the 2 position jumper and the 3 position switch The scanner functionality of the dual port supports I O control functions such as synchronizing scans to the application e forcing I O e defining discrete input interrupts e defining I O module driven interrupts such as for the 1746 BAS module e enabling and disabling I O slots e resetting I O Publication 1747 UM002A US P June 2000 1 6 Overview Scanner Modes Publication 1747 UM002A US P June 2000 In addition to providing access to the control scanner the dual port memory also provides non volatile optional battery backed storage for e VO values application parameters timers counters presets In both application types the scanner CPU operates in six basic modes performing POS
38. ROM in 16 bit K words For example a value of 64 indicates 64K words or 128K bytes Publication 1747 UM002A US P June 2000 6 34 Library of Routines Return Value Name Value Description SUCCESS 0 system status file was read successfully ERR_OCACCESS 2 handle does not have access to scanner Considerations OC GetSwitchPosition Supported in the DOS API library and the Windows NT API library Example HANDLE Handle STSFILE stsfile int retcode retcode OC GetStatusFile Handle amp stsfile OC GetSwitchPosition reads the current position of the three position front panel switch from the scanner Syntax int OC GetSwitchPosition HANDLE handle BYTE swpos Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner swpos If swpos IS SWITCH_TOP switch is in the top position SWITCH_MIDDLE switch is in the middle position SWITCH_BOTTOM switch is in the bottom position Description Publication 1747 UM002A US P June 2000 The switch position has no effect on the scanner The application can use this switch for any purpose The scanner must be initialized before you can monitor the switch position Library of Routines 6 35 Return Value Name Value Description SUCCESS 0 switch position was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 sc
39. Should contain the bits in the discrete input module to include in the comparison Only bits 0 7 of word 0 of the module can be configured for DIl s IOIncludeMask IS a bit mapped mask Any bit set to 1 in this mask includes the corresponding bit of the discrete input module in the comparison Any bit set to 0 is ignored Publication 1747 UM002A US P June 2000 Library of Routines 6 5 This value Means IOEdgeType Defines the bit pattern to compare Only bits that correspond to bits set to 1 in IOIncludeMask are used Only bits 0 7 are valid roEagerype is a bit mapped value If a bit is set to 1 the comparison for the bit matches when its corresponding discrete input bit changes from 0 to 1 If a bit is set to 0 the comparison for the bit matches when its corresponding discrete input bit changes from 1 to 0 PresetCount When PresetCount is 0 or 1 the scanner generates a message each time the comparison matches When it is between 2 and 65535 the message is generated when the number of comparison matches meets PresetCount The scanner recognizes a match when every bit in the IOIncludeMask has finished transitioning After a message is generated another message will be generated as soon as the next specified number of matches occurs To disable DII s set IOIncludeMask to 0 with a valid S1otNum DII s are disabled by default on reset Return Value Name Value Description SUCC
40. US P June 2000 Header File C 15 char Name pointer to module name string OCSLOTCFG EN AAA Structure Name OCIOCFG Description ka Used by OC CreateloConfiguration OC GetIOConfiguration and OC DownloadlIOConfiguration Configuration information for a system 1 2 or 3 w racks may be configured for up to 30 I O modules x Slot 0 is reserved for the Open Controller x x KAKKKAKKKA KKK KKK ck KKK KKAKKKAKKKAK KKK k k ck ck k ck ckckck ck kckok ck k ko k kk e ke ke x x typedef struct tagOCIOCFG BYTE Rack1Size number of slots in Rack 1 BYTE Rack2Size number of slots in Rack 2 BYTE Rack3Size number of slots in Rack 3 OCSLOTCFG SlotCfg OCMAXSLOT configuration for each slot OCIOCFG E AAA Structure Name FORCEDATA Description Passed to OC SetForces b Configures input and output forces KAKKKAKKKKKKAKKKAKKKAKKKA KKK K KKK K KKK KKAKKKAKKKKAKKKKKKKKKKKKK typedef struct tagFORCEDATA BYTE SlotNum slot number WORD WordOffset offset to word to force BYTE IOType selects force inputs or outputs WORD ForceMask bits set to 1 are forced 0 removes forces WORD ForceVal selects force state of bits set to 1 in ForceMask FORCEDATA JAKKKKKKKAKKKKKKAKKKAK KKK KKKK kk kk Kk KC AS Structure Name DII_CFG Description x Passed to OC ConfigureDII X Configures a discrete inpu
41. Windows NT API library Example HANDLE Handle BYTE temp int retcode retcode OC GetTemperature Handle temp 06 GetUserJumper OC GetUserJumpersState reads the state of the user selectable jumper State Syntax int OC GetUserJumperState HANDLE handle BYTE jmpr Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner jmpr If 3mpr Is JUMPER_PRESENT jumper is installed JUMPER_ABSENT jumper is not installed Description The scanner reads the state of the jumper once during its POST and does not continually monitor the state of the jumper The scanner must be initialized before you can monitor the jumper position Publication 1747 UM002A US P June 2000 Library of Routines 6 37 Return Value Name Value Description SUCCESS 0 switch position was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner Considerations OC_GetUserLEDState Supported in the DOS API library and the Windows NT API library Example HANDLE Handle BYTE jmpr int retcode retcode OC GetUserJumperState Handle amp jmpr OC GetUserLEDsState reads the status of one of the four user defined LEDs Syntax int OC GetUserLEDState HANDLE handle int lednum int state Parameters Parameter Description h
42. an extended error is generated The error code and slot number of the most recent fault is retained and returned by this function The fault cause is a duplicate of the most recent extended error The OC_ClearFault function clears the fault in the scanner but does not clear the cause of the last fault See Appendix A for error codes Return Value Name Value Description SUCCESS 0 fault was cleared successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC InitScanner Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle BYTE status FaultCause int FaultSlot int retcode OC_GetScannerStatus Handle amp status if status SCANSTS_FAULT retcode OC_GetLastFaultCause Handle amp FaultCause amp FaultSlot Publication 1747 UM002A US P June 2000 6 24 Library of Routines 0C GetMeasuredScan Time OC GetMeasuredScanTime returns the maximum and last observed I O scan times Syntax int OC GetMeasuredScanTime HANDLE Handle WORD maxtime WORD lasttime Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner maxtime Returns the maximum scan time lasttime Returns the last scan time Description The scanner calculates these values at the end of each I O
43. be a valid handle returned from OC OpenScanner stsfil Points to the sTsFILE structure that contains scanner system status Description The status file is updated by the scanner at the end of each I O scan The STSFILE structure is defined as typedef struct tagSTSFILE WORD wWordNum OCSTSFILEWSIZE STSFILE The status file is organized by words The status file uses these classifications to define the data each word contains Classification Means the data status is used primarily to monitor scanner options or status This information is usually not written by the application except to clear a function such as a minor error bit dynamic configuration can be written by application to select scanner options while in Scan mode The status file contains Word Bit Classification Description 0 0 to 0 4 status Scanner mode status bit4 bit3 bit2 biti bitO 1 0 0 0 0 16 download in progress 1 0 0 0 1 17 Idle mode program 1 1 1 1 0 30 Scan mode run All other values for bits 0 4 are reserved 0 5 status Forces enabled bit This bit is set if forces have been enabled 0 6 status Forces installed bit This bit is set is forces have been installed Publication 1747 UM002A US P June 2000 Library of Routines 6 31 Word Bit Classification Description 0 7 to 0 12 reserved 0 13 dynamic configuration Major error halted bit This bit is set by the scanner when a major error is
44. encountered The scanner enters a fault condition Word 2 Fault Code will contain a code which can be used to diagnose the fault condition When bit 0 13 is set the scanner places all outputs in a safe state and sets the Status LED to the fault state flashing red Once a major fault state exists the condition must be corrected and bit 0 13 cleared before the scanner will accept a mode change request 0 14 reserved 0 15 status First pass bit The bit is set by the scanner to indicate that the first 1 0 scan following entry into Scan mode is in progress The scanner clears this bit following the first scan 1 0to 1 10 reserved 1 11 status Battery low bit This bit is set by the scanner when the Battery Low LED is on It is cleared when the Battery Low LED is off 1 12 status DII overflow bit This bit is set by the scanner when a DII interrupt occurs and the scanner is unable to successfully transmit the DII Received priority message to the host 1 13 to 1 15 reserved 2 status Major error fault code A code is written to this word by the scanner when a major error occurs See word S 0 13 The code defines the type of fault If not zero the upper byte indicates the slot associated with the error This word is not cleared by the scanner 3to4 dynamic configuration VO slot enables These two words are bit mapped to represent the 30 possible 170 slots in an SLC 500 system Bits 3 0 through 4 14 represent slots 0 30 slot O i
45. for a module Chapter Using the API Structures This chapter describes the structures the API uses These structures are declared in ocapi h The table below list API structures Syntax typedef struct tagDIl CFG FORCEDATA Passed to OC SetForces Configures input and output forces BYTE SlotNum slot number BYTE lOlncludeMask declare which Discrete Inputs can cause interrupts BYTE lOEdgelype select required transition of each discrete input WORD PresetCount set the number of transitions required to cause interrupt DII CFG typedef struct tagFORCEDATA BYTE SlotNum slot number WORD WordOffset offset to word to force BYTE lOType selects force inputs or outputs WORD ForceMask I bits set to 1 are forced 0 removes forces WORD ForceVal selects force state of bits set to 1 in ForceMask FORCEDATA MSGBUF Returned by OC PollScanner define OCMSGDATASIZE4 number of bytes of message data typedef struct tagMSGBUF MsglD identifies the message type Type specific BYTE MsglD Message type kr data is contained in BYTE MsgDatalOCMSGDATASIZE Type specific data MsgData MSGBUF OCEXTERR define OCERRDATASIZE3 number of bytes of error data Returned by typedef struct tagOCEXTERR OC GetExtendedError VO error report from scanner BYTE ErrorCode Extended error code BYTE SlotNum Asso
46. has already been initialized scanner has not been initialized Init failed due to invalid partition info scanner POST failure parameter contains invalid value 10 Configuration is invalid scanner responded with slot number is invalid request denied because scanner faulted Scanner IO Configuration not downloaded no forces installed cannot enable forces 1 0 Int or ErrReport message overrun memory allocate failed unknown module type error occured while reading writing disk file function not supported on this platform structure that is returned from the OC GetExtendedError function define EERR_OCINVALIDDIR 0x01 Downloaded directory file is invalid define EERR OCINTSWERR 0x08 Internal scanner software error define EERR OCCFGCORRUPT 0x12 Downloaded configuration is corrupted define EERR OCEXPPWRFAIL 0x21 Power fail on expansion rack detected define EERR OCINVALIDDII Ox2E Invalid DII input slot Publication 1747 UM002A US P June 2000 to request successfully an extended error message 2 7 7 xf El A 4 x ty x ou 4 AY ti x id f 7 7 4 D gl El Header File C 11 define EERR_OCWDTIMEOUT 0x40 Host Watchdog Timeout occurred define EERR_OCMODACCESS 0x50 Data error while accessing module ES define EERR_OCPINTSTUCK 0x51 Stuck PINT error define EERR_OCMODMISSING 0x52 Module is missing kj def
47. lib for Windows NT and include ocapi h You can copy the sample files and adapt them for your application Publication 1747 UM002A US P June 2000 2 2 Using the API Programming Conventions The API is supplied as an object code library file DOS ocapi1 1ib This convention calling convention or a DLL NT ocapi d11 that you link with the host application s object code using commercially available tools Considerations The DOS API functions are specified using the C programming language syntax To allow you to develop control applications in other programming languages the API functions use the standard Pascal calling convention The Windows NT API supports any programming languages that use the Win32 _stdcall calling convention for application interface functions The Windows NT API function names are exported from the DLL in undecorated format to simplify access from other programming languages header files The API includes a header file ocapi h that contains API function declarations data structure definitions and other constant definitions The header file is in standard C format sample code The API comes with sample files to provide an example application that communicates with the scanner The sample files include all source files and MAKE files required to build the sample application compiler support This requirement memory mapping The DOS API is supplied in the large memory model c
48. module types specified in iocfg The scanner configuration can then be downloaded to the scanner with OC DownloadlIOConfiguration which allows the application to control the number of racks and their sizes and the position and type of modules installed in the racks The OCIOCFG structure is defined as typedef struct tagOCIOCFG BYTE RacklSize number of slots in Rack 1 BYTE Rack2Size number of slots in Rack 2 BYTE Rack3Size number of slots in Rack 3 OCSLOTCFG slotCfg OCMAXSLOT configuration for each slot OCIOCFG Return Value Name Value Description SUCCESS 0 1 0 configuration was read successfully ERR OCUNKNOWN 18 at least one module was not found in the internal database The slotcfg data for the unknown module is not altered the remaining modules are configured Publication 1747 UM002A US P June 2000 Considerations Supported in the DOS API library and the Windows NT API library Library of Routines 6 7 0C DemandinputScan Example OCIOCFG iocfg int retcode numslots i char module name 1746 BAS 10 10 slot chassis 7 7 slot chassis 0 Only 2 chassis iocfg RacklSize iocfg Rack2Size iocfg Rack3Size numslots iocfg RacklSize iocfg Rack2Size locfg Rack3Size for i l i numslots i iocfg SlotCfg i mix OCEMPTYMIX iocfg SlotCfg i type OCEMPTYTYPE Empty all slots
49. monitor on the discrete I O module Only bits 0 7 are used in the DII function Setting a bit indicates that it is to be included in the comparison of the discrete 1 0 module s bit transition to the DII compare value word 16 Clearing a bit indicates that the transition state of that bit is a don t care This word is applied upon detection of the DII reconfigure bit 11 10 and at the end of each 1 0 scan Publication 1747 UM002A US P June 2000 Library of Routines 6 33 Word Bit Classification Description 16 dynamic configuration DII compare value This vvord contains a bit mapped value that corresponds to the bit transitions that must occur in the discrete 1 0 module for a count or interrupt to occur Only bits 0 7 are used in the DII function Setting a bit indicates that the bit must transition from a 0 to a 1 to satisfy the compare condition for that bit Clearing a bit indicates that the bit must transition from a 1 to a 0 in order to satisfy the compare condition for that bit An interrupt or count will be generated upon the last bit transition of the compare value This word is applied upon detection of the DII reconfigure bit 11 10 and at the end of each 1 0 scan dynamic configuration DII preset When this value is 0 or 1 an interrupt is generated each time the bit transition comparison is satisfied see words 15 and 16 When this value is 2 65535 a count occurs each time the bit transition
50. one of these values This value Has Means the this hex value SCANSTS_BPIC 4 POST backplane IC test failed scanner is halted SCANSTS_CRC 2 software CRC checksum failed SCANSTS_DPR 5 POST dual port RAM test failed scanner is halted SCANSTS_FAULT 13 scanner faulted scanner is in Scan mode SCANSTS_IDLE 11 scanner initialized scanner is in Idle mode SCANSTS_INIT 10 POST passed waiting for OC_InitScanner from host SCANSTS_INT 8 POST interrupt test failed scanner is halted SCANSTS_POST power on self test POST is in progress SCANSTS_RAM 3 POST RAM test failed scanner is halted SCANSTS_SCAN 20 scanner initialized scanner in Scan mode SCANSTS_THERM 6 POST thermometer test failed scanner is halted SCANASTS_TIMER 7 POST timer test failed scanner is halted SCANSTS_WDOG 12 scanner watchdog timeout scanner is halted Return Value Name Value Description SUCCESS 0 scanner status was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCEXTERR 11 scanner extended error message scansts is returned Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle BYTE scansts int retcode retcode OC GetScannerStatus Handle amp scansts Publication 1747 UM002A US P June 2000 Library of Routines 6 29 0C_GetScanner WatchdogCount OC GetScannerWatchdogCoun
51. partition the dual port memory in the 1746 I O PCI Interface How the API Functions Each of the API functions falls into one of these four categories Are Organized e scanner initialization e scanner I O configuration e data input output e user interface miscellaneous Chapter 6 describes each API function and identifies its functionality group Programming Sequence Follow this programming sequence when you develop your application 1 Access the scanner 2 Initialize the scanner 3 Configure the scanner 4 Control scanner operation Scan I O Publication 1747 UM002A US P June 2000 3 2 Developing Applications Publication 1747 UM002A US P June 2000 Access the scanner The host application must first call OC OpenScanner to gain access to the scanner Once an application has access no other application can gain access to the scanner When the application no longer requires access to the scanner it must call OC CloseScanner to release access of the scanner to other applications Once the scanner is opened you must call OC CloseScanner before exiting the application Initialize the scanner After the scanner is reset and performs its POST the scanner waits for initialization In this state the scanner can t be configured or control I O The only operational function is that which controls the LEDs Any call to a function that requires the scanner to be initialized returns an error You mu
52. structure that contains the initialization information passed from the application Publication 1747 UM002A US P June 2000 6 40 Library of Routines Description If the scanner is executing POST when this function is called ERR_OCPOST is returned If the scanner has been previously initialized and the partition information in scaninit is identical to the current scanner partitioning OC_InitScanner returns successfully If the scanner has been previously initialized and the partition information in scaninit is different from the current scanner partitioning OC_InitScanner returns an error value that indicates that the scanner was previously initialized The scanner must be reset via OC_ResetScanner before the initialization information can be changed If the scanner has already been initialized you can call OC GetScannerlnitinfo to retrieve current partition information The OCINIT structure is defined as typedef struct tagOCINIT WORD OutputImageSize size in bytes WORD Input ImageSize size in bytes WORD HostRetentiveDataSize size in bytes OCINIT Return Value Name Value Description SUCCESS 0 scanner was initialized successfully ERR_OCACCESS 2 handle does not have access to the scanner ERR_OCMEM 3 shared memory not found ERR_OCPAR 6 initialization failed due to invalid partition information ERR_OCPOST 7 POST in progress or scanner POST failed see OC
53. synchronize with the scanner s I O scan is to monitor the scanner watchdog register which is incremented at the end of each timed I O scan See OC_GetScannerWatchdogCount Return Value Value Description SUCCESS 0 notification was generated successfully ERR_OCACCESS handle does not have access to scanner ERR_OCINIT scanner has not been initialized see OC_InitScanner ERR_OCPARAM 2 5 8 parameter contains invalid value Considerations Supported in the DOS API library and the Windows NT API library Publication 1747 UM002A US P June 2000 6 12 Library of Routines OC EnableForces Example HANDLE Handle int retcode retcode OC EnableEOSNotify Handle EOSMSG ENABLE Use OC PollScanner to check EOS messages OC EnableForces enables disables forces for all inputs and outputs with entries in the force files on the scanner ATTENTION Enabling forces vvill potentially change the output data values that your application was previously controlling Syntax int OC EnableForces HANDLE handle int mode Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode IS FORCE ENABLE forces are enabled FORCE DISABLE forces are disabled FORCE CLEAR forces are disabled and all input and output forces are cleared from the force files Description
54. to help diagnose your API application software See appendix B for more information When you purchase either product 1746 I O PCI Interface system or open controller system you also receive firmware upgrades during the 12 month warranty period You can purchase extended support in blocks of 5 hours by ordering support contracts 1747 OCTS Publication 1747 UM002A US P June 2000 Preface 4 Publication 1747 UM002A US P June 2000 Overvievv Using the API Developing Applications Table of Contents Chapter 1 Introduction jest pe tnd A A 1 1 Relationship to the Open Controller 1 1 Interface API to the CAME a A a 1 2 API Software for DO Ss dea po mea ee gj n la 1 2 API Software for Windows NT 1 3 Understanding the 1746 I O PCI Interface Architecture 1 4 Understanding the Open Controller Architecture 1 4 Common Attributes of the 1746 I O PCI Interface and 1747 Open Controller Architectures s s v os nte ete ad 1 5 Scanner Modes vut esu a c nts e e BEP Mea 1 6 Checking LED Indicators 1 nii s eR Eh 1 7 STATUS s Keqe PM T 1 7 Tnstalling the DOS NPD eau asi vans a CT GA 1 8 Installing th Windows NT APIgusbos rita 42 5 1 8 Installation Details 1 9 Uninstalling the Windows NT API 1 10 Chapter 2 MORE AAA DA epa peo d 2 1 Getting Stellar did 2 1 Programming Conventions 2 2 DOS Considerations
55. to your environment CPATH D BC5 Location of Borland tools CC CPATH bin Bcc32 compiler LINK S CPATH bin TLink32 linker MAKE CPATH bin Make make utility Path to API Library and Include file Note Modify the following path to correspond to your environment APIDLL api lib ocapi dll Path to Open Controller API library APIINC api include Path to Open Controller API include file APILIB ocapi lib Borland compatible import library Options CFLAGS c v 4 tWM w IS APIINC FLAGS v Tp d SE ap T Final Target sample exe sample obj APILIB sampleb mak S LINK amp amp S LFLAGS t D BC5 LIB c0x32 obj 0bj exe map D BC5 LIB import32 lib D BC5 LIB cw32mt lib S APILIB clean del del del del 0b3 map lib A F rebuild S MAKI MAKI f sampleb mak clean f sampleb mak an an c obj CC S CFLAGS c Create a Borland compatible import library Es e SoS x S APILIB S APIDLL implib S APILIB APIDLL sample obj sample c APIINC ocapi h sampleb mak Publication 1747 UM002A US P June 2000 2 10 Using the API Notes Publication 1747 UM002A US P June 2000 Chapter 3 Developing Applications Introduction This chapter describes the proper programming sequence for your application This chapter also describes how to
56. to your environment APILIB ocapil lib Path to Open Controller API library Publication 1747 UM002A US P June 2000 Using the API 2 5 APIINC Path to Open Controller API include file Options CFLAGS c v w ml I APIINC LFLAGS V Td OSE sample exe sample obj S APILIB sampleb mak LINK LFLAGS c0l sample obj exe map S APILIB cl clean del exe del obj del map rebuild MAKE clean MAKE GJO S CC S CFLAGS c sample obj sample c APIINC ocapi h sampleb mak Sample DOS MAKE file for Microsoft compilers The following sample file shows how to use a Microsoft MAKE file The bold headings indicate the statements you need to modify for your environment HEKAKAKKKAKKKAKKKAKKKKKKAKKKKKKAKKKAKKKKKKKKKKKKKAKKKAKKKKKKKKKKAKKKKKKAKKKK Title Makefile for Open Controller API Sample Abstract This file is used by the Microsoft NMake utility to build the sample application Environment 1747 OCE Open Controller MS DOS Microsoft C C Compiler 16 bit KEKE KKK KKK KKK KKK KKK ck ck KKK KKK KKK KKK KK KKK KKK KK ck ck kk ARA KKK KKK KKK KKK KK KK Note The environment variables LIB and INCLUDE must be set to the path to the Microsoft C library and include files For example set LIB D MSVC15 LIB set INCLUDE D AMSVC15 INCLUDE Paths to Tools Note Modify the following paths to correspond to your environment
57. values e status values type definitions e structures e function prototypes DOS Header File E AAA Title 1746 I O PCI Interface API library header file Abstract Contains definitions structures and function templates for all functions defined in the Open Controller API This file is distributed as part of the API Environment 1747 PCIS PCIS2 Bus Interface MS DOS Borland Microsoft C C Compiler 16 bit x x x x x x x x x x x x x c Copyright Allen Bradley x AKAKAKAKAKAKAKAKAKAKAKAKAKAKAKKKKKKKKKKKKAKKKAKAKAKAKAKAKKKKKKKKKKKKKKKKJ tifndef OCAPI H define OCAPI H kk ck kk ee ee Se ke e e Se Se e Se e S S S S S S KKK KA M amp M amp A M X AEE CONSTANTS xx ES APT Function Return Values x These values are returned by the API functions to indicate success or possible K error conditions YA LE define SUCCESS 0 function returned successfully kA define ERR OCOPEN 1 scanner already open x define ERR OCACCESS 2 handle does not have access to scanner EA define ERR_OCMEM 3 shared memory cannot be found T define ERR OCREINIT 4 scanner has already been initialized El define ERR_OCINIT 5 scanner has not been initialized define ERR_OCPAR 6 Init failed due to invalid partition info Ef define ERR_OCPOST 7 scanner POST failure EA define ERR_OCPARAM 8 parameter contains invalid value YA define ERR OCIOCFG 9 IO Configuratio
58. 00 Handle retent data OC ReadInputImage reads the current input image from the scanner Syntax int OC Readinput Image HANDLE handle WORD inpimgcpy int slotnum WORD offset WORD len WORD imagebuf Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner inpimgcpy If inpimgepy IS NULL OC_Readinputimage reads data directly from the input image in the scanner s shared memory not NULL OC ReadlInputlmage reads data from inpimgcpy Which contains a copy of the scanner s input image slotnum If slotnumis offset positive input data for that slot is read into the array len pointed to by imagebuf Then imagebuf contains 1en words of input data starting at word offset of the module in the slot Data will not be read past the end of the input image for the slot 1 the entire input image is read into the array pointed to by imagebuf and offset and len are ignored imagebuf Must point to an array that is large enough to accept the amount of data in the requested input image Publication 1747 UM002A US P June 2000 6 48 Library of Routines Description To guarantee that a series of calls to OC Readinputimage read data from a single input scan OC Readinputimage can first be called to read the entire input image into a local buffer pointed to by imagebuf vvith the inpimgcpy pointer set to NULL and slotnum set to 1 The imagebuf buffer can then be p
59. 00 6 14 Library of Routines Description This function enables or disables the scanner from scanning the module in a specific s1otnum This applies to both the input and output scan Slots that are disabled are not included in the I O scan By default all slots are enabled Return Value Name Value Description SUCCESS 0 module was updated successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCNOFORCES 15 no forces installed scanner cannot enable forces ERR_OCPARAM 8 parameter contains invalid value ERR_OCRESPONSE 10 scanner did not respond to request ERR_OCSCANCFG 14 scanner has not been configured Considerations OC ErrorMsg Publication 1747 UM002A US P June 2000 Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC EnableSlot Handle 6 SLOT DISABLE Exclude slot 6 OC ErrorMsg returns a descriptive text message associated with the API return value errcode Syntax int OC ErrorMsg int errcode char msg Description The null terminated message string is placed in a static buffer that is reused each time this function is called A pointer to this buffer is returned in msg Library of Routines 6 15 Return Value Name Description SUCCESS errcode was valid msg points to corresponding error description ERR_OCPARAM errcode was invalid msg p
60. 00 6 64 Library of Routines OC SetScanTime OC SetScanTime sets the I O scan time and I O scan interval of the scanner Syntax int OC_SetScanTime HANDLE handle int mode int time Parameters Parameter Description handle Must be a valid handle returned from OC_OpenScanner mode If mode IS time SCAN_PERIODIC time determines the frequency of 1 0 scans in multiples of 250us and must contain a value between 1 and 255 SCAN_DELAYED time determines the delay between 1 0 scans in multiples of 10us and must contain a value between 1 and 256 The default mode is SCAN_PERIODIC and the default time is 10 if OC SetScanTime is not used to change the scan time Description A scan time change will take effect when the scanner transitions from Idle mode to Scan mode Return Value Name Value Description SUCCESS 0 scan time was set successfully ERR_OCACCESS 2 handle does not have access to the scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner ERR_OCPARAM 8 parameter contains invalid value Considerations Publication 1747 UM002A US P June 2000 Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC_SetScanTime Handle SCAN_PERIODIC 20 Scan set to start every 5 msec Library of Routines 6 65 OC_SetUserLEDState OC_SetUserLEDState sets the state of a user defined LED
61. 11 0 0C_CalculateCRC Routine 6 1 0C_ClearFault Routine 6 2 0C_CloseScanner Routine 6 3 OC_ConfigureDLL Routine 6 4 OC CreatelOConfiguration Routine 6 6 0C DemandinputScan Routine 6 7 0C DemandOutputScan Routine 6 8 0C DownloadlOConfiguration Routine 6 9 OC EnableEOSNotify Routine 6 10 OC EnableForces Routine 6 12 OC EnableSlot Routine 6 13 OC ErrorMsg Routine 6 14 OC ExtendedErrorMsg Routine 6 15 OC GetBatteryStatus Routine 6 17 OC GetDevicelnfo Routine 6 18 OC GetExtendedError Routine 6 19 OC GetlnputUpdateCounter Routine 6 20 OC GetlOConfiguration Routine 6 21 OC GetLastFaultCause Routine 6 22 OC GetMeasuredScanTime Routine 6 24 OC GetResetCause Routine 6 25 OC GetScannerlnitInfo Routine 6 26 OC GetScannerStatus Routine 6 27 OC GetScannerWatchdogCount Routine 6 29 OC GetStatusFile Routine 6 30 OC GetSwitchPosition Routine 6 34 0C GetTemperature Routine 6 35 OC GetUserJumperState Routine 6 36 OC GetUserLEDState Routine 6 37 OC GetVersioninfo Routine 6 38 OC InitScanner Routine 6 39 OC OpenScanner Routine 6 41 OC PetHostWatchdog Routine 6 43 OC PollScanner Routine 6 44 Publication 1747 UMOO2A US P June 2000 OC ReadHostRetentiveData Routine 6 46 OC Readinputimage Routine 6 47 OC ReadlOConfigFile Routine 6 49 0C ReadModuleFile Routine 6 50 OC ReadOutputlmage Routine 6 51 OC ReadSRAM Routine 6 52 OC ResetScanner Routine 6 54 OC SetForces Routine 6 55 OC SetHostWatchdog Routine 6 56 OC Setlnpu
62. 4 136 21 1746 0V Open Loop Velocity 4 131 15 1747 DCM1 Direct Commun Module 1 4 RACK 1 32 25 1747 DCM2 Direct Commun Module 1 2 RACK 1 33 25 1747 DCM3 Direct Commun Module 3 4 RACK 1 34 25 1747 DCM4 Direct Commun Module FULL RACK 1 35 25 1747 MNET Module Interface 4 158 11 1747 SDN DeviceNet Scanner 4 136 6 1747 SN Remote 1 0 Scanner 4 136 8 1747 DSN1 Distributed 1 0 Scanner 7 Blks 1 35 1 1747 DSN26 Distributed 1 0 Scanner 30 Blks 4 136 7 1747 KE15 Interface Module Series A 1 42 9 1747 KE2 Interface Module Series B 1 35 9 OC CreatelOConfiguration functions bits represent the 1 0 mix of the module digit is appended to the module name The module names shown in this table correspond to those used by the OC GetlOConfiguration and The mix code for a module is composed of one byte field The upper 3 bits represent the class of the module and the lovver 5 Some modules can have multiple configurations To distinguish between different configurations of the same module a single 5 5 Publication 1747 UM002A US P June 2000 5 6 Configuring 1 0 Modules Notes Publication 1747 UM002A US P June 2000 Introduction OC CalculateCRC Chapter 6 Library of Routines The MS DOS API is a run time library that can be linked with most industry standard programming language compilers using the Pascal calling convention The Windows NT API is a 32 bit DLL that can be linked with most indus
63. 47 Open Controller IDE Interface Module for an Internally Mounted 2 5 IDE 1747 5 30 Drive Installation Instructions Each open controller component ships with installation instructions The user manuals are part of the open controller documentation set catalog number 1747 OCDOC1 so you can order as many copies as you need The documentation set includes one copy of each open controller document as listed above In addition to the above documentation the e 1747 OCVGA1 video interface module and the 1747 OCVGAE video and Ethernet interface module include a disk with documentation for the video drivers e 1747 OCPCM2 PCMCIA interface module kit 1747 OCPCM1 interface module plus CardSoft for DOS includes a disk with CardSoft documentation Publication 1747 UM002A US P June 2000 Preface 3 Support Due to the PC based architecture of the 1746 VO PCI Interface and open controller the telephone support provided with the purchase price of either product consists primarily of determining if the system software and hardware is operating within documented specifications The tools for this support are e diagnostic utility disks that ship with the 1746 I O PCI Interface and open controller system diagnostic LEDs for 1746 I O PCI Interface and open controller The diagnostic utility disk uses the DOS API as its programming interface which provides examples of how to use the API The diagnostic utility disk is a good tool
64. Allen Bradley API Software for 1746 1 0 PCI Interface and 1747 06 Open Controller 1747 0CF PCIS User Manual Automation Important User Information Because of the variety of uses for the products described in this publication those responsible for the application and use of this control equipment must satisfy themselves that all necessary steps have been taken to assure that each application and use meets all performance and safety requirements including any applicable laws regulations codes and standards The illustrations charts sample programs and layout examples shown in this guide are intended solely for purposes of example Since there are many variables and requirements associated with any particular installation Allen Bradley does not assume responsibility or liability to include intellectual property liability for actual use based upon the examples shown in this publication Allen Bradley publication SGI 1 1 Safety Guidelines for the Application Installation and Maintenance of Solid State Control available from your local Allen Bradley office describes some important differences between solid state equipment and electromechanical devices that should be taken into consideration when applying products such as those described in this publication Reproduction of the contents of this copyrighted publication in whole or part without written permission of Rockwell Automation is prohibited Throughout
65. CCESS the scanner printf NnERROR OC DownloadIOConfiguration failed d n retcode Ioexit 1 Jo Set output update mode to always Ay retcode OC SetOutputUpdateMode Handle OUTUPD ALWAYS if retcode SUCCESS printf XnERROR OC SetOutputUpdateMode failed d n Control scanner retcode operation Ioexit 1 Set scan time to 5ms periodic scan mode ES retcode OC SetScanTime Handle SCAN PERIODIC 20 if retcode SUCCESS printf XnERROR OC SetScanTime failed d n retcode Ioexit 1 j E Goto Scan Mode EJ retcode OC SetScanMode Handle SCAN RUN if retcode SUCCESS printf XnERROR OC SetScanMode failed d n retcode Ioexit 1 Turn on User LED 1 T retcode OC SetUserLEDState Handle 1 LED GREEN SOLID if retcode SUCCESS printf XnERROR OC SetUserLEDState failed d n retcode Ioexit 1 printf n n LED1 is on solid green now An delay 3000 Publication 1747 UM002A US P June 2000 3 10 Developing Applications Read first Input word retcode OC_ReadInputImage Handle NULL input slot 0 1 amp wData if retcode SUCCESS printf NXnERROR OC ReadInputImage failed d n retcode Ioexit 1 printf Anin First input image data
66. CESS 2 handle does not have access to the scanner ERR_OCPOST 7 scanner POST failed Considerations Publication 1747 UM002A US P June 2000 Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC ResetScanner Handle OCWAIT Library of Routines 6 55 0C SetForces OC_SetForces installs and removes input and output forces to 7 the scanner Syntax int OC_SetForces HANDLE handle FORCEDATA forcedata Parameters Parameter Description handle Must be a valid handle returned from OC_OpenScanner forcedata Defines the inputs and outputs to force Description The FORCI If the result of OC_SetForces removes all I O forces the scanner disables forces If any I O forces are later installed OC_EnableForces must be called to re enable forces EDATA Structure is defined as typedef struct tagFORCEDATA BYTE SlotNum Slot Number of local I O or 1747 SN module 1 30 WORD WordOffset Word Offset in I O image BYTE IOType Selects Input or Output Image WORD ForceMask Install Remove bitmask WORD ForceVal Install value bitmask FORCEDATA This value Means SlotNum SlotNum and wordoffset select the word of 1 0 that contains the WordOffset bits to be forced IOType LOType must be FORCE INPUTS or FORCE OUTPUTS ForceMask All 16 bits of the word are installed removed a
67. CPARAM 8 parameter contains invalid value Publication 1747 UM002A US P June 2000 Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC SetInputUpdateMode Handle INUPD NEVER Must use OC DemandInputScan function to obtain new input data Library of Routines 6 59 0C SetloldleState OC SetIOIdleState controls the state of I O when the scanner goes from Scan mode to Idle mode Syntax int OC SetIOIdleState HANDLE handle int mode Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode IS IDLESTATE HOLD module 0 s maintain their last state IDLESTATE_RESET module I O s are reset by the scanner The default 1 0 idle state is IDLESTATE_RESET Description The VO will always be reset in the case of a fault Return Value Name Value Description SUCCESS 0 1 0 state was changed successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner ERR_OCPARAM 8 parameter contains invalid value Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC_SetIOIdleState Handle IDLESTATE HOLD Outputs will remain in last state when scanner goes to idle
68. DOS API library and the Windows NT API library Example HANDLE Handle BYTE batt sts int retcode retcode OC GetBatteryStatus Handle amp batt sts Publication 1747 UM002A US P June 2000 6 18 Library of Routines OC GetDevicelnfo Publication 1747 UM002A US P June 2000 OC GeDeviceInfo returns information about the scanner device Syntax int OC GetDeviceInfo HANDLE handle OCDEVICEINFO devinfo Description The OCDEVICEINFO is defined as WORD WORD DWORD WORD DWORD ScannerType scanner device type ScannerIrq allocated interrupt ScannerMemory dual port memory access Controllo PCIS control registers address SRAM Size size of available SRAM in bytes OCDEVICEINFO handle must be a valid handle returned from OC OpenScanner Return Value Description SUCCESS The extended error information was read successfully ERR OCACCESS handle does not have access to scanner Considerations Supported in the DOS API library and the Windows NT API library Description HANDLE Handle OCDEVICEINFO devinfo disp lay size of available SRAM OC GetDeviceInfo Handle amp devinfo printf SRAM Size is ld bytes n devinfo SRAM Size Library of Routines 6 19 OC GetExtendedError OC_GetExtendedError reads extended error information from the scanner
69. Description handle Must be a valid handle returned from OC OpenScanner iocfg Specifies the rack sizes and installed modules Description The scanner must be in Idle mode to receive an I O configuration This function forces the scanner to Idle mode to download the configuration The scanner checks the downloaded I O configuration for validity and if there are any errors an extended error might be generated If an error is generated the scanner will fault The OCIOCFG structure is defined as typedef struct tagOCIOCFG Publication 1747 UM002A US P June 2000 6 10 Library of Routines BYTE RacklSize number of slots in Rack 1 BYTE Rack2Size number of slots in Rack 2 BYTE Rack3Size number of slots in Rack 3 OCSLOTCFG slotCfg OCMAXSLOT configuration for each slot OCIOCFG Return Value Name Value Description SUCCESS 0 1 0 configuration was downloaded successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner ERR_OCOUTOFMEM 17 unable to allocate memory for configuration data ERR_OCRESPONSE 10 scanner did not respond to request Considerations OC EnableEOSNotify Publication 1747 UM002A US P June 2000 Supported in the DOS API library and the Windows NT API library Example HANDLE Handle OCIOCFG iocfg int retcode Either OC CreatelOConfi
70. E 0 Select Idle mode not scanning 1 0 define SCAN_RUN 1 Select Scan mode scanning 1 0 Ki kkk O dle State kkk These values are passed to the OC SetlIOIdleState function Y pe define IDLESTATE_RESET 0 1 0 bus is reset in Idle mode 7 define IDLESTATE HOLD 1 1 0 is held in last state in Idle mode PpollScanner Message ID s These values are passed to the OC PollScanner function message filter and are returned in the MsgID member of the MSGBUF structure 7 ge define OCMSG NONE 0 No messages are available msg ID i define OCMSG ANY 0 Poll for any message filter ez define OCMSG_IOINT x I O Module Interrupt E define OCMSG_DIINT 2 Discrete Input Interrupt E define OCMSG_EOS 3 End of Scan notification i define OCMSG_EOS_DMDIN 4 End of Scan notification from demand input define OCMSG_EOS_DMDOUT 5 End of Scan notification from demand output KKKKK KKKKK Scanner Force Settings These values are passed to the OC EnableForces function LE E define FORCE ENABLE 0 Enable forces define FORCE DISABLE 1 Disable forces define FORCE CLEAR 2 Clear all forces Sh Module Force Settings These values are passed to the OC SetForces function ef 75 KI define FORCE INPUTS 0 Select input forces 7 define FORCE OUTPUTS 1 Select output forces kkk Slot Settings KKKKAK T
71. EOS notification is received from the scanner or msTimeout milliseconds have elapsed Syntax int OC_WaitForEosDmdOut HANDLE handle DWORD msTimeout Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner msTimeout Specifies the number of milliseconds to wait Set to INFINITE to wait forever Description If a demand output EOS message has been received since the last OCMSG_EOS_DMDOUT message was retrieved with the OC PollScanner function OC WaitForEosDmdOut returns SUCCESS immediately You can use this function to synchronize a control application with the I O scan See the OC EnableEOSNotify and OC DemandoOutputScan functions Publication 1747 UM002A US P June 2000 6 72 Library of Routines Return Value Name Value Description SUCCESS 0 demand output EOS message was received ERR_RESPONSE 10 msTimeout milliseconds elapsed without an EOS ERR_OCACCESS 2 handle does not have access to scanner Considerations Publication 1747 UM002A US P June 2000 Supported in the Windows NT API library only Example HANDLE handle intro MSGBUF eosMSG Request an output scan but don t wait OC DemandoutputScan handle OCNOWAIT Could have other code here Wait 1 second for the EOS rc OC WaitForEosDmdOut handle 1000 switch rc case SUCCESS got EOS reset the EOS DMDOUT event OC P
72. ESS 0 discrete input interrupt DII was configured successfully ERR OCACCESS 2 handle does not have access to the scanner ERR OCRESPONSE 10 scanner did not respond to request ERR OCSCANCFG 14 scanner has not been configured ERR OCSLOT 12 slot number is invalid Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle DII CFG diicfg int retcode diicfg Slotnum 6 Slot 6 has discrete input module diicfg IOIncludeMask 1 bit 0 is the input trigger diicfg IOEdgeType 1 bit 0 must toggle from low to high diicfg PresetCount 3 bit 0 must toggle 3 times retcode OC ConfigureDII Handle amp diicfg Use OC PollScanner to check for DII messages Publication 1747 UM002A US P June 2000 6 6 Library of Routines OC Createlo OC CreatelOConfiguration creates a scanner configuration from an application specific installation of rack sizes and installed modules Configuration See chapter 5 for more information Syntax int OC CreatelOConfiguration OCIOCFG iocfg Parameters Parameter Description iocfg Specifies the rack sizes and installed modules Description Modules can be specified by name or by mix and type The function automatically fills in the rest of the required information in the OCIOCFG structure This function returns in iocfg the scanner configuration information obtained from the rack sizes and installed
73. ESS 2 handle does not have access to scanner ERR_OCPARAM 8 parameter contains invalid value ERR_OCRESPONSE 10 scanner did not respond to request ERR_OCSCANCFG 14 scanner has not been configured ERR_OCSLOT 12 slot number is invalid Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle WORD filedata 2 int retcode filedata 0 0x55AA filedata 1 0xAA55 retcode OC WriteModuleFile Handle FILTYP MO filedata 6 3 2 Writes words 3 and 4 from module in slot 6 0C WriteO utputimage OC WriteOutputImage updates the output image on the scanner Syntax int OC NriteOutput Image HANDLE handle WORD outimgcpy int slotnum WORD offset WORD len WORD imagebuf Publication 1747 UM002A US P June 2000 Parameters Library of Routines 6 79 Parameter Description handle Must be a valid handle returned from OC OpenScanner outimgcpy If out imgcpy iS NULL OC WriteOutputlmage writes data directly to the output image in the scanner s shared memory if the update mode is OUTUPD_CHANGE the scanner is signalled to update the outputs not NULL OC WriteOutputlmage writes data to outimgcpyj the output image data is not affected If file integrity is not necessary the host application can set outimgcpy to NULL slotnum offset len If slotnum Is positive the output image for that slot is written from the array pointe
74. File ts S22 vret da eld 6 76 OC WmeNoduleEiles ete da ET NS ERE 6 77 OC_WriteOutputImage os p eim A eae eas 6 78 OC WHntesRAM ape bo neis en ep quem Trete e d Ru 6 80 Appendix A IBDIEOUGOUOR a is sro icti X oe pt ouo i ook edet A 1 Error Code Returned by API Functions A 1 Extended Error Codes n n auaa bbe amp Reine doe Sap A 2 Appendix B Introductio ths se pri a el oC Mito iiy E B 1 Appendix C Inttotge Off Sos tu mh K gae ES Es C 1 DOS Header File pa deem me pe anto PU we Fett C 1 Windows NT Header File a cae isn b EU am D de bee E C 10 Publication 1747 UM002A US P June 2000 Table of Contents iv Publication 1747 UM002A US P June 2000 Introduction Relationship to the Open Controller Chapter 1 Overvievv This chapter provides an overview of the 1746 VO PCI Interface and the API software This chapter also describes how to install the API You should have one of the following APIs e API for DOS catalog number 1747 PCIDOS or 1747 OCAPID e API for Windows NT catalog number 1747 PCINT or 1747 OCAPINT The API software license agreement allows you to freely distribute the executable The API software for the 1746 VO PCI Interface is compatible with the API for the 1747 Open Controller The sample code and header files contain comments and functions that are supported by the Open Controller but not supported by the 1746 I O PCI Interface The following table lists the differenc
75. GetBatteryStatus 6 17 OC GetDevicelnfo 6 18 OC_GetExtendedError 6 19 OC GetinputimageUpdateCounter 6 20 OC GetlOConfiguration 6 21 OC GetLastFaultCause 6 22 OC GetMeasuredScanTime 6 24 OC GetResetCause 6 25 OC GetScannerinitinfo 6 26 OC GetScannerStatus 6 27 OC GetScannerWatchdogCount 6 29 OC GetStatusFile 6 30 OC_GetSwitchPosition 6 34 OC GetTemperature 6 35 OC GetUserJumpersState 6 36 OC_GetUserLEDState 6 37 OC GetVersionInfo 6 38 OC InitScanner 6 39 OC OpenScanner 6 41 OC PetHostWatchdog 6 43 OC PollScanner 6 44 OC ReadHostRetentiveData 6 46 OC Readinputimage 6 47 OC ReadlOConfigFile 6 49 OC ReadModuleFile 6 50 OC ReadOutputimage 6 51 OC ReadSRAM 6 52 OC ResetScanner 6 54 OC SetForces 6 55 OC SetHostWatchdog 6 56 OC SetinputUpdateMode 6 58 Index 3 OC SetlOldleState 6 59 OC SetModulelnterrupt 6 60 OC SetOutputUpdateMode 6 61 OC SetScanMode 6 63 OC SetScanTime 6 64 OC SetupPovverFailAction 6 66 OC SetUserLEDState 6 65 0C_WaitForDll 6 68 OC WaitForEos 6 69 OC WaitForEosDmdln 6 70 OC WaitForEosDmdOut 6 71 OC WaitForExtError 6 73 OC VVaitForlolnt 6 74 OC WriteHostRetentiveData 6 75 OC WritelOConfigFile 6 76 OC WriteModuleFile 6 77 OC WriteOutputlmage 6 78 OC WriteSRAM 6 80 S Sample DOS MAKE File Borland compilers 2 4 Microsoft compilers 2 5 Sample NT MAKE File Borland compilers 2 8 Microsoft compilers 2 6 Scan 1 6 Scan 1 0 During the progra
76. HANDLE OCEXTERR int WORD in tyr OCVERSION WORD WORD BYTE YTE WORD WORD TE WORD WORD INFO OC ExtendedErrorMsg HANDLE OCEXTERR char Ot ErrorMsg int char tej OC_GetMeasuredScanTime HANDLE WORD OC_WriteIOConfigFile OCIOCFG cha OC ReadIOConfigFile OCIOCFG char OC ReadRtcSRAM HANDLE BYT OC_WriteRtcSRAM HANDLE BY ReadSRAM HANDLE BYTE DWORD WriteSRAM HANDLE BYTE DWORD OC OC 7 OC SetInputUpdateMode OC DemandInputScan HAN OC OC WaitForloInt HANDLE OC OC WaitForEosDmdIn HAN WaitForDII HANDLE WaitForEos HANDLE HAND DLE DLE E WORD WORD E NY WORD TE WORD WORD LE int int DWORD DWORD DWORD DWORD OC_WaitForEosDmdOut HANDLE DWORD OC_WaitForExtError HAN DLE DWORD OC_WaitForPowerFail HANDLE DWORD OC_GetDevicelnfo HANDLE x Publication 1747 UM002A US P June 2000 DWORD DWORD OCDEVICEINFO Numerics 1746 1 0 PCI Interface Architecture 1 4 A Access the Scanner During the programming sequence 3 2 API Functions Error codes A 1 Organization 3 1 API Interface Installing the DOS API 1 8 Installing the NT API 1 8 Removing the NT API 1 10 Tools to use 2 4 API Software for DOS 1 2 API Software for NT 1 3 API Structures 4 1 Architecture 1746 1 0 PCI interface 1 4 Commo
77. Handle amp status if retcode SUCCESS printf NnERROR OC GetScannerStatus failed d n retcode Ioexit 1 if status SCANSTS INIT printf NnERROR POST failure detected d n status Toexit 1 xx Initialize the DPR partitions You can use OC_CreatelOConfiguration to determine the I O image xx sizes before paritioning the DPR ocpart OutputImageSize 0x800 ocpart InputImageSize 0x800 ocpart HostRetentiveDataSize 0 retcode OC_InitScanner Handle amp ocpart if retcode SUCCESS printf nERROR OC InitScanner failed d n retcode Toexit 1 Display software hardware versions th retcode OC GetVersionInfo Handle amp verinfo if retcode SUCCESS printf XnERROR OC GetVersioninfo failed d n retcode Ioexit 1 printf Anin Scanner Firmware Series 02d Revision 02d 7 verinfo ScannerFirmwareSeries verinfo ScannerFirmwareRevision printf Nn Hardware Series 02d Revision 02d verinfo OCHardwareSeries verinfo OCHardwareRevision delay 3000 Read switch position EJ retcode OC_GetSwitchPosition Handle amp swpos if retcode SUCCESS printf XnERROR OC GetSwitchPosition failed d n retcode Ioexit 1 Initializethe scanner 3 7 Publication 1747 UM002A US P June 2000 3 8 Developing Applicat
78. Import library in Microsoft COFF format ocapi h API header file that contains API referenced structures ocapi dll API DLL sample c Sample application program calling the API functions sampleb mak Sample make file for the Borland C compiler samplem mak Sample make file for the Microsoft C compiler Installation Details This section describes the actions the setup utility performs to install the API and OCdriver If you select Runtime Complete the setup utility 1 copies the device driver file ocdriver to the system device driver directory SSystemRoot system32 drivers Publication 1747 UM002A US P June 2000 1 10 Overvievv 2 adds this key and these values to the system registry HKEY_LOCAL_MACHINEASYSTEM CurrentControlSet Services OCdriver ErrorControl REG_DWORD 0x1 Group REG_SZ Extended base Start REG_DWORD 0x2 Type REG_DWORD 0x1 HKEY LOCAL MACHINENSYSTEM CurrentControlSet Services Drivers OCdriver EventMessageFile REG_EXPAND_SZ SystemRoot System32 Drivers OCdriver sys TypesSupported REG_DWORD 0X00000007 3 copies the library file OCapi d11 to the systemRoot system32 directory If you select Runtime amp Development the setup utility performs the same steps as for Runtime only and the setup utility copies ocapi lib ocapi h and the sample source files to a development directory If you want to develop your application on a computer other than the open controller copy the ocapi lib and oc
79. KKKAKKKAKKKAK KKK KKAKKKAKKKKKKAKKKAKKKKKKAKKKAKKKKKKKKKKKKKKOJ define OCERRDATASIZE 3 number of bytes of error data typedef struct tagOCEXTERR BYTE ErrorCode Major error code A BYTE SlotNum Associated slot number BYTE ErrorData OCERRDATASIZE Subsystem error data 7 OCEXTERR JAKKKKAKKAKKKAKKKAKKKK KKK K KKK KKAKKKAKKKKKKAKKKAKKKKK KKK KKKKKK Structure Name OCVERSIONINFO x Description x x Returned by OC GetVersionInfo Software and hardware version numbers Fe KR IK AR RRA kk KKK K KKK KKAKKKAKKKKKKAKKKAKKKKKKKKKKKKKKJ typedef struct tagOCVERSIONINFO WORD APISeries API series WORD APIRevision API revision 7 WORD ScannerFirmwareSeries Scanner firmware series ey WORD ScannerFirmwareRevision Scanner firmware revision WORD OCHardwareSeries Hardware series WORD OCHardwareRevision Hardware revision WORD OCdriverSeries Device driver series Es Publication 1747 UM002A US P June 2000 Header File C 17 NORD OCdriverRevision Device driver revision Ef OCVERSIONINFO JAKKKAKKKAKKKKKKAKKKAK KKK e A e e AA Structure Name OCDEVICEINFO x Description x Returned by OC GetDeviceInfo X Information regarding the scanner device x KAKKKAKKKAKKKA KKK KKKAK KKK KKK A typedef struct tagOCDEVICEINFO WORD ScannerType OC PGIS WORD ScannerIrg Interrupt DWORD ScannerMemory Memory window physical addres
80. LL 6 O0 2 outputdata Read slot 6 data first 2 words directly from the output image table to outputdata buffer OC ReadSRAM reads data from the battery backed user memory Syntax int OC ReadSRAM HANDLE Handle BYTE bufptr DWORD offset DWORD length Description The battery backed memory may be used to store important data that needs to be preserved in the event of a power failure The size of the available memory in bytes may be obtained using OC GetDeviceInfo IMPORTANT Lis recommended that the integrity of data stored in the user memory be verified by some means The OC CalculateCRC function may be used to generate a 16 bit CRC that may be used for this purpose handle must be a valid handle returned from OC OpenScanner bufptr points to a buffer to be receive the data offset specifies Library of Routines 6 53 the offset within the memroy to begin reading length specifiies the number of bytes to be read If offset tlength points past the end of the memory no bytes will be written and ERR_OCPRAM will be returned Return Value Name Description SUCCESS data was read successfully ERR_OCACCESS handle does not have access to scanner ERR_OCPARAM offset length points past the end of the memory Considerations Supported in the Windows NT API library only Example Byte buf 100 buffer of 100 bytes of important data HANDLE handle Wor
81. OC GetUserLEDState s 6 37 OC GerVersiOnlntos oua en Ga cde oe PR C 6 38 OC Mil SEAMS Su ER t Op dod e Ret 6 39 Error Codes Testing Function Calls Header File Table of Contents iii OC HOPE CANE ba Ja su too qve ti ls ug oC e eb e 6 41 OC_PetHostWatchdog iato naue ted Maca ta Cd ated 6 43 OC PollSCannet a vio yn banja Gy Fides eb bee o ER 6 44 OC_ReadHostRetentiveData oo oaoa e ea kt 6 46 OG NS TAN DIDIER a e era 6 47 OC_ReadIOConfigFile nnana iri mt t rs 6 49 OC ReadModuleFile i celle 6 50 OG ReadQutpullmage io dk e ane dA Rad 6 51 OG RATS RANTE a oa e es ne r 6 52 OC_ResetScanner AAA bbe 9 Le de ud ket r 6 54 A o A A 6 55 OC_SetHostWatchdog iaa NS ENT A 6 56 OC SetinputUpdateMode 6 58 OCTO T AAA de eb 6 59 OC_SetModulelnterrupt 2452 ea xx d ee b RR E 6 60 OC_SetOutputUpdateMode 44 4 0 ste aC a d 6 61 OC_SetScanMode ect eet ad NECS es er Sok 6 63 OG Sebocar Times vr wat Em 2 eg avt qa s pto o at Tee ot 6 64 OC Sel UserLEDSUM e ato das rre Web LGN AA d oes 6 65 OC_SetupPowerFailAction 6 66 OC C D RIM daos m r a Bi oed dt e sat ERR 6 08 OC_WaitForEoOS o sis Sie AO 6 69 OC_WaitForEosDmdIn ai parecieron creada 6 70 OC_WaitForEosDmdOut ooa 6 ad ere Ne ke 6 71 OC_WaitForExtErrOT oed i e india sain rd 6 73 OC_WaitForloInt se o Ka wae ses Eee ook A a 6 74 OC_WriteHostRetentiveData 6 75 OC_WritelOConfig
82. S Xu ye KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKXXXX ensure structures are byte aligned tifdef BORLANDC pragma option al endif _BORLANDC tifdef _MSC_VER pragma pack 1 tendif MSC VER JAKKKKAKKKKKKAKKKAKKKA KKK K KKK KKAKKKAKKKKKKAKKKAKKKKAKKKAKKKKKK Structure Name OCINIT Description k Passed to OC InitScanner function to specify K dual port RAM partition sizes for output image input image and host retentive data KAKKKKAKKKKKKAKKKAKKKA KKK K Kk KC KKAKKKAKKKKKKKAKKKAKKKKKKKKKKKKKJ typedef struct tagOCINIT WORD OutputImageSize size in bytes WORD InputImageSize size in bytes WORD HostRetentiveDataSize size in bytes OCINIT JAKKKKAKKAKKKAKKKAKKKAKKKK KKK KKAKKKAKKKKKKKAKKKAKKKAKAKKKKKKKKK Structure Name OCSLOTCFG Description E Configuration information for a module The mix and x type codes together form a unique identification for K each module x x KAKKKKAKKKKKKAKKKAKKKA KKK K KKK KKAKKKAKKKKKKKAKKKAKKKKKKKKKKKKK typedef struct tagOCSLOTCFG BYTE mix mix code BYTE type type code BYTE InputSize number of inputs in bytes BYTE OutputSize number of outputs in bytes WORD M0Size size of MO file in words WORD MISize size of M1 file in words WORD GSize size of G file in words WORD GData pointer to array of length GSize words Publication 1747 UM002A
83. SET mode see OC SetHostWatchdog this function may be called during initialization to determine if the system was reset due to a host watchdog timeout Return Value Name Value Description SUCCESS 0 Scanner watchdog count read successfully ERR OCACCESS 1 handle does not have access to scanner Example HANDLE Handle int nResetCause if reset caused by host watchdog timeout notify the operator OC GetResetCause Handle amp nResetCause if nResetCause RESET HOST ND printf AnHost Watchdog timed out and reset the system n Publication 1747 UM002A US P June 2000 6 26 Library of Routines OC GetScannerinitinfo This function retrieves current information about the shared memory partitioning Syntax int OC GetScannerInitInfo HANDLE handle OCINIT scaninit Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner scaninit Points to the structure that contains the initialization information this function returns Description If the scanner has not been initialized OC GetScannerinitinfo returns an error If the scanner has been previously initialized an application can retrieve the current scanner partitioning information with this function instead of resetting and re initializing the scanner The OCINIT structure us defined as typedef struct tagOCINIT WORD OutputImageSize size
84. ScannerStatus function A JE 7 define SCANSTS_POST 0x01 Scanner is executing Power On Self Test f define SCANSTS CRC 0x02 Scanner firmware failed CRC checksum define SCANSTS_RAM 0x03 Scanner RAM test failed 7 define SCANSTS_BPIC 0x04 Scanner backplane IC test failed y define SCANSTS_DPR 0x05 Scanner Dual Port Ram test failed define SCANSTS_THERM 0x06 Scanner thermometer test failed tdefine SCANSTS_TIMER 0x07 Scanner timer test failed EVA define SCANSTS_INT 0x08 Scanner interrupt test failed 7 define SCANSTS_INIT Ox10 Scanner POST passed waiting for initialization KA define SCANSTS_IDLE 0x11 Scanner has been initialized and is in Idle mode define SCANSTS_WDOG 0x12 Scanner internal watchdog timeout scanner halted define SCANSTS_FAULT 0x13 Scanner is faulted define SCANSTS SCAN 0x20 Scanner is in Scan mode KKKKK Scan Time KKKKK These values are passed to the OC SetScanTime function RA Wf define SCAN DELAYED 0 Select delayed mode next scan occurs time 10us after end of scan define SCAN PERIODIC 1 Select periodic mode next scan occurs every time 250us x KKKKK Scan Mode KKKKK These values are passed to the OC SetScanMode function 7 define SCAN_IDLE 0 Select Idle mode not scanning 1 0 define SCAN_RUN 1 Select Scan mode scanning 1 0 ay KKKKK IO Idle State KKKKK These values are passed
85. T power on self test waiting for host initialization e Idle e Scan Faulted e non recoverable fault After the scanner successfully completes the POST the scanner waits for an initialization complete command from the application Once the scanner receives this command the scanner enters Idle mode Before the scanner can enter Scan mode the application must download a valid I O configuration to the scanner If a recoverable fault occurs the scanner enters Faulted mode Use the OC_ClearFault API function to clear the fault before the scanner can resume operating in Scan mode If a non recoverable fault occurs reset the scanner cycle power Some possible non recoverable faults include POST failure background diagnostic failure internal watchdog timeout Ghecking LED Indicators The graphics below show LED displays 1746 PCI 1 0 Interface PCI INTERFACE STATUS BATT LED 1 LED 2 LED 3 LED 4 STATUS Overview 1 7 1747 Open Controller OC 266 PENTIUM STATUS BATT COM 1 COM 2 LED 1 LED2 LED 3 LED 4 The STATUS indicator reports the status of the scanner The following table lists the LED states for STATUS This state Means Take this action Yellow The scanner is running POST None Flashing green The scanner is in idle mode and None is not scanning 1 0
86. TRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY E tendif int int int int int int int int int int int int int int int N int int int int int int int int int int int int int int int int int int int int int int void OCAPI OC CalculateCRC BYTE int int int int int int int int int int int int int int int int int int int OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI_H OC CreatelOConfiguration OCIOCFG OC DownloadlIOConfiguration HANDLE OC GetlIOConfiguration HANDLE OCIOC OC ConfigureDII HANDLE DI OC SetModuleInterrupt HANDLE in
87. V dc 0 5 10 1746 ITB16 16 Input FAST SINK 24V dc 0 5 19 1746 ITV16 16 Input FASTISOURCE 24V de 0 5 18 1746 IV8 8 Input SOURCE 24 V dc 0 3 20 1746 IV16 16 Input SOURCE 24 V dc 0 5 20 1746 1432 32 Input SOURCE 24 V de 0 1 20 1746 0A8 8 Output TRIAC 100 240 V ac 0 21 3 1146 0416 16 Output TRIAC 100 240 V ac 0 29 3 1746 DAP12 Enhanced ac 0 28 3 1746 0B8 8 Output TRANS SOURCE 10 50 V de 0 21 13 1746 0B16 16 Output TRANSI SOURCE 10 50 V dc 0 29 13 1746 OB16E 16 Output de 0 29 20 1746 0B32 32 Output TRANS SOURCE 10 50 V dc 0 31 13 1146 0BP8 8 Output de 0 21 21 1746 OBP16 16 Output TRANS 1 ampJ SRC 24V dc 0 29 21 1746 0616 16 Output TTL SINK 5 V de 0 29 15 1746 0V8 8 Output TRANS SINK 10 50 V dc 0 21 14 1746 0V16 16 Output TRANS SINK 10 50 V dc 0 29 14 1746 0V32 32 Output TRANS SINK 10 50 V dc 0 31 14 1746 OW4 4 Output RELAY V ac V de 0 25 0 1746 OW8 8 Output RELAY V ac V dc 0 21 0 1746 0VV16 16 Output RELAY V ac V dc 0 29 0 1746 0X8 8 Output ISOLATED RELAY V ac V dc 0 21 1 1746 OVP16 16 Output TRANS 1 amp SINK 24V de 0 29 22 The module names shown in this table correspond to those used by the OC_GetlOConfiguration and OC_CreatelOConfiguration functions The mix code for a module is composed of one byte field The upper 3 bits represent the class of the module and the lower 5 bits represent the 1 0 mix of the module Publication 1747 UM002A US P June 2000 Configuring 170 Modules
88. able module nA define SLOT DISABLE 1 Disable module ap KKKKK LED States KKKKK These values are passed to the OC_SetUserLEDState function and are returned by the OC_GetUserLEDState function JE define LED OFF 0 LED is off define LED RED SOLID 1 LED is Red continuous define LED GREEN SOLID 2 LED is Green continuous LA define LED RED FLASH 3 LED is flashing Red 1 2 only ti define LED GREEN FLASH 4 LED is flashing Green 1 2 only pe Battery Status Sri xy These values are returned by the OC GetBatteryStatus function i pas define BATTERY_LOW 0 Battery voltage is low define BATTERY GOOD 1 Battery is OK f Switch Position These values are returned by the OC GetSwitchPosition function 7 1 7 define SWITCH_TOP OxFF Switch is in the Top position define SWITCH MIDDLE 0x00 Switch is in the Middle position define SWITCH BOTTOM 0x01 Switch is in the Bottom position Jumper State These values are returned by the OC GetUserJumperState function Es es Publication 1747 UM002A US P June 2000 Header File C 13 define JUMPER PRESENT 0 User jumper is installed EJ define JUMPER_ABSENT 1 User jumper is not installed EA JF Watchdog Settings These values are passed to the OC SetHostWatchdog function 7 Le 7 define WATCHDOG_IGNORE 0 Hos
89. ait forever Description If an EOS message has been received since the last OCMSG_EOS message was retrieved with the OC_PollScanner function OC_WaitForEos returns SUCCESS immediately You can use this function to synchronize a control application with the I O scan See the OC_EnableEOSNotify function Return Value Name Value Description SUCCESS 0 an EOS message was received ERR_RESPONSE 10 msTimeout milliseconds elapsed without an EOS ERR_OCACCESS 2 handle does not have access to scanner Considerations Supported in the Windows NT API library only Example HANDLE handle intro MSGBUF eosMSG Wait for 10 seconds for the EOS rc OC WaitForEos handle 10000 switch rc case SUCCESS got EOS reset the EOS event OC PollScanner handle OCMSG_EOS amp eosMSG break case ERR OCRESPONSE timed out printf nTimed out waiting for EOS Mn break default printf MnError Nn break Publication 1747 UM002A US P June 2000 6 70 Library of Routines OC WaitForEosDmdin Blocks the calling thread until a demand input end of scan EOS notification is received from the scanner or msTimeout milliseconds have elapsed Syntax int OC_WaitForEosDmdIn HANDLE handle DWORD msTimeout Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner msTimeout Spec
90. aking too long to complete increase the scan time to provide more time for the scanner to process messages If the scan time is set too large VO won t update fast enough From the end of post until entering scan mode the scanner holds the I O reset line high For information about estimating scan time see PCIS Bus Card for 1746 Local VO Installation Instructions publication 1747 5 31 Scan 1 0 The scanner provides two basic methods for scanning VO timed scans and on demand scans The host application can use either or a combination of both Typically the scanner reads inputs from modules and writes outputs to modules once every scan time To read inputs and write outputs the application calls OC Readinputimage and OC YriteOutputimage independently from the scanner s scan sequence Developing Applications 3 5 Programming Example for DOS The application can change the behavior of the input and output scans by allowing the application to have more control over I O scanning The application can prevent the scanner from doing any output scans and allow the application to read inputs and initialize outputs before the scanner begins to write outputs This mode allows the application to pre scan the inputs before the outputs are written The application can set the scanner to a conditional scan mode where the scanner writes outputs at the next scan time after the application writes data to the output image In this mode the
91. alid partition information ERR_OCPARAM 8 parameter contains invalid value ERR_OCPOST 7 scanner POST failure ERR_OCREINIT 4 scanner has already been initialized ERR_OCRESPONSE 10 scanner did not respond to request successfully ERR_OCSCANCFG 14 scanner I O configuration not downloaded ERR OCSLOT 12 slot number is invalid ERR OCUNKNOWN 18 unknown module type ERR OCNOTSUPP 20 function not supported on this platform Publication 1747 UM002A US P June 2000 A 2 Error Codes Extended Error Codes Publication 1747 UM002A US P June 2000 The OC GetExtendedError function returns error information in a structure of type OCEXTERR This structure is five bytes in length and contains the following information Buffer Offset Bytes Description 0 1 extended error code 1 1 associated slot or file number 2 3 error code data When the scanner encounters an error the extended error code and associated slot if any is written to the extended error code and slot number fields Error dependent information is written to the remaining field and the scanner goes to Idle mode The extended error codes that can be reported by the scanner are Extended Error Code Description 0x00 No errors present 0x01 Downloaded directory file is invalid 0x08 Internal software error 0x12 Downloaded configuration is corrupted 0x21 Power fail on expansio
92. and 3 position switch reading 1746 I O PCI Interface status enabling disabling forces Application API 1746 1 0 PCI Interface Open Controller dual port memory o local 1 0 remote VO via 1747 SN or 1747 SDN API Software for DOS The DOS API software provides a library of C function calls for DOS application programs to interface with the dual port memory The DOS API supports any language compiler that uses the Pascal calling convention Overvievv 1 3 API Software for Windows NT The Windows NT API supports any programming languages that use the Win32 _stdcall calling convention for application interface functions The Windows NT APT function names are exported from a DLL in undecorated format to simplify access from other programming languages The Windows NT API software consists of two main components e the OCdriver depending on your application either 1746 I O PCI Interface device driver or Open Controller device driver e the API library which is a DLL dynamically linked library The Windows NT API library is a DLL and must be installed on the system in order to run an application which uses it The Windows NT API accesses the scanner via the driver created for the bus interface The driver e allocates resources interrupt and memory window e initializes scanner hardware e provides access to the scanner s dual port RAM services interrupts from the s
93. andle Must be a valid handle returned from OC OpenScanner lednum Must be a value from 1 to 4 which corresponds to LED 1 LED 2 LED 3 and LED 4 state If state Is LED_OFF LED is off LED_RED_SOLID LED is on red solid LED_GREEN_SOLID LED is on green solid LED_RED_FLASH LED is on red flashing LED1 and LED2 only LED_GREEN_FLASH LED is on green flashing LED1 and LED2 only Description The application can use this function to determine the current state of the LEDs Publication 1747 UM002A US P June 2000 6 38 Library of Routines Return Value Name Value Description SUCCESS 0 LED was read successfully ERR_OCACCESS 2 handle does not have access to scanner Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int led_state int retcode retcode OC GetUserLEDState Handle 1 amp led state OC GetVersioninfo OC GetVersioninfo retrieves the current version of the API library Ts 1746 I O PCI Interface hardware and scanner firmware Syntax int OC_GetVersionInfo HANDLE handle OCVERSIONINFO verinfo Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner verinfo Returns the current version of the API library 1746 1 0 PCI Interface hardware and scanner firmware Description Publication 1747 UM002A US P June 2000 The scanner must be initialized before this fu
94. anner has not been initialized see OC_InitScanner Considerations OC_GetTemperature Supported in the DOS API library and the Windows NT API library Example HANDLE Handle BYTE Sw pos int retcode retcode OC GetSwitchPosition Handle amp sw pos if sw pos SWITCH BOTTOM OC SetScanMode Handle SCAN IDLE OC GetTemperature reads the current temperature of the 1746 I O PCI Interface s built in thermometer Syntax int OC GetTemperature HANDLE handle BYTE temp Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner temp Returns the temperature in degrees Celsius Description The temperature is updated every 10 seconds by the scanner The optimal operating temperature range for the 1746 I O PCI Interface is 0 to 60 C When OC GetTemperature returns a value of 75 C or higher the 1746 I O PCI Interface is operating beyond its optimal operating temperature range and you need to correct the situation The scanner must be initialized before you can monitor the temperature Publication 1747 UM002A US P June 2000 6 36 Library of Routines Return Value Name Value Description SUCCESS 0 temperature was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner Considerations Supported in the DOS API library and the
95. anner returns a message only OCMSG_EOS_DMDIN of the corresponding type if any or OCMSG_EOS_DMDOUT OCMSG_ANY OC_PollScanner searches for a message in the order OCMSG_DIINT OCMSG_IOINT OCMSG_EOS_DMDIN OCMSG_EOS_DMDOUT then OCMSG_EOS from any of the sources msgbuf A structure that contains scanner messages Description Publication 1747 UM002A US P June 2000 The MSGBUF structure is defined as typedef struct BYTE MsgID BYTE MsgData 4 MSGBUF Library of Routines 6 45 The MsgID member of the msgbuf structure will be one of the follovving values This value Means OCMSG NONE No message available OCMSG_IOINIT 1 0 module interrupt message see OC SetModulelnterrupt OCMSG_DIINT Discrete input interrupt message see OC_ConfigureDIl OCMSG_EOS_DMDIN End of scan notification message from OC_DemandInputScan command see OC_EnableEOSNotify OCMSG_EOS_DMDOUT End of scan notification message from OC_DemandOutputScan command see OC_EnableEOSNotify OCMSG_EOS End of scan notification message for timed 1 0 scan see OC_EnableEOSNotify The data returned in the MsgData member array depends upon the value in MsgID This MsgID Returns MsgID OCMSG_IOINT MsgDatal0 slot number that generated the interrupt MsglD OCMSG_DIINT MsgDatal0 mask of last bit transition that generated the interrupt MsgData 2 lowbyte of count of matches that generated
96. api h files to the development computer do not run the setup utility on the development computer You won t be able to run your application on the development computer The runtime API only works on an open controller Uninstalling the Windows NT API To uninstall Windows NT API use the following instructions 1 From the Control Panel select Add Remove Programs 2 From the list of installed programs select Open Control API 3 Click on Add Remove 4 Click on Yes All of the API files and registry keys will be deleted Publication 1747 UM002A US P June 2000 Introduction Getting Started Chapter 2 Using the API This chapter describes the API and how to use its components For more information about developing applications using the API see chapter 3 To use the API make sure you have copied the follovving files to your development directories The sample files are optional This file Contains ocapil lib API functions that you link to your application DOS only ocapi lib Import library in Microsoft COFF format Windows NT only ocapi h API header file that contains API referenced structures ocapi dil API DLL Windows NT only sample c Sample application program calling the API functions sampleb mak Sample MAKE file for the Borland C compiler samplem mak Sample MAKE file for the Microsoft C compiler Your application must link to the appropriate library ocapil lib for DOS or ocapi
97. assed as inpimgcpy in subsequent OC Readinputimage calls to retrieve the slot data from the copy of the input image This preserves input image file integrity across multiple calls to OC Readinputimage If file integrity is not necessary the host application can set inpimgcpy to NULL and access data directly from shared memory Return Value Name Value Description SUCCESS 0 input image was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCPARAM 8 parameter contains invalid value ERR_OCSCANCFG 14 scanner has not been configured ERR_OCSLOT 12 slot number is invalid Considerations Publication 1747 UM002A US P June 2000 Supported in the DOS API library and the Windows NT API library Example HANDLE Handle WORD inputdata 2 int retcode retcode OC ReadInputImage Handle NULL 6 O0 2 inputdata Read slot 6 data first 2 words directly from the input image table to inputdata buffer Library of Routines 6 49 OC ReadlOConfigFile OC ReadIOConfigFile reads the configuration data that is already stored in the DOS file created using OC WriteIOConfigFile Syntax int OC ReadIOConfigFile OCIOCFG iocfg char filename Parameters Parameter Description iocfg A structure that contains a copy of the configuration data that is in filename filename References a file that was created using OC WritelOCo
98. before the fault can be cleared If the scanner encounters an error condition it generates an extended error and faults The fault forces the scanner into Idle mode The scanner cannot be placed into Scan mode until the fault is cleared Return Value Name Value Description SUCCESS 0 fault was cleared successfully ERR OCACCESS 2 handle does not have access to the scanner ERR OCEXTERR 11 scanner extended error message see OC GetExtendedError ERR OCINIT 5 scanner has not been initialized see OC InitScanner ERR OCRESPONSE 10 scanner did not respond to request Publication 1747 UM002A US P June 2000 Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC ClearFault Handle Library of Routines 6 3 0C CloseScanner This function must always be called before exiting the application Syntax int OC CloseScanner HANDLE handle Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner Description This function releases control of the scanner device releases the interrupt assigned by OC OpenScanner and disables the segment address assignment ATTENTION The system might become unstable if you don t call OC CloseScanner before exiting the application Return Value Name Value Description SUCCESS 0 scanner was c
99. bit must be set in order for an 170 interrupt received priority message to be generated when a module issues an interrupt request 11 0 to 11 8 reserved 11 9 status 1 0 scan toggle bit This bit is cleared upon entry into Scan mode and is toggled changes state at the end of every 1 0 scan 1 10 dynamic configuration DII reconfiguration bit If the bit is set by the host the DII function will reconfigure itself at the end of the next 1 0 scan 11 to 11 reserved 15 12 status Last VO scan time This word indicates the current observed interval between consecutive I O scans The interval time is reported in units of 250 ms Resolution of the last scan time is 0 to 250 ms For example the value 10 indicates that 2 25 2 5 ms was the last scan time 13 dynamic configuration DII function enable A value of zero written to this word will disable the discrete input interrupt function Any non zero value will enable the function 14 dynamic configuration DII slot number This word is used to configure the DII function The slot number 1 30 that contains the discrete 1 0 module should be written to this word The scanner will fault if the slot is empty or contains a non discrete 170 module This word is applied upon detection of the DII reconfigure bit 11 10 or upon entry to Scan mode 15 dynamic configuration DII bit mask This word contains a bit mapped value that corresponds to the bits to
100. bufptr If bufptr Is NULL no data is copied default Not NULL at power fail length bytes of data are copied from bufptr to the host retentive data partition starting at offset offset Specifies the offset within the host retentive data partition to begin copying length Number of bytes to copy If length points beyond the end of the host retentive data partition it is truncated callback If callback IS NULL no callback function is executed default Not NULL the power fail interrupt routine calls this function after copying the data to the host retentive data partition if configured Description Publication 1747 UM002A US P June 2000 You can configure the power failure action in four ways No action default the power failure interrupt is ignored bufptr is NULL callback is NULL e Copy a block of data to the host retentive data partition in dual port RAM bufptr points to the data to save callback is NULL e Execute a user callback function bufptr is NULL callback points to the routine to call e Copy a block of data and execute a callback function bufptr points to the data to save callback points to the routine to call Library of Routines 6 67 A system typically has at least 10 milliseconds and possibly as much as 50 milliseconds or more between the power fail interrupt and the loss of power The duration of this interval is a function of the power supply and system configuration and it va
101. ca int pasca int pasca int pasca tendif a x OC CloseScanner HANDLE OC_InitScanner HANDLE OCINIT OC GetScannerInitInfo HANDLE OCINIT OC ResetScanner HANDLE int OC GetScannerStatus HANDLE BYTE OC CreatelOConfiguration OCIOCFG OC DownloadlIOConfiguration HANDLE OCIOCFG OC GetIOConfiguration HANDLE OCIOCFG OC ConfigureDII HANDLE DII CFG OC SetModuleInterrupt HANDLE int int OC SetScanTime HANDLE int int OC SetOutputUpdateMode HANDLE int OC EnableEOSNotify HANDLE int OC GetLastFaultCause HANDLE BYTE int OC SetScanMode HANDLE int OC ClearFault HANDLE OC SetlIOIdleState HANDLE int OC GetStatusFile HANDLE STSFILE OC OC OC OC PollScanner HANDLE int MSGBUF ReadInput Image HANDLE WORD int WORD WORD WORD GetInputImageUpdateCounter HANDLE BYTE Header File C 9 ReadOutput Image HANDLE WORD int WORD WORD WORD OC_Write0utputImage HANDLE WORD int WORD WORD WORD OC_WriteModuleFile HANDLE BYTE WORD int WORD WORD OC OC OC OC ReadModuleFile HANDLE BYTE WORD int WORD WORD EnableForces HANDLE int SetForces HANDLE FORCEDATA EnableSlot HANDLE int int OC DemandOutputScan HANDLE int OC GetUserLEDState HANDLE int int OC SetUserLEDState HANDLE int int OC GetBatteryStatus HANDLE BYTE OC GetTemperature HANDLE
102. canner priority messages provides access to SRAM IMPORTANT Only access the OCdriver through the API library functions When the OCdriver is loaded it tries to allocate an interrupt and a memory window for the memory and interrupt that were allocated using the settings by the PCI bus at power up for the dual port RAM If IRQ 11 and address oxC8000 are not available G e another device already allocated the resource OCdriver tries to allocate any resource for which the scanner hardware can be configured IRQ 10 12 and 15 memory address OXCA000 OxDE000 OCdriver fails to load if an interrupt and memory window cannot be allocated Once an interrupt and memory window are allocated OCdriver initializes the scanner hardware to match the allocated resources Publication 1747 UM002A US P June 2000 1 4 Overview Understanding the 1746 1 0 The 1746 1 O PCI Interface architecture consists of a PCI card that plugs into a PC and cables to a 1746 I O chassis The scanner scans PCI Interface Architecture the 1746 local I O bus and reads writes inputs and outputs to from the dual port registers 1747 PCIS 1747 PCIL dual port memory 1746 backplane interface Partition Bytes cable register 1K aile PCI bus Scanner CPU omrande variable status and user LEDs response variable tput i iabl o e
103. ccording to ForceVal ForceMask and ForceVal Each bit in ForceMask that is set to 0 will have its force removed Each bit in ForceMask that is set to 1 will have its force installed For each bit that has its force installed the corresponding bit in ForceVal determines the state of the force For bits that have their force removed the corresponding bit in Forceva1 is ignored Publication 1747 UM002A US P June 2000 6 56 Library of Routines Return Value Name Value Description SUCCESS 0 1 0 forces were configured successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCPARAM 8 parameter contains invalid value ERR_OCRESPONSE 10 scanner did not respond to request ERR_OCSCANCFG 14 scanner has not been configured ERR_OCSLOT 12 slot number is invalid Considerations 0C_SetHostWatchdog Publication 1747 UM002A US P June 2000 Supported in the DOS API library and the Windows NT API library Example HANDLE handle FORCEDATA forces int retcode Force low byte of input word 1 of slot 6 to 0x5A forces SlotNum 6 forces WordOffset 1 forces IOType FORCE_INPUTS forces ForceMask Ox00FF forces ForceVal 0x005A retcode OC SetForces handle amp forces Must call OC EnableForces to actually apply the force data OC SetHostWatchdog sets the host to scanner watchdog delay and mode of the scanner Syntax int
104. ciated slot number BYTE ErrorData OCERRDATASIZE Error code data OCEXTERR OCINIT typedef struct tagOCINIT Passed to OC InitScanner function to specify dual port RAM partition sizes for output image input image and host retentive data WORD OutputlmageSize size in bytes WORD InputlmageSize size in bytes WORD HostRetentiveDataSize size in bytes OCINIT Publication 1747 UM002A US P June 2000 4 2 Using the API Structures Structure Name OCIOCFG Used by OC CreatelOConfiguration OC GetlOConfiguration and OC DownloadlOConfiguratio n Configuration information for a system 1 2 or 3 racks may be configured for up to 30 1 0 modules Slot 0 is reserved for the 1746 1 0 PCI Interface Syntax typedef struct tagOCIOCFG BYTE Rack1Size number of slots in Rack 1 BYTE Rack2Size number of slots in Rack 2 BYTE Rack3Size number of slots in Rack 3 OCSLOTCFGSlotCfg OCMAXSLOT configuration for each slot OCIOCFG OCSLOTCFG typedef struct tagOCSLOTCFG Configuration information for a module The mix and type BYTE mix mix code codes together form a unique BYTE type type code identification for each BYTE InputSize number of inputs in bytes module BYTE OutputSize number of outputs in bytes WORD MOSize size of MO file in words WORD MiSie I size of M1 file in words WORD GSize size
105. culate CRC OC CalculateCRC buf Write data CRC to OC WriteSRAM handle data to offset 0 in SRAM buf 0 100 100 amp crc offset 100 in SRAM amp crc 100 2 Publication 1747 UM002A US P June 2000 6 82 Library of Routines Notes Publication 1747 UM002A US P June 2000 Introduction Error Gode Returned by API Functions Error Godes Appendix A This appendix describes the error code data Most of the API functions return values see chapter 6 These are the values returned by the API functions to indicate success or possible error conditions but not all are returned by each function The table below lists API Function values Name Return Value Description SUCCESS 0 function returned successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCEXTERR 11 scanner responded with an extended error message ERR_OCFAULT 13 request denied because scanner faulted ERR_OCFILERROR 19 error occurred while reading writing disk file ERR_OCINIT 5 scanner has not been initialized ERR_OCIOCFG 9 1 0 configuration is invalid ERR_OCMEM 3 shared memory cannot be found ERR OCNOFORCES 15 no forces installed cannot enable forces ERR_OCOPEN 1 scanner already open da DOE 17 memory allocate failed ERR_OCOVERRUN 16 DII 1 0 initialization or error report message overrun ERR_OCPAR 6 initialization failed due to inv
106. d crc crc_saved Read 100 bytes of data from offset 0 in SRAM OC ReadSRAM handle buf 0 100 Calculate CRC OC CalculateCRc buf 100 amp crc Read saved CRC at offset 100 in SRAM OC ReadSRAM handle amp crc saved 100 2 Check CRC if crc saved crc printf ERROR Data is corrupted in Publication 1747 UM002A US P June 2000 6 54 Library of Routines OC ResetScanner OC ResetScanner generates a hard or soft reset to the scanner ATTENTION This call stops scanning and resets outputs Syntax int OC ResetScanner HANDLE handle int mode Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode Is OCNOWAIT OC_ResetScanner returns after releasing the reset signal to the scanner OCWAIT OC_ResetScanner returns after POST is completed OCSOFTRESET OC_ResetScanner reinitializes while avoiding the 7 second POST delay In this mode the scanner performs a warm boot and bypasses the POST The dual port RAM can be epartitioned quickly The scanner stops scanning resets all outputs and returns to the power on condition After the reset is complete you must call OC_InitScanner to initialize the shared memory interface Description After the reset is generated the scanner begins to execute its POST Return Value Name Value Description SUCCESS 0 scanner was reset successfully ERR_OCAC
107. d to by imagebuf Then len words of output data starting at word offset are written to the module in the slot and will not write past the end of the output image for the slot 1 the entire output image is written from the array pointed to by imagebuf and offset and len are ignored imagebuf Must point to an array that is large enough to accept the amount of data from the requested output image Description To guarantee that changes to the output image resulting from a series of calls to OC_WriteOutputImage are posted to the I O modules in a single output scan OC_WriteOutputImage can be called to modify a local copy of the output image then finally called to write the entire copy of the output image to the scanner s shared memory This preserves output image file integrity across multiple calls to OC_WriteOutputImage Return Value Value Description SUCCESS output image was written successfully ERR_OCACCESS handle does not have access to scanner ERR_OCPARAM parameter contains invalid value ERR_OCSCANCFG scanner has not been configured ERR_OCSLOT slot number is invalid Publication 1747 UM002A US P June 2000 6 80 Library of Routines OC WriteSRAM Publication 1747 UM002A US P June 2000 Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle WORD outputdata 2 int retcode outputdata 0
108. de HANDLE handle int mode Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode IS SCAN_IDLE the scanner changes to Idle mode and stops scanning 170 SCAN_RUN the scanner changes to Scan mode and begins scanning 1 0 Description The scanner must be properly configured before going to Scan mode OC_SetScanMode will fail if there are any unread extended errors or faults Call OC_GetExtendedError to extract all extended errors and call OC_ClearFault to clear any faults before calling OC_SetScanMode Before the scanner changes to Scan mode it compares the downloaded I O configuration to the racks and I O modules actually installed If there are any problems an extended error is generated and OC_SetScanMode returns an error If the scanner finds no problems the scanner is in Scan mode when this function returns Return Value Name Value Description SUCCESS 0 scan mode was set successfully ERR_OCACCESS 2 handle does not have access to the scanner ERR_OCFAULT 13 scanner is faulted ERR_OCINIT 5 scanner has not been initialized see OC InitScanner ERR OCPARAM 8 parameter contains invalid value ERR OCRESPONSE 10 scanner did not respond to request Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC SetScanMode Handle SCAN RUN Scan I O Publication 1747 UM002A US P June 20
109. dentifies the message type Type specific data is contained in MsgData KAKKKAKKKAKKKAKKAKKKAKKKAKKAKKKAK AA define OCMSGDATASIZE 4 number of bytes of message data typedef struct tagMSGBUF BYTE MsgID Message type 7 BYTE MsgData OCMSGDATASIZE Type specific data EE MSGBUF E AAA Structure Name OCEXTERR Publication 1747 UM002A US P June 2000 C 8 Header File Description Returned by OC GetExtendederror I O error report from scanner KKAKKAKKAAKKKKKKAKKKAKKKA KKK K KKK KKAKKKAKKKKKKAKKKAKKKKKKKKKKKKKKOJ define OCERRDATASIZE 3 number of bytes of error data typedef struct tagOCEXTERR BYTE ErrorCode Major error code E BYTE SlotNum Associated slot number BYTE ErrorData OCERRDATASIZE Subsystem error data OCEXTERR JAKKKKAKKAKKKAKKKAKKKA KKK K KKK KKAKKKAKKKKKKAKKKAKKKAKAKKAKKKKKK Structure Name OCVERSIONINFO x Description x x Returned by OC GetVersionInfo Software and hardware version numbers KAKKAKKAKKAKKKAKKKAKKKAKKKK Kk KC KKAKKKAKKKKKKKAKKKAKKKKKKKKKKKKKJ typedef struct tagOCVERSIONINFO WORD APISeries API series EZ WORD APIRevision API revision f WORD ScannerFirmwareSeries Scanner firmware series ay WORD ScannerFirmwareRevision Scanner firmware revision WORD OCHardwareSeries Hardware series WORD OCHardwareRevision Hardware revision KT OCVERSIONINFO JAKKKKAKKKKKKAKKKAKKKA
110. dle exit retcode end Ioexit Programming Example for The following Windows NT example sample c on your Windows Wind NT NT APT disk shows how to program the above steps Callouts on the Indows right margin identify the code for each step BK HK IK IK I A A A RAR A A RAR RA RRA RA RARA RARA RARA Title Simple application sample code for 1746 I O PCI Interface API Abstract This file contains a simple application using the PCI bus interface API Environment 1747 PCIS 1746 I O PCI Interface Microsoft Windows NT 4 0 Microsoft Visual C Borland C c Copyright Allen Bradley Fe A A A A AA INCLUDE FILES ACA CA Ro X X X X F F FH include lt windows h gt include lt process h gt include lt stdio h gt include lt stdlib h gt include lt time h gt include lt conio h gt include lt string h gt include ocapi h MODULE WIDE GLOBAL VARIABLES s HANDLE OChandle OCIOCFG OCcfg JAKKAKKKKKKKKKKKKAKKKAKKKAKKKAKAKAKAKAKAKAKAKAKAKAKKKKKKKKKKKKKKKKKKKKKKKK K Entry point Ioexit Description Common error handling routine This routine displays any extended error and exits the program Arguments rg 5 dnt input This error code is passed to the exit routine ox x A A A F FH Publication 1747 UM002A US P June 2000 3 12 Developing Appli Exter Retur non ACCES cations nal effects n va
111. dog Only scan outputs when output image chages Disable end of scan notification messages ENS ur RJ Hf ay 7 xp I a x oy Return without waiting for operation to complete Wait for operation to complete before returning and OC ReadModuleFile Maximum number of slots define OCNOWAIT 0 define OCWAIT 1 Module File Types These values are passed to the OC WriteModuleFile functions define FILTYP_G 0x05 Module G file define FILTYP_MO 0x08 Module MO file define FILTYP_M1 0x09 Module M1 file T O Configuration Definitions define OCMAXSLOT 31 define OCEMPTYTYPE OxFF define OCEMPTYMIX OxFF define OCWILDTYPE OxFF KA i sel 25 quA Wildcard type code matches any module type 7 slot 0 is reserved for PCIL Mix and type codes for empty slots and slot 0 4 Publication 1747 UM002A US P June 2000 C 14 Header File define OCSTSFILEWSIZE 25 Status file size in words define OCRTCSRAMSIZE 0x1000 size of real time clock SRAM define OCSEGMENTSIZELIMIT OxlA00 size of dual port RAM available for I O and host partitions Device Type Definitions qe Returned by OC GetDeviceInfo tj define OCDEVTYPE OC 1 1747 PCIL define OCDEVTYPE PCIS 2 1747 PCIS KAKKKKKKKKKKKKK kk KKK ck ck Sk Sk Sk sk sk ko ko ko ko JET de STRUCTURE
112. e initinfo Outpu initinfo Input Publication 1747 UM002A US P June 2000 lots 31 initinfo InputImageSize 0 tImageSize iocfg SlotCfglil OutputSizetl 2 2 ImageSize iocfg SlotCfg i InputSizet l 2 2 initinfo H OCSE Developing Applications 3 19 Any remaining shared memory can be allocated for host retentive data which is the portion of the dual port RAM that you can use to store data in case povver fails If the application doesn t need host retentive data set its size to 0 If the application needs host retentive data the application can determine the amount of memory available by using the OCSEGMENTSIZELIMIT constant This constant specifies the total number of bytes available for the three segment sizes To calculate the maximum memory available for the host retentive data use this formula ostRetentiveDataSize GM ENTSIZ LIMIt initinfo OutputImageSize initinfo InputImageSize If the I O configuration changes and causes the image sizes to change the maximum memory available for Host Retentive Data will change accordingly and information stored in the Host Retentive Data memory may be overwritten Publication 1747 UM002A US P June 2000 3 20 Developing Applications Notes Publication 1747 UM002A US P June 2000 Introduction API Structures Structure Name DII CFG Passed to OC ConfigureDIl Configures a discrete input interrupt
113. e Description SUCCESS 0 host watchdog was set successfully ERR OCACCESS 2 handle does not have access to scanner ERR OCINIT 5 scanner has not been initialized see OC InitScanner ERR OCPARAM 8 parameter contains invalid value Considerations Supported in the DOS API library and the Windows NT API library Publication 1747 UM002A US P June 2000 6 58 Library of Routines OC SetlnputUpdate Example HANDLE Handle int retcode retcode OC SetHostWatchdog Handle WATCHDOG IDLE 10 Watchdog times out in 1 second and places scanner in idle mode OC SetInputUpdateMode controls how the scanner updates inputs Mode Syntax int OC SetInputUpdateMode HANDLE handle int mode Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode Is INUPD_NEVER The scanner does not scan inputs unless explicitly requested by the C DemandinputScan function INUPD ALVVAYS The scanner continuously updates inputs on every scan By default the input update mode is INUPD_ALWAYS A change in status of the input update mode takes effect at start of next scan Description This function does not affect output image scanning Return Value Name Value Description SUCCESS 0 conditional scan was set successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner ERR_O
114. e default control break handler is installed by OC OpenScanner If you pressa Ct r1 C or Ctrl Break key sequence the following prompt is displayed Terminate Application Y N _ A response of v properly exits the application a response of N causes the application to continue If you need a different control break handler you must install it after calling the OC OpenScanner function Always call the OC CloseScanner function before exiting an application This requirement memory mapping Using the API 2 3 Windows NT Considerations During development the application must be linked with an import library that provides information about the functions contained within the DLL The API import library is compatible with the Microsoft linker You can generate import libraries for other programming languages from the DLL The Windows NT API can only be accessed by one process at a time The API is designed to be multi thread safe so that multi threaded control applications can be developed Where necessary the API functions acquire a mutex before accessing the scanner interface In this way access to the scanner device is serialized If the mutex is in use by another thread a thread will be blocked until it is freed To create a consistent API careful consideration was given to these requirements Considerations The NT API device driver detects the Scanner Adapter and automatically configures the memory window address a
115. e received For Windows NT use the OC_WaitForxxx functions Every function call returns a status code for the function Check this status code before using the data returned by the function The scanner reports faults and other errors via messages The API library buffers these errors internally and reports their existence as an Extended Error The application must periodically call OC_GetExtendedError to determine if an extended error message exists The library buffers extended errors in a queue The queue can hold as many as 5 extended errors at one time If the queue is full when a new extended error is received from the scanner the oldest extended error is lost and ERR_OCOVERRUN is returned The host application must call OC_GetExtendedError periodically to remove existing extended errors from the buffer Extended Frrors cause the scanner to fault Once the scanner is faulted it is forced to Idle mode and cannot go to Scan mode until the Extended Errors are extracted via OC_GetExtendedError and the fault is cleared via OC_ClearFault For Windows NT use the OC_WaitForExtError function Publication 1747 UM002A US P June 2000 3 18 Developing Applications Determining Partition Sizes for Shared Memory typedef struct tagOCINIT WORD WORD WORD OCINIT OCINIT initinfo OCIOCFG iocfg int assuming application has Output ImageSize Input ImageSize HostRetentiveDataSize The host application initializes t
116. e system lib LIBS libcmt lib kernel32 1ib Final target Publication 1747 UM002A US P June 2000 2 8 Using the API sample exe sample obj APILIB L INK lt lt S LDEBUG S LFLAGS LIBS lt lt echo Finished clean del del del rebuild MAKI exe obj map f samplem mak clean MAKE f samplem mak Intermediate target rules COJ CC lt lt c S CDEBUG CFLAGS c lt lt Intermediate target dependancies sample obj sample c APIINC ocapi h samplem mak KKK KKK Tit KKK KKK Sample Windows NT MAKE file for Borland compilers The following sample file shows how to use a Borland MAKE file The bold headings indicate the statements you need to modify for your environment KKK KKK KKK KKK KKK KKK KKK KKK KKK KK KKK KA KKK KA KOKA KA KOKA K KA KOKA K KKK KKK KKK KKK le Makefile for Open Controller API Sample Abstract This file is used by the Borland MAKE utility to build the sample application Environment 1747 OCE Open Controller Microsoft Windows NT 4 0 Borland C Compiler c Copyright Allen Bradley KAKKKKAKKAKAK KA K KA KKK KKK KKK KK KA KOKA OK KA KA KOKA KKK KA K KA K KA KKK KA ko KA KKK KK Paths Note to Tools Modify the folloving paths to Publication 1747 UM002A US P June 2000 Using the API 2 9 correspond
117. e the error Publication 1747 UM002A US P June 2000 6 74 Library of Routines OC WaitForlolnt Blocks the calling thread until a module interrupt is received from the scanner or msTimeout milliseconds have elapsed Syntax int OC WaitForIlIoInt HANDLE handle DWORD msTimeout Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner msTimeout Specifies the number of milliseconds to wait Set to INFINITE to wait forever Description If a module interrupt has been received since the last OCMSG_IOINT message was retrieved with the OC_PollScanner function OC WaitForloInt returns SUCCESS immediately Return Value Name Value Description SUCCESS 0 a module interrupt was received ERR RESPONSE 10 msTimeout milliseconds elapsed without a module interrupt ERR OCACCESS 2 handle does not have access to scanner Considerations Publication 1747 UM002A US P June 2000 Supported in the Windows NT API library only Example HANDLE handle intrc MSGBUF mintMSG Wait for 10 seconds for a module interrupt rc OC_WaitForlolnt handle 10000 switch rc case SUCCESS got a module interrupt fetch the module interrupt message OC_PollScanner handle OCMSG_IOINT amp mintMSG handle the module interrupt break case ERR_OCRESPONSE timed out printf nTimed out waiting for mod
118. ead data past the end of the module file for the slot slotnum Must be a valid slot number offset Must be valid word number within module file len Number of words read from the module located at s1otnum on the scanner into the buffer mfile Description This function accesses an internal data file of the selected module I O scanning is blocked while this access takes place Return Value Name Value Description SUCCESS 0 file was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCPARAM 8 parameter contains invalid value ERR_OCRESPONSE 10 scanner did not respond to request ERR_OCSCANCFG 14 scanner has not been configured ERR_OCSLOT 12 slot number is invalid Considerations Supported in the DOS API library and the Windows NT API library Publication 1747 UM002A US P June 2000 Library of Routines 6 51 OC ReadOutputlmage Example HANDLE Handle WORD filedata 2 int retcode retcode OC ReadModuleFile Handle FILTYP M1 filedata 6 3 2 Reads words 3 and 4 from module in slot 6 OC ReadOutputImage reads the current output image from the scanner Syntax int OC_ReadOutput Image HANDLE handle WORD outimgcpy int slotnum WORD offset WORD len WORD imagebuf Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner outimgcpy If out imgcpy IS NULL OC ReadOutputlmage reads data directly from the outp
119. en Bradley kk ck Ck ck ck kk ck Ck ck KA KKK KA KKK KKK KA ck KA K KA KA K KA KKK KKK KKK KA KKK KKK KKK KKK KKK KKK KKK KKK Note The environment variable LIB must be set to the path to the Microsoft C library files For example set LIB D MSDEV LIB Publication 1747 UM002A US P June 2000 Using the API 2 1 Paths to Tools Note Modify the following paths to correspond to your environment CPATH D MSDEV Location of Microsoft tools CC CPATH bin cl compiler LINK CPATH bin link linker MAKE CPATH bin nmake make utility Path to API Library and Include file Note Modify the following paths to correspond to your environment APILIB api lib ocapi lib Path to Open Controller API library APIINC api include Path to Open Controller API include file Compiler Linker Debugging Options Define DEBUG for debugging lifdef DEBUG CDEBUG Zi Od DEBUG debug full debugtype cv lelse CDEBUG Ox DEBUG RELEASE lendif Compiler Options W3 Turn on warnings GB Optimize code for 80486 Pentium MT Use Multithreaded runtime lib CFLAGS W3 GB MT IS APIINC I CPATH include Linker Options FLAGS NODEFAULTLIB SUBSYSTEM CONSOL INCREMENTAL NO PDB NON td El Libraries libcmt Multithreaded C runtime kernel32 Bas
120. entification for a each module x x KAKKAKKAKKAKKKAKKKAKKKA KKK KKKAKKKAKKKAKKKKKKKAKKKAKKKKKKKKKKKKKJ typedef struct tagOCSLOTCFG BYTE mix mix code BYTE type type code BYTE InputSize number of inputs in bytes BYTE OutputSize number of outputs in bytes WORD M0Size size of MO file in words WORD M1Size size of Ml file in words WORD GSize size of G file in words WORD GData pointer to array of length GSize words char Name pointer to module name string OCSLOTCFG JAKKKKAKKKKKKAKKKAKKKA IK KR IR RRA IR IK I k k k ke ke Structure Name OCIOCFG Description x X Used by OC CreatelOConfiguration OC_GetIOConfiguration E and OC DownloadlIOConfiguration x Configuration information for a system 1 2 or 3 racks may be configured for up to 30 I O modules Slot 0 is reserved for the Open Controller KAKKAKKAKKAKKKAKKKAKKKA KKK K Kk KC KKAKKKAKKKKKKKAKKKAKKKKKKKKKKKKKJ typedef struct tagOCIOCFG BYTE Rack1Size number of slots in Rack 1 BYTE Rack2Size number of slots in Rack 2 BYTE Rack3Size number of slots in Rack 3 OCSLOTCFG SlotCfg OCMAXSLOT configuration for each slot OCIOCFG JAKKKKAKKAKKKAKKKAKKKA KKK KC KKK KKAKKKAKKKKKKKAKKKAKKKKKKKAKKKKKAK Structure Name FORCEDATA Description Passed to OC SetForces Configures input and output forces KAKKKKAKKKKKKAKKKAKKKA Kk KC Kk
121. eout occurred K define EERR_OCMODACCESS 0x50 Data error while accessing module eS define EERR_OCPINTSTUCK 0x51 Stuck PINT error define EERR OCMODMISSING 0x52 Module is missing el define EERR OCMODINNOSLOT 0x53 Module detected in unused slot KA define EERR OCMODMISMATCH 0x54 Module type does not match downloaded configuration ey define EERR_OCIOMISMATCH 0x55 Module I O mix does not match downloaded configuration define EERR_OCRACKMISMATCH 0x56 Rack type does not match downloaded configuration ti define EERR OCSPIOLOCKTOUT 0x57 Specialty I O module lock memory command timeout xg define EERR OCSPIOFAULT 0x58 Specialty I O module fault xf define EERR OCSPIOCMDTOUT 0x59 Specialty I O module command timeout define EERR OCMODINT 0x5A Module interrupt problem RA define EERR_OCGFILE 0x5B G file configuration error E define EERR_OCMFILE 0x5C MO M1 file configuration error 7 define EERR OCINVALIDINT 0x5D Unsupported interrupt service requested by module define EERR_OCIODRIVER Ox5E 1 0 driver error define EERR_OCMODULEMIN 0x60 0x60 0x8F Module specific errors see module doc define EERR_OCMODULEMAX 0x8F 0x60 0x8F Module specific errors see module doc define EERR OCINVALIDMINT 0x90 MINT occurred on disabled slot n define EERR OCINVALIDPINT 0x91 PINT occurred on disabled slot define EERR OCUNKMODERR 0x93 Unsupported module error K define EERR OCMODRESET 0
122. es between the 1747 OCF Open Controller and the 1746 I O PCI Interface Open Controller 1747 OCF Watchdog can reset the entire system 1746 1 0 PCI Interface 1746 PCIS Watchdog cannot reset entire system API function call OC GetResetCause returns reason scanner was reset No function call OC GetResetCause because the watchdog cannot reset the entire system Dual port memory not battery backed Jumper to enable battery backup for the dual port memory All references to Open Controller in the example IMPORTANT IMPORTANT code or header files apply to the 1746 I O PCI Interface Publication 1747 UM002A US P June 2000 1 2 Overview Interface API to the Scanner Publication 1747 UM002A US P June 2000 You must develop a software interface between your application and a scanner to control local I O and to control remote I O via the 1747 SN or 1747 SDN scanners Develop a software interface in one of the following methods Use the 1746 I O PCI Interface API to develop the interface between your application and the 1746 VO PCI Interface scanner Use the API for 1747 Open Controller to develop the interface between your application and the 1747 Open Controller In either application type 1746 I O PCI Interface or 1747 Open Controller the API provides calls for typical control functions such as configuring I O files initializing the scanner accessing the user LEDs user jumper
123. f SUCCESS rc OC GetSwitchPosition OChandle amp swpos printf NnERROR OC GetSwitchPosition failed d n rc Ioexit 1 printf AnSwitch position switch swpos case SWITCH TOP printf Top break case SWITCH_BOTTOM printf Bottom break case SWITCH MIDDLE printf Middle break Read temperature if SUCCESS rc OC GetTemperature OChandle amp temp Publication 1747 UM002A US P June 2000 Developing Applications 3 15 printf InERROR OC GetTemperature failed d n rc Toexit 1 printf AnTemperature dC temp Read auto config if SUCCESS rc OC_GetIOConfiguration OChandle 0Ccfg printf NnERROR OC GetIOConfiguration failed d n rc Ioexit 1 Display rack configuration slots OCcfg RacklSize OCcfg Rack2Size OCcfg Rack3Size it slots gt 31 slots 31 printf AninRack configuration for i 1 i lt slots 1 if OCcfg SlotCfg i type Oxff printf nSlot 2d Type 2d Mix 3d s i OCcfg SlotCfg il type OCcfg SlotCfg i mix OCcfg SlotCfg i Name else printf nSlot 2d s i OCcfg SlotCfg i Name check for BAS modules class 1 or 4 if OCcfg SlotCfg i mix 35 OCcfg SlotCfg i mix 131 ss OCcfg SlotCfg i type 6 if OCcfg SlotCfg i mix 35 if Class 1 BAS module
124. guration or OC GetIOConfiguration vere called previously to fill in iocfg structure retcode OC_DownloadIOConfiquration Handle amp iocfg OC EnableEOSNotify controls whether end of scan notification messages are generated by the scanner Syntax int OC EnableEOSNotify HANDLE handle int mode Parameters Library of Routines 6 11 Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode Is EOSMSG ENABLE the scanner generates an end of scan message after each scan Use the OC PollScanner function to retrieve end of scan messages EOSMSG DISABLE the scanner does not generate End of scan messages End of scan messages are disabled after the scanner has been reset Description There are three types of end of scan messages This type of message Is generated after OCMSG_EOS_DMDIN a OC_DemandInputScan command has completed OCMSG_EOS_DMDOUT a OC_DemandOutputScan command has completed OCMSG_EOS each timed 170 scan End of scan messages are generated from the scanner to the API via interrupts after each scan The scan rate is controlled by the OC_SetScanTime function and end of scan interrupts are generated at the scan rate Enabling end of scan messages can affect the performance of the application due to the overhead incurred in processing these interrupts An alternative method to
125. handle returned from OC OpenScanner msTimeout Specifies the number of milliseconds to wait Set to INFINITE to wait forever Description If a DIT has been received since the last OCMSG_DIINT message was retrieved with the OC PollScanner function OC_WaitForDII returns SUCCESS immediately Return Value Name Value Description SUCCESS 0 a DII was received ERR_RESPONSE 10 msTimeout Milliseconds elapsed without a DII ERR_OCACCESS 2 handle does not have access to scanner Considerations Publication 1747 UM002A US P June 2000 Supported in the Windows NT API library only Example HANDLE handle intro MSGBUF diiMSG Wait for 10 seconds for a DII rc OC WaitForDII handle 10000 switch rc case SUCCESS got a DII fetch the DII message OC PollScanner handle OCMSG DIINT amp diiMSG break case ERR OCRESPONSE timed out printf nTimed out waiting for DII n break default printf MAnError Nn break Library of Routines 6 69 OC WaitForEos Blocks the calling thread until an end of scan EOS notification is received from the scanner or msTimeout milliseconds have elapsed Syntax int OC_WaitForEos HANDLE handle DWORD msTimeout Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner msTimeout Specifies the number of milliseconds to vvait Set to INFINITE to vv
126. he scanner by providing partitioning information which contains the size of memory to be reserved in the shared memory for the input and output images The size of memory to be reserved for each of the images must be greater than or equal to the number of input and output words required by each module The host application can t communicate with the scanner until it has been initialized The partitioning information is passed to OC InitScanner in the OCINIT structure which is defined as size in bytes size in bytes size in bytes To determine the input and output image sizes call OC CreatelOConfiguration with a configuration that contains the I O modules to be installed OC CreatelOConfiguration returns the number of bytes of I O required by each module Or you can use OC GetIOConfig to use the current configuration if one exists The input and output sizes are based on the number of words of I O required by each module As an estimate take the total number of input and output words for all the modules in the system and multiply by two to get the number of required bytes The following code fragment calculates the number of bytes required by the input and output images i numslots filled iocfg with I O configuration OC CreatelOConfiguration amp iocfg numslots if numslots 31 nums initinfo OutputImageSize for i l i lt numslots iocfg RacklSize t i iocfg Rack2Size iocfg Rack3Siz
127. hese values are passed to the OC EnableSlot function i xy define SLOT ENABLE 0 Enable module define SLOT DISABLE 1 Disable module ES KKKKA LED States KKKKA These values are passed to the OC SetUserLEDState function and are returned by the OC GetUserLEDState function define LED_OFF 0 LED is off define LED_RED_SOLID 1 LED is Red continuous define LED_GREEN_SOLID 2 LED is Green continuous define LED_RED_FLASH 3 LED is flashing Red 1 amp 2 only define LED_GREEN_FLASH 4 LED is flashing Green 1 amp 2 only Battery Status These values are returned by the OC GetBatteryStatus function EJ Paul a define BATTERY_LOW 0 Battery voltage is low A define BATTERY GOOD 1 Battery is OK f N A xy Ky ky f Publication 1747 UM002A US P June 2000 C 4 Header File f Switch Position These values are returned by the OC_GetSwitchPosition function ay T E tdefine SNITCH TOP OxFF Switch is in the Top position define SWITCH_MIDDLE 0x00 Switch is in the Middle position define SWITCH_BOTTOM 0x01 Switch is in the Bottom position KKK Jumper State KKKKK These values are returned by the OC_GetUserJumperState function ay p s E define JUMPER PRESENT 0 User jumper is installed K define JUMPER ABSENT 1 User jumper is not installed x Watchdog Settings
128. ifies the number of milliseconds to wait Set to INFINITE to wait forever Description If a demand input EOS message has been received since the last OCMSG_EOS_DMDIN message was retrieved with the OC PollScanner function OC_WaitForEosDmdIn returns SUCCESS immediately You can use this function to synchronize a control application with the I O scan See the OC EnableEOSNotify and OC DemandinputScan functions Return Value Name Value Description SUCCESS 0 demand input EOS message was received ERR_RESPONSE 10 msTimeout milliseconds elapsed without an EOS ERR_OCACCESS 2 handle does not have access to scanner Considerations Publication 1747 UM002A US P June 2000 Supported in the Windows NT API library only Example HANDLE handle intrc MSGBUF eosMSG Request an input scan but don t wait OC_DemandInputScan handle OCNOWAIT Could have other code here Library of Routines 6 71 OC WaitForEosDmdOut Wait 1 second for the EOS rc OC_WaitForEosDmdIn handle 1000 switch rc case SUCCESS got EOS reset the EOS_DMDIN event OC PollScanner handle OCMSG_EOS_DMDIN amp eosMSG do logic etc synchronized with the 1 0 scan break case ERR_OCRESPONSE timed out printf nTimed out waiting for EOS n break default printf nError n break Blocks the calling thread until a demand output end of scan
129. ight order Other Comments Use back for more comments Your Name Location Phone Return to Marketing Communications Allen Bradley Co 1 Allen Bradley Drive Mayfield Hts OH 44124 6118Phone 440 646 3176 FAX 440 646 4320 Publication ICCG 5 21 August1995 PN955107 82 PLEASE FASTEN HERE DO NOT STAPLE Other Comments PLEASE FOLD HERE BUSINESS REPLY MAIL FIRST CLASS MAIL PERMIT NO 18235 CLEVELAND OH POSTAGE VVILL BE PAID BY THE ADDRESSEE ON Rockwell Automation Allen Bradley 1 ALLEN BRADLEY DR MAYFIELD HEIGHTS OH 44124 9705 NO POSTAGE NECESSARY IF MAILED IN THE UNITED STATES PLEASE REMOVE Reach us now at www rockwellautomation com Wherever you need us Rockwell Automation brings together leading brands in industrial automation including Allen Bradley controls Reliance Electric power transmission products Dodge mechanical power transmission components and Rockwell Software Rockwell Automation s unique flexible approach to helping customers achieve a competitive advantage is supported by thousands of authorized partners distributors and system integrators around the world Allen Bradley PEAME DOGE Americas Headquarters 1201 South Second Street Milwaukee WI 53204 USA Tel 1 414 382 2000 Fax 1 414 382 4444 beu Ro ckuvell European Headquarters SAJNV avenue Herrmann Debroux 46 1160 Brussels Belgiu
130. in bytes WORD InputImageSize size in bytes WORD HostRetentiveDataSize size in bytes OCINIT Return Value Name Value Description SUCCESS 0 scanner initialization information was retrieved successfully ERR OCACCESS 2 handle does not have access to the scanner ERR OCINIT 5 scanner has not been initialized see OC InitScanner ERR OCPOST 7 scanner POST failed see OC GetScannerStatus Publication 1747 UM002A US P June 2000 Considerations Supported in the DOS API library and the Windows NT API library Library of Routines 6 27 OC_GetScannerStatus Example HANDLE Handle OCINIT scaninit int retcode retcode OC GetScannerInitInfo Handle amp scaninit if retcode SUCCESS printf Input Image Size d bytes An scaninit InputImageSize printf Output Image Size d bytes Wn scaninit OutputImageSize printf Host Retentive Data Size d bytes Wn Scaninit HostRetentiveDataSize else handle error OC GetScannerStatus reads the current status of the scanner Syntax BYTE int OC_GetScannerStatus HANDLE handle scansts Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner scansts Status of the scanner Publication 1747 UM002A US P June 2000 6 28 Library of Routines Description If OC GetScannersStatus returns SUCCESS scansts has
131. ine EERR OCMODINNOSLOT 0x53 Module detected in unused slot define EERR OCMODMISMATCH 0x54 Module type does not match downloaded configuration i define EERR OCIOMISMATCH 0x55 Module I O mix does not match downloaded configuration define EERR OCRACKMISMATCH 0x56 Rack type does not match downloaded configuration i define EERR_OCSPIOLOCKTOUT 0x57 Specialty 1 0 module lock memory command timeout define EERR_OCSPIOFAULT 0x58 Specialty I O module fault kj define EERR OCSPIOCMDTOUT 0x59 Specialty I O module command timeout El define EERR_OCMODINT Ox5A Module interrupt problem define EERR OCGFILE Ox5B G file configuration error LA define EERR OCMFILE 0x5C MO M1 file configuration error define EERR_OCINVALIDINT 0x5D Unsupported interrupt service requested by module i define EERR OCIODRIVER Ox5E 1 0 driver error define EERR_OCMODULEMIN 0x60 0x60 0x8F Module specific errors see module doc ES define EERR_OCMODULEMAX 0x8F 0x60 0x8F Module specific errors see module doc KA define EERR OCINVALIDMINT 0x90 MINT occurred on disabled slot 7 define EERR OCINVALIDPINT 0x91 PINT occurred on disabled slot define EERR OCUNKMODERR 0x93 Unsupported module error define EERR OCMODRESET 0x94 Module has been inserted or reset E define EERR_OCSCANNERINT OxFO Scanner internal error Es E Scanner Status wee These values are returned by the OC Get
132. initial state of outputs Once the output image is written with the initial state data the output update mode can be changed to allow updating of the outputs Publication 1747 UM002A US P June 2000 6 62 Library of Routines Setting the output update mode to OUTUPD CHANGE allows the host application to signal the scanner to write outputs by calling OC_WriteOutputImage This setting allows the scanner s minimum scan time to be reduced since it is only scanning inputs most of the time and is provided as a performance enhancement Setting the output update mode to OUTUPD_ALWAYS forces the scanner to write outputs from the output image on every scan Return Value Value Description SUCCESS 0 conditional scan was set successfully ERR_OCACCESS handle does not have access to the scanner ERR_OCINIT ERR_OCPARAM 2 5 scanner has not been initialized see OC InitScanner 8 parameter contains invalid value Publication 1747 UM002A US P June 2000 Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC SetOutputUpdateMode Handle OUTUPD NEVER Must use OC DemandOutputScan function to send new output data Library of Routines 6 63 0C SetScanMode OC SetScanMode changes the scan mode of the scanner Syntax int OC_SetScanMo
133. ions printf Anin Switch position switch swpos case SWITCH_TOP printf Top Mn break case SWITCH BOTTOM printf Bottom Mn break case SWITCH MIDDLE printf Middle Mn break delay 3000 xx Read auto config xy retcode OC GetlIOConfiguration Handle amp OCcfg if retcode SUCCESS printf AnERROR OC_GetIOConfiguration failed d n retcode Ioexit 1 Display rack configuration El slots OCcfg Rack1Size OCcfg Rack2Size OCcfg Rack3Size if C slots 31 slots 31 printf Anin Chassis configuration for i l i lt slots i if OCcfg SlotCfg i type Oxff printf An Slot 2d Type 2d Mix 3d s i OCcfg SlotCfg i type OCcfg SlotCfg i mix OCcfg SlotCfg i Name else printf An Slot 2d s i OCcfg SlotCfg i Name Find digital input card if OCcfg SlotCfg i mix lt 8 amp amp linput found input found 1 input slot i Find digital output card i if OCcfg SlotCfg i mix gt 7 amp amp OCcfg SlotCfg i mix lt 32 amp amp output_found output found 1 output slot i delay 3000 Publication 1747 UM002A US P June 2000 Developing Applications 3 9 Download the configuration to the scanner E retcode OC DownloadlIOConfiguration Handle amp OCcfg Configure if retcode SU
134. losed successfully ERR_OCACCESS 2 handle does not have access to the scanner Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC CloseScanner Handle Publication 1747 UM002A US P June 2000 6 4 Library of Routines OC_ConfigureDII OC_ConfigureDIT allows an application to receive a message from the scanner when an input bit pattern of a discrete I O module matches a compare value Syntax int OC ConfigureDII HANDLE handle DII CFG diicfg Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner diicfg Points to the DII configuration Description The application configures the compare value using this function and when the comparison completes the scanner generates a message to the application The application must then call OC PollScanner to retrieve the message The DII CFG structure is defined as typedef struct BYTE SlotNum slot number 1 30 BYTE IOIncludeMask bits allowed mask BYTE IOEdgeType bit pattern to compare WORD PresetCount number of matches DII CFG This value Means Slotnum Must contain the slot number of a Class 0 Discrete Input module An 1 0 error report is generated if the scanner determines the slot does not contain a valid discrete input module IOlncludeMask
135. lue e s Public The program is terminated x x x x x x x x x K Notes x x void Ioexit int rc OCEXTER char m if OC G KAKKAKKKKKKKKKKKKAKKKAKKKAKKKAKKKAKAKAKAKAKAKAKAKAKKKKKKKKKKKKKKKKKKKKKKKJ R exterr sg etExtendedError OChandle amp exterr SUCCESS exterr ErrorCode 0 OC ExtendedErrorMsg OChandle amp exterr amp msg printf n nERROR d s n msg exterr ErrorCode OC CloseScanner OChandle exit rc end Ioe i xit RR KR KK KK KK A A A A A A A I AAA Entry Descri Argume none Extern none Return none Access point tError ption nts al effects value Public Event Thread to handle errors Notes void tError while 1 loex Event void dummy KAKKAKKKKKKKKKKKKAKKKKKKKAKKKKKKKAKAKAKAKAKAKAKAKAKKKKKKKKKKKKKKKKKKKKKKJ Sleep until the scanner reports an error OC_WaitFor An error has occurred that is necessary and Ext Error OChandle In this case 7 it 1 end t nr rorEvent Publication 1747 UM002A US P June 2000 xit the process E INFINITE Perform whatever error handling we just print a message Developing Applications 3 13 JKAKKKKKKKKKKKKKKAKAKAKKKAKKKAKKKAKAKAKAKAKAKAKAKAKKKKKKKKKKKKKKKKKKKKKKKK x
136. m Tel 32 2 663 06 00 Fax 32 2 663 06 40 Asia Pacific Headquarters 27 F Citicorp Centre 18 Whitfield Road Causeway Bay Hong Kong Tel 852 2887 4788 Fax 852 2508 1846 Automation Publication 1747 UM002A US P June 2000 PN 957259 85 Supersedes Publication 1747 6 5 3 June 1998 O 2000 Rockwell International Corporation Printed in the U S A
137. mming sequence 3 4 Scanner Modes 1 6 Faulted 1 6 Idle 1 6 Non recoverable fault 1 6 Performing POST 1 6 Scan 1 6 Waiting for host initialization 1 6 Shared Memory Determining partition sizes 3 18 Software Interface Developing API software for DOS 1 2 Developing API software for NT 1 3 Developing interface 1 2 Status LED indicators 1 7 Structures API 4 1 Support P 3 Supported 1 0 Modules 5 4 Publication 1747 UM002A US P June 2000 4 Index T U Telephone Support P 3 Using MO MT and G Files 5 3 Terminology P 1 Testing Function Galls B 1 W Tools 2 4 Troubleshooting Waiting for Host Initialization 1 6 LED indicators 1 7 Publication 1747 UMOO2A US P June 2000 Allen Bradley uy Publication Problem Report If you find a problem with our documentation please complete and return this form Pub Name API Software for 1746 1 0 PCI Interface and 1747 0C Open Controller User Manual Cat No 1747 PCIS OCF Pub No 1747 UMO02A US P Pub Date June 2000 Part No 997259 85 Check Problem s Type Describe Problem s Internal Use Only I Technical Accuracy J text _ illustration _ Completeness _ procedure step _ illustration _ definition L info in manual What information is missing example _ guideline _ feature accessibility _ explanation _ other info not in manual Clarity What is unclear Sequence What is not in the r
138. n attributes of the 1747 OCF and 1746 PCIS 1 5 Open Controller 1 4 Borland Compilers Sample DOS MAKE file 2 4 Sample NT MAKE file 2 8 C Common attributes of the 1747 OCF and 1746 PCIS 1 5 Configure the Scanner During the programming sequence 3 3 Configuring 1 0 5 1 Control Scanner Operation During the programming sequence 3 4 D Determining Partition Sizes for Shared Memory 3 18 Documentation Additional Open Controller publications P 2 Reference material P 1 DOS Header File C 1 DOS Programming Considerations 2 2 DOS Programming Example 3 5 Index E Error Codes Extended A 2 Errors 3 17 Errors Codes Returned by API functions A 1 Extended Error Codes A 2 F Faulted 1 6 Function Calls Testing B 1 G G Files Using 5 3 Getting Started 2 1 H Handling Errors 3 17 Handling Interrupt Messages 3 17 Header File DOS C 1 NT C 10 1 0 Configuring 5 1 Supported modules 5 4 Idle 1 6 Initialize the Scanner During the programming sequence 3 2 Installing the DOS API 1 8 Installing the NT API 1 8 Interfacing API to the Scanner 1 2 API software for DOS 1 2 API software for NT 1 3 Interrupt Messages 3 17 L LED Indicators 1 7 Library of Routines 6 1 Publication 1747 UM002A US P June 2000 2 Index MO M1 Files Using 5 3 Microsoft Compilers Sample DOS MAKE file 2 5 Sample NT MAKE file 2 6 N Non Recoverable Fault 1 6 NT Header File G 10 NT Programming Considerations 2 3 NT Programming Example 3
139. n is invalid 7 define ERR OCRESPONSE 10 scanner did not respond to request successfully define ERR OCEXTERR LE scanner responded with an extended error message Publication 1747 UM002A US P June 2000 C 2 Header File define ERR OCSLOT 2 slot number is invalid E define ERR_OCFAULT 3 request denied because scanner faulted E define ERR_OCSCANCFG 4 Scanner IO Configuration not downloaded ey define ERR_OCNOFORCES 5 no forces installed cannot enable forces Le define ERR_OCOVERRUN 6 DII 1 0 Int or ErrReport message overrun Ef define ERR_OCOUTOFMEM 7 memory allocate failed ES define ERR_OCUNKNOWN 8 unknown module type FA define ERR OCFILERROR 9 error occured while reading writing disk file YA define ERR_OCNOTSUPP 20 function not supported on this platform f Extended Error Codes These values are returned in the ErrorCode member of the OCEXTERR i structure that is returned from the OC GetExtendedError function 4 LE E define EERR_OCINVALIDDIR Ox01 Downloaded directory file is invalid define EERR OCINTSWERR 0x08 Internal scanner software error EN define EERR_OCCFGCORRUPT Ox12 Downloaded configuration is corrupted v define EERR_OCEXPPWRFAIL Ox21 Power fail on expansion rack detected define EERR_OCINVALIDDII Ox2E Invalid DII input slot tj define EERR_OCWDTIMEOUT 0x40 Host Watchdog Tim
140. n rack occurred Ox2E Invalid DII input slot 0x40 Host Watchdog Timeout 0x50 Data error while accessing module 0x51 Stuck PINT error 0x52 Module is missing 0x53 Module detected in unused slot 0x54 Module type does not match downloaded configuration 0x55 Module 170 mix does not match downloaded configuration Ox56 Rack type does not match downloaded configuration 0x57 Specialty I O module lock memory command timeout 0x58 Specialty I O module fault 0x59 Specialty I O module command timeout Ox5A Module interrupt problem 0x5B G file configuration error 0x5C MO0 MI file configuration error 0x5D Unsupported interrupt service requested by module Ox5E 1 0 driver error Extended Error Code Error Codes A 3 Description 0x60 Ox8F Module specific errors see 1 0 module documentation 0x90 MINT occurred on disabled slot 0x91 PINT occurred on disabled slot 0x93 Unsupported module error 0x94 Module has been inserted or reset OxFO Internal scanner error The error code data provides information specific to the cause of all extended errors except OxFO The first byte of the error code data contains a subsystem identifier with the following information Subsystem ID 0x06 Description Scanner Communications 0x08 Backplane Interface module 1 0 The second byte of the error code data provides details about the subsystem identifier with the following information Error Code
141. nction returns valid version information The OCVERSIONINFO structure is defined as typedef struct tagOCVERSIONINFO WORD APISeries API series WORD APIRevision API revision WORD ScannerFirmwareSeries Scanner firmware series WORD ScannerFirmwareRevision Scanner firmware revision WORD OCHardwareSeries Hardware series Library of Routines 6 39 OC InitScanner WORD OCHardwareRevision Hardware revision OCVERSIONINFO The Windows NT version uses the above structure with these additional members WORD OCDriverSeries Device driver series WORD OCDriverRevision Device driver series revision Return Value Name Value Description SUCCESS 0 version information was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle OCVERSIONINFO verinfo int retcode retcode OC GetVersionInfo Handle amp verinfo This function initializes the shared memory interface between the host and scanner and this function configures the shared memory partitioning Syntax int OC InitScanner HANDLE handle OCINIT scaninit Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner scaninit Points to the
142. nd interrupt assignment The base memory address jumper must be positioned to choose 32 bit addressing The API and device driver must be installed on the system Place the base memory select jumper in 32 bit position to allow the PCI BIOS to assign a base memory address anywhere in 32 bit memory for protected mode applications WinNT NT device drivers 1747 PCINT use the PCI BIOS or OS services to determine the memory window base address and provide access to the dual port memory e To determine the allocated memory base address and interrupt run the Windows NT diagnostic found in Administrative Tools NT interrupts An interrupt is automatically assigned to the scanner by the PCI bus at power up e To determine the allocated memory base address and interrupt run the Windows NT diagnostic found in Administrative Tools A group of thread blocking functions are provided to aid multi threaded application development The functions are e OC_WaitForDIT e OC_WaitForEos e OC_WaitForEosDmdOut e OC_WaitForloInt e OC WaitForDmdIn e OC WaitForExtError For more information see chapter 6 Publication 1747 UM002A US P June 2000 2 4 Using the API Tools to Use The API functions support both Microsoft and Borland C compilers The API disk includes sample MAKE files for each compiler When you use the DOS API and link to ocapil lib use the appropriate command line switch to select the large memory model For more information
143. nfigFile Description If G file data is included in the configuration file OC ReadlIOConfigFile allocates memory for the data and initializes the G data values to point to the allocated memory The host application should release the allocated memory via the free function when it is no longer needed Return Value Name Value Description SUCCESS 0 1 0 configuration file was read successfully ERR OCFILERROR 19 error encountered while opening or reading the file Considerations Supported in the DOS API library and the Windows NT API library Example OCIOCFG iocfg int retcode DOS file named RACK1 CFG is storing the rack configuration info retcode OC ReadIOConfigFile amp iocfg RACK1 CFG Use OC DownloadlIOConfiguration to download the information Publication 1747 UM002A US P June 2000 6 50 Library of Routines 0C ReadModuleFile OC_ReadModuleFile reads a data file from a module Syntax int OC_ReadModuleFile HANDLE handle BYTE ftype WORD mfile int slotnum WORD offset WORD len Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner ftype Defines the module type as FILTYP_MO MO file FILTYP_M1 M1 file FILTYP_G G file mfile Buffer file that contains data read from the module at slotnum The data in m ile is read from the module starting at word offset This function does not r
144. odules not included in the internal database of modules the host application can initialize the mix type InputSize OutputSize MOSize M1Size and GSize before downloading the I O configuration to the scanner See the I O module s user manual to determine the proper configuration information After the OC_CreatelOConfiguration and OCGetIOConfiguration functions return the I O configuration structure must be checked for installed modules with G files If the Gsize field of a non empty slot configuration is not zero then the module contains a G file If the module contains a G file initialize GData to point to an array of Gsize words to be loaded into the module during scanner configuration See the I O module s user manual to determine the proper G file data Using MO M1 Files and G Files Configuring VO Modules 5 3 The 1746 1 O PCI Interface uses MO M1 files and G files to download configuration information to specialty I O modules The following descriptions describe the basics of MO M1 and G files For detailed information see the user manual for the specialty I O module you are configuring MO MI1 files MO and Mi files are data files that reside in specialty 1 0 modules only There is no image for these files in the dual port memory like the discrete input and output image files The application of these files depends on the function of the particular specialty 1 0 module Your application program initiates the transfer of the
145. of G file in words WORD GData pointer to array of length GSize words char Name pointer to module name string OCSLOTCFG OCVERSIONINFO typedef struct tagOCVERSIONINFO Returned by OC GetVersionInfo Software WORD APlSeries API series and hardware version WORD APlRevision API revision numbers WORD ScannerFirmwareSeries Scanner firmware series WORD ScannerFirmwareRevision Scanner firmware revision WORD OCHardwareSeries Hardware series WORD OCHardwareRevision Hardware revision WORD OCdriverSeries OCdriver series Windows NT only WORD OCdriverRevision Ocdriver reviwion Windows NT only OCVERSIONINFO STSFILE typedef struct tagSTSFILE Scanner status file WORD wWordNum OCSTSFILEWSIZE STSFILE Publication 1747 UM002A US P June 2000 Introduction Configuring 1 0 struct BYTI or 13 BYTI or 13 BY or 13 OCIOCFG E Chapter 5 Configuring 1 0 Modules This chapter explains how to configure the I O modules for your 1746 I O PCI Interface system You can either use the autoconfigure OC GetlOConfiguration function or build your own configuration OC CreatelOConfiguration A separate I O configuration utility is available for the PCI SLC I O bus interface to simplify this process The utility is on the 1746 I O PCI Interface utilities disk that ships with the 1746 I O PCI Interface 1747 PCIS 2D The
146. oints to unknown error code string Considerations Supported in the DOS API library and the Windows NT APT library Example HANDLE Handle char msg int tc if SUCCESS rc OC OpenScanner amp Handle Open failed display error message OCErrorMsg rc amp msg printf Error s n msg 0C_ExtendedErrorMsg OC_ExtendedErrorMsg returns a descriptive text message associated with an extended error Syntax int OC_ExtendedErrorMsg HANDLE handle OCEXTERR exterr char msg Parameters Parameter Description andle ust be a valid handle returned from OC_OpenScanner exterr Points to an extended error msg Points to a static buffer that contains a null terminated message string for the associated extended error Publication 1747 UM002A US P June 2000 6 16 Library of Routines Description This function is useful when displaying an error message You should use OC_GetExtendedError to obtain the message before using OC_ExtendedErrorMsg to display the message If you don t use OC_GetExtendedError first OC_ExtendedErrorMsg displays a null message The OCEXTERR structure is defined as define OCERRDATASIZE3 number of bytes of error data typedef struct tagOCEXTERR BYTEErrorCode Extended error code ES BYTESlotNum Associated slot number BYTEErrorData OCERRDATASIZE Error code data
147. ollScanner handle OCMSG_EOS_DMDOUT amp eosMSG do logic etc sychronized with the 1 0 scan break case ERR_OCRESPONSE timed out printf nTimed out waiting for EOS n break default printf nError n break Library of Routines 6 23 OC WaitForExtError Blocks the calling thread until an extended error is received from the scanner or msTimeout milliseconds have elapsed Syntax int OC_WaitForExtError HANDLE handle DWORD msTimeout Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner msTimeout Specifies the number of milliseconds to vvait Set to INFINITE to vvait forever Description If an extended error has been received since the last extended error message was retrieved with the OC GetExtendedError function OC_WaitForExtError returns SUCCESS immediately Return Value Name Value Description SUCCESS 0 an extended error occurred ERR_RESPONSE 10 msTimeout Milliseconds elapsed without an extended error ERR_OCACCESS 2 handle does not have access to scanner Considerations Supported in the Windows NT API library only Example HANDLE handle intrc OCEXTERR exterr Error handler thread while 1 loop forever OC_WaitForExtError handle INFINITE fetch the error data OC_GetExtendedError handle amp exterr handl
148. ompatible with both Microsoft and Borland compilers The DOS library ocapil 1ib is compiled as a 16 bit MS DOS library using the 80386 instruction set The Windows NT library ocapi d11 is compiled for use with Microsoft Visual C or Borland C DOS Considerations The DOS APT is as consistent as possible with APIs for other operating system platforms This makes it easier for you to migrate applications and it simplifies support To create a consistent API careful consideration was given to these requirements Considerations The dual port RAM or shared memory is mapped automatically at power up by the PCI bus in the host processor s memory address space on any even 8K boundary between 0xC0000 and OxDFFFF For MS DOS it is important that any installed memory managers such as EMM386 or other TSR software avoid accessing the 8K dual port memory window Place the base memory select jumper in 1M position to allow the PCI BIOS to assign a base memory address DOS interrupts An interrupt is automatically assigned to the scanner by the PCI bus at power up control break handler Publication 1747 UM002A US P June 2000 Because communication with the scanner requires memory and interrupt resources as described above improper termination of the host application can leave these resources allocated by the scanner and unusable by other applications For this reason the API includes a default control break handler Th
149. one of the segment addresses in Table 2 Otherwise the scanner cannot be opened Publication 1747 UM002A US P June 2000 6 42 Library of Routines The shared memory segment address must be set to an address that does not conflict with other hardware and software The recommended segment address is 0xC800 You can use any of the following shared segment addresses listed in hex e C000 D000 e C200 D200 e C400 D400 e C600 D600 e C800 D800 e CAOO DAO0 e CC00 DCOO e CE00 DEOO irqnum defines the ISA bus interrupt number assigned to the scanner irqnum must be set to one of the values listed in the table below or the scanner cannot be opened The MS DOS API library communicates with the scanner via interrupts and installs an interrupt service routine for the interrupt The application must not service these interrupts The IRQ assignment must be set to an interrupt that does not conflict with other hardware and software The recommended interrupt assignment is IRQ11 irqnum IRO assignment 10 IRQ10 11 IRO11 12 IRO12 14 IRQ14 15 IRQ15 Return Value Name Value Description SUCCESS 0 scanner was opened successfully ERR OCOPEN 1 scanner is already open ERR OCPARAM 2 invalid value in segaddr or irgnum ERR OCMEM 3 shared memory not found Publication 1747 UM002A US P June 2000 Library of Routines 6 43 0C_PetHostWatchdog Considerations
150. rameters Parameter Description handle Must be a valid handle returned from OC OpenScanner buf Contains the data that is read offset The data is read offset bytes from the beginning of the data partition If the number of bytes from offset to the end of the partition is smaller than Len no bytes will be read and ERR OCPARAM is returned len Defines how many bytes to read Description Publication 1747 UM002A US P June 2000 Data is not read past the end of the host retentive data partition It is recommended that you verify the integrity of the data stored in the host retentive data partition You can use the OC CalculateCRC function to generate a 16 bit CRC On the 1747 PCIS only the jumper for the IMPORTANT IMPORTANT battery backup dual port memory is disabled by default You must switch the jumper to enable the battery backup feature The 1747 OCF dual port is NOT battery backed Library of Routines 6 47 Return Value Name Value Description SUCCESS 0 host retentive data was written successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner ERR_OCPARAM 8 parameter contains invalid value Considerations OC Readinputimage Supported in the DOS API library and the Windows NT API library Example HANDLE BYTE int retcode Handle retent data 500 retcode OC ReadHostRetentiveData 0 5
151. ries from system to system You might need to experiment to determine the typical value for a particular system Data is copied to the host retentive data partition at the rate of approximately 1K bytes per millisecond Declare bufptr as static if the OC_SetupPowerFail function is used other than in main otherwise random data will be sent to the host retentive data area Return Value Name Value Description SUCCESS 0 power fail action was registered successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC_InitScanner ERR_OCPARAM 8 parameter contains invalid value Considerations Supported in the DOS API library only Example This example is for DOS only HANDLE Handle BYTE buffer1 100 BYTE buffer2 100 int retcode void PowerFailSave void power fail callback routine len 100 OC_WriteRtcSRAM buffer2 0 amp len Put data in protected area retcode OC SetupPoverFailAction Handle bufferi 0 100 PowerFailSave Publication 1747 UM002A US P June 2000 6 68 Library of Routines OC WaitForDII Blocks the calling thread until a DII interrupt is received from the scanner or msTimeout milliseconds have elapsed Syntax int OC NaitForDII HANDLE handle DWORD msTimeout Parameters Parameter Description handle Must be a valid
152. ry and the Windows NT API library Example HANDLE Handle int retcode retcode OC DemandInputScan Handle OCWAIT 0C DemandOutputScan OC_DemandOutputScan forces the scanner to immediately perform a an output scan Syntax int OC DemandOutputScan HANDLE handle int mode Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner mode If mode IS OCWAIT 0C_DemandOutputScan waits for the output scan to be completed before returning to the caller OCNOWAIT OC_DemandOutputScan returns immediately Description The scanner updates module outputs from the data in the output image Use OC_WriteOutputlmage to write data to the output image Publication 1747 UM002A US P June 2000 Library of Routines 6 9 OC DownloadlO Return Value Name Value Description SUCCESS 0 demand output request was successful ERR_OCACCESS 2 handle does not have access to scanner ERR OCRESPONSE 10 scanner did not respond to request ERR OCSCANCFG 14 scanner has not been configured Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle int retcode retcode OC DemandOutputScan Handle OCWAIT OC DownloadIOConfiguration downloads an I O configuration to the scanner Configuration Syntax int OC DownloadlIOConfiguration HANDLE handle OCIOCFG iocfg Parameters Parameter
153. s El WORD Controllo PCIS Control registers 1 0 address DWORD SRAM_Size Size of SRAM in bytes OCDEVICEINFO return packing alignment to command line option tifdef _BORLANDC_ pragma option a endif _BORLANDC 4 tifdef _MSC_VER pragma pack tendif _MSC_VER 7 Define a convenient macro for library function declarations fif defined DLLEXPORT tif defined cplusplus define DLLENTRY extern C declspec dllimport telse define DLLENTRY declspec dllimport tendif telse _DLLEXPORT_ 7 tif defined __cplusplus define DLLENTRY extern telse define DLLENTRY __declspec dllexport tendif tendif _DLLEXPORT_ 4 Define api calling convention 4 __stdcall define OCAPI JAKKKAKKKAKKKKAKKAKKKAKKKA KKK ke kk ko ke kk KG ke e KE FUNCTION PROTOTYPES EN E AN DLLENTRY DLLENTRY DLLENTRY DLLENTRY DLLENTRY DLLENTRY int int int int int int OCAPI OCAPI OCAPI OCAPI OCAPI OCAPI OC_OpenScanner HANDLE OC_CloseScanner HANDLE C declspec dllexport OC InitScanner HANDLE OCINIT OC GetScannerInitInfo HANDLE OCINIT OC ResetScanner HANDLE int OC GetScannerStatus HANDLE BYTE Publication 1747 UM002A US P June 2000 C 18 Header File LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLENTRY LLEN
154. s reserved for the 1746 1 0 PCI Interface Bit 4 15 is unused When a bit is set default condition it allows the 1 0 module in the referenced slot to be updated in the 170 scan When a bit is cleared the corresponding 170 module will no longer be included in the 1 0 Scan Changes to the 170 slot enable bits will take affect at the end of the next 1 0 scan 5 status Maximum observed scan time This word indicates the maximum observed interval between consecutive I O scans The interval time is reported in units of 250 ms Resolution of the observed scan time is 0 to 250 ms For example the value 10 indicates that 2 25 2 5 ms was the longest scan time 6 dynamic configuration Index register This word indicates the element offset used in indexed addressing Publication 1747 UM002A US P June 2000 6 32 Library of Routines Word Bit Classification Description 7t08 status 1 0 interrupt pending These two words are bit mapped to the 30 170 slots Bits 7 1 through 8 14 refer to slots 1 30 Bits 7 0 and 8 15 are not used The pending bit associated with a slot is set when an interrupt request is received from that slot This bit is set regardless of the state of the 170 interrupt enabled bit wee word 9 and 10 9 to 10 status 1 0 interrupt enabled These two words are bit mapped to the 30 170 slots Bits 9 1 through 10 14 refer to slots 1 30 Bits 9 0 and 10 15 are not used The corresponding enable
155. scan The values are represented in units of 250 microseconds The scan times are reset to zero when changing to Scan mode and are not valid until the end of the second VO scan Only the timed I O scans are measured the demand input or output scans are not Return Value Name Value Description SUCCESS 0 measured scan time was read successfully ERR OCACCESS 2 handle does not have access to scanner ERR OCINIT 5 scanner has not been initialized see OC InitScanner Considerations Publication 1747 UM002A US P June 2000 Supported in the DOS API library and the Windows NT API library Example HANDLE Handle WORD max time last time int retcode retcode OC GetMeasuredScanTime Handle amp max time amp last time Library of Routines 6 25 0C_GetResetCause This function can only be used on the 1747 OCF controller The 1747 PCIS cannot reset the host Syntax int OC GetResetCause HANDLE handle int Cause Description OC GetResetCause returns the reason the scanner was last reset Handle must be a valid handle returned from OC OpenScanner The cause of the last scanner reset is written to the address pointed to by Cause If Cause is RESET HOST WD the last scanner reset was caused by a Host Watchdog timeout If Cause is RESET NOT HOST WD the last scanner reset was not caused by a Host Watchdog timeout If an application enables the host watchdog function and selects the WATCHDOG RE
156. scanner only writes outputs each time the application writes data to the output image The application can also prevent output scans by the scanner and have the scanner send a message after every input scan The application can detect an end of scan message and then read the input image perform logic and write outputs using OC_DemandOutputScan to force the scanner to write outputs immediately This lets the application synchronize its control loop with the input and output scans The application can also disable both input and output scans In this mode the scanner is a slave and input or output scans only take place when requested by the host application The following DOS example sample c on your API disk shows how to program the above steps Callouts on the right margin identify the code for each step JKAKKAKKKKKKKKKKKKAKKKAKKKAKKKAKKKAKAKAKAKAKAKAKAKAKKKKKKKKKKKKKKKKKKKKKKKK FILE sample c PURPOSE Sample application code for 1746 1 0 PCI Interface API SUMMARY This program Resets and initializes the scanner Displays the scanner firmware and hardware versions Autconfigures the 1 0 in chassis Reads the front panel switch position and lights LED 1 Reads first discrete input module data word Writes incremental data to first output module data word Closes connection to scanner and exits ENVIRONM ENT 1747 PCIS 1746 1 0 PCI Interface MS DOS Borland Microsoft C C Compiler 16 bit
157. se files Each transfer is a single request or an API call With respect to the 1746 I O PCI Interface the MO file is a module output file a write only file and the M1 file is a module input file a read only file You can address MO and MI files in your application and they can also be acted upon by the specialty I O module independent of the processor scan G files Some specialty modules such as the 1747 SN use configuration files which act as the software equivalent of DIP switches The data you enter into the G file is automatically passed to the specialty I O module when you enter Scan mode Publication 1747 UM002A US P June 2000 5 4 Configuring 1 0 Modules Supported 1 0 Modules Module Name Description Class Mi Type AMCI 1561 1 35 14 1203 SM1 Classi 1 35 16 1203 SM1 Class 4 4 136 17 1394 SJT 4 136 17 1746 IA4 4 Input 100 120 V ac 0 1 0 1746 1A8 8 Input 100 120 V ac 0 3 0 1746 1416 16 Input 100 120 V ac 0 5 0 1746 IB8 8 Input SINK 24 V dc 0 3 6 1746 IB16 16 Input SINK 24 V dc 0 b 6 1146 1B32 32 Input SINK 24 V de 0 1 6 1746 1016 16 Input de 0 5 9 1746 IH16 16 Input ac 0 b 1 1146 1616 16 Input TTL SOURCE 5 V dc 0 5 15 1746 IM4 4 Input 200 240 V ac 0 1 1746 IM8 8 Input 200 240 V ac 0 3 1746 IM16 16 Input 200 240 V ac 0 5 1746 IN16 16 Input 24 V ac
158. setup utility Follow the displayed instructions Click on Continue The next dialog lets you choose whether to install the API executable alone Runtime or the API executable and the development files Runtime and amp Development To develop applications with the API you need the development files To only run applications the development files are not necessary The development files consist of an include file import library and sample code aaa Runtime files may only be installed on a Windows NT system However the development files may be installed on either Windows NT or Windows 95 systems Choose the appropriate installation option and click on Next Overvievv 1 9 5 Click on Continue 6 If the development files were selected in the last dialog the next dialog allows a destination directory to be specified Click on Continue after you select the directory 7 The necessary files are copied to the disk and the system registry is updated to include the OCdriver information 8 Press OK to exit the setup utility The contents of the temporary directory can now be deleted IMPORTANT You must shutdown and reboot the scanner before using the API The setup utility sets the registry Start parameter for OCdriver to Automatic therefore the service manager starts the OCdriver when the system is booted The Windows NT API uses these files This file Contains ocapi lib
159. shing Company PCI Hardware and Software Architecture and Design Edward Solari and George Willse ISBN 0 929392 28 0 In addition to the books listed above the following books might be useful as you develop your 1746 VO PCI Interface applications This document By Has this ISBN number PC System Architecture Series MindShare Inc ISBN 0 201 40996 8 ISA System Architecture Addison Wesley Publishing Company PC System Architecture Series MindShare Inc ISBN 0 201 40991 7 ISA System Architecture Addison Wesley Publishing Company The PCMCIA Developerys Guide Michael T Mori and W Dean Welder ISBN 0 9640342 1 2 Publication 1747 UM002A US P June 2000 Preface 2 Additional Open Controller The following documents are available for additional information about the open controller and its options Documentation This document Has this publication 1747 Open Controller PCI Expansion Bus Installation Instructions 1747 5 16 1747 Open Controller PCMCIA Interface Module Installation Instructions 1747 5 13 1747 Open Controller A B Communication Interface Module Installation 1747 5 14 Instructions 1747 Open Controller Video Interface Module Installation Instructions 1747 5 15 1747 Open Controller A B Communication Interface Module User Manual 1747 6 18 1747 Open Controller IDE Interface Module for IDE Compatible ATA Devices 1747 5 29 PCCards Installation Instructions 17
160. sol SRE 3 position switch inputimage variable host data variable user jumper watchdog contact Understanding the Open The open controller architecture consists of two CPUs scanner and controller that share dual port memory The scanner scans the 1746 local I O bus and reads writes inputs and outputs to from the dual port registers The controller has a PC based architecture with a 266Mhz Pentium to run your application software Controller Architecture Open Controller CPU module PCI scanner OE controller PC based architecture dual port memory lt a Partition Bytes to 1746 local 4 U register 1K bus 266MHz VO bus commands variable Penti T memory responses variable le BIOS OS ee output image variable Kot input image variable memory host data variable scanner firmware to 1746 PCI bus Publication 1747 UM002A US P June 2000 Overvievv 1 5 Common Attributes of the 1746 1 0 PCI Interface and 1747 Open Controller Architectures The functionality described in the rest of this chapter is shared by both architectures 1746 1 0 PCI Interface and 1747 Open Controller The dual port is an SK byte memory partition optionally battery backed that provides an interface between the integrated scanner and your application software that resides on the host
161. st initialize the scanner by sending it partitioning information before the host application can communicate with the scanner Initialize the scanner by calling the OC InitScanner function to send the scanner partitioning information which defines in bytes the size of the output image the input image and the host retentive data Each of these memory segments must be at least large enough to hold their respective data and must be an even number If the input or output partition is initialized smaller than the actual size of the input or output image for a configuration the OC DownloadlIOConfiguration function returns an error The host retentive data size is optional and can be 0 To determine the input image and output image sizes use the OC CreatelOConfiguration function to create an I O configuration OC CreatelOConfiguration returns an I O configuration with the number of bytes of inputs and outputs for each module If a configuration already exists you can use OC GetlOConfig to return the current I O configuration The application can then calculate the minimum size of the segments required to hold the input and output images For more information see page 3 18 Developing Applications 3 3 The API has a defined constant specifying the total number of bytes available for the three segmenters This constant is specified as OCSEGMENTSIZELIMIT Once the scanner has been initialized properly it cannot be re initiali
162. t 1747 PCIS Microsoft Windows NT 4 0 c Copyright Allen Bradley PCIS2 Bus Interface AN A tifndef define tinclude OCAPI H OCAPI H lt windows h gt include standard windows definitions KAKKKKKKKKKKKKKK kk kk ck ck kk ck ck Sk kx Sk kx kx kx kx kx kx kk CONSTANTS xxx KAKKKKKKKKKKKKK KKK KKK kk kk kk ck sk sk sk sk ko ko ko KKKKK API Function Return Values KKKKK These values are returned by the API functions to indicate success or possible jt error conditions define define define define define define define define define define define define define define define define define define define define define KKKKXX SUCCESS ERR_OCOPEN ERR_OCACCESS ERR_OCMEM ERR_OCREINIT ERR_OCINIT ERR_OCPAR ERR_OCPOST ERR_OCPARAM ERR OCIOCFG ERR OCRESPONSE LO ERR OCEXTERR EL ERR OCSLOT 12 ERR OCFAULT 13 ERR OCSCANCFG 14 ERR OCNOFORCES L5 ERR_OCOVERRUN L6 ERR_OCOUTOFMEM 17 ERR_OCUNKNOWN L8 9 0 0 0 I oO NS amp NN HR ERR_OCFILERROR 1 ERR_OCNOTSUPP 2 Extended Error Codes These values are returned in the ErrorCode member of the OCEXTERR scanner did not respond DII KKKKK function returned successfully scanner already open handle does not have access to scanner shared memory cannot be found scanner
163. t OC SetScanTime HANDLE int To CHG Ke int OC SetOutputUpdateMode HANDLE int OC EnableEOSNotify HANDLE OC GetLastFaultCause HANDLE BYTE OC OC SetScanMode HANDLE ClearFault HANDLE int OC Set IOIdleState HANDLE OC GetStatusFile HANDLE OC OC ReadInput Image HAND PollScanner HANDLE int LE int i int MSGBUF WORD i OCIOCFG EG int int STSFILE nt WORD WORD WORD OC_GetInputImageUpdateCounter HANDLE BYTE ReadOutput Image HANDLE NriteOutput Image HANDLE WORD WriteModuleFile HANDLE OC OC oC OC_ReadModuleFile HAND OC OC OC LE EnableForces HANDLE in SetForces HANDLE FORCEDATA EnableSlot HANDLE int WORD BYTE WO int WORD WORD WORD int WORD WORD WORD RD int WORD WORD BYTE WORD int WORD WORD t int OC DemandOutputScan HANDLE int OC GetUserLEDState HANDLE OC SetUserLEDState HANDLE OC GetBatteryStatus HANDLE BYTE OC GetTemperature HAND LE lnt unt int int BYTE OC GetSwitchPosition HANDLE BYTE OC GetUserJumperState HANDLE BYTE OC SetHostWatchdog HANDLE OC PetHostWatchdog HANDLE OC GetScannerWatchdogCount HANDLE OC GetResetCause HANDLE OC WriteHostRetentiveData HANDLE B OC ReadHostRetentiveData HANDLE BY OC GetVersionInfo HANDLE OC GetExtendedError
164. t The application passes this configuration structure to OC CreatelOConfiguration OC CreatelOConfiguration returns a scanner configuration that can be downloaded to the scanner For more information see chapter 5 Once a valid scanner configuration is successfully downloaded to the scanner via OC DownloadIOConfiguration the application can set the scanner to Scan mode and control I O Both OC CreateIOConfiguration and OC GetIOConfiguration build the configuration data from an internal database of supported I O modules Publication 1747 UM002A US P June 2000 3 4 Developing Applications Publication 1747 UM002A US P June 2000 Control scanner operation Once the scanner has been configured the application can control scanner operation The host application can set the scanner to Idle or Scan mode control the scan time control I O read or write module files clear faults enable disable slots set I O Idle state e install remove forces handle module interrupts and discrete input interrupts The API uses messages to communicate with the scanner The scan time settings affect the time allowed by the scanner to process a message OC SetScanTime adjusts the scan time of the application The scanner processes messages during any available time that it is not scanning I O If the scan time is set too small some API functions might take a relatively long time to complete If some functions seem to be t
165. t interrupt for a module x x KAKKKAKKKKK KKK KKAKKKAKKKA KKK K KKK KKK KA KKK KKKAKKKKKKKKKKKKKKKKK typedef struct tagDII CFG BYTE SlotNum slot number BYTE IOIncludeMask declare which Discrete Inputs can cause interrupts BYTE IOEdgeType select required transition of each discrete input WORD PresetCount set the number of transitions required to cause interrupt DII CFG JAKKKAKKKAKKKKKKAKKKAKKKA KKK K KKK K KKK KKAKKKAK KKK KKKAKKKKKKKKKK Structure Name STSFILE Publication 1747 UM002A US P June 2000 C 16 Header File Description Scanner status file KAKKKKAKKKKKKAKKKAKKKA KKK KKKAKKKAKKKAKKKKAKKKAKKKAKKKKKKKKKKKKKJ typedef struct tagSTSFILE WORD wWordNum OCSTSFILEWSIZE STSFILE JAKKKKAKKAKKKAKKKAKKKA KKK K KKK KKAKKKAKKKKKKKAKKKAKKKKKKKKKKKKKAK Structure Name MSGBUF Description x x x x Returned by OC PollScanner X MsgID identifies the message type Type specific d data is contained in MsgData l KKAKKAKKKKKAKKKAKKKKAKKKAKKKAKKKKKKAKKKAKKKAKKKAKKKAKKKKKKKKKKKKKKJ define OCMSGDATASIZE 4 number of bytes of message data typedef struct tagMSGBUF BYTE MsgID Message type E BYTE MsgData OCMSGDATASIZE Type specific data MSGBUF JAKKKKAKKAKKKAKKKAKKKA KKK KKK KKKAKKKAKKKKKKAKKKAKKKKAKKKKKKKKAK Structure Name OCEXTERR Description Returned by OC GetExtendedError I O error report from scanner KKAK
166. t reads the contents of the watchdog register of the scanner Syntax int OC_GetScannerWatchdogCount HANDLE handle BYTE count Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner count Returns the watchdog register contents Description The watchdog register is incremented by the scanner after every timed I O scan This register is incremented in both Scan and Idle modes and is incremented even if both output and input scans are disabled The control application can monitor this register to ensure that the scanner is functioning normally It is also useful for synchronizing with the I O scan Return Value Name Value Description SUCCESS 0 watchdog was read successfully ERR OCACCESS 2 handle does not have access to scanner Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle BYTE vdog count int retcode retcode OC GetScannerWatchdogCount Handle amp wdog count Publication 1747 UM002A US P June 2000 6 30 Library of Routines 0C_GetStatusFile OC GetStatusFile reads a copy of the current scanner system status file into the STSFILE structure pointed to by stsfil on the scanner Syntax int OC_GetStatusFile HANDLE handle STSFILE stsftil Parameters Parameter Description handle Must
167. t watchdog is disabled l define WATCHDOG_IDLE d Scanner with change to Idle mode on host wdog timeout define WATCHDOG RESET 2 Scanner will issue a system reset on host wdog timeout KKKKK KKKKK Reset Cause These values are returned by the OC GetResetCause define RESET NOT HOST WD 0 define RESET HOST WD 1 JA KKKKK KKKKK k Module I O Int Modes These values are passed to the OC_Se define IOINT ENABLE HN define IOINT DISABLE 0 define IOINT ACK JE KKKKK Output Update Modes These values are passed to the OC_Se define OUTUPD_NEVER 0 define OUTUPD_CHANGE 1 define OUTUPD_ALWAYS 2 KKKKK KKKKK KKKKK Input Update Modes These values are passed to the OC Se JA define INUPD_NEVER 0 define INUPD ALWAYS 1 KKKKK EndofScan Modes KKKKK These values are passed to the OC EnableEOSNotify define EOSMSG ENABLE 0 PE define EOSMSG_DISABLE 1 JE KKKKK KKKKK Wait Flags function Reset was caused by the host watchdog tModuleInterrupt function EJ Enable module interrupt Disable module interrupt EJ Acknowledge module interrupt tOutputUpdateMode function Never scan outputs Scan outputs every scan tInputUpdateMode function Never scan outputs Scan outputs every scan function Enable end of scan notification messages Reset was not caused by the host watch
168. tUpdateMode Routine 6 58 OC SetlOldleState Routine 6 59 OC SetModulelnterrupt Routine 6 60 OC SetOutputUpdateMode Routine 6 61 OC SetScanMode Routine 6 63 OC SetScanTime Routine 6 64 0C SetupPovverFailAction Routine 6 66 OC SetUserLEDState Routine 6 65 OC VVaitForDll Routine 6 68 OC WaitForEos Routine 6 69 OC WaitForEosDmdln Routine 6 70 OC WaitForEosDmdOut Routine 6 71 OC WaitForExtError Routine 6 73 OC WaitForlolnt Routine 6 74 0C WriteHostRetentiveData Routine 6 75 OC WritelOConfigFile Routine 6 76 0C WriteModuleFile Routine 6 77 0C WriteOutputlmage Routine 6 78 0C WriteSRAM Routine 6 80 Open Controller Architecture 1 4 P Partition Sizes Determining for shared memory 3 18 Performing POST 1 6 Programming Conventions 2 2 DOS considerations 2 2 NT considerations 2 3 Programming Example DOS 3 5 NT 3 11 Programming Information Routines 6 1 Programming Sequence 3 1 Access the scanner 3 2 Configure the scanner 3 3 Control scanner operation 3 4 Initialize the scanner 3 2 Scan 1 0 3 4 Reference Material P 1 Relationship Between the 1747 OCF and 1746 PCIS 1 1 Removing the NT API 1 10 Routines 6 1 OC_CalculateCRC 6 1 OC ClearFault 6 2 OC CloseScanner 6 3 OC ConfigureDLL 6 4 OC CreatelOConfiguration 6 6 OC DemandinputScan 6 7 OC DemandOutputScan 6 8 OC DownloadlOConfiguration 6 9 OC EnableEOSNotify 6 10 OC EnableForces 6 12 OC EnableSlot 6 13 OC ErrorMsg 6 14 OC ExtendedErrorMsg 6 15 OC
169. tains an invalid value Considerations Supported in the DOS API library and the Windows NT API library Publication 1747 UM002A US P June 2000 6 76 Library of Routines 0C WritelOConfigFile Example HANDLE Handle BYTE retent data 500 int retcode retcode OC WriteHostRetentiveData Handle retent data 0 500 OC WriteIlOConfigFile writes the configuration data contained in the iocfg structure to the file named filename Syntax int OC WritelOConfigFile OCIOCFG iocfg char filename Parameters Parameter Description iocfg A structure that contains the configuration data that is to be written to filename filename References the file to write If filename does not exist it is created Description Configuration files created by OC WritelOConfigFile can be read by OC ReadlOConfigFile The OCIOCFG structure is defined as typedef struct tagOCIOCFG BYTE RacklSize number of slots in Rack 1 BYTE Rack2Size number of slots in Rack 2 BYTE Rack3Size number of slots in Rack 3 OCSLOTCFG SlotCfg OCMAXSLOT configuration for each slot OCIOCFG Return Value Name Value Description SUCCESS 0 1 0 configuration file was written successfully ERR_OCFILERROR 19 error encountered while opening or writing the file Publication 1747 UM002A US P June 2000 Library of Routines 6 77 0C WriteModuleFile Considerations
170. this manual we use notes to make you aware of safety considerations Identifies information racti r ATTENTION de ifies information about practices o 7 circumstances that can lead to personal injury or death property damage or economic loss Attention statements help you to e identify a hazard e avoid a hazard recognize the consequences IMPORTANT Identifies information that is critical for successful application and understanding of the product Allen Bradley is a trademark of Rockwell Automation European Communities EC If this product has the CE mark it is approved for installation within Directive Compliance the European Union and EEA regions It has been designed and tested to meet the following directives EMC Directive This product is tested to meet the Council Directive 89 336 EC Electromagnetic Compatibility EMC by applying the following standards in whole or in part documented in a technical construction file e EN 50081 2 EMC Generic Emission Standard Part 2 Industrial Environment e EN 50082 2 EMC Generic Immunity Standard Part 2 Industrial Environment This product is intended for use in an industrial environment Low Voltage Directive This product is tested to meet Council Directive 73 23 EEC Low Voltage by applying the safety requirements of EN 61131 2 Programmable Controllers Part 2 Equipment Requirements and Tests For specific information required by
171. to the OC SetlIOIdleState function 7 pe define IDLESTATE RESET 0 I O bus is reset in Idle mode El define IDLESTATE HOLD 1 1 0 is held in last state in Idle mode Publication 1747 UM002A US P June 2000 C 12 Header File PollScanner Message ID s x These values are passed to the OC PollScanner function message filter and are returned in the MsgID member of the MSGBUF structure T uu define OCMSG NONE 0 No messages are available msg ID 2 define OCMSG_ANY 0 Poll for any message filter tj define OCMSG IOINT 1 1 0 Module Interrupt i define OCMSG DIINT 2 Discrete Input Interrupt E define OCMSG_EOS 3 End of Scan notification define OCMSG_EOS_DMDIN 4 End of Scan notification from demand input define OCMSG EOS DMDOUT 5 End of Scan notification from demand output jt Scanner Force Settings e These values are passed to the OC EnableForces function 1 xy define FORCE ENABLE 0 Enable forces define FORCE DISABLE 1 Disable forces define FORCE CLEAR 2 Clear all forces x Module Force Settings f These values are passed to the OC SetForces function K 7 define FORCE INPUTS 0 Select input forces define FORCE_OUTPUTS 1 Select output forces ES KKKKK Slot Settings KKKKK These values are passed to the OC EnableSlot function JH KA define SLOT_ENABLE 0 En
172. try standard programming language compilers This chapter provides the programming information for each routine and identifies which operating system supports the routine The calling convention for each APT function is shown in C format OC_CalculateCRC calculates a 16 bit CRC Syntax void OC CalculateCRC BYTE bufPtr WORD bLen WORD LEC Parameters Parameter Description bufPtr Points to the buffer that contains the bytes for the CRC calculation blen Number of bytes for which to calculate the CRC Cre A word that returns the calculated CRC Description This function is useful for verifying data integrity For example a CRC might be appended to data stored in the host retentive data partition When the data is later retrieved a new CRC can be calculated and compared to the old CRC to ensure the data is valid Return Value none Considerations Supported in the DOS API library and the Windows NT API library Publication 1747 UM002A US P June 2000 6 2 Library of Routines OC ClearFault Example BYTE buffer 100 WORD buffer crc int retcode retcode OC CalculateCRC buffer 100 amp buffer crc OC ClearFault clears any fault condition of the scanner Syntax int OC ClearFault HANDLE handle Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner Description All extended error information must be retrieved
173. ule interrupt n break default printf MAnError Nn break Library of Routines 6 75 0C WriteHostRetentive Data OC NriteHostRetentiveData writes data to the host retentive data partition of the scanner Syntax int OC WriteHostRetentiveData HANDLE handle BYTE buf WORD offset WORD len Parameters Parameter Description handle Must be a valid handle returned from OC OpenScanner buf Contains the data that is read offset The data is written offset bytes from the beginning of the data partition If the number of bytes from offset to the end of the partition is smaller than Len no bytes are written and ERR OCPARAM is returned len Defines how many bytes to write Description Data is not written past the end of the host retentive data partition It is recommended that you verify the integrity of the data stored in the host retentive data partition You can use the OC CalculateCRC function to generate a 16 bit CRC Data written to the host retentive data partition of the shared memory is battery backed and will be retained if power is removed from the rack as long as the battery voltage is good Return Value Name Value Description SUCCESS 0 host retentive data was written successfully ERR OCACCESS 2 handle does not have access to scanner ERR OCINIT 5 scanner has not been initialized see OC InitScanner ERR OCPARAM 8 parameter con
174. ut image in the scanner s shared memory not NULL OC Readinputimage reads data from outimgcpy Which contains a copy of the scanner s output image slotnum If slotnumis offset positive the output image for that slot is read into the len array pointed to by imagebuf Then imagebuf is filled with 1en words of output data starting at word offset of the module in the slot 1 the entire output image is read into the array pointed to by imagebuf and offset and len are ignored imagebuf Must point to an array that is large enough to accept the amount of data in the requested output image Description Since the scanner never changes data in the output image it is not necessary to copy the image as with the OC_ReadInputImage function to preserve file integrity It is supported however to provide a consistent interface Publication 1747 UM002A US P June 2000 6 52 Library of Routines Return Value Name Value Description SUCCESS 0 output image was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCPARAM 8 parameter contains invalid value ERR OCSCANCFG 14 scanner has not been configured ERR OCSLOT 12 slot number is invalid Considerations 0C ReadSRAM Publication 1747 UM002A US P June 2000 Supported in the DOS API library and the Windows NT API library Example HANDLE Handle WORD outputdata 2 int retcode retcode OC ReadOutputImage Handle NU
175. v Red 5 3 Supported I O Modules koi 4 dee ade 5 4 Chapter 6 Ttt COCIUELRODI A aes ir doe dote dono eta ME TILES n dodo 6 1 OC Cale lateC INC LE us oae psi ue SEE 6 1 OCC i QURE TTE ana dote a eee ne 6 2 OC Clos scann tisss A 6 3 ER AA 6 4 OC_CreatelOConfiguration 3 o ont pora tr 6 6 OC_DemandInputScan gara bash td A ada E Gc 6 7 OG DemandOuiputScan 235 olx a vA a A LR 6 8 OC DownloadlO Conf curation x 00x eviter 6 9 OG EfnableEOSNOLY ane see treat E 6 10 OC Enablebotees l 2s uam ex ieee eh RA 6 12 OE Erablesl ta x uus ata vd AE x Eo AT eura ate 6 13 OC ESFORMSS co ED Ue uet dw EE mets FE bus dete os E oodd 6 14 OC_ExtendedErrorMsg 5 24 Te oa qd cde oed weal e Gr 6 15 OC_GetBatteryStatus c ra al aa Hed Bie D iiit 6 17 OC Gelbevcelffosssv stie ESReSTOXESREtOPULDES RA 6 18 OC_GetExtendedError 6 19 OC_GetInputlmageUpdateCounter 6 20 OC_GetIOConfiguration nn pa e A 6 21 OC_GetLastFaultCause desa D derbi boobs dls ce dt 6 22 OC GetMeasuredScan Time 6 24 OC_GetResetCause A th awa tay ae aah tr eed ete 6 25 OC GetScannerIpit Info ou eT vr Ee patas vU EE 6 26 OC oGel5canmerS LES sk abs a ner ur o etis Ea 6 27 OC GetScannerWatchdogCount 6 29 OC_GetStatusFile etti e paa es eo atk 6 30 OC GetSwitchPosition 6 34 OG Ger Temperance s Cad E se en 6 35 OC_GetUserJumperState so bs Pera our bas red 6 36
176. w lists the internal scanner extended error sources Error Code Description 0x03 Scanner message queue full 0x06 Internal scanner watchdog timeout 0x07 CRC checksum failure 0x09 Invalid message Ox0A RAM failure Ox0B Host watchdog timeout Introduction Appendix B Testing Function Galls Both the DOS API and the Windows NT API come with a utility program called api_test exe This interactive program lets you execute from the keyboard every API call for the 1746 I O PCI Interface Use the source code of the utility program along with the executable program to test different argument values for each function call and to verify correct scanner operation Another DOS utility program called ocdiag exe comes with the 1746 I O PCI Interface hardware Use this utility program to verify e hardware operation e scanner functionality e VO control The Windows NT utility program is oc nt exe To get a copy of this utility e contact A B Technical Support Services at 440 646 6800 or e download a copy from the Technical Support Services bulletin board at 440 646 5441 Use the d option when executing the self unzipping file so that you preserve subdirectory structures Publication 1747 UM002A US P June 2000 B 2 Testing Function Calls Notes Publication 1747 UM002A US P June 2000 Appendix C Header File Introduction The API comes with a header file ocapi h that defines error code
177. was read successfully ERR_OCACCESS 2 handle does not have access to scanner ERR_OCINIT 5 scanner has not been initialized see OC InitScanner Publication 1747 UM002A US P June 2000 Library of Routines 6 21 OC GetlOConfiguration Considerations Supported in the DOS API library and the Windows NT API library Example HANDLE Handle BYTE count int retcode retcode OC GetInputImageUpdateCounter Handle amp count OC GetlOConfiguration queries the I O rack about the installed rack sizes and I O modules in each 1746 chassis ATTENTION OC GetlOConfiguration can take several milliseconds to complete depending upon the rack configuration While it is executing I O scanning and DII s are disabled Syntax int OC GetIOConfiguration HANDLE handle OCIOCFG iocfg Parameters Parameter Description handle Must be a valid handle returned from OC_OpenScanner iocfg Specifies the rack sizes and installed modules Use the information in iocfg as input to OC DownloadlOConfiguration to configure the scanner Description If the scanner is in Scan mode and OC GetIOConfiguration returns successfully OC GetIOConfiguration enables the host application to access I O The scanner must have previously received a valid configuration prior to going to Scan mode The OCIOCFG structure is defined as typedef struct tagOCIOCFG BYTE RacklSize number of slots in Rack 1
178. word gt 0x 04x An wData delay 3000 Scan 1 0 xx Write to the first Output word printf Anin Incrementing first discrete output word An for wData 0 wData 256 wData retcode OC WriteOutputImage Handle NULL output slot 0 1 amp wData if retcode SUCCESS printf nERROR OC NriteOutput Image failed d n retcode Toexit 1 delay 10 Must always close the scanner befor xiting EA OC_CloseScanner Handle printf Anin Program is done n n end main JAKKAKKKKAKAKAKAKKKAKAKAKAKAKAKAKAKKKKKKKKKKKKKKKKKKAKKKKKKKKKAKKKKKKKAKKK x X X F F X F X Xo F ACA F HF F Name Ioexit Description Common error handling routine This routine displays any extended error and exits the program Arguments retcode int input This error code is passed to the exit routine External effects The program is terminated Return value none KAKAKAKAKAKAKAKAKAKKKKKKKKKKKKKKKKAKKKAKKKAKKKKKKKAKAKAKAKAKKAKKAKKKKKKKKKJ void Ioexit int retcode OCEXTERR exterr char msg if OC_GetExtendedError Handle amp exterr SUCCESS if exterr ErrorCode 0 Publication 1747 UM002A US P June 2000 Developing Applications 3 11 OC_ExtendedErrorMsg Handle amp exterr amp msg printf AnERROR s n msg OC_CloseScanner Han
179. x94 Module has been inserted or reset 7 define EERR OCSCANNERINT OxFO Scanner internal error j Scanner Status These values are returned by the OC GetScannerStatus function I Le El define SCANSTS_POST 0x01 Scanner is executing Power On Self Test t tdefine SCANSTS_CRC 0x02 Scanner firmware failed CRC checksum define SCANSTS_RAM 0x03 Scanner RAM test failed define SCANSTS_BPIC 0x04 Scanner backplane IC test failed ES define SCANSTS_DPR 0x05 Scanner Dual Port Ram test failed ey define SCANSTS_THERM 0x06 Scanner thermometer test failed KJ define SCANSTS_TIMER 0x07 Scanner timer test failed define SCANSTS INT 0x08 Scanner interrupt test failed EL define SCANSTS_IDLE 0x11 Scanner has been initialized and is in Idle mode Ef define SCANSTS_WDOG 0x12 Scanner internal watchdog timeout scanner halted define SCANSTS_FAULT 0x13 Scanner is faulted 7 define SCANSTS_SCAN 0x20 Scanner is in Scan mode y ckckck ck Scan Time kkkk These values are passed to the OC_SetScanTime function J tJ define SCAN DELAYED 0 Select delayed mode next scan occurs time 10us after end of scan Publication 1747 UM002A US P June 2000 Header File C 3 define SCAN_PERIODIC 1 Select periodic mode next scan occurs every time 250us ES KKKKA Scan Mode KKKKA These values are passed to the OC SetScanMode function Ry aa A define SCAN_IDL
180. zed unless it is reset with the OC_ResetScanner function Once the scanner is reset scanner communications are disabled again until the scanner is initialized The host application can call OC GetScannerStatus to determine if the scanner has been initialized If the scanner was previously initialized the host application can retrieve the initialization partition information with the OC GetScannerlnitInfo function instead of resetting and re initializing the scanner Configure the scanner To access I O modules in a rack you must define the rack sizes and installed module types for the scanner You can either create a specific configuration or read the current configuration The scanner cannot be set to Scan mode until it has been configured received a valid scanner configuration If the scanner is in Scan mode and the host application has not downloaded a scanner configuration the scanner has already been configured To control I O use OC GetlOConfiguration to retrieve the current scanner configuration The application can read the current I O configuration with the OC GetlOConfiguration function If the scanner is not in Scan mode this function returns the current scanner configuration which can be downloaded to the scanner using OC DownloadIOConfiguration If the application requires a specific I O configuration the application can define the I O configuration structure with the rack sizes and module types installed in each slo

Download Pdf Manuals

image

Related Search

Related Contents

DHC-MD77  Manuale di istruzioni  APC 66063  PDFをダウンロード(1 MB)  M atrix    TY-ST65PE7 取扱説明書  LG GR3790BWA fridge-freezer  Cooker Hood User Manual  Delta 77135 Installation Guide  

Copyright © All rights reserved.
Failed to retrieve file