⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 burst_n.c

📁 rt采集卡dos下dm6430驱动源代码
💻 C
字号:
/***************************************************************************

	FILE NAME: BURST_N.C

	FILE DESCRIPTION: BURST_N (Scanning Multiple Channels)

	 Sample program that demonstrates how to perform an analog to digital
	 conversion on multiple channels using the channel gain table. Burst mode
	 means that all the channels in the table are sampled once for each
	 trigger. The time between channels is set by the burst clock. If the
	 burst clock is set to the highest rate, this mode simulates
	 simultaneous sampling.

	 Sample program that uses the Burst Clock, Pacer clock and the channel
	 gain table to acquire data on several channels. The burst clock will
	 start the conversions and the burst clock will be triggered by the
	 pacer clock.

	 While the measurement is running the acquired data on the A/D channels
	 is displayed on the screen, one line with every sample.

	PROJECT NAME: BURST_N (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 FIRST_CHAN       0             // First channel of burst.
#define NUM_OF_CHAN      8             // Number of channels of burst.
#define RATE             1.0 	         // Sample rate in [Hz].
#define BURST_RATE       100000.0 	   // Burst rate in [Hz].
#define ADSLOPE   		(65536.0/20.0) // Number Bits divided by AD Range.

/***************************************************************************
  SetProgramScreen()

  The SetProgramScreen() function initializes the screen.
****************************************************************************/

void SetProgramScreen(void)
{
  int i;

  clrscr();

  // Print header and footer.
  gotoxy( 1, 1); cprintf(TitleString6430());
  gotoxy(50, 1); cprintf("Multi Channel Burst");
  gotoxy( 1,25); cprintf("Press any key to exit. . .");

  // Define data window and print the header of the samples.
  window(1, 3, 80, 23);
  gotoxy(7, 3);
  for (i = 0; i < NUM_OF_CHAN; i++)
	 cprintf("  CH %d  ", FIRST_CHAN + i + 1);
} //SetProgramScreen


int main(void)
{
  float Data;                    // Store acquired data.
  unsigned int i;                // Row index or sample index.
  unsigned int BurstCounter;     // Column index or channel index.
  int ADData;                    // Store A/D data.

  ADTableRow ADTable[NUM_OF_CHAN];

  SetProgramScreen();

  SetBaseAddress(BASE_ADDRESS);
  InitBoard6430();               // Board initializing.

  for (i=0;i<NUM_OF_CHAN;i++) {
	  ADTable[i].Channel=FIRST_CHAN +i;
	  ADTable[i].Gain=0;
	  ADTable[i].Se_Diff=0;
	  ADTable[i].Pause=0;
	  ADTable[i].Skip=0;
  }

  SetPacerClock6430(RATE);             // Initialize pacer clock.
  SetBurstClock6430(BURST_RATE);       // Initialize burst clock.
  SetBurstTrigger6430(1);              // Set Burst Trigger = Pacer Clock.
  SetStartTrigger6430(0);              // Set Start Trigger = Software.
  SetStopTrigger6430(0);               // Set Stop Trigger = Software.
  SetConversionSelect6430(2);          // Set Conversion select to Burst Clock.
  LoadADTable6430( NUM_OF_CHAN,ADTable); // Load AD Table.
  EnableTables6430(1,0);               // Enable Ad Table.
  ClearADFIFO6430();                   //Clear FIFO.



  i = 0;
  StartConversion6430();               // Start conversion.

  while ( !kbhit() ) {                 // Run until any key pressed.
	 gotoxy(7, 5 + i);
	 for (BurstCounter=0; BurstCounter<NUM_OF_CHAN; BurstCounter++) {
		while ( IsADFIFOEmpty6430() & !kbhit());// Wait until data is ready to read.
		ADData = ReadADData6430();              // Get data and convert it to voltages.
		Data = ADData /ADSLOPE;
		cprintf("%6.3f  ", Data);        // Display 'Data'.
	 } //for
	 if (++i == 10) i = 0;
  } //while
  getch();

  window(1,1,80,25);                   // Reset original screen coordinates,
  clrscr();                            // and clears the screen.
  return 0;
} //main

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -