#include #include #include #include #include #include "SSH0XDRV.H" unsigned BaseAddress=0x0350; void ExitProgram(int errorCode) { clrscr(); puts("A fatal error occured, program halted!"); printf("Error code returned was %d.\n", errorCode); } unsigned AskForBaseAddress(unsigned int OldOne) { char msg[7]; int NewOne = 0, Success = 0, Dummy; int AddrInputPosX, AddrInputPosY; puts("\nPlease enter the Base Address for your card (in hex)"); printf("or press ENTER for %X.\n>", OldOne); AddrInputPosX = wherex(); AddrInputPosY = wherey(); do { gotoxy(AddrInputPosX, AddrInputPosY); clreol(); msg[0] = 5; msg[1] = 0; cgets(msg); sscanf(msg + 2, "%x", &NewOne); Success = 1; Dummy = NewOne; if (msg[1] == 0) { gotoxy(AddrInputPosX, AddrInputPosY); printf("%X", OldOne); Success = 1; Dummy = OldOne; } } while(!Success); return (Dummy); } /* end of AskForBaseAddress */ int main(void) { uint *buf = (unsigned*)malloc(8); char Choice = 1; uint i, error; clrscr(); BaseAddress=AskForBaseAddress(BaseAddress); // Prompt for base address SetBaseAddress(BaseAddress); // Tell driver the base address // to use puts("Borland C Language Sample for SSH-0x. Version 1.06\n\n"); puts("This sample will show how to use the driver in mode 0."); puts("Specs for mode 0:"); puts(" Total Software control."); puts(" OP3 (PIN 10) controls HOLD.\n"); puts("A/D Card setup:"); printf(" Card is at base address %3X Hex.\n", BaseAddress); if (AD_NAME() == AD128CARD) puts(" Remove jumpers D0-D3 on your AD12-8 card."); puts(""); puts("SSH-0x Card setup:"); puts(" Please place the A/D CH SEL jumper at 0."); puts(" Switches A, B, and C of MODE CONTROL should all be OFF."); if (AD_NAME() == AD128CARD || AD_NAME() == AD1216CARD) puts(" MASTER, 2, and 3 should be ON. Switches 1 and 4 should be OFF.\n"); else puts(" MASTER, 1, and 4 should be ON. Switches 2 and 3 should be OFF.\n"); puts("Press any key to continue...\n"); getch(); clrscr(); puts("The card will now be placed in Hold mode by setting OP3 high."); puts("Eight data points will be taken from the SSH-0x card, one from each"); puts("channel. (If you are using an SSH-04 card, channels 4-7 should be"); puts("ignored) The card will then be placed back into Sample mode and"); puts("the values will be displayed. Two passes will be taken."); puts("Press a key to proceed..."); getch(); clrscr(); while (Choice) { // As long as user wants to // continue // Call driver --- // Parameter list // 1 : First channel is channel number 0 // 2 : Last channel is channel number 7 // 3 : Repeat for only 1 scan // 4 : Trigger source is by software // 5 : No initial delay // 6 : Acquistion not controlled by counters, so period is 0 // 7 : IRQ not necessary, set to 0 // 8 : Use Mode 0 // 9 : Data buffer is buf error = PerformSSHDataAcquisition(0,7,1,1,0,0,0,0,buf); if (error) { ExitProgram(error); return error; } clrscr(); puts("\n Channel Volts\n"); // display data for for (i=0;i<=7;i++) // 8 channels used printf(" %2u % 1.3f\n\r", i, (float)((buf[i] * (10.0 / 4096.0))) - 5.0); // display in volts puts("\n"); puts("Press the space bar to repeat or any other key to exit..."); Choice = getch() == ' '; // repeat as long // as user presses // the spacebar } puts("Exiting Sample 0 Program..."); return 0; }