Exemplo n.º 1
0
long eAIN(HANDLE Handle, ue9CalibrationInfo *CalibrationInfo, long ChannelP, long ChannelN, double *Voltage, long Range, long Resolution, long Settling, long Binary, long Reserved1, long Reserved2)
{
    uint8 IOType, Channel, AINM, AINH, ainGain;
    uint16 bytesVT;

    if( isCalibrationInfoValid(CalibrationInfo) == 0 )
    {
        printf("eAIN error: calibration information is required");
        return -1;
    }

    if( Range == LJ_rgBIP5V )
        ainGain = 8;
    else if( Range == LJ_rgUNI5V )
        ainGain = 0;
    else if( Range == LJ_rgUNI2P5V )
        ainGain = 1;
    else if( Range == LJ_rgUNI1P25V )
        ainGain = 2;
    else if( Range == LJ_rgUNIP625V )
        ainGain = 3;
    else
    {
        printf("eAIN error: Invalid Range\n");
        return -1;
    }

    if( ehSingleIO(Handle, 4, (uint8)ChannelP, ainGain, (uint8)Resolution, (uint8)Settling, &IOType, &Channel, NULL, &AINM, &AINH) < 0 )
        return -1;

    bytesVT = AINM + AINH*256;

    if( Binary != 0 )
    {
        *Voltage = (double)bytesVT;
    }
    else
    {
        if( ChannelP == 133 || ChannelP == 141 )
        {
            if( getTempKCalibrated(CalibrationInfo, 0, bytesVT, Voltage) < 0 )
                return -1;
        }
        else
        {
            if( getAinVoltCalibrated(CalibrationInfo, ainGain, (uint8)Resolution, bytesVT, Voltage) < 0 )
                return -1;
        }
    }

    return 0;
}
Exemplo n.º 2
0
long eDAC(HANDLE Handle, ue9CalibrationInfo *CalibrationInfo, long Channel, double Voltage, long Binary, long Reserved1, long Reserved2)
{
    uint8 IOType, channel;
    uint16 bytesVoltage;

    if( isCalibrationInfoValid(CalibrationInfo) == 0 )
    {
        printf("eDAC error: calibration information is required");
        return -1;
    }

    if( getDacBinVoltCalibrated(CalibrationInfo, (uint8)Channel, Voltage, &bytesVoltage) < 0 )
        return -1;

    return ehSingleIO(Handle, 5, (uint8)Channel, (uint8)( bytesVoltage & (0x00FF) ), (uint8)(( bytesVoltage /256 ) + 192), 0, &IOType, &channel, NULL, NULL, NULL);
}
Exemplo n.º 3
0
long eDAC(HANDLE Handle, ue9CalibrationInfo *caliInfo, long Channel, double Voltage, long Binary, long Reserved1, long Reserved2)
{
  uint8 IOType, channel;
  uint16 bytesVoltage;

  if(isCalibrationInfoValid(caliInfo) == -1)
  {
    analogToUncalibratedBinaryVoltage(Voltage, &bytesVoltage);
  }
  else
  {
    if(analogToCalibratedBinaryVoltage(caliInfo, (uint8)Channel, Voltage, &bytesVoltage) < 0) 
      return -1;
  }

  return ehSingleIO(Handle, 5, (uint8)Channel, (uint8)( bytesVoltage & (0x00FF) ), (uint8)(( bytesVoltage /256 ) + 192), 0, &IOType, &channel, NULL, NULL, NULL);
}
Exemplo n.º 4
0
long eAIN(int fd, ue9CalibrationInfo *caliInfo, long ChannelP, long ChannelN, double *Voltage, long Range, long Resolution, long Settling, long Binary, long Reserved1, long Reserved2)
{
  uint8 IOType, Channel, AINM, AINH, ainGain;
  uint16 bytesVT;

  if(Range == LJ_rgBIP5V)
    ainGain = 8;
  else if(Range == LJ_rgUNI5V)
    ainGain = 0;
  else if(Range == LJ_rgUNI2P5V)
    ainGain = 1;
  else if(Range == LJ_rgUNI1P25V)
    ainGain = 2;
  else if(Range == LJ_rgUNIP625V)
    ainGain = 3;
  else
  {
      printf("eAIN error: Invalid Range\n");
      return -1;
  }

  if(ehSingleIO(fd, 4, (uint8)ChannelP, ainGain, (uint8)Resolution, (uint8)Settling, &IOType, &Channel, NULL, &AINM, &AINH) < 0)
    return -1;

  bytesVT = AINM + AINH*256;

  if(Binary != 0)
  {
    *Voltage = (double)bytesVT;
  }
  else
  {
    if(isCalibrationInfoValid(caliInfo) == -1)
    {
      if(Channel == 133 || ChannelP == 141)
      {
        binaryToUncalibratedAnalogTemperature(bytesVT, Voltage);
      }
      else
      {
        if(binaryToUncalibratedAnalogVoltage(ainGain, Resolution, bytesVT, Voltage) < 0)
          return -1;
      }
    }
    else
    {
      if(ChannelP == 133 || ChannelP == 141)
      {
        if(binaryToCalibratedAnalogTemperature(caliInfo, 0, bytesVT, Voltage) < 0)
          return -1;
      }
      else
      {
        if(binaryToCalibratedAnalogVoltage(caliInfo, ainGain, (uint8)Resolution, bytesVT, Voltage) < 0)
          return -1;
      }
    }
  }

  return 0;
}