📄 softtrig.c
字号:
/***************************************************************************
FILE NAME: SOFTTRIG.C
FILE DESCRIPTION: SOFTTRIG (Software Triggering)
Sample program that demonstrates how to trigger an analog to digital
conversion using a software trigger.
This simple program samples from the A/D board using software triggering.
The acquired data is displayed on the screen.
PROJECT NAME: SOFTTRIG (Part of DM6430 DOS Driver)
DRIVER VERSION: 1.1
COMPILER: Borland C++ 3.1
TARGET: Real-Mode DOS
Copyright 2003 RTD Embedded Technologies
***************************************************************************/
#include <conio.h>
#include <dos.h>
#include "drvr6430.h"
#include "dio5812.h"
/***************************************************************************
Defines
Change these constants to alter the program parameters.
****************************************************************************/
#define BASE_ADDRESS 768 // Base address of DM6430.
#define CHANNEL 0 // A/D channel.
#define GAIN 0 // Gain.
#define SE_DIFF 0 // Single-ended
#define ADSLOPE (65536.0/20.0) // Number Bits divided by AD Range.
/***************************************************************************
SetProgramScreen()
The SetProgramScreen() function initializes the screen.
****************************************************************************/
void SetProgramScreen(void)
{
clrscr();
// Print header and footer.
gotoxy(1,1); cprintf(TitleString6430());
gotoxy(43, 1); cprintf("Single conversions, software trigger");
gotoxy(1, 25); cprintf("Press any key to exit. . .");
window(1, 3, 80, 23);
gotoxy(25, 8); cprintf("Channel %d : Volts", CHANNEL + 1);
} //SetProgramScreen
int main(void)
{
int ADData;
float Data; // Variable to store acquired data.
SetProgramScreen();
SetBaseAddress(BASE_ADDRESS);
InitBoard6430(); // Board initializing.
SetConversionSelect6430(0); // Set conversion select to software.
SetChannelGain6430(CHANNEL, GAIN, SE_DIFF); // Set channel and gain.
ClearADFIFO6430(); // Clear A/D fifo.
while ( !kbhit() ) { // Run untill any key is pressed.
StartConversion6430(); // Perform a Single A/D conversion.
while ( IsADFIFOEmpty6430() ); // Wait until data is ready to read.
ADData = ReadADData6430(); // Read acquired data
Data = (float)ADData / ADSLOPE; // Convert Data to voltages.
gotoxy(37, 8); cprintf("%6.3f", Data);
// Display 'Data' on the screen.
} //while
getch(); // Get the pressed character.
window(1,1,80,25); // Reset original screen coordinates,
clrscr(); // clears the screen.
return 0;
} //main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -