13.07.2015 Views

CompuScope SDK Manua.. - Egmont Instruments

CompuScope SDK Manua.. - Egmont Instruments

CompuScope SDK Manua.. - Egmont Instruments

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Volume I:<strong>CompuScope</strong> C/C++Software Development Kit<strong>Manua</strong>lSupporting the<strong>CompuScope</strong> <strong>SDK</strong> for C/C++ forWindowsfor all Gage <strong>CompuScope</strong> modelsFor <strong>SDK</strong> Version 3.50+P/N: 0045031Reorder #: MKT-SWM-<strong>SDK</strong>150404


© Copyright Gage Applied Technologies, Inc. 2002Fourth Edition (May 2002)GAGE, GAGESCOPE, GAGEBIT, GAGEPCI, GAGEP500, COMPUSCOPE, COMPUSCOPE 85G, COMPUSCOPE 85GC, COMPUSCOPE82G, COMPUSCOPE 8500, COMPUSCOPE 12100, COMPUSCOPE 1250, COMPUSCOPE 14100, COMPUSCOPE 14100C, COMPUSCOPE1450, COMPUSCOPE 1602, COMPUSCOPE 1610, COMPUSCOPE 1610C, GSINST, PCIINST, P500INST, 85DETECT, MULTI-CARD, COMPUGEN, CGWIN, COMPUGEN 1100, and INSTRUMENT MANAGER, are registered trademarks of Gage AppliedTechnologies, Inc.MS-DOS, WINDOWS, WINDOWS 95, WINDOWS 98, WINDOWS NT, WINDOWS ME, AND WINDOWS XP are trademarks ofMicrosoft Incorporated. MATLAB is a trademark of TheMathWorks Inc. LABVIEW and LABWINDOWS/CVI are trademarks ofNational <strong>Instruments</strong> Corp. IBM, IBM PC, IBM PC/XT, IBM PC AT and PC-DOS are trademarks of International BusinessMachines Corporation.Changes are periodically made to the information herein; these changes will be incorporated into new editions of thepublication. Gage Applied Technologies, Inc. may make improvements and/or changes in the products and/or programsdescribed in this publication at any time.Copyright © 2002 Gage Applied Technologies, Inc. All Rights Reserved, including those to reproduce this publication or partsthereof in any form without permission in writing from Gage Applied Technologies, Inc.The installation program used to install the the <strong>CompuScope</strong> <strong>SDK</strong>s for Windows, InstallShield, is licensed software provided byInstallShield Software Corp., 900 National Parkway, Ste. 125, Schaumburg, IL. InstallShield is Copyright ©1998 byInstallShield Software Corp., which reserves all copyright protection worldwide. InstallShield is provided to you for theexclusive purpose of installing the <strong>CompuScope</strong> <strong>SDK</strong>s. In no event will InstallShield Software Corp. be able to provide anytechnical support for <strong>CompuScope</strong> <strong>SDK</strong>s.How to reach Gage Applied Technologies, Inc.Product Manager - <strong>CompuScope</strong> <strong>SDK</strong>sGage Applied Technologies, Inc.How to reach Gage from outside North AmericaTel: (514) 633-7447Fax: (514) 633-0770Toll-free phone: (800) 567-4243Toll-free fax: (800) 780-8411Online technical support form:E-mail: prodinfo@gage-applied.comWebsite: http://www.gage-applied.comwww.gage-applied.com/support.aspPlease complete the following section and keep it handy when calling Gage Applied Technologies, Inc. for technical support:Owned by: ___________________________Serial Number: ___________________________Purchase Date: ___________________________Purchased From: ___________________________You must also have the following information when you call:. Software Driver and Application version. Software Development Kit type and version· Brand name and type of computer· Processor and bus speed· Total memory size· Information on all other hardware in the computer


Gage Applied Technologies, Inc. Software & Documentation License AgreementCAREFULLY READ THE FOLLOWING TERMS AND CONDITIONS BEFORE OPENING THECOMPUSCOPE <strong>SDK</strong> PACKAGE. OPENING THE COMPUSCOPE <strong>SDK</strong> PACKAGE INDICATESACCEPTANCE OF THESE TERMS AND CONDITIONS. IF YOU DO NOT AGREE WITH THEM,PROMPTLY RETURN THE PACKAGE UNOPENED AND YOUR MONEY WILL BE REFUNDED.Title to the media on which the program is recorded and to documentation in support thereof is transferred to you,but title to the program is retained by Gage Applied Technologies, Inc. You assume responsibility for the selectionof the program to achieve your intended results, and for the installation, use, and results obtained from theprogram.LICENSEUnder the terms and conditions of this License Agreement you may:a) use the program on a single machine;b) copy the program into any machine-readable or printed form for backup or modification purposes in support ofyour use of the program on the single machine. Copying of documentation and other printed material isprohibited;c) modify the program and/or merge it into another program for your use on the single machine (any portion ofthis program merged into another program will continue to be subject to the terms and conditions of thisAgreement); andd) transfer the program and license to another party if the other party agrees to accept the terms and conditions ofthis Agreement. If you transfer the program, you must at the same time either transfer all copies whether inprinted or machine-readable form to the same party or destroy any copies not transferred; this includes allmodifications and portions of the program contained or merged into other programs.You must reproduce and include the copyright notice on any copy, modification or portion merged into anotherprogram.You may not use, copy, modify, or transfer the program, or any copy, modification or merged portion, in whole orin part, except as expressly provided for in this License Agreement.If you transfer possession of any copy, modification or merged portion of the program to another party, yourlicense is automatically terminated.TERMSThe license is effective until terminated. You may terminate it at any time by destroying the program together withall copies, modifications and merged portions in any form. The license will also terminate upon conditions setforth elsewhere in this Agreement or if you fail to comply with any term or condition of this Agreement. Youagree upon such termination to destroy the program together with all copies, modifications and merged portions inany form.LIMITED WARRANTYGage Applied Technologies, Inc. warrants the media on which the program is furnished to be free from defects inmaterials and workmanship under normal use for a period of one year from the date of delivery to you asevidenced by a copy of your receipt.THE PROGRAM IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITYAND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK TO THE QUALITY ANDPERFORMANCE OF THE PROGRAMS LIES WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,YOU (AND NOT GAGE APPLIED TECHNOLOGIES, INC.) ASSUME THE ENTIRE COST OF ALLNECESSARY SERVICING, REPAIR OR CORRECTION.SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THEABOVE EXCLUSION MAY NOT APPLY TO YOU. THIS WARRANTY GIVES YOU SPECIFIC LEGALRIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS WHICH VARY FROM ONE JURISDICTION TOANOTHER.Continued on next page


