home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1996 September
/
pcwk_09_96.iso
/
demo
/
wgelectr
/
pk51demo
/
files.2
/
EXAMPLES
/
MEASURE
/
MEASURE.FNC
< prev
next >
Wrap
Text File
|
1995-09-07
|
2KB
|
54 lines
/*--------------------------------------------*/
/* MyStatus shows analog and other values ... */
/*--------------------------------------------*/
FUNC void MyStatus (void) {
printf ("=============================\n");
printf (" Analog-Input-0: %f\n", ain0);
printf (" Analog-Input-1: %f\n", ain1);
printf (" Analog-Input-2: %f\n", ain2);
printf (" Analog-Input-3: %f\n", ain3);
printf (" Register-Bank: %d\n", (psw & 0x18) >> 3);
printf (" Program Counter: %06lXH\n", $);
printf ("=============================\n");
}
/*-------------------------------------------*/
/* Function MyRegs() shows Registers R0...R7 */
/*-------------------------------------------*/
FUNC void MyRegs (void) {
printf ("-------- MyRegs() --------\n");
printf (" R0 R1 R2 R3 R4 R5 R6 R7\n");
printf (" %02X %02X %02X %02X %02X %02X %02X %02X\n",
R0, R1, R2, R3, R4, R5, R6, R7);
printf ("--------------------------\n");
}
/*-----------------------------------------------*/
/* Analog0() simulates analog input values given */
/* to channel-0 (AIN0) of the 80C517 */
/*-----------------------------------------------*/
SIGNAL void analog0 (float limit) {
float volts;
printf ("ANALOG0 (%f) ENTERED\n", limit);
while (1) { /* forever */
volts = 0;
while (volts <= limit) {
ain0 = volts; /* analog input-0 */
twatch (30000); /* 30000 Cycles Time-Break */
volts += 0.5; /* increase voltage */
}
volts = limit - 0.5;
while (volts >= 0.5) {
ain0 = volts;
twatch (30000); /* 30000 Cycles Time-Break */
volts -= 0.5; /* decrease voltage */
}
}
}