DCMotorCommand::~DCMotorCommand(void) { for(int i = 0; i < numMotors; i++) { cbVOut(BoardNumVoltage, 2 * i, voltageGain, 0, Options); } cbDOut(BoardNumVoltage, 1, 0); }
int DCMotorCommand::SendVoltageArrayOut(double *voltages) { for(int i = 0; i < numMotors; i++) { if(*(voltages + i) >= minVoltage && *(voltages + i) <= maxVoltage) { cbVOut(BoardNumVoltage, 2 * i, voltageGain, *(voltages + i), Options); motorVoltages[i] = *(voltages+i); } } return 0; }
bool MccUSBDAQDevice::setOutputVoltage(int channel, float outputVoltage) { bool success = false; if (driverMutex != 0) { driverMutex->lock(); // the cbw.h library requires that this takes a float?! really? UDStat = cbVOut (boardNum, analogInChannels.find(channel)->second, DAOutRange, outputVoltage, Options); if(UDStat == NOERRORS) success = true; driverMutex->unlock(); } return success; }
DCMotorCommand::DCMotorCommand(void) { numMotors = 7; BoardNumVoltage = 0; Options = DEFAULTOPTION; voltageGain = UNI10VOLTS; minVoltage = 0.0; maxVoltage = 2.0; bIsAmplifiersOn = false; // Initializing VoltageOut modules for(int i = 0; i < numMotors; i++) { cbVOut(BoardNumVoltage, 2 * i, voltageGain, 0, Options); } // Configuring Digital Outputs cbDConfigPort(BoardNumVoltage, 1, DIGITALOUT); cbDOut(BoardNumVoltage, 1, 0); }
void main () { /* Variable Declarations */ int ch; int Row, Col; int BoardNum = 0; int ULStat = 0; int Gain = BIP10VOLTS; int Options = DEFAULTOPTION; int Chan; float DataValue; int UDStat = 0; float min, max; 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 display screen */ ClearScreen(); printf ("Demonstration of cbVOut()\n\n"); /* get the D/A channel to sample */ printf ("Enter the channel to display: "); scanf("%i", &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); while (Gain > 0 && !kbhit()) { do { /* select gain */ MoveCursor(Col,Row); 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; min=0.0; max=10.0; break; case 2: Gain = BIP10VOLTS; min=-10.0; max=10.0; break; case 3: Gain = UNI5VOLTS; min=0.0; max=5.0; break; case 4: Gain = BIP5VOLTS; min=-5.0; max=5.0; break; default: break; } UDStat = NOERRORS; while (UDStat == NOERRORS) { printf ("\n\nEnter a voltage between %.1f and +%.1f: ", min, max); scanf ("%f", &DataValue); ULStat = cbVOut (BoardNum, Chan, Gain, DataValue, Options); if(UDStat == NOERRORS) { printf ("\n %.2f volts has been sent to D/A %d.\n\n", DataValue, Chan); printf ("Press Q to quit , any other key to continue:\n "); while (!kbhit()){} ch=getch(); if (ch=='q' || ch=='Q') exit(1); } } } }