Beispiel #1
0
asynStatus USB1608G::readInt32(asynUser *pasynUser, epicsInt32 *value)
{
  int addr;
  int function = pasynUser->reason;
  int status=0;
  unsigned short shortVal;
  int range;
  //static const char *functionName = "readInt32";

  this->getAddress(pasynUser, &addr);

  // Analog input function
  if (function == analogInValue_) {
    getIntegerParam(addr, analogInRange_, &range);
    status = cbAIn(boardNum_, addr, range, &shortVal);
    *value = shortVal;
    setIntegerParam(addr, analogInValue_, *value);
  }

  // Other functions we call the base class method
  else {
     status = asynPortDriver::readInt32(pasynUser, value);
  }
  
  callParamCallbacks(addr);
  return (status==0) ? asynSuccess : asynError;
}
Beispiel #2
0
void main ()
    {
    /* Variable Declarations */
    int Row,Col;
        int Row2,Col2;
    int BoardNum = 0;
    int UDStat = 0;
    int Chan;
    int Gain = BIP5VOLTS;
    WORD DataValue = 0;
        float    EngUnits;
        float    RevLevel = (float)CURRENTREVNUM;

  /* Declare UL Revision Level */
   UDStat = cbDeclareRevision(&RevLevel);


    /* Initiate error handling
       Parameters:
           PRINTALL :all warnings and errors encountered will be printed
           DONTSTOP :program will continue even if error occurs.
                     Note that STOPALL and STOPFATAL are only effective in 
                     Windows applications, not Console applications. 
   */
    cbErrHandling (PRINTALL, DONTSTOP);

    /* set up the screen */
    ClearScreen();
    printf ("Demonstration of cbAIn()\n");
    printf ("Press any key to quit.\n\n");

    /* get the A/D channel to sample */
    printf ("Enter the channel to display: ");
    scanf("%i", &Chan);

        printf ("\n\nThe raw data value on Channel %u is: ", Chan);
    GetTextCursor (&Col, &Row);

        printf ("\nThe voltage on Channel %u is:......... ", Chan);
        GetTextCursor (&Col2, &Row2);

    /* collect the sample from the channel until a key is pressed */
    while (!kbhit())
        {
        /*Parameters:
            BoardNum    :number used by CB.CFG to describe this board
            Chan        :input channel number
            Gain        :gain for the board in BoardNum
            DataValue   :value collected from Chan */

        UDStat = cbAIn (BoardNum, Chan, Gain, &DataValue);
        UDStat = cbToEngUnits (BoardNum, Gain, DataValue, &EngUnits);

        MoveCursor(Col, Row);
                printf ("%6u ", DataValue);
                MoveCursor(Col2, Row2);
                printf ("%.2f ", EngUnits);
        }
    }
