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

📄 amltbrst.c

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

	FILE NAME: AMLTBRST.C

	FILE DESCRIPTION: Automatic Burst

	 Sample program that demonstrates how to use the pacer clock, burst clock,
	 sample counter and channel gain table to scan groups of channels,
	 multiple times.

	 This program will show how to use the sample counter, burst clock
	 and the pacer	clock features of the DM6430 to do MULTI-BURST sampling.
	 The board will be set up to sample a set of channels, 3 times every
	 time the board receives a trigger from the on board 8254.


	 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: AMLTBRST (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             // Number of samples


#define ADSLOPE          (65536.0/20.0)// Number Bits divided by AD Range.
#define FIRST_CHAN       0             // First channel of the burst.
#define NUM_OF_CHAN      8             // Number of channels in one burst.
#define RATE             1000.0        // Sample rate in [Hz].
#define BURST_RATE       10000.0       // Burst rate in [Hz].
#define USER_RATE		    1.0           // Measurement trigger period in [Hz].

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

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

void SetProgramScreen(void)
{
  int i;

  clrscr();

  // Print header.
  gotoxy( 1, 1); cprintf(TitleString6430());
  gotoxy(50, 1); cprintf("Automatic Multi Burst");
  gotoxy(1, 25);
  cprintf("Press <Esc> to exit. . .");

  // Define window for data and print header above 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)
{
  unsigned int i;               // Cycle variable for display.
  float Data;                   // Store acquired data.
  int	ch;                       // Store the pressed character.
  int	ADData;                   // Store the AD data.
  float ActualRate0;				  // Actual clock rate returned from timer 0.

  ADTableRow  ADTable[8];

  SetProgramScreen();                  // Prepare the screen.

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

  for (i=0;i<NUM_OF_CHAN;i++) {        // Set Up AD Table.
	  ADTable[i].Channel=FIRST_CHAN+i;
	  ADTable[i].Gain=0;
	  ADTable[i].Skip=0;
	  ADTable[i].Se_Diff=0;
	  ADTable[i].Pause=0;
  }
  SetPacerClock6430(RATE);             // Initialize Pacer Clock.
  SetBurstClock6430(BURST_RATE);       // Initialize Burst Clock.

  ActualRate0 = SetUserClock6430(0, 8000000.0, 20000.0);	// Initialize User Clock0.
  SetUserClock6430(1, ActualRate0, USER_RATE);     		// Initialize User Clock1.

  SetBurstTrigger6430(1);              // Set Burst Trigger to Pacer Clock.
  SetTriggerRepeat6430(1);             // Set Repeat Trigger True.
  SetStartTrigger6430(3);              // Set Start Trigger to User TC Counter 1 out.
  SetStopTrigger6430(3);               // Set Stop Trigger to Sample Counter.
  SetConversionSelect6430(2);          // Set Conversion Select to Burst Clock.
  LoadADSampleCounter6430(NUM_OF_CHAN*3);// Load Sample Counter.
  LoadADTable6430(NUM_OF_CHAN,ADTable);// Load AD Table.
  EnableTables6430(1,0);               // Enable Ad Table.
  ClearADFIFO6430();                   // Clear FIFO.
  ch = 0;                              // Initialize program variables.
  i = 0;
  gotoxy(7, 5);                        // Position the cursor on the screen.

  StartConversion6430();               // Start conversion.

  while ( ch != 27 ) {                 // Run untill <ESC> is pressed.
	 if ( kbhit() )                     // Check the keyboard.
		ch = getch();                    // Get the pressed character.
	 if ( !IsADFIFOEmpty6430() ) {      // Check if conversion ready.
		 ADData = ReadADData6430();      // Read acquired data.
		 Data = ADData /ADSLOPE;
		 cprintf("%6.3f  ", Data);       // Display Data.
		 if ((++i % NUM_OF_CHAN) == 0)
			gotoxy(7, 5 + i/NUM_OF_CHAN); // Next line.
		 if (i == (9 * NUM_OF_CHAN)) {
			i = 0;                        // Next screen.
			gotoxy(7, 5);
		 } //if
	 } //if A/D ready
  } //while

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

⌨️ 快捷键说明

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