Continued from previous pageGage Applied Technologies, Inc. does not warrant that the functions contained in the program will meet yourrequirements or that the operation of the program will be uninterrupted or error free. However, Gage AppliedTechnologies, Inc. warrants the media on which the program is furnished to be free from defects in materials andworkmanship under normal use for a period of one year from the date of delivery to you as evidenced by a copy ofyour receipt.LIMITATIONS OF REMEDIESGage Applied Technologies, Inc.’s entire liability and your exclusive remedy shall be:a) with respect to defective media during the warranty period, Gage Applied Technologies, Inc. will replacemedia not meeting Gage Applied Technologies, Inc.’s “Limited Warranty” if returned to Gage AppliedTechnologies, Inc. or its authorized representative with a copy of your receipt, orb) if Gage Applied Technologies, Inc. or its representative is unable to deliver replacement media free of defectsin materials and workmanship, you may terminate the Agreement by returning the program and your moneywill be refunded.IN NO EVENT WILL GAGE APPLIED TECHNOLOGIES, INC. BE LIABLE FOR ANY DAMAGES,INCLUDING ANY LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR CONSEQUENTIALDAMAGES ARISING OUT OF THE USE OF OR INABILITY TO USE SUCH PROGRAM, EVEN IF GAGEAPPLIED TECHNOLOGIES, INC. OR ITS AUTHORIZED REPRESENTATIVE HAS BEEN ADVISED OFTHE POSSIBILITY OF SUCH DAMAGES, OR ANY CLAIM BY ANY OTHER PARTY.SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OR EXCLUSION OF LIABILITY FORINCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATION OR EXCLUSION MAYNOT APPLY TO YOU.GENERALYou may not sublicense, assign or transfer the license or the program except as expressly provided in thisAgreement. Any attempt otherwise to sublicense, assign or transfer any of the rights, duties or obligationshereunder is void.This Agreement is governed by the laws of the Province of Quebec, Canada.The parties agree that this Agreement be written in English. Les partis consentent à ce que cette entente soitrédigée en anglais.Should you have any questions concerning this Agreement, you may contact Gage Applied Technologies, Inc. inwriting. Please check the Gage website (http://www.gage-applied.com/aboutgag/contact.htm) for the most currentaddress.YOU ACKNOWLEDGE THAT YOU HAVE READ THIS AGREEMENT, UNDERSTAND IT AND AGREETO BE BOUND BY ITS TERMS AND CONDITIONS. YOU FURTHER AGREE THAT IT IS THECOMPLETE AND EXCLUSIVE STATEMENT OF THE AGREEMENT BETWEEN US WHICHSUPERSEDES ANY PROPOSAL OR PRIOR AGREEMENT, ORAL OR WRITTEN, AND ANY OTHERCOMMUNICATIONS BETWEEN US RELATING TO THE SUBJECT MATTER OF THIS AGREEMENT.


Global Table of ContentsVolume I <strong>CompuScope</strong> C/C++ Software Development Kit<strong>Manua</strong>lChapter 1Chapter 2Chapter 3Chapter 4Chapter 5Appendices<strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows PrefaceBasic <strong>CompuScope</strong> OperationIntroduction to <strong>CompuScope</strong> Windows Drivers andC/C++ <strong>SDK</strong>Writing a C Application for <strong>CompuScope</strong> CardsSample ProgramsData Structures Used by <strong>CompuScope</strong> drivers<strong>CompuScope</strong> Power ManagementCompiling CompuSCope <strong>SDK</strong> C/C++ SamplePrograms under LabWindows CVICompuGen CardsVolume II <strong>CompuScope</strong> API Reference <strong>Manua</strong>l<strong>CompuScope</strong> API RoutinesAppendices Comparison of Various Data Transfer RoutinesFrequently Asked QuestionsMultiple/Independent Mode OperationMultiple Record Mode Operation


Table of Contents - <strong>CompuScope</strong> <strong>SDK</strong> for C/C++for Windows <strong>Manua</strong>lChapter 1: <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows PrefacePreface ............................................................................................................................. 3What You Receive with the <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows...................... 4Chapter 2: Basic <strong>CompuScope</strong> OperationBasic <strong>CompuScope</strong> Operation......................................................................................... 7Single Record Mode............................................................................................................................... 8Multiple Record...................................................................................................................................... 8Master/Slave Multi-Card Systems.......................................................................................................... 9Multiple Independent Multi-Card Systems............................................................................................. 9Multiple <strong>CompuScope</strong> Systems............................................................................................................ 10PCI Bus <strong>CompuScope</strong>s.................................................................................................. 11PCI Bus................................................................................................................................................. 11Plug-n-Play........................................................................................................................................... 11DMA or Bus-Mastering on the PCI Bus............................................................................................... 12Memory Mode Operation of the PCI Bus <strong>CompuScope</strong> Cards............................................................ 13Data throughput across the PCI Bus..................................................................................................... 13Number of PCI Slots in one Chassis..................................................................................................... 13On-Board Memory Organization of the <strong>CompuScope</strong> Cards ....................................... 14A/D Data Storage ................................................................................................................................. 14Timing Diagrams for <strong>CompuScope</strong> Capture ........................................................................................ 16On-board Memory: A Programmer’s View.......................................................................................... 20<strong>CompuScope</strong> Repetitive Capture Performance ............................................................. 22Chapter 3: Introduction to <strong>CompuScope</strong> Windows Drivers and C/C++ <strong>SDK</strong>Introduction ................................................................................................................... 27What are the <strong>CompuScope</strong> Windows Drivers? .................................................................................... 27<strong>CompuScope</strong> C/C++ Software Development Kit................................................................................. 27Sample Programs Folder Structure used in <strong>CompuScope</strong> <strong>SDK</strong>s.......................................................... 28Common Files used in <strong>CompuScope</strong> C/C++ <strong>SDK</strong>s ............................................................................. 29Chapter 4: Writing a C Application for <strong>CompuScope</strong> CardsWriting a C Application for <strong>CompuScope</strong> Cards.......................................................... 33Useful program structures and variables .............................................................................................. 34Initializing the <strong>CompuScope</strong> driver and hardware ............................................................................... 34Preparing the <strong>CompuScope</strong> Card for Data Capture.............................................................................. 34Starting an Acquisition ......................................................................................................................... 35Completing an Acquisition................................................................................................................... 35Transferring the <strong>CompuScope</strong> Data ..................................................................................................... 361


Chapter 5: Sample ProgramsWindows Sample Programs........................................................................................... 39Detailed Description of Selected Sample Programs...................................................... 41GAG2A2D_MS_BM.EXE................................................................................................................... 41GAG2A2D_MUL_BM.EXE................................................................................................................ 46DIGITAL_INPUT.EXE ....................................................................................................................... 50Chapter 6: AppendicesAppendix A: Data Structures Used by <strong>CompuScope</strong> Drivers....................................... 55Appendix B: <strong>CompuScope</strong> Power Management ........................................................... 69Appendix C: Compiling <strong>CompuScope</strong> <strong>SDK</strong> C/C++ Sample Programs underLabWindows CVI.......................................................................................................... 71Appendix D: CompuGen Cards..................................................................................... 75


Chapter 1:<strong>CompuScope</strong> <strong>SDK</strong>for C/C++ forWindows Preface


PrefaceImportant Notes:• The <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows supports all the <strong>CompuScope</strong> cards includingCompactPCI/PXI <strong>CompuScope</strong>s and CP500-class single PCI <strong>CompuScope</strong>s. Older CSx012/PCI<strong>CompuScope</strong>s and ISA <strong>CompuScope</strong>s are no longer sold by Gage and are not supported by currentC/C++ <strong>SDK</strong>s. The last <strong>CompuScope</strong> C/C++ <strong>SDK</strong> that supported these <strong>CompuScope</strong> models wasversion 3.46.02.• No hardware installation instructions are included in this guide. For information on how to install your<strong>CompuScope</strong> hardware, please see your hardware manual.• You must install the <strong>CompuScope</strong> Drivers before using the <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ forWindows. Please refer to <strong>CompuScope</strong> Driver Installation Guide on how to install <strong>CompuScope</strong>Windows Drivers.• All sample programs provided are written in MS Visual C++ version 5.0. Complete MS Visual C++projects provided for each <strong>SDK</strong> sample program. The sample programs may be operated using otherWindows C compilers, but no project files are provided.• Throughout this manual the terms “<strong>CompuScope</strong> Software Development Kit for C/C++ for Windows”,“<strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows”, <strong>CompuScope</strong> C/C++ <strong>SDK</strong>” and “C/C++ <strong>SDK</strong>” will beused interchangeably.This manual assumes that the programmer is familiar with the C programming language. No instructionsare given on the use of the C programming language. If the user is not comfortable using C, a review ofrelevant reference material is strongly recommended.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 3


What You Receive with the<strong>CompuScope</strong> <strong>SDK</strong> forC/C++ for WindowsAlong with this guide, you should receive the following items when you purchase the <strong>CompuScope</strong> <strong>SDK</strong>for C/C++ for Windows:• <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows disk(s).• <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows <strong>Manua</strong>l. (Volume I)• <strong>CompuScope</strong> Applications Programming Interface (API) Reference <strong>Manua</strong>l (Volume II)Page 4<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Chapter 2: Basic<strong>CompuScope</strong>Operation


Basic <strong>CompuScope</strong>Operation<strong>CompuScope</strong>s are a line of ultra-fast PC-based A/D or oscilloscope cards. Installed in a standard PC,<strong>CompuScope</strong> hardware is able to acquire analog signals at very high sampling speeds on a large number ofchannels with a very high vertical resolution into extremely deep memory buffers. A key advantage of thePC-based <strong>CompuScope</strong> is its extremely fast data transfer rate to PC RAM from where data can be easilyanalyzed, stored or displayed. No auxiliary data connection, such as a GPIB interface, is required since the<strong>CompuScope</strong> plugs directly into the PC add-on card slot, which explains its high data transfer ratecapability. This section introduces basic signal capture methods using <strong>CompuScope</strong> hardware. There arealso digital <strong>CompuScope</strong> models like the <strong>CompuScope</strong> 3200, which allow capture of digital multi-bitsignals.Below is a diagram that illustrates a simplified schematic of a generalized analog input <strong>CompuScope</strong> card.Most <strong>CompuScope</strong>s have two input channels. The signal connected to each BNC input channel is initiallysignal conditioned. This consists generally of three steps. The input termination can be selected as 1MOhm, for minimal signal loading, or 50 Ohms, for impedance matching with the 50 Ohm signal cable,The input coupling can be programmatically selected as DC or AC. Finally, the input range can beprogrammatically selected, which switches in an appropriate gain amplifier.The Analog-to-Digital Converter (ADC) takes in analog signals and puts out digital signal at the specifiedclock rate. Data are then latched to ADC’s memory. Most <strong>CompuScope</strong>s are equipped with two ADCchips and their associated memory banks.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 7


<strong>CompuScope</strong> A/D cards generally operate in two capture modes – single and dual channel modes. In thedual channel mode, the two on-board A/D digitize the analog signals from the two input channels. The firstADC, labeled as ADC 1, digitizes the input analog signal on channel 1 while ADC 2 digitizes the inputanalog signal on channel 2. Both ADCs are synchronized using exactly the same clock signal so that notiming disparity exists between the digitized data from the two ADCs. Sampling is truly simultaneous onboth channels.In the single channel mode, however, the input analog signal is internally connected to both ADCs. Thetwo ADCs are then clocked 180 degrees out of phase. When the acquisition starts, at the first rising edge ofthe clock, the signal from Channel 1 is sampled by ADC1 and the digital data are stored in memory bank 1.The next sample is digitized by the ADC2, whose clock signal is inverted with respect to ADC 1’s clockand the digital data are stored in memory bank 2. This process is then repeated until acquisition iscomplete. This method is referred to as ping- ponging of the ADCs, meaning that both ADCs digitizealternate data points from channel 1. After acquisition, the data from memory banks 1 and 2 areinterleaved to yield a record that was effectively sampled at twice the ADC clocking frequency. This iswhy most <strong>CompuScope</strong>s in single channel mode can sample at double the maximum rate possible in dualchannel mode.There are two basic methods of acquiring data records using a <strong>CompuScope</strong>: Single Record Mode andMultiple Record Mode. These are described in the next two sections.Single Record ModeSingle Record Mode is the simplest method of acquiring data records with a <strong>CompuScope</strong>. In the singlerecord, a <strong>CompuScope</strong> card digitizes the analog signal on one or two channels. The digitized data arestored in the on-board memory of the <strong>CompuScope</strong> card. The data are then downloaded to PC memory forpost-processing after the acquisition ends. The card is now ready for next acquisition. The time taken tocapture and download a record, is dependent primarily on the size of the record captured and on bus datatransfer speed.In Single Record Mode, the <strong>CompuScope</strong> is able to capture both pre and post trigger data points in eithersingle or dual channel mode. For single channel capture, the entire memory depth can be used for thecaptured record. . For dual channel capture, the memory must be shared between both channels so that themaximum capture length is one half of the total on-board memory.It is straightforward to understand that the time taken by the <strong>CompuScope</strong> to get ready for next acquisitionincreases with the length of the captured record. Thus the single record mode may not be the best methodfor capturing signals whose triggers repeat at a high rate. Gage <strong>CompuScope</strong>s have a unique feature calledMultiple Record, which allows capture of successive records in the on-board memory for fast trigger rateapplications. A detailed explanation of Multiple Record feature for the <strong>CompuScope</strong> cards is provided inthe next section.Multiple RecordIf a signal trigger repeats very quickly, there may not be enough time to transfer the captured data to PCmemory before the next trigger occurs. For such fast trigger requirements, Gage <strong>CompuScope</strong>s can beoperated in Multiple Record Mode.In Multiple Record Mode, successive acquisitions are stacked in the <strong>CompuScope</strong>’s on-board memory.Between successive acquisitions, the <strong>CompuScope</strong> re-arms itself to await the next trigger with no CPUinteraction required. This hardware re-arm typically takes place in under 16 sample points, which isusually well under 1 microsecond for the higher sampling rates.Page 8<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Multiple Record capture can continue until the <strong>CompuScope</strong> memory is full. So, for instance, a<strong>CompuScope</strong> with 1 MegaSamples of on-board memory can capture up to 1000 records of 1000 pointseach.Please note that no pre-trigger data are acquired in Multiple Record Mode.The diagram below shows a typical repetitive signal. The figure also shows the contents of <strong>CompuScope</strong>memory if the signal were to be acquired in Multiple Record Mode.Master/Slave Multi-Card SystemsOne of the most unique features of the <strong>CompuScope</strong> cards is the Multi-Card system that can be configured.A Multi-Card system, consisting of one Master and multiple Slave <strong>CompuScope</strong>s, can be ordered from thefactory if the user wants to capture more than two channels with a common clock and trigger. Each<strong>CompuScope</strong> in the system must be of the same model number and memory size. Sampling and triggeringis always simultaneous in a Master/Slave <strong>CompuScope</strong> system.A board-to-board interconnect is supplied with a Master/Slave <strong>CompuScope</strong> system. This interconnectscarries all the timing signals required for proper inter-<strong>CompuScope</strong> synchronization. Gage’s proprietaryrigid bridgeboard technology ensures proper distribution of the sampling clock and trigger signal from theMaster <strong>CompuScope</strong> to all the Slave <strong>CompuScope</strong>s.The <strong>CompuScope</strong> Windows drivers are built to naturally support a single Master/Slave <strong>CompuScope</strong>system. GageScope ® , the World’s Most Powerful Oscilloscope Software, can display up to 32 channelsfrom all boards in a <strong>CompuScope</strong> Master/Slave system on the same screen. The C/C++ <strong>SDK</strong> containsexplicit sample programs for Master/Slave <strong>CompuScope</strong> systems.Multiple Independent Multi-Card SystemsIndependent <strong>CompuScope</strong> cards of different types and memory sizes can be operated within the samecomputer chassis. Such a configuration is referred to as a Multiple Independent Multi-Card system of<strong>CompuScope</strong>s. Each <strong>CompuScope</strong> can be operated with a different sampling rate, trigger source, inputrange etc.A Multiple Independent <strong>CompuScope</strong>s system is useful for experiments where signals of a different naturemust be acquired. For instance, a user might have to acquire high speed raw RF communication signalswith a <strong>CompuScope</strong> 82G and at the same time acquire lower speed demodulated audio signals with a<strong>CompuScope</strong> CS1610.The <strong>CompuScope</strong> Windows drivers are able to support a single Multiple Independent <strong>CompuScope</strong> system.GageScope ® supports Multiple Independent systems and displays the signals from each <strong>CompuScope</strong> in aseparate display Window. The C/C++ <strong>SDK</strong> contains explicit sample programs for Multiple Independent<strong>CompuScope</strong>s system.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 9


Multiple <strong>CompuScope</strong> SystemsThe <strong>CompuScope</strong> Windows drivers are designed to support a single <strong>CompuScope</strong> system. A single<strong>CompuScope</strong> system is defined as one of the two following configurations:1. A single Master/Slave Multi-Card <strong>CompuScope</strong> System2. A system consisting of Multiple Independent single <strong>CompuScope</strong> cards.The <strong>CompuScope</strong> drivers do NOT support the simultaneous configuration and operation of MultipleSystems. So, for instance, the drivers do not support a computer equipped with a 2 board Master/SlaveCS8500 system AND a 4 board Master/Slave CS14100 system. Similarly, the drivers do not support acomputer equipped with a 6 board Master/Slave CS12100 system AND two independent CS82Gs.It is possible to equip a computer with multiple <strong>CompuScope</strong> systems and operate them at different timesduring different measurement sessions. This is possible using the CP5000ED.EXE <strong>CompuScope</strong>Enable/Disable utility that is included with the <strong>CompuScope</strong> drivers. CP500ED.EXE can be used todisable a certain <strong>CompuScope</strong> model so that the drivers do not detect it.Suppose that a user had a computer equipped with a 4 board Master/Slave CS1602 system and a 2 boardindependent CS85Gs. For a low speed experiment, the user could run CP500ED.EXE to disable theCS85G model so that the drivers did not detect the two CS82Gs. The user could then operate the CS1602Master/Slave system, as usual. For a high-speed experiment, the user could run CP500ED.EXE anddisable the CS1602 model. The drivers would then not detect the CS1602 system and the user couldoperate the two CS85Gs as a Multiple Independent system. After each change, the <strong>CompuScope</strong> hardwarewould have to be correctly software configured using the configuration utility described in the<strong>CompuScope</strong> Driver Installation Guide.Page 10<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


PCI Bus <strong>CompuScope</strong>sPCI BusThe PCI bus is a processor-independent, multi-mastering 32 bit synchronous bus running at 33 MHz.The PCI bus can be found in almost any new personal computer, be it a Pentium-based or PowerPC orAlpha-based computer.A 64 bit extension of PCI is also becoming available. Similarly, 66 MHz bus speed will also be supportedby many motherboards.One of the main reasons for the popularity of PCI is the fast data throughput it offers between add-ondevices, such as video and SCSI controllers or <strong>CompuScope</strong> cards, and the CPU.The CompactPCI bus is electrically almost identical to the PCI bus but has a different mechanical formfactor and comes housed in an industrial quality chassis. CompactPCI (cPCI) card modules are installablefrom the front panel.PCI Local BusA Simplified Block DiagramPCI-ISA BridgePCI Slot 3PCI Slot 2ISA1ISA2ISANPCI Slot 1CPUCACHEPCIChipsetPCIChipsetSystem MemoryPlug-n-PlayAnother impressive feature that PCI brings to the PC platform is true plug-n-play capability. The user nolonger has to play with DIP switches to set addresses on the add-on cards — the system configures itself!At boot-up time, the PCI BIOS queries all add-on cards for the resources they need: I/O space, memoryspace, interrupts lines, etc. All add-on cards must be able to answer this query if they are to be deemed PCIcompatible.Once the BIOS knows the complete list of resources needed by the add-on cards, it configures the systemby assigning mutually exclusive resources to different add-on cards. All add-on cards must be able toaccept the base addresses provided by the BIOS for communicating with their resources.In other words, PCI cards must not be hard-wired to specific I/O or memory addresses or interrupt lines.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 11


Plug-n-Play is an inherent part of the PCI specifications. Any add-on cards, which do not adhere to itsprotocols, are not PCI-compliant.DMA or Bus-Mastering on the PCI BusDirect Memory Access (DMA) is a technique by which two system resources on a bus can transfer databetween themselves without any CPU involvement.In the PCI bus specification, these two devices are called “initiator” and “target,” i.e. the initiator devicetakes control of the data, address and control lines of the bus and writes the data to the target device.The PCI Bus implements DMA by allowing any device to become a bus-master and write data to a targetdevice. The correct PCI language for DMA is PCI bus-mastering.A PCI Bus-master is a hardware device that takes control of the data, address and control lines of the busand uses them to transfer data to a target device. A PCI Slave is a hardware device in a bus-based systemthat accepts data transfers coming from a Master. A slave is almost always a “target” device.A good analogy of bus-mastering exists in most businesses in the shape of a telephone system. Officesgenerally have a receptionist who answers all incoming calls and directs them to different employees,depending on whom the caller wants to talk to.This is a good example of Slave mode operation. The receptionist is the “Central Processing Unit (CPU)”of the system, all the employees are “target devices” and the caller is the “initiator.”Slave mode does not require very sophisticated hardware, but requires considerable “processing power”(the receptionist’s time) and slows down the routing of the “transactions” (calls).Some companies have implemented “Direct Inbound Dialing (DID)”, a system in which each employee hasa unique telephone number. A caller can reach an employee, without having to go through the receptionist,by dialing their number.DID is analogous to bus-mastering: the “initiator” (caller) takes control of the bus (the telephone line) andconnects with the “target” (employee) without having to disturb the CPU (receptionist).It is fairly clear that bus-mastering is more efficient not only because the CPU (receptionist) can do othertasks while all the bus transactions (calls) take place, but also because it is faster.The obvious question, which arises in the case of a Multi-Master bus, is; how is the bus arbitrated? In otherwords, how does the system know who is the current bus-master and how does a device become a busmaster?The arbiter is always included with the motherboard or CPU card. Unfortunately, there is no clearspecification for bus arbitration in PCI, so the exact schemes are dependent upon the motherboard or CPUbeing used. Nonetheless, bus arbitration is almost always handled in a safe and predictable manner,making PCI a very stable and well-defined system.The PCI bus allows any of the system resources to become a bus-master. For example, it is possible for anadd-on card, such as a <strong>CompuScope</strong>/PCI, to be a master at one point in time and another add-on card, suchas a DSP card, to be the master at a later time. Naturally, the CPU is also allowed to be the bus-master.Page 12<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Memory Mode Operation of the PCI Bus <strong>CompuScope</strong>CardsIn memory mode, PCI Bus <strong>CompuScope</strong> cards digitize the analog signal and store the resulting digital datain on-board memory. This memory can be accessed by the CPU (or any other PCI device) only after theacquisition has stopped.A/DRAMP C I B U SOn-board <strong>CompuScope</strong> memory is therefore single-port memory. If the A/D is writing into it, neither theCPU nor any other PCI device can access it.The on-board memory is designed to accept data from the A/D converters at the highest sampling speeds ofthe card. For example, the on-board memory on <strong>CompuScope</strong> 8500 has a cycle time of 2 nanoseconds per8 bit sample, or 500 MB/s.The maximum record length of the signal being captured by a PCI bus <strong>CompuScope</strong> card is determined bythe amount of on-board memory. The captured data can than be transferred to the PC memory at the speedallowed by the PCI bus. In bus-mastering mode, a <strong>CompuScope</strong> card is capable of sustained PCI datatransfer rates of up to 100 Megabytes/sec (depending on the motherboard). In Slave mode, the transfer rateis up to 10 Megabytes/sec.Data throughput across the PCI BusThe PCI bus is capable of transferring data from an add-on card to the CPU memory using either Slave orMaster moves. PCI Bus <strong>CompuScope</strong> cards allow both types of data transfers to take place. Anapplication program can select which mode to use by using a driver function. This driver function writesthe appropriate control words into the PCI controller on-board the <strong>CompuScope</strong>/PCI cards.Number of PCI Slots in one ChassisThe PCI bus can usually have no more than 3 or 4 add-on slots, due to the unterminated nature of the bus.Each add-on device has strict restrictions on how much it can load the bus.It is possible to have more than 3 or 4 PCI slots on the same backplane if the slots are part of differentbuses (called peer buses) and each bus has no more than 3 or 4 peer slots. For instance, a Gage InstrumentMainframe is available with 16 contiguous PCI slots.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 13


On-Board MemoryOrganization of the<strong>CompuScope</strong> CardsThe A/D speeds at which <strong>CompuScope</strong> cards produce digital data can be too fast for the IBM PC bus. Themaximum transfer rate for the PCI bus is approximately 120 Mbytes/second while the maximum transferrate for the ISA bus is approximately 1.5 Mbytes/second. Consequently, all the <strong>CompuScope</strong> boards havehigh-speed on-board memory to store the digital data. The PC only accesses this data after the acquisitionis over.A/D Data StorageData from the <strong>CompuScope</strong> A/D converters are stored in on-board Static Memory (SRAM), which isconfigured as a circular buffer. A circular buffer is used to allow capture of data before a trigger event isdetected.The sequence of events that occur during a <strong>CompuScope</strong> data capture is as follows. This is list of low-levelsteps given purely for illustrative purposes. <strong>CompuScope</strong> users implement high-level driver subroutinecalls, which typically execute several low-level steps at once.—The PC’s CPU tells the <strong>CompuScope</strong> to GET DATA using the Get Data bit.—The BUSY flag is set by the <strong>CompuScope</strong> so that the PCI bus is denied any further access to the onboardmemory.—The on-board memory counters are initialized to ZERO by software and start counting up, therebystarting data storage at memory address ZERO.—The system waits for a trigger event to occur while it is storing data in the on-board memory. These dataare called Pre-Trigger data.—When the trigger event occurs, the on-board memory counter value is stored as the trigger address.—Once the trigger event occurs, a specified number of Post Trigger points are captured. The number ofPost Trigger Points were previously specified by writing to the registers on the <strong>CompuScope</strong>.—After capturing and storing the specified number of Post Trigger Points, acquisition is terminated. TheBUSY flag is then reset and the PCI bus is allowed to access the on-board memory.A graphical representation of the above sequence is shown below:Page 14<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


In the diagram, the circular memory buffer is shown as an annulus with the physical memory addressZERO at the bottom. Data storage is shown as a spiraling line going counter-clockwise. Storage starts ataddress ZERO and keeps on writing into the memory until it is filled (the spiraling line completes a circle).With memory filled, the <strong>CompuScope</strong> then starts overwriting the data stored in addresses ZERO, 1, 2, .…At the instant when a trigger event is detected, the current memory address is tagged as the TriggerAddress. A specified number of Post Trigger points are captured and then the acquisition is stopped.The memory address at which the acquisition is stopped is designated as the End Address and the addressafter that one is called Start Address. The Pre Trigger data lies between Start Address and Trigger Address.The Post Trigger data lies between Trigger Address and End Address.It is clear from the diagram shown above that memory address ZERO is not necessarily the first point, orStart Address, of the signal being captured. In fact, the physical address ZERO has very little significancein such a system, since the trigger can happen at any time.ZERO is the Start Address when a trigger is received right after the CPU tells the <strong>CompuScope</strong> to GETDATA and data storage stops before the memory has been filled up. This situation is illustrated below:The memory fail condition can be detected by polling at the RAMFULL bit in the STATUS registers. TheRAMFULL bit is reset to ZERO when a GET DATA command is issued and is set to ONE when the<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 15


memory counter overflow rolls over to zero. In the second diagram, Pre-Trigger data lies between ZEROand Trigger Address and Post Trigger between Trigger Address and End Address.Timing Diagrams for <strong>CompuScope</strong> CaptureAt the start of capture on the <strong>CompuScope</strong> board, the GET DATA signal is strobed low. This clears theTRIGGER and RAM FULL signals and their status bits and initializes the data acquisition counters toZERO. The BUSY signal and its status bit are now set to high. At this point, the data conversion processbegins and data are stored in the on-board memory at each sample clock. The memory is configured as acircular buffer.At some point a trigger event occurs. This starts another counter (one section of an 8254 counter chip).This is the sample depth counter. When it expires, the BUSY signal and status bit are cleared, which endsthe data acquisition process. A complete timing diagram illustrating a data acquisition in which memorydoes not get filled is shown below.Page 16<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


<strong>CompuScope</strong> Timing Diagram: RAMFULL = 0STARTGET DATARAM FULLTRIGGERBUSYTime to AcquirePre-Trigger DataTime toAcquireDesired No.of SamplesPre-Trigger: Not All Data Points in Buffer ValidMemoryAddressZeroTrigger!Capturestops.BufferEndAddressTriggerAddress= valid pretrigger data= valid post trigger data= valid data<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 17


If during the data acquisition the sample counter causes the memory to roll over, the RAM FULL status bitwill be set, indicating that all of the data acquisition memory contains valid data for this acquisition. TheRAM FULL status bit is used, along with the trigger address (which contains the value of the samplecounter at the time of the trigger event), to establish the starting address, trigger address and endingaddress. The following diagram illustrates data acquisition where on-board memory is completely filled.Page 18<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


<strong>CompuScope</strong> Timing Diagram: RAMFULL = 1STARTGET DATARAM FULLTRIGGERBUSYTime to acquirePre-Trigger dataTime toAcquireDesired No.of SamplesPre-Trigger: All Data Points in Buffer ValidCircular bufferfilled onceMemoryBuffer startsrecording dataat memoryaddress 0Buffer continuesto fill until triggeror abortAddressZero0Trigger!0BufferBufferTriggerAddressCapture stops.EndAddress= valid pretrigger data= valid post trigger data= valid data<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 19


On-board Memory: A Programmer’s ViewThe total memory on a two-channel <strong>CompuScope</strong> card is divided between the two A/D converters on theboard. For instance, a 256M two-channel <strong>CompuScope</strong> card devotes 128M of memory to converter A and128M to converter B.In dual channel mode, each input channel is routed to one of the two converters. Consequently, channel #1captures its data into the memory for converter A and channel #2 captures its data into the memory forconverter B. In single channel mode, however, channel #1 is routed to both A/D converters. Consequentlyboth converter memories contain data from channel #1. Even points are stored in converter A’s memorywhile odd points are stored in converter B’s memory. Single channel <strong>CompuScope</strong>s, like the CS8500, onlyhave one A/D converter so that the memory is not divided as usual.The addresses returned from the routine gage_calculate_addresses represent the trigger address, thestarting address and the ending address of the captured data. These addresses can then be used to loopthrough the desired locations to retrieve the captured data.Gage_mem_read Data Transfer RoutinesThe simplest data transfer routines are the gage_mem_read routines. This family of subroutines transfers asingle data point from <strong>CompuScope</strong> memory to the user buffer. The routines support all classes of<strong>CompuScope</strong> cards – PCI, cPCI, ISA and ISA/PCI. The are ideal for transferring small quantities of databut do not take advantage of high-speed data transfer techniques like PCI bus-mastering. There areseparate gage_mem_read routines for single and dual channel mode.Although the gage_mem_read_single routine returns one point at a time, internally the routine stilltransfers a full four Kilosample block of memory. This speeds up the access to the <strong>CompuScope</strong> memorydramatically for data that is accessed sequentially. Gage_mem_read_single is the preferred method formost applications that need to use discrete data points, since the data are corrected by the driver for anyidiosyncrasies in memory layout and polarity. The data are always returned as integers with the smallestvalue representing the highest voltage and the largest value representing the lowest voltage.As discussed previously, care must be taken to wrap around at the end of the memory address space. Thisis usually done by using the MOD function with the index and gdi.max_available_memory. If thememory depth is a power of 2, then a faster way is to use the AND function withgdi.max_available_memory - 1.location [max_available_memory - 1]location [max_available_memory - 2]location [0]location [1]If one of the block transfer routines, gage_trigger_view_transfer, gage_transfer_buffer or a user-definedroutine is used, then the memory is split between channel A and channel B.As discussed, in single channel mode, the data are divided between the two converter memories, with thefirst data point in converter A memory, the second in converter B memory, the third in A, etc., as shownbelow.Converter A Data 0 Data 2 Data 4 Etc.Converter B Data 1 Data 3 Data 5 Etc.Page 20<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


As mentioned above, using the gage_mem_read subroutines, <strong>CompuScope</strong> cards internally transfer a 4Kilosample block of memory. Sample size is one byte for 8 bit cards and two bytes for 12, 14 and 16 bitcards. Specific blocks can be accessed by using the driver routine called gage_set_block_number. Thememory blocks are organized with all of converter A's data occupying the first set of four kilobyte blocksup to the total size of one converter's maximum memory size. The same number of blocks are available forconverter B.For example, a 16K <strong>CompuScope</strong> card would have 16K / 4 Kilosamples = 4 blocks. In dual channel mode,half the blocks would belong to converter A and half to converter B. Block 0 and block 1 would belong toconverter A and block 0 + bank_offset_value and block 1 + bank_offset_value would belong toconverter B. In single channel mode, both converter memory banks are used by channel #1. The value ofbank_offset_value is defined in the source files for each <strong>CompuScope</strong> card and is available through thegage_driver_info_type structure.Gage_transfer_buffer Data Transfer RoutinesIn order to take advantages of high speed PCI bus-mastering data transfer, Gage provides block datatransfer routines called the gage_transfer_buffer routines.Gage_transfer_buffer() transfers data from a PCI or cPCI <strong>CompuScope</strong> using PCI slave mode transfer. Insingle channel mode, the user must call the routine twice, once for each A/D converter, and interleave thedata afterwards in order to reconstruct the complete signal. If used on ISA <strong>CompuScope</strong>s, this routineinternally defaults to gage_mem_read subroutines.Gage_transfer_buffer_2() transfers data from a PCI or cPCI <strong>CompuScope</strong> using PCI bus-masteringtransfer. In single channel mode, the user must call the routine twice, once for each A/D converter, andinterleave the data afterwards in order to reconstruct the complete signal. If used on ISA <strong>CompuScope</strong>s,this routine internally defaults to gage_mem_read subroutines.Gage_transfer_buffer_3() transfers data from a PCI or cPCI <strong>CompuScope</strong> using PCI bus-masteringtransfer. This routine handles the interleaving of the memory from both ADC converters in single channelmode and so only needs to be called once in single channel mode. Gage_transfer_buffer_3() is therecommended subroutine data transfer. Gage_transfer_buffer_2() should be used only if the user requiresthe highest possible transfer rate during a burst of triggers without wasting time interleaving and wants todo the interleaving after the burst is finished. If used on ISA <strong>CompuScope</strong>s, this routine internallydefaults to gage_mem_read subroutines.Other Data Transfer RoutinesOther data transfer routines such as gage_trigger_view_transfer() are still supported by the <strong>CompuScope</strong>drivers and are documented in the API manual. These routines have been maintained strictly to allowbackward compatibility for older customers and are not recommended for new designs. Generally,Gage_transfer_buffer_3() should be used for all new designs.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 21


<strong>CompuScope</strong> RepetitiveCapture PerformanceSince <strong>CompuScope</strong> cards are installed directly on the PCI or CompactPCI bus, their on-board acquisitionmemory can be accessed directly through this bus, without having to go through a GPIB or RS-232interface. This direct access allows data transfer rates that are hundreds of times faster than those of GPIBor RS-232. Fast data throughput is one of the key advantages of the PC-based <strong>CompuScope</strong> over thetraditional stand-alone oscilloscope interfaced to a PC through a GPIB or RS-232 interface.Applications that require fast data throughput are generally those in which the user must capture recordsthat occur at a high Pulse Repeat Frequency (PRF). Working in <strong>CompuScope</strong> Single Record mode, theuser must be able to transfer the data from <strong>CompuScope</strong> acquisition memory to PC RAM and re-arm the<strong>CompuScope</strong> in time to be ready for the next trigger. If the data throughput is not fast enough, then the<strong>CompuScope</strong> will not be prepared for the next trigger and the trigger will be missed.One application that makes use of the high data throughput of <strong>CompuScope</strong> cards is radar signal processingor any other application which requires short bursts of data to be captured at very high repeat frequencies.A typical example is a radar system which requires capture of 64 point bursts at least a few thousand timesa second. This application requires development of a custom <strong>CompuScope</strong> Windows application. This isvery easy using the example C programs provided by the <strong>CompuScope</strong> <strong>SDK</strong>.While the performance of a <strong>CompuScope</strong> card is deterministic in single-tasking operating systems such asMS DOS, its performance is not deterministic under MS Windows – a non-Real-Time multi-taskingoperating system. The uncertainty arises because of the indeterminate time during which a Windowsprocess may be ”put to sleep” while Windows services other processes. In a Real-Time Operating System(RTOS), such as QNX or RealTime Linux, the operating system can guarantee a worst case “process sleeptime”. In a non-RTOS like Windows, however, no such worst-case sleep time can be guaranteed.Consequently, even though a <strong>CompuScope</strong> may in theory meet certain transfer speed performancebenchmarks, no such performance can be guaranteed under Windows Practically, performance is heavilydependent on the type of Windows operating system and on system configuration. In addition, furtherreduction in performance occurs due to the overhead of calling Windows Kernel-level driver functionsthrough the Dynamically Linked Library (DLL) from the application or user level. Each subroutine call tothe drivers requires crossing of the user/Kernel boundary, which has an associated boundary crossing timethat is at least a few microseconds. This boundary crossing time is also dependent on the OS and systemconfiguration.Typically, customers who do repetitive signal capture want to know what is the maximum Pulse RepeatFrequency (PRF) that can be achieved for their <strong>CompuScope</strong> card. As discussed, the PRF calculation is100 % reliable only for operation under DOS. Under Windows, due to its non-RealTime nature,deterministic operation cannot be guaranteed. No matter how slow the trigger rate is, the possibility alwaysexists of missing triggers. However, PRF calculations can be used as a reliable guide to determine averagerepetitive capture performance under Windows.The minimum Pulse Repeat Interval (PRI) is equal to the time required to completely handle one triggerand re-arm for the next one. The minimum PRI is equal to the sum of the capture time, which is the timerequired to capture the signal, the transfer time, which is the time required to transfer the signal data from<strong>CompuScope</strong> acquisition memory to PC RAM and the overhead time, which is the time required to re-armthe <strong>CompuScope</strong> for the next acquisition. The minimum PRI increases with the post-trigger depth, theamount of data to be transferred, the number of acquisition channels and the number of Bytes per Sample(1 for 8 bit <strong>CompuScope</strong>s, 2 for <strong>CompuScope</strong>s with more than 8-bit resolution).The capture time calculation is straightforward. The transfer time is determined using the PCI busmasteringtransfer rate. <strong>CompuScope</strong>s can achieve sustained PCI bus-mastering transfer rates of up to 100Page 22<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Mega Bytes/second (MB/s). The overhead time includes such constants as the trigger re-arm time and thePCI transfer setup time. The overhead time varies for different <strong>CompuScope</strong> models and is higher in aWindows environment compared to under DOS because of additional subroutine call overhead.As an example, let us assume that a user who must capture rapidly repeating triggers with an 8 bit PCI<strong>CompuScope</strong> 82G and wants to know the maximum achievable PRF. Assume further that the user mustcapture 25 µs records in single channel mode at a 2 GS/s sampling rate. In a Windows environment, Gageengineers have shown that, for single channel acquisition, the CS82G is able to sustain a PCI bus–mastering transfer rate of up to 80 MB/s. The overhead time for the CS82G in single channel acquisitionmode in a Windows environment is about 200 µs (about 50 µs of which, for instance, is the time requiredto set up the PCI bus-mastering data transfer).For this example, therefore, the PRF calculation is:CAPTURE TIME = 25µs [ 2000 MS/s × 25µs = 50000 samples ]+ TRANSFER TIME = 625 µs [ 50000 Samples × (1 channel) × (1 Byte/Sample)/(80 MB/s) ]+ OVERHEAD TIME = 200µsMINIMUM PRI = 850 µsSo, the MAXIMUM PRF = 1/ MINIMUM PRI = 1/850 µs ≈ 1.2 kHzSo the customer should be able do repetitive capture under the stated conditions at a PRF of up to 1.2 kHz.The above calculation makes three assumptions.First, we have assumed that the user’s PC has a PCI bus that can sustain an 80 MB/s data transfer rate.Some older desktop PCs could only sustain a 50 MB/s PCI transfer. <strong>CompuScope</strong>s will operate correctlyin such a PC, but the data transfer rate will be bottlenecked by the capability of the PC. Most of today’sPCs can sustain PCI transfer rates of up to 100 MB/s.Secondly, we have assumed that the user wants to transfer the total post-trigger depth to PC RAM.Consequently, the number of Samples used in the capture time and transfer time calculations are the same.This need not be the case and the user may have needed, for example, to transfer only the last 5µs of the25µs capture. In this case, only 10,000 samples would have been used for the transfer rate calculation.Alternatively, the user may have wanted to transfer 25µs of pre-trigger data in addition to the all of thepost-trigger data. In this case, 100,000 samples would have been used for the transfer rate calculation.Finally, we have assumed that data records are only transferred to PC RAM, where they are accumulated ina large buffer that can be manipulated after the repetitive capture sequence ends. Any additional operationsthat are performed during the acquisition sequence such as data analysis, display or disk storage must beincorporated into the above calculation.Gage engineers have performed extensive PRF benchmarks on <strong>CompuScope</strong> cards. The graph belowshows the results of a PRF benchmark measurement on a <strong>CompuScope</strong> 82G operating under Windows NTin a 600 MHz Pentium III with 128 MB of PC RAM. A PRF benchmark software utility rapidly acquiredmany records and accumulated the transferred data in PC RAM. No operations were performed on the dataduring the acquisition sequence and no non-essential Windows processes were active while the PRFbenchmark program was operating. Furthermore, the benchmark program used thegage_init_clock/gage_get_data code sequence, rather than gage_start_capture in order to startacquisition for best performance. (See Starting an Acquisition in Chapter 0). Also, the programmaintained the power to ADC circuitry ON throughout the acquisition sequence for best performance. (Seethe Appendix: <strong>CompuScope</strong> Power Management).The calculation above suggested that the CS82G can capture 50,000 Sample records at 2 GS/s in singlechannel mode with a PRF of about 1.2 kHz. This value of 1.2 kHz is very consistent with the curve shownbelow for single channel acquisition. At very low capture depths, the PRF is limited by the overhead timeof 200µs. In fact, the overhead time can be defined as the PRF obtainable for the capture and transfer ofzero samples. The overhead time, therefore puts an absolute upper limit on the maximum PRF of 1/200µs= 5 kHz for the CS82G in single channel mode. This 5 kHz maximum PRF is consistent with the low<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 23


depth portion of the single channel curve below. Above depths of about 100,000 Samples, the curvebecomes linear on the logarithmic plot. This is the region in which the overhead time becomesinsignificant and the PRF is determined mostly by the capture and transfer times, both of which increaselinearly with the post-trigger depth. The maximum PRF curve for dual channel mode is lower than that forsingle channel mode. This is simply because twice as much data must be transferred in dual channel mode,which takes longer. Both the number of channels and the number of Bytes per Sample must always beincluded in the transfer time calculation.10000Dual Channel at 1 GS/sMax Pulse Repeat Frequency (Hz)1000100Single Channel at 2 GS/s101000 10000 100000 1000000 10000000Post Trigger Depth in SamplesFor customer with PRFs that are higher than those afforded using Single Record acquisition mode, the usermay operate a <strong>CompuScope</strong> using Multiple Record mode. In this mode, the maximum PRF is muchhigher, since data are not transferred between acquisitions but are stacked in on-board <strong>CompuScope</strong>memory and since re-arm is done in hardware with no CPU intervention required. However, since MultipleRecord operation accumulates data in <strong>CompuScope</strong> on-board memory, the length of the acquisitionsequence is limited by the size of this on-board memory. See sections of this manual on Multiple Recordfor further details.With both Single Record mode using PCI bus-mastering and with the powerful Multiple Record feature,Gage <strong>CompuScope</strong> hardware is able to provide the fastest available repetitive capture performance.Page 24<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Chapter 3:Introduction to<strong>CompuScope</strong>Windows Drivers andC/C++ <strong>SDK</strong>


Page 26<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


IntroductionWhat are the <strong>CompuScope</strong> Windows Drivers?A software driver is a layer of software that allows a Windows Application Program to communicate with aSystem Resource. For example, a software driver allows a word processor (Application Program) tocommunicate with a Printer (System Resource). Similarly, Gage’ <strong>CompuScope</strong> Windows Drivers allow auser’s application program to communicate with and control a <strong>CompuScope</strong> board.<strong>CompuScope</strong> C/C++ Software Development KitThere are many types of software drivers available for data acquisition cards: Some vendors supply sourcecode drivers, others supply object code and yet others supply a library or a system-level device driver.Obviously, source code drivers are the most flexible from the user’s point of view. For example, code canbe optimized for critical applications and compiled with the rest of the program, eliminating the need forloading drivers before running the application.For Windows applications, Dynamically Linked Libraries (DLLs) are the most convenient for a user, sincethe operating system (OS) does not allow the user application to access the hardware directly. A DLLhandles all the OS-related protocols for these accesses and provides the user with a simple set of high-levelsubroutine calls with which to control the hardware.The <strong>CompuScope</strong> C/C++ Software Development Kit (<strong>SDK</strong>) is a set of files that are used for programdevelopment with Gage’s line of <strong>CompuScope</strong> high-speed data acquisition cards. The C/C++ <strong>SDK</strong> can beused under a C or C++ development environment, such as MicroSoft Visual C/C++ or Borland C builder.The <strong>CompuScope</strong> C/C++ <strong>SDK</strong> supports multiple <strong>CompuScope</strong>s model in addition to Multi Card<strong>CompuScope</strong> systems. There are two types of <strong>CompuScope</strong> Multi Card systems – Master Slave systemsand Multiple Independent systems – which are described earlier in this manual. From the programmer’spoint of view, however, only one <strong>CompuScope</strong> is accessible by a software application at any one time.The sample programs in the <strong>CompuScope</strong> C/C++ <strong>SDK</strong> are built upon the subroutines that comprise the<strong>CompuScope</strong> Applications Programming Interface (API). This set of subroutines is the gateway thatprovides access from the user's Windows software application, through the DLL to the low level<strong>CompuScope</strong> Windows drivers. The subroutines of the API are thoroughly documented in the<strong>CompuScope</strong> API Reference <strong>Manua</strong>l. Gage has implemented one single API for all <strong>CompuScope</strong> models.This means that a user application can be easily upgraded from one <strong>CompuScope</strong> model to another, inmany cases without changing a single line of the application code.The <strong>CompuScope</strong> C/C++ <strong>SDK</strong> includes complete sample projects for Visual C/C++ Version 5.0. Other Ccompilers, such as Borland C Builder, can also be used, but the user must construct their own project files,simply by collecting all the relevant files manually under the preferred compiler environment. Otherprogramming environments that can make calls to a Windows DLL can use the <strong>CompuScope</strong> <strong>SDK</strong> as aguide on how to do so. Such programming environments include Visual BASIC for Windows,LabWindows/CVI and DELPHI.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 27


Sample Programs Folder Structure used in<strong>CompuScope</strong> <strong>SDK</strong>sThe default directory for the <strong>CompuScope</strong> C/C++<strong>SDK</strong> sample programs is C:\Gage\<strong>CompuScope</strong> <strong>SDK</strong>for Windows\<strong>SDK</strong> for C-C++\. There are several example programs provided with the <strong>CompuScope</strong>C/C++ <strong>SDK</strong>. These sample programs each reside in their own Windows folder and acquire data usingseveral unique features of the <strong>CompuScope</strong> cards. Each folder contains all the files that are required tocompile the project in MS Visual C/C++.Each sample program is written to highlight a particular feature of the <strong>CompuScope</strong> hardware. Forexample, the gage_busmastering project is the simplest sample program that captures a signal on a single<strong>CompuScope</strong> card (in dual or single channel mode) and writes the data from all active channels to separateASCII data files. Data transfer is done using PCI bus-mastering.The list of all files contained in the gage_busmastering folder is as follows:Gage_busmasteringGage_busmastering.dswGage_busmastering.dspGage_busmastering.cGage_busmastering.hApp_supp.cApp_supp.hEeprom.hGage_drv.hGage_drv.libStructs.cStructs.hWhichdrv.hDebugGage_busmastering.exeGage_busmastering folder contains a subfolder named Debug. Debug folder consists of thegage_busmastering.exe, an executable built from the gage_busmastering project.The gage_busmastering project can be opened either by clicking on the gage_busmastering.dsw file or fromwithin the MS VC environment. If the project file gage_busmastering.dsw is opened in MS Visual C/C++and is rebuilt, then the executable will be created in the Debug folder.The layout of all other sample programs follow the same format as the one described above for thegage_busmastering project. Sample programs provided with the <strong>CompuScope</strong> C/C++ <strong>SDK</strong> have beenbuilt in the Microsoft Visual C 5.0 environment. These sample projects can also be compiled usingBorland Compiler. In order to do this, the user must simply collect the files required for the project andcreate a Borland project. Furthermore, the GAGE_DRV.LIB file must be modified using the IMPLIBfunctionality.Page 28<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Common Files used in <strong>CompuScope</strong> C/C++ <strong>SDK</strong>sThe <strong>CompuScope</strong> C/C++ <strong>SDK</strong> source code is compiled with the so-called "<strong>CompuScope</strong> common files".The common files compiled into a C application program and those that have been compiled into the<strong>CompuScope</strong> drivers MUST be the same. Otherwise, application/driver incompatibility may result. Thecurrent are listed below:Eeprom.h,Gage_drv.h,Gage_drv.lib,Structs.c,Structs.h,Whichdrv.hGagePlus.hGageEx.libThe <strong>CompuScope</strong> C/C++ <strong>SDK</strong> and driver version naming scheme is the following: MAJORNUMBER.MINOR NUMBER.PATCH NUMBER. For instance, for the <strong>CompuScope</strong> driver version3.46.02, MAJOR NUMBER = 3, MINOR NUMBER = 46 and PATCH NUMBER=02. If the majornumber or minor number changes, the common files have been changed. For instance, <strong>CompuScope</strong> driver3.46.02 and C <strong>SDK</strong> version 3.46.00 share the same common file, while <strong>CompuScope</strong> driver 3.46.02 and C<strong>SDK</strong> version 3.50.00 do not.If you update your driver, to a version with newer common files, then your C application program mustalso be updated. For instance, if you developed an application using C <strong>SDK</strong> version 3.46.00 and you haveupgraded your drivers to version 3.50.000, then you must update your application program in order to avoidincompatibility and potential incorrect operation.In order to remove incompatibility between <strong>CompuScope</strong> driver and <strong>CompuScope</strong> C/C++ <strong>SDK</strong>, you willneed to re-compile your C/C++ code with the common files associated with this new <strong>CompuScope</strong> driver.This will re-establish compatibility between your <strong>CompuScope</strong> C/C++ <strong>SDK</strong> and the <strong>CompuScope</strong> driver.For your convenience, the common files are installed with the <strong>CompuScope</strong> drivers in the C:\Gagedirectory. Simply copy these files into your application directory, overwriting the old ones, and recompile.Brief Description of the Common FilesThe <strong>CompuScope</strong> common files can be categorized as either source files, header files or library files. Abrief description of each common file is given as follows:Source File• Structs.cStructs.c is a source file that implements and initializes all useful data structures and variablesused to describe the <strong>CompuScope</strong> hardware capabilities and states. Examples includeboarddef, srtype and irtype structure types. These structure types are used by all sampleprograms provided in the <strong>CompuScope</strong> C/C++ <strong>SDK</strong>s for Windows. Please open the Structs.csource file in either a text editor (MS Note Pad, MS Word Pad, etc) or in the MS Visual Cenvironment to view the contents.Header Files• Eeprom.hEeprom.h is one of the header files provided with the <strong>CompuScope</strong> drivers. This file containsthe definition of constants determining OPTIONS supported by <strong>CompuScope</strong> hardware.These options include features such as Multiple Record, Master/Slave upgrade and Externalclock option. For a detailed list of possible hardware features provided, view the contents ofthis file in either a text editor or in the MS Visual C environment.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 29


• Gage_drv.hGage_drv.h contains global definitions of all constants, variables, and functions that can beused by an application programmer while using the <strong>CompuScope</strong> hardware. Examples includedefinitions for <strong>CompuScope</strong> driver error codes, buffer size, channel and mode options values,sample rate values, input range values, pre-defined post trigger values, and board type values.Global definitions for important structures such as gage_driver_info_type are also included.• Structs.hThe Structs.h header file defines all useful program structures and variables. Examplesinclude boarddef, srtype and irtype structure types. These structure types are used by allsample programs provided in the <strong>CompuScope</strong> <strong>SDK</strong>s for Windows. Please open Structs.hheader file in either a text editor (MS Note Pad, MS Word Pad, etc) or in the MS Visual Cenvironment to view the contents.• Whichdrv.hWhichdrv.h contains definitions for parameters that allow the <strong>CompuScope</strong> drivers to be usedunder several MS Windows operating systems. Definitions for platform-independentdatatypes and conventions for calling API calls are also included.• GagePlus.hGagePlus.h header file contains prototypes for the GAGEEX_API calls, which are used infunctions provided in the GageEx library file.Library Files• Gage_drv.libThis is a library file to be used with the Gage_drv.dll. It contains a library of Gage APIroutines that can be used by the application programmers during development processinvolving <strong>CompuScope</strong> cards.• GageEx.libThis is a library file to be used with GageEx.dll. GageEx.lib contains query functions thatreturn the capabilities of Gage <strong>CompuScope</strong> hardware. It is the generalization and abstractionof the <strong>CompuScope</strong> capability interface implemented in Structs.c.Page 30<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Chapter 4: Writing aC Application for<strong>CompuScope</strong> Cards


Writing a C Application for<strong>CompuScope</strong> CardsThis section explains how a typical application is written using the C source code in the <strong>CompuScope</strong>C/C++ <strong>SDK</strong>. For the complete explanation of the Gage API routines, please refer to the <strong>CompuScope</strong> APIReference <strong>Manua</strong>l. The basic algorithm for any sample data acquisition application within the C/C++ <strong>SDK</strong>is shown below:<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 33


Useful program structures and variablesUseful program structures and variables have been used in all C/C++ <strong>SDK</strong> sample programs. Threeimportant structures, boarddef, srtype and irtype, are defined and initialized in each sample project. Thesethree structures are explained in the first few pages of the Appendix: Data Structures Used by GageDrivers. It is not necessary to use these structures; they are provided as a convenience.Initializing the <strong>CompuScope</strong> driver and hardwareInitializing the <strong>CompuScope</strong> driver and hardware is accomplished in two parts. First, the location of theinstalled hardware in the I/O and memory maps is established. This is generally done by reading theGAGESCOP.INC configuration file to find out the memory segment and I/O addresses of <strong>CompuScope</strong>sinstalled in the system. GAGESCOP.INC is created and updated by ComuScopes configuration utilitiessuch as Gage Config and Instrument Manager. The second part is the actual initialization of thedriver/hardware.For most users, initialization of the <strong>CompuScope</strong> driver and hardware can be done with a single subroutinecall that has been created for the <strong>CompuScope</strong> C/C++ <strong>SDK</strong>. This function is called InitBoard() and itssource code is in the app_supp.c source file that is included with each C sample program. Users who wantto know more about the initialization procedure can read through the description of gage_driver_inititalizein the <strong>CompuScope</strong> API Reference <strong>Manua</strong>l. Most users needed not concern themselves with initializationdetails. The drivers and hardware need only be initialized once using within an application program usingInitBoard().Preparing the <strong>CompuScope</strong> Card for Data CapturePreparing the <strong>CompuScope</strong> card for data capture can be done at any time prior to starting a data acquisitionsequence. An attempt to change the board settings during data capture can result in a poor andunpredictable behavior.For most users, Gage recommends use of the function called SetBoard(). Its source code is in theapp_supp.c source file that is included with each C sample program. SetBoard() uses a structure calledboard that is defined within each sample program. The <strong>CompuScope</strong> settings in the board structure areactually implemented on the <strong>CompuScope</strong> hardware by SetBoard(). SetBoard() executes multiple GageAPI calls in the correct sequence in order to implement the requested settings. Users who want to do themultiple board setting calls themselves should be careful to respect the call order used in SetBoard().SetBoard() also handles both single board and multiple board Master / Slave configurations. Users whowant to know more about the <strong>CompuScope</strong> setup procedure can read through the following text. Otherusers can move to the next section.Three routines are used to implement the <strong>CompuScope</strong> settings.The first routine is the gage_capture_mode, which sets the <strong>CompuScope</strong> operating mode. The singlechannel operation mode is used when the full memory depth of the <strong>CompuScope</strong> or the maximum samplerate are required. If neither the full sampling rate nor full memory usage are required, then dual channeloperation mode is recommended in order to simplify data transfer.The sample rate is also set using gage_capture_mode routine. There are two parameters used when settingthe sample rate. The first is the base rate and the second is the multiplier. These values should use the predefinedconstants, as the srtable definition illustrates in the Appendix on <strong>CompuScope</strong> Data Structures.The second routine is the gage_input_control routine, which initializes the input parameters for eachchannel. This routine must be called once for each channel that needs its input parameters updated. If thesettings for channel A require adjustment and the single channel operation mode is being used then channelB must be initialized to the same settings. For instance, if you are capturing in single channel mode usingthe ± 1 Volt input range, then you must set both channel A and B for the ± 1 Volt input range.Page 34<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


The last routine, gage_trigger_control_2, is used to initialize the trigger circuitry. The external triggersource is configured with this routine along with the trigger, slope and threshold level that are used todetect trigger events. The number of samples to acquire after the trigger event, called the post-triggerdepth, is also set by this routine.The board settings will remain in effect between acquisitions. It is only necessary, therefore, to call theseroutines again when changes to the board parameters are required.Starting an AcquisitionThe gage_start_capture routine starts the <strong>CompuScope</strong> hardware acquiring pre-trigger data and awaiting atrigger event.This routine takes a parameter that is used to automatically start the data acquisition when the triggersource has been set to SOFTWARE. The software trigger may also be issued by callinggage_software_trigger after this routine, when the parameter passed is zero.When gage_start_capture finishes, the board has started its data acquisition sequence. This routine is agood candidate for optimization, since it does a lot of extra work ensuring that any <strong>CompuScope</strong> hardwaresystem (Master/Slave, Multiple Independent) is in a known state before trying to start the acquisition. For asystem consisting of only a single <strong>CompuScope</strong>, gage_start_capture can be replaced by gage_init_clockfollowed by gage_get_data. These two calls execute much faster than gage_start_capture. Please notethat a software trigger, if required, must then be issued explicitly.Completing an AcquisitionOnce acquiring, the <strong>CompuScope</strong> is generally queried repeatedly by the application in order to determine ifacquisition is complete. This is usually done in two steps. First, the <strong>CompuScope</strong> is polled until it hasbeen triggered using the gage_triggered routine. Once triggered, the <strong>CompuScope</strong> is polled until it is nolonger acquiring using the gage_busy routine.Usually, the application polls the <strong>CompuScope</strong> in a loop for a specified amount of time called the “timeout”.Depending on the application, trigger and busy timeouts should be carefully chosen by the user. Forinstance, a short trigger timeout is generally used for the capture of rapidly repeating triggers, while a muchlonger trigger timeout is used for one-shot triggers.Usually, if the trigger timeout is exceeded, the <strong>CompuScope</strong> is forced to trigger using thegage_force_capture routine. Similarly, if the busy timeout is exceeded, capture is generally aborted usingthe gage_abort_capture routine.A code example that illustrates polling for the trigger even and then for acquisition completion is shownbelow. The code uses the GetTickCount routine, which returns a time in milliseconds./* Check to see if a trigger has occurred. If one has not occurred within the specifiedamount of ticks, force one by calling gage_force_capture. If the trigger signal is slow,the value of the constant, TRIG_TIMEOUT, should be increased. It is not necessary tohave a trigger timeout.*/ticks = GetTickCount();while (!gage_triggered()){if (GetTickCount() >= ticks + TRIG_TIMEOUT)gage_force_capture(board.source);}/* Check to see if the acquisition is complete. If it is not within the specified amount of ticks, abortby calling gage_abort_capture. For slow sample rates, the value of the timeout constant,BUSY_TIMEOUT, should be increased. It is not necessary to have a busy timeout. */<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 35


ticks = GetTickCount();while (gage_busy ()){if (GetTickCount() > ticks + BUSY_TIMEOUT) {gage_abort_capture (board.source);return (0);}}Transferring the <strong>CompuScope</strong> DataThe acquired <strong>CompuScope</strong> data can be transferred when the board is no longer busy, and the gage_busyroutine returns a 0. First, the location of the sampled data within on-board <strong>CompuScope</strong> memory isdetermined with a call to the gage_calculate_addresses routine. This routine returns the start address, thetrigger address and the end address that are required to determine the location of data that was capturedinto <strong>CompuScope</strong> memory.<strong>CompuScope</strong> memory is organized as a circular buffer, so that direct numerical comparisons of theaddresses should be avoided. For instance, because the memory counter rolls over when the acquisitionreaches the end of on-board memory, the end address may actually have a lower numerical value than thestart address. Naively subtracting the start address from the end address in order to determine thecapture length would therefore incorrectly yield a negative number. The gage_normalize_address routine,which accounts for memory roll-over, can be used for such comparisons.Before data transfer, the <strong>CompuScope</strong> must be prepared for data transfer using the gage_need_ramroutine. Generally, the application should call gage_need_ram(1) before transferring data and shouldcall gage_need_ram(0) after data transfer is complete.The recommended method of retrieving data from <strong>CompuScope</strong> on-board acquisition memory is thegage_transfer_buffer_3 routine. This routine transfers data using PCI bus-mastering of large data blocks,if supported by the <strong>CompuScope</strong> hardware. PCI bus-mastering is the fastest method of transferring dataacross the PCI bus. It requires no CPU arbitration and bus-mastering transfer rates can be sustained at upto 100 Mega Bytes per second. Gage_transfer_buffer_3 also automatically interleaves data from bothADC memory bank when operating <strong>CompuScope</strong> hardware in single channel mode.Other <strong>CompuScope</strong> data transfer methods are described in the <strong>CompuScope</strong> API Reference <strong>Manua</strong>l forolder Gage users. These routines are not recommended, however, for new designs.Page 36<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Chapter 5:Sample Programs


Windows Sample ProgramsComplete MS Visual C/C++ sample projects that create executable files (*.exe) have been installed on yoursystem as part of the <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows. By default, the <strong>SDK</strong> files are installed inthe C:\Gage\<strong>CompuScope</strong> <strong>SDK</strong> for Windows\<strong>SDK</strong> for C-C++. Within this folder, are several subfolders– one for each sample program. Each sample program folder contains all required files associatedwith the sample program and a Debug folder containing its built executable.In the table below, are the names and descriptions of the executable Windows Sample Programs. Completesource code is provided along with project files (*.DSW) for Microsoft Visual C. Other compilers maybe used but the user must construct the project files. Most of these executables generate ASCII data files.These ASCII files can be viewed by a simple text editor such as MS NotePad, by Microsoft Excel orby any other program capable of importing ASCII files.Program NameGAGE_BUSMASTERING.EXEGAGEA2D_MASTER_SLAVE.EXEGAGEA2D_MS_BM.EXEGAGEA2D_MUL_BM.EXEGAGEA2D_MUL_MS_BM.EXELocation and DescriptionThe sample program GAGE_BUSMASTERING captures asignal on a single <strong>CompuScope</strong> (in dual or single channelmode) and writes the data from all active channels to separateASCII data files. Data transfer is done using PCI busmasteringThis sample program captures a signal from all <strong>CompuScope</strong>sin a Master/Slave <strong>CompuScope</strong> system (in dual or singlechannel mode) and writes the data from all active channels toseparate ASCII data files.This sample program captures a signal from all <strong>CompuScope</strong>sin a Master/Slave <strong>CompuScope</strong> system (in dual or singlechannel mode) and writes the data from all active channels toseparate ASCII data files. Data transfer is done using PCI busmastering.The sample program GAGEA2D_MUL_BM, does a multiplerecord capture on a single <strong>CompuScope</strong> (in dual or singlechannel mode), and bus-masters the data to PC memory. Allthe records from all the channels are then written to separateASCII data files.The sample program GAGEA2D_MUL_MS_BM, does amultiple record capture from all <strong>CompuScope</strong>s in aMaster/Slave <strong>CompuScope</strong> system (in dual or single channelmode), and bus-masters the data to PC memory. All therecords from all the channels are then written to separateASCII data files.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 39


Program NameA2D_PAGED_TRANSFER.EXEDIGITAL_INPUT.EXEDIG_PAGED_TRANSFER.EXEGAGEA2D_MULIND_BM.EXEPEAKDETECT.EXEMEANRMS.EXETV_TRIGGER.EXELocation and DescriptionThe sample program A2D_PAGED_TRANSFER captures asignal on a single <strong>CompuScope</strong> (in dual or single channelmode). The program then transfers all captured data in 32Kiloample pages and stores them in a GageScope ® signal file.Using this paged transfer method, memory only needs to beallocated for the 32 KS page and not for the entire capturedepth. This is very useful for very deep captures. Datatransfer is done using PCI bus-mastering.The sample program DIGITAL_INPUT supports only digitalinput <strong>CompuScope</strong>s such as the CS3200 in single, dual andquad mode. It captures the data and writes them to an ASCIIdata file. The program transfers data using bus-mastering.The sample program DIG_PAGED_TRANSFER captures asignal from a digital input <strong>CompuScope</strong> such as the CS3200 insingle, dual and quad mode. The program then transfers allcaptured data in 32 Kilosample pages and stores them in aGageScope ® signal file. Using this paged transfer method,memory only needs to be allocated for the 32 KS page and notfor the entire capture depth. This is very useful for very deepcaptures. Data transfer is done using PCI bus-mastering.The sample program GAGEA2D_MULIND_BM captures thesignal from multiple single-<strong>CompuScope</strong>s configured asindependent boards (in dual or single channel mode). Theprogram then writes all the captured channels to separateASCII data files. Data transfer is done using PCI busmastering.The sample program PEAKDETECT captures a signal on oneof the channels of a single <strong>CompuScope</strong> board and determinesthe peak value of the signal. It captures and reads the signalfrom channel A, either in Dual or Single channel mode. Whilereading the data, the program determines the minimum andmaximum value of the signal. This program was designed towork with one <strong>CompuScope</strong> board but it can easily beextended for more boards.The sample program MEANRMS captures the signal on eachof the channels of a single <strong>CompuScope</strong> board and determinesthe minimum, maximum, mean and the Root Mean Square(RMS) values of the signal. This program was designed towork with one <strong>CompuScope</strong> board. It can easily be extendedfor multiple boards.This sample program supports CS85G boards. The sampleprogram captures TV signals for NTSC and PAL VideoStandards in dual channel mode. All captured data is written toseparate ASCII files.Page 40<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Detailed Description ofSelected Sample ProgramsGAG2A2D_MS_BM.EXEThe sample program GAGEA2D_MS_BM.EXE is provided with <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ forWindows.The GAGEA2D_MS_BM sample program captures signals from all <strong>CompuScope</strong>s in a Master/Slave<strong>CompuScope</strong> system (in dual or single channel mode), transfers the data to a buffer using PCI busmasteringand then writes the data from all active channels to separate ASCII data files. In order to viewthe resulting files, you will have to run Microsoft Excel or another program, which allows you to importASCII data. You can also use any text editor. In Microsoft Excel, the data files can be read by openingit from the File menu. Excel’s Import Wizard will guide you through importing the data. Select“Delimited” for the type of data, and “Tab” as the delimiter for the data. You can then plot the data.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 41


Flow Chart describing the sample program.StartInitialize Driver and HardwareSet Hardware ParametersAllocate Buffer(s)Start CaptureNTriggeredNTimeoutYForce CaptureYNTimeoutYYBusyNAbort CaptureRead Trigger, Startand End addressesTransfer data using scatter-gatherDMA for optimal speed.Save data to file(s)**Readable by ExcelYMore boardsNEndDescription of the Routines used by the sample programFollowing are the routines used by the sample program GAGEA2D_MS_BM. Brief descriptions of theGage API routines used by each of the following routines are also given. For a detailed description of allthe Gage API routines, please refer to the <strong>CompuScope</strong> API Reference <strong>Manua</strong>l.voidSetDefaultBoardLocation (uInt16 seg, uInt16 ind)This routine is in app_supp.c and is called if the DLL routine gage_read_config_file returns false whichindicates that the board location configuration file is corrupted or missing. A default segment and index arepassed to this routine. The global data structure gage_board_location, which contains the addresses of thememory segments and I/ O addresses, is updated prior to calling the DLL gage_driver_initialize routine.For the CP500 family of <strong>CompuScope</strong>s, the memory segment and I/ O addresses are set to 0xFFFF.Page 42<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Gage API routines used:gage_set_records:Sets the values for the memory segment and I/O address in thegage_board_location array.intInitBoard (void)This routine is in APP_SUPP.C and does all the necessary calls in the proper order to initialize the driver.Some modifications to this routine are necessary if the programmer does not want the progress messagesdisplayed.Gage API routines used:gage_get_config_filename:gage_read_config_file:gage_driver_initialize:gage_board_type_size_to_text:gage_get_driver_info_structure:gage_get_driver_info:gage_get_boards_found:gage_initialize_start_capture:gage_select_board:gage_detect_multiple_record:Determines the complete path to the configuration file that containsthe board location data.Reads the configuration file and stores the data in an array of words.Fully configures each board found in the system.This routine returns a pointer to a string with the parameters thatcontain information about the <strong>CompuScope</strong> board(s) installed in thesystem.Returns the size of the main structure used by the driver and alsoretrieves the driver version and number.Fills a structure with the relevant information from the drivervariables about the current settings on the current <strong>CompuScope</strong>board.Determines the number of the <strong>CompuScope</strong> boards found.Sets up the gage_start_capture routine.Sets the driver so that the current board is the board identified bythe number passed to the routine.Used to determine if a <strong>CompuScope</strong> board has multiple recordcapability.void SetBoard (void)This routine is in APP_SUPP.C. It uses the boarddef structure named board, which was previously loadedwith the desired capture parameters. The sample program initializes these parameters statically.Note that the order in which SetDefaultBoardLocation, InitBoard and SetBoard are called is importantfor the proper operation of the <strong>CompuScope</strong> hardware. The order is also important if the user wants thedriver to correctly maintain such information as the amount of memory available for each channel. Thevalues of the GAGE constants are defined in GAGE_DRV.H.Gage API routines used:gage_get_driver_info:gage_select_board:gage_capture_mode:gage_input_control:Fills a structure or record with the relevant information from thedriver variables about the current <strong>CompuScope</strong> board settings.Sets the driver so that the current board is the board identified bythe number passed to the routine.Sets the data capture mode and the sampling rate.Used to set up the input channels on the <strong>CompuScope</strong> boards. Thisroutine must be called for each channel in the system.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 43


gage_trigger_control_2:gage_set_ext_clock_variables:gage_multiple_record:Takes the advantage of certain <strong>CompuScope</strong> board’s ability to have2 different trigger inputs (source, slope and level) and is used to setup the trigger parameters on the <strong>CompuScope</strong> boards.Sets the variables required for use of an external clock.Allows the application program to force the <strong>CompuScope</strong> hardwareto capture only the depth specified when the trigger event occurs.The card then re-arms itself automatically to accept another triggerevent and record that data immediately following the first capture inon-board memory.gage_multiple_record_acquisitions: Sets the number of multiple record groups that will be taken by the<strong>CompuScope</strong> hardware.voidboard_settings(void)This routine is in GAGEA2D_MS_BM.C. It is used to change any of the board parameters. For example,the default value for board.slope is now GAGE_POSITIVE. If you want the slope to be negative, simplychange GAGE_POSITIVE to GAGE_NEGATIVE and then re-compile your application. This routinemust be called before SetBoard routine.For the detailed description of the board parameters and their legal settings for the <strong>CompuScope</strong> boards,please see the Appendix: Data Structures Used by Gage Drivers.int CALLBACK WinMain . . . . . . . .This is the main routine in GAGEA2D_MS_BM.C. In this routine, we first initialize the <strong>CompuScope</strong>driver and hardware and then verify the board structure for the <strong>CompuScope</strong> boards. Next, we set theboard setting variables by calling the board settings routine. These settings are actually passed to thehardware and the <strong>CompuScope</strong> boards are prepared for data capture by the SetBoard routine. We thenstart the acquisition. Two driver routines, gage_triggered and gage_busy, are used to monitor the progressof the trigger event and the completion of the current data acquisition, respectively.Once the acquisition is complete, we determine the relevant addresses by callinggage_calculate_addresses and read samples from each channel into a buffer. After a channel’s data hasbeen read, we save the raw data from the channel to a separate ASCII data file in the current workingdirectory. The raw data from a <strong>CompuScope</strong> board has the most positive voltage represented as the leastpositive value and the least positive voltage represented as the most positive value. To change this for thepurposes of plotting the data, we negate the raw values for the 12 bit boards and subtract them from 255 for8 bit boards. This continues until the data from all the channels are stored.For example in dual channel mode, for 2 boards (1 Master and 1 Slave) the file names are as follows:GAGE_MS_BM1.DAT, contains the data of channel A of master board.GAGE_MS_BM2.DAT, contains the data of channel B of master board.GAGE_MS_BM3.DAT, contains the data of channel A of slave board.GAGE_MS_BM4.DAT, contains the data of channel B of slave board.Gage API routines used:gage_get_driver_info:gage_start_capture:gage_triggered:Fills a structure or record with the relevant information from thedriver variables about the current <strong>CompuScope</strong> board settings.Prepares the <strong>CompuScope</strong> hardware for data acquisition.Determines if the <strong>CompuScope</strong> hardware has encountered a triggerevent.Page 44<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


gage_force_capture:gage_busy:gage_abort_capture:gage_calculate_addresses:gage_select_board:gage_transfer_buffer_3:How the Memory is ReadForces the capture of data by the <strong>CompuScope</strong> board(s).Determines if the <strong>CompuScope</strong> board is busy capturing the data.Used to regain control of the <strong>CompuScope</strong> board(s).Returns the starting, trigger and ending addresses.Sets the driver so that the current board is the board identified bythe number passed to the routine.Copies the number of sample points in the <strong>CompuScope</strong> board’smemory space, from the specified channel to the supplied bufferusing bus-mastering. This routine returns an offset to the beginningof the d-word aligned buffer that the driver uses.The memory is read from the boards in a for loop using the gage_transfer_buffer_3 routine. The syntaxfor gage_transfer_buffer_3 is as follows:-Syntax:uInt32 GAGEAPI gage_transfer_buffer_3 (int32 ta, int16 channel, void far *buffer, int32 nsamples);gage_transfer_buffer_3 is used to copy nsamples points from the specified channel to the supplied bufferbeginning from address ta. The channel can be either GAGE_CHAN_A or GAGE_CHAN_B. Therelevant addresses can be obtained by calling gage_calculate_addresses routine. The buffer should betype cast to the appropriate size before accessing it. <strong>CompuScope</strong> 8-bit boards should be typecast to uInt8.<strong>CompuScope</strong> 12 and 16 bit boards should be typecast to int16. The <strong>CompuScope</strong> PCI boards will use busmasteringif available, otherwise this routine is the same as gage_transfer_buffer. The buffer must beslightly longer than the size required to store nsample samples. The extra buffer space required isdetermined by the variable board_info-> user_buffer_padding which is returned by the driver.The application does not need to interleave the data when the acquisition has been performed in singlechannel mode, as is the case with gage_transfer_buffer and gage_transfer_buffer_2.gage_transfer_buffer_3 returns an offset in Bytes to the beginning of the D-word aligned buffer that thedriver uses. The offset is the difference in Bytes between the pointer passed to the driver and the bufferthat the driver uses.Each board is selected in sequence by calling the routine gage_select_board.By default, all the post trigger data are read starting from the trigger address (the address where the triggerevent occurred). You can easily change this address in order to download data starting from anotheraddress. For example, by default the program has the following line:location = trigger; points = board.depth;where trigger contains the trigger address. If you change the code to:location = trigger - 100; points = 200;The program will read 200 samples starting from 100 points before the trigger address. In this way, theuser will download 100 points of pre-trigger data. Note that the start address determines the startingaddress of the valid pre-trigger data. If the difference between the trigger address and the starting addressis less then 100, then there will not be 100 valid pre-trigger data points. If you subtract the starting addressfrom the trigger address, you must take into account the fact that the memory is configured as a circularbuffer. The gage routine gage_normalize_addresses can be used to determine the difference between thetwo addresses taking into account the circular buffer.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 45


GAG2A2D_MUL_BM.EXEThe sample program GAGEA2D_MUL_BM.EXE is provided with <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ forWindows.GAGEA2D_MUL_BM sample program does a multiple record capture from a single <strong>CompuScope</strong> (dual orsingle channel mode), and bus-masters the data to PC memory. All the records from all the channels arethen written to the separate ASCII data files. In order to view the resulting files, you will have to runMicrosoft Excel or another program, which allows you to import ASCII data. You can also use any texteditor. In Microsoft Excel, the data files can be read by opening it from the File menu. Excel’s ImportWizard will guide you through importing the data. Select “Delimited” for the type of data, and “Tab” asthe delimiter for the data. Then you can plot the data.Flow Chart describing the sample program.StartInitialize Driver and HardwareSet Hardware ParametersAllocate Buffer(s)Start CaptureNTriggeredNTimeoutYForce CaptureYNTimeoutYYBusyNAbort CaptureGroup. Read Trigger,Start and EndaddressesTransfer data using scatter-gatherDMA for optimal speed.Save data to file(s)**Readable by ExcelYMore GroupsNEndPage 46<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Description of the Routines used by the sample programFollowing are the routines used by the sample program GAGEA2D_MUL_BM. A brief description for allthe Gage API routines used by each of the following routines is also given. For detailed description of allthe Gage API routines, please see the <strong>CompuScope</strong> API Reference <strong>Manua</strong>l.For a complete description of the SetDefaultBoardLocation, InitBoard, SetBoard, One_SetBoard andboard_settings, refer to their description in the previous section, which describes the GAGEA2D_MS_BMsample program.int CALLBACK WinMain . . . . . . . .This is the main routine in GAGEA2D_MUL_BM.C. In this routine, we first initialize the <strong>CompuScope</strong>driver and hardware and verify the board structure for the <strong>CompuScope</strong> boards.Next, we set the board setting variables by calling the board settings routine. These settings are actuallypassed to the hardware and the <strong>CompuScope</strong> boards are prepared for data capture by the SetBoard routine.We then start the acquisition. As in single record acquisition, the gage_triggered routine is used to detectwhen the first trigger occurs. In multiple record mode, however, gage_busy remains active until the<strong>CompuScope</strong> has captured all multiple records. This occurs when the requested number of records, as setby gage_multiple_record_acquisitions_32, has been acquired for CP500, single PCI or cPCI<strong>CompuScope</strong>s. For older ISA and X12/PCI <strong>CompuScope</strong>s, however, multiple recording terminates andgage_busy becomes inactive only when on-board memory is full.We determine the relevant addresses by calling gage_calculate_mr_addresses for each group. Thegage_calculate_mr_addresses routine returns the addresses for a specific group. If the addresses are read,the return value is the group number that was passed to the routine. In this way, we can loop until all thegroups are read. When this occurs, we know that there are no more groups to be downloaded. Within thisloop we also check if the board supports embedded enhanced trigger bits (EETBs). If the board supportsEETBs, we then call the gage_calculate_mra_addresses routine to adjust the trigger address according tothe EETBs. The gage_calculate_mra_addresses routine is required due to the architecture of thehardware. Depending on the <strong>CompuScope</strong> model, some lower trigger address bits are not stored on the<strong>CompuScope</strong> but must be embedded in the data records, typically in the first sample of each multiplerecord group. Using the gage_calculate_mra_addresses routine, the sample program extracts the EETBsand corrects the trigger address as required.The CP500 <strong>CompuScope</strong>s have the capability of specifying the number of groups to capture rather thanfilling up all of the onboard memory. Each group from the specified channel is saved to an ASCII file inthe current working directory. The raw data from a <strong>CompuScope</strong> board has the most positive voltagerepresented as the least positive value and the least positive voltage represented as the most positive value.To change this for the purposes of plotting the data, we negate the raw values for the 12 bit boards andsubtract them from 255 for 8 bit boards.For example, in dual channel mode the file names are as follows:GAGE_MUL_BM_DUAL_CHANA_GR1.DAT, contains the data of group 1 of channel A.GAGE_MUL_BM_DUAL_CHANB_GR1.DAT, contains the data of group 1 of channel B.GAGE_MUL_BM_DUAL_CHANA_GR2.DAT, contains the data of group 2 of channel A.GAGE_MUL_BM_DUAL_CHANB_GR2.DAT, contains the data of group 2 of channel B.…….In single channel mode the file names are as follows:GAGE_MUL_BM_SINGLE_GR1.DAT, contains the data of group 1.GAGE_MUL_BM_SINGLE_GR2.DAT, contains the data of group 2.GAGE_MUL_BM_SINGLE_GR3.DAT, contains the data of group 3.…….<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 47


Gage API routines used:gage_get_driver_info:gage_start_capture:gage_triggered:gage_force_capture:gage_busy:gage_abort_capture:gage_calculate_mr_addresses:gage_mem_read_single:gage_mem_read_chan_a:gage_calculate_mra_addresses:gage_transfer_buffer_3:Fills a structure or record with the relevant information from thedriver variables about the current <strong>CompuScope</strong> board settings.Prepares the <strong>CompuScope</strong> hardware for data acquisition.Determines if the <strong>CompuScope</strong> hardware has encountered a triggerevent.Forces the capture of data by the <strong>CompuScope</strong> board(s).Determines if the <strong>CompuScope</strong> board is busy capturing the data.Used to regain control of the <strong>CompuScope</strong> board(s).Returns the starting, trigger and ending addresses of the specifiedgroup for the specified channel of the current board.Reads one sample out of the <strong>CompuScope</strong> board’s memory insingle channel mode.Reads one sample out of the <strong>CompuScope</strong> board’s memory forchannel A.Corrects the trigger address based on the ETB information locatedin the data acquired from the card at the raw calculated triggeraddress.Copies the number of sample points of the <strong>CompuScope</strong> board’smemory space, from the specified channel to the supplied bufferusing bus-mastering. This routine returns an offset to the beginningof the d-word aligned buffer that the driver uses.How the Memory is ReadThe memory is read from the boards in a for loop using the gage_transfer_buffer_3 routine. The syntaxfor gage_transfer_buffer_3 is as follows:-Syntax:uInt32 GAGEAPI gage_transfer_buffer_3 (int32 ta, int16 channel, void far *buffer, int32 nsamples);gage_transfer_buffer_3 is used to copy nsamples points from the specified channel to the supplied bufferbeginning from address ta. The channel can be either GAGE_CHAN_A or GAGE_CHAN_B. Therelevant addresses can be obtained by calling the gage_calculate_mr_addresses routine. The buffershould be typecast to the appropriate size before accessing it. <strong>CompuScope</strong> 8-bit board users shouldtypecast to uInt8. <strong>CompuScope</strong> 12 and 16-bit board users should typecast to int16. The <strong>CompuScope</strong> PCIboards will use bus-mastering if available, otherwise gage_transfer_buffer_3 is the same asgage_transfer_buffer. The extra buffer space required, is determined by the variable board_info->user_buffer_padding which is returned by the driver. Since the program downloads the data records one ata time and stores them to files using the same buffer, the buffer need only be large enough to hold a singlerecord.The application does not need to interleave the data when the acquisition has been performed in singlechannel mode, as is the case with gage_transfer_buffer and gage_transfer_buffer_2.gage_transfer_buffer_3 returns an offset in Bytes to the beginning of the D-word aligned buffer that thedriver uses. The offset is the difference in Bytes between the pointer passed to the driver and the bufferthat the driver uses.Page 48<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


By default, all the post trigger data are read starting from the trigger address (the address where the triggerevent occurred). You can easily change this address in order to download data starting from anotheraddress. For example, by default the program has the following line:location = trigger;points = board.depth;where trigger contains the trigger address. If you change the code to:location = trigger + 100;points = 200the program will read 200 samples starting from 100 points after the trigger address. Note that there are nopre-trigger data in multiple record mode.The size of a multiple record group can be determined by calling gage_calculate_mr_addresses and usingthe equation:multiple record group size = ending_address - trigger_address + 1Because there are no pre-trigger data in multiple record mode, the board will not capture until a triggerevent has occurred. The <strong>CompuScope</strong> board's circular buffer will not wrap around in Multiple RecordMode, so that the ending address will always be greater then the trigger address for each group.The program continues reading groups until they have all been read. This occurs when the return valuefrom gage_calculate_mr_addresses and the first parameter are not equal or the number of groupsspecified in gage_multiple_record_acquisitions has been reached.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 49


DIGITAL_INPUT.EXEThe sample program DIGITAL_INPUT.EXE is provided with <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows.The sample program is provided for use with digital input <strong>CompuScope</strong>s like the CS3200. Conceptually, adigital input <strong>CompuScope</strong> is just like analog input <strong>CompuScope</strong> with its analog signal conditioning frontend and A/D converter chips replaced with a digital input buffer. Because of the similarity in the operationof the analog and digital <strong>CompuScope</strong>s, Gage uses exactly the same set of subroutines (the API) to accessboth types of <strong>CompuScope</strong>s. Gage has modified the operation of some API subroutines for digital input<strong>CompuScope</strong>s so that they fit the functionality of these boards.Three important differences exist that must be considered when programming a digital input <strong>CompuScope</strong>1. <strong>CompuScope</strong> Mode. – For an analog <strong>CompuScope</strong> the operating mode, SINGLE or DUAL, specifiesthe number of channels on which to acquire analog signals. For digital input <strong>CompuScope</strong>s, however, themode parameter is used to specify the digital input width. The <strong>CompuScope</strong> 3200, for instance, can beconfigured for 8, 16 or 32 bit input width. In this way, memory usage is optimized. For example, a<strong>CompuScope</strong> 3200 with 2 Mega Bytes of on-board memory can capture 2 Mega Samples in 8-bit mode, 1Mega Samples in 16-bit mode and one-half Mega Samples in 32-bit mode. In order to control the mode,the programmer must set the board.opmode to GAGE_SINGLE_CHAN for 8-bit mode,GAGE_DUAL_CHAN for 16-bit mode and GAGE_QUAD_CHAN for 32-bit mode.2. Logic Input Levels. – One may specify the logic input levels for digital input <strong>CompuScope</strong>s. Forinstance, for the single-ended <strong>CompuScope</strong> 3200, the logic level may be selected to be either CMOS (witha logic threshold of about 2.5 Volts) or TTL (with a logic threshold of about 1.4 Volts). The selection ofeither logic level is done through the analog input range control for channel A, which has no meaning on adigital input <strong>CompuScope</strong>. For selection of the CMOS logic level, the programmer must select the ±5Volts input range and for TTL, the ±1 input range. So the programmer should set board.range_a toGAGE_PM_5_V for CMOS logic and should set board.range_a to GAGE_PM_1_V for TTL logic.3. External Sampling Clock Inversion. – Most digital input applications require the use of an externalclock. In digital electronics, the digital data are generally stable on either one clock edge or the other(rising or falling). The user’s device under test may have differential signal propagation delays, whichmeans that the clock and digital data may take different times to arrive at the digital <strong>CompuScope</strong>. Theuser, therefore, may not know upon which clock edge the data are stable. Consequently, the user must becapable of selecting on which clock edge the digital signals are sampled. The sampling clock edge may beselected using the use_invert_clock variable. If the use_invert_clock variable is set to 0 then the digital<strong>CompuScope</strong> will sample on the rising edge of the input external clock. If the use_invert_clock variable isset to 1 then the digital <strong>CompuScope</strong> will sample on the falling edge of the input external clock.The DIGITAL_INPUT sample program captures a digital signal in single-(8 bit), dual-(16 bit), or quad-(32bit) mode from a digital input <strong>CompuScope</strong>. All captured data are written to separate ASCII data files.Data are stored as unsigned integers in decimal format with ranges 0-255, 0-32767 and 0-4,294,967,295 for8, 16 and 32 bit modes respectively.In order to view the resulting files, you will have to run Microsoft Excel or another program, whichallows you to import ASCII data. You can also use any text editor. In Microsoft Excel, data files can beread by opening them from the File menu. Excel’s Import Wizard will guide you through importing thedata. Select “Delimited” for the type of data, and “Tab” as the delimiter for the data. You can then plot thedata.Page 50<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Description of the Routines used by the sample programFollowing are the routines used by the sample program DIGITAL_INPUT. A brief description for all theGage API routines used by each of the following routines is also given. For detailed description of all theGage API routines, please see the <strong>CompuScope</strong> API Reference <strong>Manua</strong>l.int CALLBACK WinMain . . . . . . . .This is the main routine in DIGITAL_INPUT.C. In this routine, we first initialize the <strong>CompuScope</strong> driverand hardware and verify the board structure for the <strong>CompuScope</strong> boards.We make setting adjustments using the board_settings routine and then prepare the <strong>CompuScope</strong> boardfor data capture with the SetBoard routine.We then start the acquisition. Two driver routines: gage_triggered and gage_busy are used to monitor theprogress of the trigger event and the completion of the current data acquisition, respectively.Once the acquisition is complete, we determine the relevant addresses by callinggage_calculate_addresses. The data record is transferred to PC RAM using PCI bus-mastering bygage_transfer_buffer_3.For 8 bit mode, gage_transfer_buffer_3 routine returns 8 bit samples in an int8 space.For 16 bit mode, gage_transfer_buffer_3 routine returns 16 bit samples in an int16 space.For 32 bit mode, gage_transfer_buffer_3 routine returns 32 bit samples in an int32 spaceAfter the data are read, we save the data from the digital input to an ASCII data file called D_INPUT.DATin the current working directory.Gage API routines used by gage_transfer_buffer_3:gage_get_driver_info:gage_start_capture:gage_triggered:gage_force_capture:gage_busy:gage_abort_capture:gage_transfer_buffer_3:Fills a structure or record with the relevant information from thedriver variables about the current <strong>CompuScope</strong> board settings.Prepares the <strong>CompuScope</strong> hardware for data acquisition.Determines if the <strong>CompuScope</strong> hardware has encountered a triggerevent.Forces the capture of data by the <strong>CompuScope</strong> board(s).Determines if the <strong>CompuScope</strong> board is busy capturing the data.Used to regain control of the <strong>CompuScope</strong> board(s).Copies the number of sample points requested from the<strong>CompuScope</strong> board’s memory space from the specified channel tothe supplied buffer using bus-mastering. This routine returns anoffset to the beginning of the d-word aligned buffer that the driveruses.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Page 51


Chapter 6:Appendices


Appendix A: Data StructuresUsed by <strong>CompuScope</strong>Driversgage_driver_info_type StructureAn important structure type used in the drivers and defined in GAGE_DRV.H is gage_driver_info_type.This structure type is used to obtain information about the currently selected board by calling thegage_get_driver_info routine. This routine is explained in the <strong>CompuScope</strong> API Reference <strong>Manua</strong>l. Notethat the parameters in a gage_driver_info_type structure cannot be directly changed from the C applicationlevel. The parameters are changed indirectly by changing the corresponding parameters in structures oftype either boarddef, srtable or irtype and then by making the appropriate API subroutine call. These callsare bundled correctly within the SetBoard() routine that resides in the app_supp.c source file. Thedefinition of the gage_driver_info_type structure type is below: The definition of this type may change infuture as additional Gage hardware and functionality is released. The changes, however, will always bedocumented within the README.TXT file that comes with the <strong>CompuScope</strong> C/C++ <strong>SDK</strong>.typedef struct {uInt16uInt16uInt16uInt32uInt32int32int32uInt16int16int16int16int16int16int16int16int16int16int16int16int32int16int16int16int16int16int16int16int16uInt16uInt32index;segment;board_type;max_memory;max_available_memory;max_memory;max_available_memory;bank_offset_value;mode;enable_a;enable_b;rate;multiplier;coupling_a;coupling_b;coupling_ext;gain_a;gain_b;gain_ext;trigger_depth;trigger_level;trigger_slope;trigger_source;trigger_res;multiple_recording;sample_offset;sample_resolution;sample_bits;external_clock_delay;external_clock_rate;<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix A Page 55


uInt32 sample_rate;void far *memptr;int16trigger_level_2;int16trigger_slope_2;int16trigger_source_2;int16imped_a;int16imped_b;uInt16 external_clock_adjust;int16trigger_step;uInt16 board_version;uInt32 ee_options;uInt16 index_offset;int32sample_offset_32;int32sample_resolution_32;int16diff_input_a;int16diff_input_b;uInt32 multiple_record_count;uInt32 real_time_active;int16trigger_enable_control;int16trigger_sensitivity;int16trigger_bandwidth;int16trigger_sensitivity_2;int16trigger_bandwidth_2;uInt16 max_trigger_sensitivity;uInt16 trigger_address_offset;uInt16 user_buffer_padding;int16bus_master_support;} gage_driver_info_type;;Page 56 Appendix A <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Description of Parameters for gage_driver_info_type StructureValues of the constants used below can be found in GAGE_DRV.H or in GAGE_LOW.H file.indexsegmentBoard_typemax_memorymax_available_memorybank_offset_valuemodeenable_aenable_bratemultipliercoupling_acoupling_extgain_again_bgain_exttrigger_depthbase I/O port index of <strong>CompuScope</strong>, used to transfer data from the<strong>CompuScope</strong> card. The value is typically read from the configurationfile GAGESCOP.INC. For PCI <strong>CompuScope</strong> boards, the value is0xffff.absolute address of memory segment, typically read fromGAGESCOP.INC. For PCI <strong>CompuScope</strong> boards, the value is 0xffff.numeric constant representing the board type as defined in theGAGE_DRV.H file.memory size of <strong>CompuScope</strong> board (in samples).available memory (in samples) in current mode, i.e. max_memory insingle channel, max_memory / 2 in dual channel.block number where the data for channel B starts.current mode of the board, which can be GAGE_SINGLE_CHAN orGAGE_DUAL_CHAN or GAGE_QUAD_CHAN. Mode is set bygage_capture_mode routine.current enable status of channel A. On board <strong>CompuScope</strong> memory iseither connected or disconnected to the transceiver by callinggage_input_control routine with either GAGE_INPUT_ENABLE orGAGE_INPUT_DISABLE.current enable status of channel B. On board <strong>CompuScope</strong> memory iseither connected or disconnected to the transceiver by callinggage_input_control routine with either GAGE_INPUT_ENABLE orGAGE_INPUT_DISABLE.set by gage_capture_mode routine.set by gage_capture_mode routine. The constants are GAGE_HZ,GAGE_KHZ, GAGE_MHZ, GAGE_GHZ and GAGE_EXT_CLK.status of the coupling for channel A, either GAGE_AC or GAGE_DC.status of the coupling for the external trigger. Use GAGE_AC orGAGE_DC with gage_trigger_control_2 routine.status of the gain value for channel A. One of the predefined constants,such as GAGE_PM_5_V, defined in GAGE_DRV.H file should beused with gage_input_control routine to set this parameter:status of the gain value for channel B. One of the predefined constants,such as GAGE_PM_1_V, defined in GAGE_DRV.H file should beused with gage_input_control routine to set this parameter:status of the gain for the external trigger. To set, use eitherGAGE_PM_5_V or GAGE_PM_1_V with gage_trigger_control_2routine.number of points captured after the trigger event set bygage_trigger_control_2 routine.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix A Page 57


trigger_level level at which trigger event is set to occur. Can be any value between 0and 255, with 0 as the minimum and 255 as the maximum for 8 bit<strong>CompuScope</strong> cards and 0-4095 for 12, 14, and 16 bit <strong>CompuScope</strong>cards. A value of 0 sets the trigger level to minus full scale and a valueof 255 or 4095 sets the trigger level to plus full scale. The value isimplemented on the <strong>CompuScope</strong> hardware by thegage_trigger_control_2 routine.trigger_slopestatus of the current trigger slope. To set, use either GAGE_POSITIVEor GAGE_NEGATIVE with a call to gage_trigger_control orgage_trigger_control_2 routine. This has no effect when using asoftware trigger.trigger_sourcestatus of current trigger source. To set, use either GAGE_CHAN_A,GAGE_CHAN_B, GAGE_EXTERNAL or GAGE_SOFTWARE witha call to gage_trigger_control or gage_trigger_control_2 routine.trigger_resresolution of trigger depth. This value is the minimum amount bywhich the post-trigger depth may be changed for the current<strong>CompuScope</strong> hardware.multiple_recording flag to determine if a multiple record has been set.sample_offsetthe value of the data returned from the card that equals 0 volts. Forinstance, this value is 127 for the <strong>CompuScope</strong> 8500.sample_resolution number of levels between 0 and positive full scale or 0 and negativefull scale. For instance, this value is 128 for the <strong>CompuScope</strong> 8500.sample_bitsnumber of sample bits in the current <strong>CompuScope</strong> hardware. Forinstance, this will be 8 for 8 bit <strong>CompuScope</strong>s.external_clock_delay current clock delay used to synchronize an external clock with the<strong>CompuScope</strong> hardware. Should be 0 if the sample rate is greater than 5MHz or the greater of 1 and (10,000 / external_clock_rate), otherwise.external_clock_rate current external clock rate when using an external clock. This valuewill be used as the sample rate in single channel mode. Depending onthe <strong>CompuScope</strong> model, there may be an integer factor between thisvalues and the sample rate in dual channel mode.sample_ratecurrent sample rate.memptrpointer to the segment:offset address of the start of <strong>CompuScope</strong> RAM.trigger_level_2 level at which second trigger event is set to occur. Can be any valuebetween 0 and 255, with 0 as the minimum and 255 as the maximumfor 8 bit <strong>CompuScope</strong> cards and 0-4095 for 12 bit <strong>CompuScope</strong> cards.The value is implemented on the <strong>CompuScope</strong> hardware by thegage_trigger_control_2 routine. Not all the <strong>CompuScope</strong>s have thiscapability.trigger_slope_2 status of the second trigger slope. To set, use either GAGE_POSITIVEor GAGE_NEGATIVE with a call to gage_trigger_control_2 routine.This has no effect when using a software trigger. Not all the<strong>CompuScope</strong>s have this capability.trigger_source_2status of the second trigger source. To set, use eitherGAGE_CHAN_A, GAGE_CHAN_B, GAGE_EXTERNAL orGAGE_SOFTWARE with a call to gage_trigger_control_2 routine.Not all the <strong>CompuScope</strong>s have this capability.Page 58 Appendix A <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


imped_aimped_bexternal_clock_adjusttrigger_stepboard_versionee_optionsindex_offsetsample_offset_32sample_resolution_32diff_input_adiff_input_bmultiple_record_countreal_time_activetrigger_enable_controlinput impedance for channel A. To set, “OR” eitherGAGE_1_MOHM_INPUT or GAGE_50_OHM_INPUT with the inputrange when setting the range with a call to gage_input_control_2routine.input impedance for channel B. To set , “OR” eitherGAGE_1_MOHM_INPUT or GAGE_50_OHM_INPUT with the inputrange when setting the range with a call to gage_input_control_2routine.value used to adjust trigger address when external clock is used.value used to determine trigger resolution.version of the current <strong>CompuScope</strong> hardware.available options for the current <strong>CompuScope</strong> hardware. The optionsare represented by one or more constants “ORed” together. Theavailable constants are defined in EEPROM.HThis parameter is used primarily in the driver. The offset, in bytes, isthe offset between the address register and the data register of the<strong>CompuScope</strong> hardware.index_offset == 0 if the hardware uses flat addressing (e.g. CS8500).index_offset == 4 if the hardware uses indexed addressing and theregisters are 1 D-word wide (e.g. CS12100 andCS1250 analog or add-on section only).index_offset == 1 if the hardware uses indexed addressing and theregisters are 1 byte wide (e.g. most other <strong>CompuScope</strong>models).This does not apply to the CP500 base board which uses flataddressing.Same as “sample_offset” but it is a 32 bit number to better support16 bit and higher resolution A/D boards.Same as “sample_resolution” but it is a 32 bit number to better support16 bit and higher resolution A/D boards.Set if channel A is in differential input mode. To set, “OR” the inputrange with GAGE_DIFFERENTIAL_INPUT and to clear “OR” withGAGE_SINGLE_ENDED_INPUT when setting the range with a callto the gage_input_control_2 routine.Set if channel B is in differential input mode. To set, “OR” the inputrange with GAGE_DIFFERENTIAL_INPUT and to clear “OR” withGAGE_SINGLE_ENDED_INPUT when setting the range with a callto the gage_input_control_2 routine.The current multiple record count as set by a call togage_multiple_record_acquisitions_32 routine.The real_time_active parameter indicates if the <strong>CompuScope</strong> driver isin the real-time modeThe trigger_enable_control parameter indicates whether the triggercircuitry is enabled or disabled. In order to ensure pretrigger datacapability, the <strong>CompuScope</strong> hardware should have this capability.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix A Page 59


trigger_sensitivitytrigger_bandwidthtrigger_sensitivity_2trigger_bandwidth_2max_trigger_sensitivitytrigger_address_offsetuser_buffer_paddingThe trigger sensitivity of trigger source 1. The trigger sensitivity isspecified in one-tenths percent of the full-scale input range for the<strong>CompuScope</strong> hardware that supports this feature. The default value fortrigger_sensitivity is 100, which implies 10 percent of the input rangeof the selected trigger source.The trigger bandwidth of trigger source 1. Following options areavailable for <strong>CompuScope</strong> hardware that supports this feature:GAGE_FULL_BW 0GAGE_HIGH_REJECT 0x20GAGE_LOW_REJECT 0x40GAGE_NOISE_REJECT 0x60GAGE_TRIG_BW_EXPAND // not supported, future devtGAGE_BW_MASK0xE0The trigger sensitivity of trigger source 2. Reserved for future use.The trigger bandwidth of trigger source 2. Reserved for future use.The maximum trigger sensitivity of the selected trigger source.This field contains the trigger address offset value. Thetrigger_address_offset value should be ORed with the CHANparameter when calling gage_calculate_mra_address routine.The number of extra bytes required in allocation of the user buffer intowhich data are transferred by the gage_transfer_buffer_2 andgage_transfer_buffer_3 routines. The size of the user buffer must beaugmented by this parameter. Follow the guidelines below wheneveryou need to compute the size of buffer for acquisition:User_buffer_size = total number of samples to be acquired*sample_size + user_buffer_paddingbus_master_supportTotal number of samples to be acquired is the sum of pre and posttrigger depth. Sample_size equals 1 for 8 bit <strong>CompuScope</strong> cards and isset to 2 for 12,14 and 16 bit <strong>CompuScope</strong> cardsValue used to determine if the <strong>CompuScope</strong> hardware and the PCI slotthat is currently housing the <strong>CompuScope</strong> card, supports busmastering.In order to transfer the on-board <strong>CompuScope</strong> data to thePC RAM using bus-mastering, both options must be available i.e.<strong>CompuScope</strong> hardware as well as the PCI slot must be bus-masteringready.Page 60 Appendix A <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


oarddef, srtable and irtype StructuresThree important structure types, boarddef, srtype and irtype, are defined in the file STRUCTS.H andinitialized in the file STRUCTS.C. The boarddef, srtype and irtype structure types are used by the sampleprograms and are reproduced here. The boarddef structure type defines all of the settings that may bechanged on the <strong>CompuScope</strong> card. The srtable structure type defines all of the possible sample ratesettings that any of the <strong>CompuScope</strong> cards may use. The top 16 bits of the flag are used to specify if thesample rate is available single channel and the bottom 16 bits are used to specify that the sample rate isavailable when acquiring data in the dual channel mode. The irtype structure type similarly defines whichinput ranges are available for the installed <strong>CompuScope</strong> hardware. These three structure types areprovided as a convenience and are used by Gage C sample programs. The definition of these types maychange in future as additional Gage hardware and functionality is released. The changes, however, willalways be documented within the README.TXT file that comes with the <strong>CompuScope</strong> C/C++ <strong>SDK</strong>Boarddef Structuretypedef struct {int32 sample_rate; /* For gage_capture-mode. */int16 opmode, srindex; /* For gage_capture_mode. */int16 range_a, couple_a, range_b, couple_b; /* For gage_input_control. */int16 imped_a, imped_b; /* For gage_input_control. */int16 source, slope, level, range_e, couple_e; /* For gage_trigger_control. */int16 source_2, slope_2, level_2; /* For gage_trigger_control_2. */int32 depth; /* For gage_trigger_control. */} boarddef;extern boarddef board;srtable Structuretypedef struct {int16 rate; /* rate and mult are used together to set thesample rate in gage_capture_moderoutine. */int16 mult; /* rate and mult are used together to set thesample rate in gage_capture_moderoutine. */uInt32 sr_flag; /* Board supports sample rate. */uInt32 rt_sr_flag; /* Board supports sample rate in real timemode. */uInt32 rts_sr_flag; /* Board supports sample rate in real timemode and is safe to use. */float sr_calc; /* Time between samples (in ns). */char *sr_text; /* Sample rate text. */} srtype;irtype Structuretypedef struct {int16 constant; /* For gage_input_control. */uInt32 ir_flag; /* Flag to see if board supports inputrange*/double ir_calc; /* Voltage amplitude. */char *ir_text; /* Input range text. */} irtype;<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix A Page 61


Settings for boarddef structure fieldsThis section provides allowed settings for the boarddef structure fields for all Gage <strong>CompuScope</strong>s. In thetables below, the Description column tells what <strong>CompuScope</strong> setting is selected, the Constant Namecolumn gives the name of the defined constant and the Values column gives the numerical constant value.In order to ascertain what settings are valid for a specific <strong>CompuScope</strong> model, please look into thehardware manual or data specification sheet for that <strong>CompuScope</strong> model.As an example, Gage’s <strong>CompuScope</strong> 85G supports a 5 GigaSamples per second sampling rate. Therefore,the following value for the srindex field in the boarddef structure is supported:DescriptionConstants Name5 GHz SRTI_5_GHZGage’s <strong>CompuScope</strong>14100 supports ±5 Volt Input Range on both its input channels. Therefore, thefollowing value for the range_a and range_b fields in the boarddef structure is supported:DescriptionConstants Name±5 V GAGE_PM_5_VThe example at the end of current section explains how to use the parameters of this structure with a call togage_capture_mode, gage_input_control and gage_trigger_control routines.• opmodeThe parameter opmode is used to set the <strong>CompuScope</strong> operating mode. Allowed values for thisparameter are listed below.DescriptionSingle Channel ModeDual Channel ModeQuad Channel ModeConstants to be usedGAGE_SINGLE_CHANGAGE_DUAL_CHANGAGE_QUAD_CHANPage 62 Appendix A <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


• srindexThe parameter srindex is used to set the <strong>CompuScope</strong> sampling rate. Allowed values for thisparameter are listed below.DescriptionConstants to be usedExternalSRTI_EXTERNAL10 GHz SRTI_10_GHZ8 GHz SRTI_8_GHZ5 GHz SRTI_5_GHZ4 GHz SRTI_4_GHZ2 GHz SRTI_2_GHZ1 GHz SRTI_1_GHZ500 MHz SRTI_500_MHZ300 MHz SRTI_300_MHZ250 MHz SRTI_250_MHZ200 MHz SRTI_200_MHZ150 MHz SRTI_150_MHZ130 MHz SRTI_130_MHZ125 MHz SRTI_125_MHZ120 MHz SRTI_120_MHZ100 MHz SRTI_100_MHZ80 MHz SRTI_80_MHZ65 MHz SRTI_65_MHZ60 MHz SRTI_60_MHZ50 MHz SRTI_50_MHZ40 MHz SRTI_40_MHZ30 MHz SRTI_30_MHZ25 MHz SRTI_25_MHZ20 MHz SRTI_20_MHZ12.5 MHz SRTI_12_5_MHZ10 MHz SRTI_10_MHZ5 MHz SRTI_5_MHZ4 MHz SRTI_4_MHZ2 MHz SRTI_2_MHZ1 MHz SRTI_1_MHZ500 KHz SRTI_500_KHZ250 KHz SRTI_250_KHZ100 KHz SRTI_100_KHZ50 KHz SRTI_50_KHZ25 KHz SRTI_25_KHZ<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix A Page 63


10 KHz SRTI_10_KHZ5 KHz SRTI_5_KHZ2 KHz SRTI_2_KHZ1 KHz SRTI_1_KHZ500 Hz SRTI_500_HZ200 Hz SRTI_200_HZ100 Hz SRTI_100_HZ50 Hz SRTI_50_HZ20 Hz SRTI_20_HZ10 Hz SRTI_10_HZ5 Hz SRTI_5_HZ2 Hz SRTI_2_HZ1 Hz SRTI_1_HZPage 64 Appendix A <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


• range_a and range_bThe parameter range_a is used to set the input range for Channel A. For two channel <strong>CompuScope</strong>s,parameter range_b is used to set the input range for Channel B. Allowed values for these parametersare listed below.DescriptionConstant to be used±50 V GAGE_PM_50_V±20 V GAGE_PM_20_V±10 V GAGE_PM_10_V±5 V GAGE_PM_5_V±4 V GAGE_PM_4_V±2 V GAGE_PM_2_V±1 V GAGE_PM_1_V±500 mV GAGE_PM_500_MV±400 mV GAGE_PM_400_MV±200 mV GAGE_PM_200_MV±100 mV GAGE_PM_100_MV±50 mV GAGE_PM_50_MV±20 mV GAGE_PM_20_MV±10 mV GAGE_PM_10_MV±5 mV GAGE_PM_5_MV• range_eThe parameter range_e is used to set the input range for the external trigger.DescriptionConstant to be used±5 V GAGE_PM_5_V±1 V GAGE_PM_1_V• couple_a and couple_bThe parameter couple_a is used to set the input coupling for Channel A. For two channel<strong>CompuScope</strong>s, parameter couple_a is used to set the input coupling for Channel B. Allowed valuesfor these parameters are listed below.DescriptionDCACConstant to be usedGAGE_DCGAGE_AC<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix A Page 65


• couple_eThe parameter couple_e is used to set the input coupling for the External Trigger Input.DescriptionDCACConstant to be usedGAGE_DCGAGE_AC• imped_a and imped_bThe parameter imped_a is used to set the input impedance for Channel A. For two channel<strong>CompuScope</strong>s, parameter imped _a is used to set the input impedance for Channel B. Allowed valuesfor these parameters are listed below.DescriptionConstant to be used1 MΩ GAGE_1_MOHM_INPUT50 Ω GAGE_50_OHM_INPUT• source and source_2The parameter source is the current trigger source for the data acquisition. The values are the same forsource_2. Note that “Channel A OR B” refers to the hardware logical ORing of trigger events fromchannel A and channel B.DescriptionChannel AChannel BChannel A OR BExternalSoftwareConstant to be usedGAGE_CHAN_AGAGE_CHAN_BGAGE_CH_A_CH_BGAGE_EXTERNALGAGE_SOFTWARE• slope and slope_2The parameter slope is the current trigger slope for the data acquisition. The values are the same forslope_2.DescriptionPositiveNegativeConstant to be usedGAGE_POSITIVEGAGE_NEGATIVEPage 66 Appendix A <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


• level and level_2The parameter level is the current trigger level to be used for the next data acquisition. The values arethe same for level 2. For simplicity, the SetBoard() routine in app_supp.c accepts 8-bit trigger levelvalues for all <strong>CompuScope</strong> models. Valid level values range from 0 to 255. Full Scale voltage is setusing a level of 255, minus full scale using a level of 0 and 0 Volts using a level of 128.To convert from a logical level value to a voltage, the formula is:voltage = (value- 128)/128 × (input range of trigger source)The gage_trigger_control_2 API subroutine actually accepts 8-bit trigger level values for 8-bit<strong>CompuScope</strong>s and 12-bit values for <strong>CompuScope</strong>s with more than 8 bit resolution. For programmerswho want to bypass the SetBoard routine and use gage_trigger_control_2 directly, 12-bit triggerlevel values range from 0 to 4095. To convert from a 12-bit logical level value to a voltage, theformula is:For 12, 14, & 16 Bit <strong>CompuScope</strong>s:voltage = (value- 2048)/2048 × (input range of trigger source)• depthThe parameter depth is the trigger or sample depth for the data acquisition. These are the onlyconstants defined, but in fact, any numerical integer value can be used. The drivers will automaticallyadjust unavailable input values to values allowed by the current <strong>CompuScope</strong> hardware.DescriptionConstant to be used0 KB GAGE_POST_0K128 Bytes GAGE_POST_128256 Bytes GAGE_POST_256512 Bytes GAGE_POST_5121 KB GAGE_POST_1K2 KB GAGE_POST_2K4 KB GAGE_POST_4K8 KB GAGE_POST_8K16 KB GAGE_POST_16K32 KB GAGE_POST_32K64 KB GAGE_POST_64K128 KB GAGE_POST_128K256 KB GAGE_POST_256K512 KB GAGE_POST_512K1 MB GAGE_POST_1M2 MB GAGE_POST_2M4 MB GAGE_POST_4M8 MB GAGE_POST_8M16 MB GAGE_POST_16M<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix A Page 67


Example:Below is illustrated a typical example that might be used to set the <strong>CompuScope</strong> 85G. As you can see, therequested sample rate is 5 GS/s, the requested input range is ± 2 Volts etc.extern boarddef board;extern srtype far sample_rate_table[];board.opmode = GAGE_SINGLE_CHAN;board.srindex = SRTI_5_GHZ;board.range_a = GAGE_PM_2_V;board.range_e = GAGE_PM_1_V;board.couple_a = GAGE_DC;board.couple_e = GAGE_DC;board.imped_a = GAGE_50_OHM_INPUT;board.source = GAGE_CHAN_A;board.slope = GAGE_POSITIVE;board.depth = GAGE_POST_4K;board.level = 128;To actually implement these settings, the programmer can simply call the SetBoard() routine that resides inapp_supp.c .Page 68 Appendix A <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Appendix B: <strong>CompuScope</strong>Power ManagementIn order to avoid unnecessary wear on A/D circuitry, some <strong>CompuScope</strong> models are able to power downA/D circuitry when it is not in use. For higher speed <strong>CompuScope</strong> models such as the <strong>CompuScope</strong> 8500and <strong>CompuScope</strong> 82G, the software drivers configure the hardware in automatic power control mode. Inthis mode, the A/D circuitry power is automatically turned ON before an acquisition is performed and isturned OFF afterwards.Toggling the state of the A/D circuitry power takes milliseconds to implement. This can have seriousconsequences for the acquisition of rapidly repeating triggers. For such rapid repetitive acquisitions, itmakes no sense to turn the power OFF and ON between acquisitions and the maximum achievable recordacquisition rate may be seriously comprised. For customers who want to override automatic power controlmode for a high speed <strong>CompuScope</strong> like the CS8500 or CS85G, Gage has provided thegage_power_control subroutine, which is described below.The gage_power_control subroutine takes a control argument that can take three possible values, eachwith a defined constant, whose effect is listed belowGAGE_POWER_ON – This argument turns power to the ADC circuitry ON and leaves it ONGAGE_POWER_OFF - This argument turns power to the ADC circuitry OFF and leaves it OFFGAGE_POWER_AUTO_MASK – This argument is used to place a <strong>CompuScope</strong> in automatic powercontrol mode. In this mode, ADC circuitry power is automatically turn ON before acquisition internally bythe gage_start_capture subroutine. Once the acquisition has been performed and the on-board addresseshave been calculated, the power is turned OFF automatically when the user calls gage_need_ram(TRUE)before downloading the acquired data.For most <strong>CompuScope</strong>s, where thermal wear is not an issue, the gage_power_control argument isautomatically set to GAGE_POWER_ON during initialization, so that the ADC circuitry power is alwaysON. For higher speed <strong>CompuScope</strong>s, like theCS8500 and CS82G, the gage_power_control argument isautomatically set to GAGE_POWER_AUTO_MASK during initialization. This ensures that ADCcircuitry power is only ON when necessary and the <strong>CompuScope</strong> does not sit consuming full power whileit is idle.The process of overriding automatic power-control mode for customers who need to perform rapidacquisitions is simple. First, the programmer needs to call the gage_power_control with an argumentequal to GAGE_POWER_ON before performing multiple acquisitions. After this acquisition sequence isfinished, the user must then call gage_power_control with an argument equal toGAGE_POWER_AUTO_MASK, in order o return the <strong>CompuScope</strong> to automatic power-control mode.Failure to do so will leave ADC circuitry power ON until the driver is reinitialized, which may lead toincreased thermal wear on <strong>CompuScope</strong> ADC circuitry. By leaving the power ON throughout a multipleacquisition sequence, the user is able to achieve the fastest possible repetitive capture performance.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix B Page 69


Appendix C: Compiling<strong>CompuScope</strong> <strong>SDK</strong> C/C++Sample Programs underLabWindows CVIThe <strong>CompuScope</strong> C/C++ <strong>SDK</strong> sample programs can be compiled under National <strong>Instruments</strong> LabWindowsCVI programming environment with relative ease. This document lists the changes required to use thecurrent sample programs from the <strong>CompuScope</strong> <strong>SDK</strong> for C/C++ under LabWindows CVI. After followingthese simple steps, your project can be compiled from within LabWindows CVI like any other CVI project.Modifications to the ‘app_supp.c’ file:App_supp.c is a C source file, which is common to all the <strong>CompuScope</strong> C/C++ <strong>SDK</strong> projects. This filecontains functions that initialize all the <strong>CompuScope</strong> boards found in the system and that set up the<strong>CompuScope</strong> hardware for acquisition by passing user defined parameters to the <strong>CompuScope</strong> boards.Using any Windows editor to open app_supp.c file, follow the steps listed below order to make necessarychanges to the app_supp.c source file so that it can be compiled within the LabWindows CVI environment.STEP 1:Remove the following include directives:#include #include #include #include STEP 2:Replace the line:with this one:gage_get_driver_info_structure (&major_version, &minor_version, &board_support, &gdi,…)gage_get_driver_info_structure ((uInt16 far *)(&major_version), (uInt16 far*)(&minor_version),(uInt16 far *)(&board_support), (void **)(&gdi), (long far *)(&gdi_size));<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix C Page 71


STEP 3:Replace these lines:// if (sample_rate_table[SRTI_EXTERNAL].sr_text != NULL)// free (sample_rate_table[SRTI_EXTERNAL].sr_text);// sample_rate_table[SRTI_EXTERNAL].sr_text = strdup (value_and_units_to_text……)strcpy (sample_rate_table[SRTI_EXTERNAL].sr_text,strdup (value_and_units_to_text…)with these 3 lines surrounded by a macro defined command:#ifndef _CVI_if (sample_rate_table[SRTI_EXTERNAL].sr_text != NULL)free (sample_rate_table[SRTI_EXTERNAL].sr_text);sample_rate_table[SRTI_EXTERNAL].sr_text = strdup (value_and_units_to_text ….)#endifSTEP 4:As in STEP 3, replace these 4 lines of code:// if (sample_rate_table[SRTI_EXTERNAL].sr_text != NULL)// free (sample_rate_table[SRTI_EXTERNAL].sr_text);// sample_rate_table[SRTI_EXTERNAL].sr_text = strdup (value_and_units_to_text……)strcpy (sample_rate_table[SRTI_EXTERNAL].sr_text,strdup (value_and_units_to_text…)with these 3 lines surrounded by a macro define#ifndef _CVI_if (sample_rate_table[SRTI_EXTERNAL].sr_text != NULL)free (sample_rate_table[SRTI_EXTERNAL].sr_text);sample_rate_table[SRTI_EXTERNAL].sr_text = strdup (value_and_units_to_text ….)#endifModifications to the ‘app_supp.h’ fileRemove the following include directives#include #include #include #include Modifications to the Project Source FileEach project in the <strong>CompuScope</strong> C/C++<strong>SDK</strong> for Windows contains a project source file. This filegenerally bears the same name as the project folder itself. For example, the Gage_busmastering projectfolder contains a source file named Gage_busmasterin.c. This file, Gage_busmastering.c, contains themain() code sequence of the Gage_busmastering project.Add following include directive at the beginning of the main C source file (e.g.#include Page 72 Appendix C <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Creating a new LabWindows CVI projectOnce all the above steps have been taken, you are ready to create your new CVI project. Simply create anew CVI project with any name you like, following the steps in the CVI manual, which was provided withyour copy of LabWindows CVI. Next, add to the new CVI project all .c, .h and .lib files that were in theproject folder for the original C <strong>SDK</strong> sample project file. Make sure that you have made the changesoutlined above. You are now ready to compile you new CVI project as you would any other CVI project.Page 73 Appendix C <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


Appendix D: CompuGenCardsWhile this manual concerns only <strong>CompuScope</strong> cards, Gage also manufactures CompuGen ArbitraryWaveform Generator cards. CompuGen cards can be used in conjunction with <strong>CompuScope</strong> cards in someapplications. For instance, signals captured by a <strong>CompuScope</strong> cards can be played back on a CompuGencard. Basic CompuGen concepts are described below.Digital to Analog ConversionDigital to Analog (D/A) conversion is the process by which an analog signal is generated based on an n-bitdigital word or series of words.90A4BAA787DigitalPatternBAA490A78744C296364366DiscreteAnalog Signal(Theoretical)56F4D9D/AOutputFilteredOutputD/A conversion converts a discrete digital signal into a continuous analog signal.Vertical ResolutionThe number of bits with which a D/A system can specify the amplitude of the analog signal is its verticalresolution. For instance, the CompuGen 1100 has 12 bits if vertical resolution.D/A Conversion RateIn any practical D/A system, conversion is controlled by a clock. The frequency of this clock is called theConversion Rate and is measured in Mega Samples per Second (MS/s).<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix D Page 75


Arbitrary Waveform GenerationOne common application of D/A conversion is Arbitrary Waveform Generation. An Arbitrary WaveformGenerator (ARB) is an instrument, which allows the user to generate complex periodic waveforms byspecifying a mathematical equation or a digital pattern. The CompuGen 1100 is an Arbitrary WaveformGenerator.Digital Pattern GenerationConceptually, a Digital Pattern Generator is an Arbitrary Waveform Generator with the D/A chip removed.The user us given access to the digital bits that normally drive the D/A chips.A Pattern Generator can output an n-bit-wide digital pattern which the user can program using simplecommands. The CompuGen 3250 is a Digital Pattern Generator.Conversion Rate vs. Output FrequencyAn analog signal is generated by an ARB by specifying a series of digital words, which are converted toanalog at the conversion rate. If the analog signal must be cyclical, (for example, a sine wave), the digitalpattern must be repeated over and over again to create the cyclical analog output. In general, there must be8 to 10 points per cycle in a pattern to create a good-quality analog signal. Waveforms with differentnumbers of points per cycle are illustrated below.4 PT8 PT16 PTMemory DepthThe maximum number of digital points that an ARB can use to generate analog signals is called theMemory Depth. Memory depth is measured in Kilosamples or Megasamples. For instance, the CompuGen1100 is available with 16 MS on on-board pattern memory.Memory LoopingOne way of increasing or optimizing the memory depth in an ARB is to allow it to loop on a specificpattern for a given number of times. While most commercial ARBs do not have this capability, allCompuGen cards do. Memory looping is completely seamless and the pattern goes from the last to the firstpoint in exactly one clock cycle. With memory looping, it is possible to generate 1000 cycles of a 1 MHzsine wave at a conversion rate of 80 MS/s, using only 80 sample points. Without memory looping, thesame output would have required 80,000 sample points!Page 76 Appendix D <strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l


FilteringThe output of an ideal D/A converter is a step function, which contains very high frequency components,usually not desirable for testing analog circuits. The output of an ARB may therefore need to be filtered inorder to smooth the signal. The CompuGen 1100 comes equipped with several software selectable lowpass output filters.Output BandwidthThe output bandwidth of an ARB is related to the D/A conversion rate as well as the analog bandwidth ofthe output amplifier. For example, the bandwidth of the CompuGen 1100 is specified as 20 MHz, eventhough the conversion rate is 80 MS/s. Generally, the bandwidth is four to ten times less than theconversion rate.Glitch EnergyOne of the key characteristics of any ARB is the Glitch Energy of the D/A.Glitch Energy is defined as the area under the curve around zero-crossing, when the signal is changing itspolarity. In simpler terms, Glitch Energy measures the error signal generated by switching the MSB from,say, low to high, while all other bits are switching from high to low (and vice-versa). This error is causedby a small skew in the internal switching of the signals. CompuGen cards are carefully designed to providethe lowest possible glitch energy.<strong>CompuScope</strong> <strong>SDK</strong> <strong>Manua</strong>l Appendix D Page 77


Technical SupportGage Applied Technologies, Inc. offers technical support for all its Software Development Kits.In order to serve you better, we have created a web-based technical support system that is available to you24 hours a day.By utilizing the internet to the fullest, we are able to provide you better than ever technical support withoutincreasing our costs, thereby allowing us to provide you the best possible product at the lowest possibleprice.To obtain technical support, simply visit:www.gage-applied.com/support.aspPlease complete this form and submit it. Our form processing system will intelligently route your requestto the Technical Support Specialist (TSS) most familiar with the intricacies of your product. This TSS willbe in contact with you within 24 hours of form submittal.In the odd case that you have problems submitting the form on our web site, please e-mail us atsupport@gage-applied.comAs opposed to automatic routing of technical support requests originating from the Gage web site, supportrequests received via e-mail or telephone calls are routed manually by our staff. Providing you with highquality support may take an average of 2 to 3 days if you do not use the web-based technical supportsystem.Please note that Technical Support Requests receivedvia e-mail or by telephone will take an average of 2 to 3 days to process.It is faster to use the web site!When calling for support we ask that you have the following information available:1. Version and type of your <strong>CompuScope</strong> <strong>SDK</strong> and drivers.(The version numbers are indicated on the distribution media. Version numbers can also be obtainedby looking in the appropriate README.TXT files)2. Type, version and memory depth of your <strong>CompuScope</strong> card.3. Type and version of your operating system.4. Type and speed of your computer and bus.5. Any extra hardware peripherals (i.e. CD-ROM, joystick, network card, etc.)6. Were you able to reproduce the problem with standalone Gage Software (e.g. GageScope, GageBit,etc)?


Gage ProductsFor ordering information, see Gage’s product catalog, or visit our web site athttp://www.gage-applied.comCompactPCI Bus Products <strong>CompuScope</strong> 85GC 8 bit, 5 GS/s Analog Input Card<strong>CompuScope</strong> 82GC8 bit, 2 GS/s Analog Input Card<strong>CompuScope</strong> 14100C14 bit, 100 MS/s Analog Input Card<strong>CompuScope</strong> 1610C16 bit, 10 MS/s Analog Input Card<strong>CompuScope</strong> 3200C32 bit, 100 MHz Digital Input for CompactPCI BusPCI Bus Products <strong>CompuScope</strong> 1610 16 bit, 10 MS/s Analog Input Card<strong>CompuScope</strong> 160216 bit, 2.5 MS/s Analog Input Card<strong>CompuScope</strong> 1420014 bit, 200 MS/s Analog Input Card<strong>CompuScope</strong> 1410514 bit, 105 MS/s Analog Input Card<strong>CompuScope</strong> 1410014 bit, 100 MS/s Analog Input Card<strong>CompuScope</strong> 145014 bit, 50 MS/s Analog Input Card<strong>CompuScope</strong> 1210012 bit, 100 MS/s Analog Input Card<strong>CompuScope</strong> 125012 bit, 50 MS/s Analog Input Card<strong>CompuScope</strong> 122012 bit, 20 MS/s Analog Input Card<strong>CompuScope</strong> 85G8 bit, 5 GS/s Analog Input Card<strong>CompuScope</strong> 82G8 bit, 2 GS/s Analog Input Card<strong>CompuScope</strong> 85008 bit, 500 MS/s Analog Input Card<strong>CompuScope</strong> 320032 bit, 100 MHz Digital Input for PCI BusCompuGen CompuGen 1100 12 bit, 80 MS/s Analog Output CardCompuGen 325032 bit, 50 MHz Digital Output CardApplication Software GageScope World's Most Powerful Oscilloscope SoftwareGageBitDigital Input/Output SoftwareCompuGen for WindowsArbitrary Waveform Generator Software for WindowsSoftware Development Kits<strong>CompuScope</strong> <strong>SDK</strong> for C/C++ for Windows<strong>CompuScope</strong> LabVIEW <strong>SDK</strong> for Windows<strong>CompuScope</strong> MATLAB <strong>SDK</strong> for Windows<strong>CompuScope</strong> LabWindows/CVI <strong>SDK</strong>(for CompactPCI/PXI bus <strong>CompuScope</strong> cards)CompuGen Analog <strong>SDK</strong> for C/C++ for WindowsCompuGen Digital <strong>SDK</strong> for C/C++ for WindowsCompuGen Analog LabVIEW <strong>SDK</strong> for WindowsCompuGen Digital LabVIEW <strong>SDK</strong> for WindowsCompuGen Analog MATLAB <strong>SDK</strong> for WindowsCompuGen Digital MATLAB <strong>SDK</strong> for WindowsInstrument Mainframes Instrument Mainframe 7000Instrument Mainframe 2000Instrument Mainframe 8000CInstrument Mainframes for Housing <strong>CompuScope</strong> andCompuGen Products.Instrument Mainframes for Housing CompactPCI/PXI<strong>CompuScope</strong> and CompuGen Products.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!