📄 debug.ini
字号:
/*-------------------------------------------------------------
This file set the analog inputs for the A/D to different
values depending on the button clicked
-------------------------------------------------------------*/
define float my_VREF;
my_VREF = 5.0
/*-------------------------------------------------------------
Create buttons -to set the analog inputs to 0.
-to set the analog inputs to VREF.
-to set different analog inputs.
-------------------------------------------------------------*/
define button "Inputs = 0V" , "Set_Inputs(0.0);"
define button "Inputs = High" , "Set_Inputs(my_VREF);"
define button "Different A/D Inputs" , "Different_Inputs();"
define button "Sine Wave (AIN0)" , "AIN0_Sine(my_VREF);"
define button "Sawtooth (AIN1)" , "AIN1_Saw (my_VREF);"
define button "Stop Signals" , "signal kill AIN0_Sine;signal kill AIN1_Saw;"
/*-------------------------------------------------------------
The following functions will set the imputs of the analog
converter to 0, limit, or different values
-------------------------------------------------------------*/
func void Set_Inputs (float volt) {
AIN0 = AIN1 = AIN2 = AIN3 =
AIN4 = AIN5 = AIN6 = AIN7 = volt;
}
func void Different_Inputs () {
AIN0 = 0.2;
AIN1 = 0.4;
AIN2 = 0.6;
AIN3 = 0.8;
AIN4 = 1.2;
AIN5 = 1.4;
AIN6 = 1.6;
AIN7 = 1.8;
}
/*----------------------------------------------------------------------
The following function generates analog voltages in a sine wave pattern.
Use the built-in Logic analyzer to view the output as a sine wave.
----------------------------------------------------------------------*/
signal void AIN0_Sine ( float sn_limit ) {
float frequency; // output frequency in Hz
float offset; // voltage offset
float val;
offset = sn_limit / 2;
frequency = 1800;
printf ("Sine Wave Signal on AIN Channel 0.\n");
while (1) {
val = __sin (frequency * (((float) STATES) / CLOCK) * 2 * 3.1415926);
AIN0 = (val * (sn_limit / 2)) + offset;
swatch (0.00001); // in 10 uSec steps
}
}
/*-----------------------------------------------------------------
The following function generates a sawtooth signal pattern for AIN1.
-----------------------------------------------------------------*/
signal void AIN1_Saw (float st_limit) {
float frequency; // output frequency in Hz
float val;
long i, steps;
frequency = 1400;
printf ("Saw Tooth Signal on AD Channel 1.\n");
steps = (100000 * (1/frequency));
for (i = 0 ; ; i++) { // Runs signal continuously
val = (i % steps) / ((float) steps);
AIN1 = (val * st_limit);
swatch (0.00001); // in 10 uSec increments
}
}
/*-------------------------------------------------------------
-------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -