13.07.2015 Views

An Integrated, Modular Simulation System for Education ... - Cal Poly

An Integrated, Modular Simulation System for Education ... - Cal Poly

An Integrated, Modular Simulation System for Education ... - Cal Poly

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

set(&yawForceOut,*uPtrs[26]);set(&rollForceOut,*uPtrs[27]);set(&pitchForceOut,*uPtrs[28]);}/*---------------------------------------------------------------------------* Source code <strong>for</strong> DACCard*---------------------------------------------------------------------------*//***** setup <strong>for</strong> d/a *****/void DACCardInit(struct DAC *card){short channel;unsigned short count;unsigned short addr1;float voltage;voltage=0;if (card->nBits > 16 || card->nBits < 2)printf("DAC error: Cannot set <strong>for</strong> %d bits\n", card->nBits);card->maxCount = (unsigned short)((1 nBits) - 1);card->gainVtoCounts = (float)card->maxCount/(card->pLimit - card->nLimit);card->vOffset = -(card->nLimit);<strong>for</strong> (channel = 0; channel < card->nChannels; channel++) {if (channel >= card->nChannels)printf("DACCard: channel %d is out of range\n", channel);if (card->vDefault > card->pLimit || card->vDefault < card->nLimit) {if (errorChecking)printf("DACCard: Voltage %1.3f is out of range\n", card->vDefault);voltage = (voltage > card->pLimit) ? card->pLimit : card->nLimit;}}}count = (unsigned short)(card->gainVtoCounts*(voltage + card->vOffset));addr1 = card->baseAddr + (channel channelNumber >= Card->nChannels) {printf("DACCard: channel %d is out of range\n", chan->channelNumber);}elsechan->addr = Card->baseAddr + (chan->channelNumber min == chan->max) {min = Card->nLimit;max = Card->pLimit;chan->gain = (float)(Card->maxCount)/(max - min);}112

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!