Delta 36-R31 User Manual Page 38

  • Download
  • Add to my manuals
  • Print
  • Page
    / 84
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 37
ACC-36E Manual
USing acc-36E with power umac 38
Example: Unipolar/Bipolar ADC Read in a CPLC
Configuring two ACC-36E cards: 1
st
card has unipolar inputs and is at base offset $A00000, and 2
nd
card
has bipolar inputs at base offset $B00000.
#include <gplib.h>
#include <stdio.h>
#include <dlfcn.h>
// Definition(s)
#define FirstCardNumber 0 // At Base Offset $A00000
#define SecondCardNumber 1 // At Base Offset $B00000
// Prototype(s)
int WaitForADC(unsigned int Card_Index);
void user_plcc() {
unsigned int ADC_Result_Unipolar[16],index;
int ADC_Result_Bipolar[16],waitResult = 0;
char buffer[32]="";
double temp = 0,ConvertCode = 0;
// Access ADC results one by one in a for loop
for(index = 0; index < 8; index++) {
// Prepare string
sprintf(buffer,"ACC36E[%d].ConvertCode",FirstCardNumber);
ConvertCode = index; // Compute convert code
// Write Unipolar convert code to Channel Select structure
SetPmacVar(buffer,ConvertCode);
// Poll conversion complete bits until the conversions are finished
waitResult = WaitForADC(FirstCardNumber);
if(waitResult < 0)
{
return; // Conversion was not successful
}
// Prepare string
sprintf(buffer,"ACC36E[%d].ADCuLow",FirstCardNumber);
GetPmacVar(buffer,&temp); // Read the structure
// Cast and store low unipolar (unsigned) ADC Result in array element
ADC_Result_Unipolar[index] = (unsigned int)temp;
// Prepare string
sprintf(buffer,"ACC36E[%d].ADCuHigh",FirstCardNumber);
GetPmacVar(buffer,&temp); // Read the structure
// Cast and store high unipolar (unsigned) ADC Result in array element
ADC_Result_Unipolar[index + 8] = (unsigned int)temp;
// Prepare string
sprintf(buffer,"ACC36E[%d].ConvertCode",SecondCardNumber);
ConvertCode = index + 8; // Compute convert code
// Write bipolar convert code to Channel Select structure
SetPmacVar(buffer,ConvertCode);
// Poll conversion complete bits until the conversions are finished
waitResult = WaitForADC(SecondCardNumber);
if(waitResult < 0)
{
return; // Conversion was not successful
}
// Prepare string
sprintf(buffer,"ACC36E[%d].ADCsLow",SecondCardNumber);
GetPmacVar(buffer,&temp); // Read the structure
// Cast and store low bipolar (signed) ADC Result in array element
ADC_Result_Bipolar[index] = (int)temp;
// Prepare string
sprintf(buffer,"ACC36E[%d].ADCsHigh",SecondCardNumber);
GetPmacVar(buffer,&temp); // Read the structure
// Cast and store high bipolar (signed) ADC Result in array element
ADC_Result_Bipolar[index + 8] = (int)temp;
/******Insert user code here, where ADC_Result_Unipolar elements
and ADC_Result_Bipolar elements
can be used for the user's calculations*************/
}
return;
}
int WaitForADC(unsigned int Card_Index)
Page view 37
1 2 ... 33 34 35 36 37 38 39 40 41 42 43 ... 83 84

Comments to this Manuals

No comments