/* FILE: DAC1_0.C AUTH: P.OH - Boondog Automation DATE: 08/30/00 DESC: DAC0832 TEST. User enters desired voltage */ #include #include #include #include void main(void) { int baseAddress = 608; /* Row 4 of 8-pin header */ int dataWord; /* Byte representation in decimal */ float voltageOut; /* Voltage out in Volts */ float voltageRef = 5.0; /* Reference voltage set to +5V */ clrscr(); window(5,5,50,75); for(;;) { gotoxy(2,2); cprintf("Enter desired output voltage: e.g. -4.5 to 4.5 or 999.0 to Quit:"); scanf("%f", &voltageOut); if(voltageOut == 999.0) exit(0); dataWord = (int)(((voltageOut * 128.0) / voltageRef) + 128); gotoxy(2,3); cprintf("Data word is %d", dataWord); outportb(baseAddress, dataWord); } }