Beispiel #3
0
void usb1208ls_ReadFeedback (acqchanPtr acqchan)
{
    MCCdevPtr dev = acqchan->dev;
    float temp;
    unsigned short reading;
    cbAIn (dev->BoardNum,   0, //channel
                BIP10VOLTS, 
                &reading);
    cbToEngUnits (dev->BoardNum, BIP10VOLTS, reading, &temp);
//  acqchan->reading = src->biaslevel ;
    
    acqchan->reading = (double)temp;
    acqchan->newreading = TRUE;
/*
    acqchan->reading HAS to be the same units and magnitude as the source->biaslevel, or it has to be converted
//*/
}
Beispiel #4
0
void main ()
{
    /* Variable Declarations */
    int Row,Col;
    int BoardNum = 0;
    int ULStat = 0;
    int Chan;
    int Gain = BIPPT625VOLTS;
    WORD DataValue = 0;
    float EngUnits;
    float    RevLevel = (float)CURRENTREVNUM;

    /* Declare UL Revision Level */
    ULStat = cbDeclareRevision(&RevLevel);

    /* Initiate error handling
        Parameters:
            PRINTALL :all warnings and errors encountered will be printed
           DONTSTOP :program will continue even if error occurs.
                     Note that STOPALL and STOPFATAL are only effective in
                     Windows applications, not Console applications.
    */
    cbErrHandling (PRINTALL, DONTSTOP);

    /* set up the screen */
    ClearScreen();
    printf ("Demonstration of voltage conversions.\n\n");

    /* get the A/D channel to sample */
    printf ("Enter the channel to display: ");
    scanf("%d", &Chan);

    printf ("\n\nNote: Please make certain that the board you are using supports\n");
    printf ("      the gain you are choosing and if it is not a programmable\n");
    printf ("      gain that the switches on the board are set correctly.\n\n");
    GetTextCursor (&Col, &Row);

    /* collect the sample with cbAIn() */
    while (Gain > 0)
    {
        do
        {   /* select gain */
            MoveCursor(12,10);
            printf("Please select one of the following ranges(1 to 4):\n\n");
            printf("                           10 VOLTS UNIPOLAR --> 1\n");
            printf("                           10 VOLTS BIPOLAR ---> 2\n");
            printf("                            5 VOLTS UNIPOLAR --> 3\n");
            printf("                            5 VOLTS BIPOLAR ---> 4\n");
            printf("                                       Quit ---> 0\n\n");
            printf("                                Your Choice ---> ");
            scanf ("%i",&Gain);
        } while ((Gain < 0) || (Gain > 4));

        /* Set Gain, MaxVal, and MinVal */
        switch (Gain)
        {
        case 0:
            exit(1);
        case 1:
            Gain = UNI10VOLTS;
            break;
        case 2:
            Gain = BIP10VOLTS;
            break;
        case 3:
            Gain = UNI5VOLTS;
            break;
        case 4:
            Gain = BIP5VOLTS;
            break;
        default:
            break;
        }

        /*Parameters:
            BoardNum    :number used by CB.CFG to describe this board
            Chan        :input channel number
            Gain        :gain for the board in BoardNum
            DataValue   :value collected from Chan */

        if (Gain >= 0)
        {
            ULStat = cbAIn (BoardNum, Chan, Gain, &DataValue);
            ULStat = cbToEngUnits(BoardNum, Gain, DataValue, &EngUnits);

            printf ("\nThe voltage on channel %d is %.2f ", Chan, EngUnits);
        }
        Gain = BIPPT625VOLTS;
    }
}
Beispiel #5
0
void MccUSBDAQDevice::getChannelInfo()
{	
	std::map <int, std::string> allRanges;

	allRanges[BIP20VOLTS] = "+/- 20 V";
	allRanges[BIP10VOLTS] = "+/- 10 V";
	allRanges[BIP5VOLTS] = "+/- 5 V";
	allRanges[BIP4VOLTS] = "+/- 4 V";
	allRanges[BIP2PT5VOLTS] = "+/- 2.5 V";
	allRanges[BIP2VOLTS] = "+/- 2 V";
	allRanges[BIP1PT25VOLTS] = "+/- 1.25 V";
	allRanges[BIP1VOLTS] = "+/- 1 V";
	allRanges[BIPPT625VOLTS] = "+/- 0.625 V";
	allRanges[BIPPT5VOLTS] = "+/- 0.5 V";
	allRanges[BIPPT25VOLTS] = "+/- 0.25 V";
	allRanges[BIPPT2VOLTS] = "+/- 0.2 V";
	allRanges[BIPPT1VOLTS] = "+/- 0.1 V";
	allRanges[BIPPT05VOLTS] = "+/- 0.05 V";
	allRanges[BIPPT01VOLTS] = "+/- 0.01 V";
	allRanges[BIPPT005VOLTS] = "+/- 0.005 V";
	allRanges[BIP1PT67VOLTS] = "+/- 1.67 V";

	allRanges[UNI10VOLTS] = "0 - 10 V";
	allRanges[UNI5VOLTS] = "0 - 5 V";
	allRanges[UNI4VOLTS] = "0 - 4 V";
	allRanges[UNI2PT5VOLTS] = "0 - 2.5 V";
	allRanges[UNI2VOLTS] = "0 - 2 V";
	allRanges[UNI1PT67VOLTS] = "+/- 1.67 V";
	allRanges[UNI1PT25VOLTS] = "+/- 1.25 V";
	allRanges[UNI1VOLTS] = "+/- 1 V";
	allRanges[UNIPT5VOLTS] = "+/- 0.5 V";
	allRanges[UNIPT25VOLTS] = "+/- 0.25 V";
	allRanges[UNIPT2VOLTS] = "+/- 0.2 V";
	allRanges[UNIPT1VOLTS] = "+/- 0.1 V";
	allRanges[UNIPT05VOLTS] = "+/- 0.05 V";
	allRanges[UNIPT02VOLTS] = "+/- 0.02 V";
	allRanges[UNIPT01VOLTS] = "+/- 0.01 V";

	std::map<int, std::string>::iterator it;
	int errorCode;
	unsigned short val;
	availableADInRanges = allRanges;

	if (driverMutex != 0)
	{
		driverMutex->lock();

		for(it = allRanges.begin(); it != allRanges.end(); it++)
		{
			errorCode = cbAIn(boardNum,0,it->first,&val);
			if(errorCode == BADRANGE)
				availableADInRanges.erase(it->first);
		}

		//If all ranges are available, it's more likely that the board is not programmable.
		if (availableADInRanges.size() == allRanges.size())
			availableADInRanges.clear();

		availableDAOutRanges = allRanges;
		val = 0;
		for(it = allRanges.begin(); it != allRanges.end(); it++)
		{
			//Check only the first DA channel
			errorCode = cbAOut(boardNum,0,it->first,val);
			if(errorCode == BADRANGE)
				availableDAOutRanges.erase(it->first);
		}

		driverMutex->unlock();
	}

	//If all ranges are available, it's more likely that the board is not programmable.
	if (availableDAOutRanges.size() == allRanges.size())
		availableDAOutRanges.clear();

}