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 >
Text File  |  1995-09-07  |  2KB  |  54 lines

  1. /*--------------------------------------------*/
  2. /* MyStatus shows analog and other values ... */
  3. /*--------------------------------------------*/
  4.  
  5. FUNC void MyStatus (void)  {
  6.   printf ("=============================\n");
  7.   printf (" Analog-Input-0:  %f\n", ain0);
  8.   printf (" Analog-Input-1:  %f\n", ain1);
  9.   printf (" Analog-Input-2:  %f\n", ain2);
  10.   printf (" Analog-Input-3:  %f\n", ain3);
  11.   printf (" Register-Bank:   %d\n", (psw & 0x18) >> 3);
  12.   printf (" Program Counter: %06lXH\n", $);
  13.   printf ("=============================\n");
  14. }
  15.  
  16.  
  17. /*-------------------------------------------*/
  18. /* Function MyRegs() shows Registers R0...R7 */
  19. /*-------------------------------------------*/
  20.  
  21. FUNC void MyRegs (void)  {
  22.   printf ("-------- MyRegs() --------\n");
  23.   printf (" R0 R1 R2 R3 R4 R5 R6 R7\n");
  24.   printf (" %02X %02X %02X %02X %02X %02X %02X %02X\n",
  25.             R0,  R1,  R2,  R3,  R4,  R5,  R6,  R7);
  26.   printf ("--------------------------\n");
  27. }
  28.  
  29.  
  30. /*-----------------------------------------------*/
  31. /* Analog0() simulates analog input values given */
  32. /*  to channel-0 (AIN0) of the 80C517            */
  33. /*-----------------------------------------------*/
  34.  
  35. SIGNAL void analog0 (float limit)  {
  36.   float volts;
  37.  
  38.   printf ("ANALOG0 (%f) ENTERED\n", limit);
  39.   while (1)  {          /* forever */
  40.     volts = 0;
  41.     while (volts <= limit)  {
  42.       ain0 = volts;     /* analog input-0 */
  43.       twatch (30000);    /* 30000 Cycles Time-Break */
  44.       volts += 0.5;     /* increase voltage */
  45.     }
  46.     volts = limit - 0.5;
  47.     while (volts >= 0.5)  {
  48.       ain0 = volts;
  49.       twatch (30000);   /* 30000 Cycles Time-Break */
  50.       volts -= 0.5;     /* decrease voltage */
  51.     }
  52.   }
  53. }
  54.