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

📄 measure.ini

📁 The MEASURE program uses the analog inputs of the P89LPC935 to implement a datalogger. This example
💻 INI
字号:
/*-------------------------------------------*/
/* Function MyRegs() shows Registers R0...R3 */
/*-------------------------------------------*/

FUNC void MyRegs (void)  {
  printf ("---------- MyRegs() ----------\n");
  printf (" R0  R1  R2  R3\n");
  printf (" %02X  %02X  %02X  %02X\n");
  printf ("------------------------------\n");
}


//
// Generate Saw Tooth Signal on A/D input AD01
//
signal void AD01_Saw (void)  {
  float volts;        // peak-to-peak volatage
  float frequency;    // output frequency in Hz
  float offset;       // volatge offset
  float duration;     // duration in Seconds
  float delay;
  float val;
  long  i, end, steps;
    
  volts     = 2.0;
  offset    = 0.2;
  frequency = 140;
  duration  = 8.0;

  printf ("Saw Tooth Signal on A/D input AD01\n");

  steps = 100;
  
  delay = (0.01/frequency);
  printf ("Saw Steps = %d\n", steps);

  end = (duration * 10000);
  for (i = 0 ; i < end; i++)  {
    val = (i % steps) / ((float) steps);
    AD01 = (val * volts) + offset;
    swatch (delay);
  }
}


//
// Generate Sine Wave Signal on A/D input AD02
//
signal void AD02_Sine (void)  {
  float volts;        // peak-to-peak volatage
  float frequency;    // output frequency in Hz
  float offset;       // volatge offset
  float duration;     // duration in Seconds
  float val;
  long  i, end;  

  volts     = 1.4;
  offset    = 1.6;
  frequency = 180;
  duration  = 5.0;

  printf ("Sine Wave Signal on A/D input AD02\n");

  end = (duration * 10000);
  for (i = 0 ; i < end; i++)  {
    val = __sin (frequency * (((float) STATES) / CLOCK) * 2 * 3.1415926);
    AD02 = (val * volts) + offset;
    swatch (0.0001);                // in 100 uSec steps
  }
}


//
// Generate Noise Signal on A/D input AD03
//
signal void AD03_Noise (void)  {
  float volts;        // peak-to-peak volatage
  float frequency;    // output frequency in Hz
  float offset;       // volatge offset
  float duration;     // duration in Seconds
  float val;
  long  i, end;  

  volts     = 1.4;
  offset    = 1.6;
  duration  = 0.5;

  printf ("Noise Signal on A/D input AD03\n");

  end = (duration * 100000);
  for (i = 0 ; i < end; i++)  {
    val =  ((float) rand (0)) / 32767.0;
    AD03 = (val * volts) + offset;
    swatch (0.00001);                // in 10 uSec steps
  }
}

//
// Run Signal Functions at Startup
//
signal void Startup (void)  {
  swatch (1.0);    // wait 1.0 seconds
  AD01_Saw ();
  swatch (0.3);    // wait 0.3 seconds
  AD02_Sine ();
  swatch (0.6);    // wait 0.6 seconds
  AD03_Noise ();
}


Startup ();        // Start the Signals

define button "AD01 Saw Tooth",    "AD01_Saw ()"
define button "AD02 Sine Wave",    "AD02_Sine ()"
define button "AD03 Noise Signal", "AD03_Noise ()"

⌨️ 快捷键说明

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