VXI SVM2608 user manual Appendix a, Data Swapping Example

Page 55

www.vxitech.com

APPENDIX A

APPENDIX A

DATA SWAPPING EXAMPLE

An example is provided below detailing how data might be swapped in to get a REAL number when the data is read “swapped”. In order to make the code easier to understand, only the portion that shuffles the data is presented here. The VME functions that actually perform the reading of the data are the responsibility of the user.

byte tempData[16]; int regRdata[16]; doublerealData;

union

{char data[8];

doublevalue;

}dblData;

// read results

data = VmeRead16(channel, VmeAddress+0x28, &Api_Result); printf("MSB1: %02x\n", data);

regRdata[0] = data;

data = VmeRead16(channel, VmeAddress+0x2a, &Api_Result); printf("MSB0: %02x\n", data);

regRdata[1] = data;

data = VmeRead16(channel, VmeAddress+0x2c, &Api_Result); printf("LSB1: %02x\n", data);

regRdata[2] = data;

data = VmeRead16(channel, VmeAddress+0x2e, &Api_Result); printf("LSB0: %02x\n", data);

regRdata[3] = data;

//now shuffle the bytes

dblData.data[0] = (byte)((regRdata[3] & 0xff00) >> 8); dblData.data[1] = (byte)((regRdata[3] & 0x00ff) >> 0); dblData.data[2] = (byte)((regRdata[2] & 0xff00) >> 8); dblData.data[3] = (byte)((regRdata[2] & 0x00ff) >> 0); dblData.data[4] = (byte)((regRdata[1] & 0xff00) >> 8); dblData.data[5] = (byte)((regRdata[1] & 0x00ff) >> 0); dblData.data[6] = (byte)((regRdata[0] & 0xff00) >> 8); dblData.data[7] = (byte)((regRdata[0] & 0x00ff) >> 0); realData = dblData.value;

SVM2608 Appendix A

55

Image 55
Contents SVM2608 VXI Technology, Inc Table of Contents Self Test Command Restricted Rights Legend WarrantyLimitation of Warranty CertificationSteve Mauga, QA Manager EMCUse Proper Power Source Service should only be performed by qualified personnelTerms and Symbols Use Proper Power CordImproper Use Avoid Electric ShockGround the Product Operating ConditionsTechnical Support VXI Technology World HeadquartersVXI Technology Cleveland Instrument Division VXI Technology Lake Stevens Instrument DivisionVXI Technology, Inc SVM2608 Preface Overview IntroductionScale Triggering Acquiring DataDelayed Trigger Linear ModePre-Trigger Test Bus Fifo ModeCommands CalibrationsOption SVM2608 Block Diagram Physical Description SVM2608 Environmental SpecificationsCH1I+ GND CH3I+ Exttrigin CH0I CH2I Front Panel Interface WiringGND CH1I CH3I GNDMtbf SVM2608 SpecificationsOption 1 SVM2608-01 VXI Technology, Inc SVM2608 Introduction Setting the Chassis Backplane Jumpers Calculating System Power and Cooling RequirementsRotary Switch Locations Setting the Base AddressDivide Decimal ExampleMSB LSB Module INSTALLATION/REMOVAL Switch to C and the front switch toRegister Offset Device Memory MapsFunction Offset ReservedMS = Most Significant LS = Least Significant SVM2608 A32 Register MAP0x72 Command Register Channel 0x74 Databyte Ordering Determining the Register Address Description of Registers Accessing the RegistersSysfailctl EXT Trig Slope Force Trigger, Start Register 0x02 Read & WriteINTLVL2 HSTRIGSRC2Reserved TimeoutctlExternal Trigger Level 0x06 Read & Write ATTN-GAIN1-GAIN0 2WIREOHMS4WIREOHMS LINEAR/FIFOSample Rate 0x0E, 0x36, 0x5E, 0x86 Read & Write Sample Rate 0x0C, 0x34, 0x5C, 0x84 Read & WriteKHz Channels 0-3/5 MHz Channels 4-5 LPF Control This bit Sample Rate, High-Speed 0xAE, 0xD6 Read & Write Sample Rate, High-Speed 0xAC, 0xD4 Read & WriteTimeout 0x1C, 0x44, 0x6C, 0x94, 0xBC, 0xE4 Read & Write Fifo Data 0x26, 0x4E, 0x76, 0x9E, 0xC6, 0xEE Read Only Fifo Data 0x24, 0x4C, 0x74, 0x9C, 0xC4, 0xEC Read OnlyReserved Registers 0xF8 0xFC Trigger Delay = Measurement Commands Microprocessor CommandsCaptured Data Calculations Resistance Measurement Offset Method Self Test CommandResistance Measurement Dynamic Method Example Preset Setting Measurement CommandsTrigger Event Forced Trigger Calibration CommandsSample Points Sample RatePage Error Processing There are no errors in the queue Diagnostic Commands Changes become effective the next time the module powers up Examples Example 2 Setting Channel 2 to Acquire 200,000 SamplesExample 3 Setting Channel 2 to Pre-acquire 100,000 Samples Timeout Register = Timeout Base * 213 + Timeout Counter Timeout Counter = Timeout / Timeout Base ClockVXI Technology, Inc SVM2608 Programming Data Swapping Example Appendix aVXI Technology, Inc SVM2608 Appendix a Index