📄 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 = 3.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(00);"
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 Signal" , "signal kill AIN0_Sine;"
define button "Set AIN1 Voltage" , "AIN1 = GetDbl(\"Enter AIN1 Voltage\");"
/*-------------------------------------------------------------
The following functions will set the imputs of the analog
converter to 0, limit, or differnt values
-------------------------------------------------------------*/
func void Set_Inputs (float volt) {
AIN00 = AIN01 = AIN02 = AIN03 = AIN04 = AIN05 = AIN06 = AIN07 = volt;
}
func void Different_Inputs () {
AIN00 = 0.2;
AIN01 = 0.4;
AIN02 = 0.9;
AIN03 = 1.3;
AIN04 = 1.7;
AIN05 = 2.0;
AIN06 = 2.2;
AIN07 = 2.5;
}
/*----------------------------------------------------------------------
The following function generates anolog 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 = 500;
printf ("Sine Wave Signal on AD Channel 0.\n");
while (1) {
val = __sin (frequency * (((float) STATES) / CLOCK) * 2 * 3.1415926);
AIN00 = (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 offset; // voltage offset
float duration; // duration in Seconds
float val;
long i, end, steps;
offset = 00;
frequency = 1400;
duration = 0.5;
printf ("Saw Tooth Signal on AD Channel 1.\n");
steps = (100000 * (1/frequency));
while (1) {
end = (duration * 100000);
for (i = 0 ; i < end; i++) {
val = (i % steps) / ((float) steps);
AIN01 = (val * st_limit) + offset;
swatch (000001); // in 10 uSec increments
}
}
}
/*---------------------------------------------
Generates a Square Wave Signal on AD Channel 0
---------------------------------------------*/
signal void AIN0_Square (float volts) {
float frequency; // output frequency in Hz
float offset; // volatge offset
float duration; // duration in Seconds
offset = 1.6;
frequency = 2400;
duration = 0.5;
printf ("Square Wave Signal on AD Channel 0.\n");
while (1) {
while (duration > 00) {
AIN00 = volts + offset;
swatch (0.5 / frequency);
AIN00 = offset;
swatch (0.5 / frequency);
duration -= 1.0 / frequency;
}
}
}
/*-------------------------------------------------------------
-------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -