//********************************************************************** /*   <定電流回路> */ //********************************************************************** //********************************************************************** unsigned long measurement(unsigned short channel) { static unsigned int cnt; static unsigned long ad; // ad = 0; for (cnt = 0; cnt < 1000; cnt++) { ad += Adc_Read(channel); } return (ad); } //********************************************************************** void SwitchONcheck() { while (Button(&PORTA, 5, 1, 0) == 0) ; while (Button(&PORTA, 5, 1, 1) == 0) ; } //********************************************************************** void main() { static double ad; static char buf[10]; static int tmp; // OSCCON = 0b01110000; // クロックを8Mhzに設定する。 ANSEL = 0b00011110; // A/D変換を使用する。 ADCON1.VCFG1 = 1; ADCON1.VCFG0 = 0; TRISA = 0b11111111; TRISB = 0b00000000; // Lcd_Custom_Config(&PORTB,7,6,5,4,&PORTB,3,2,1); Lcd_Custom_Cmd(LCD_CURSOR_OFF); Lcd_Custom_Cmd(LCD_CLEAR); Lcd_Custom_Out(1, 6, "mA"); Lcd_Custom_Out(1, 14, "mA"); Lcd_Custom_Out(2, 6, "mV"); // while (1) { ad = (measurement(2) / 1000) * 2.4365234375; tmp = ad / 10; if ((ad - (tmp * 10)) >= 5) tmp++; WordToStr(tmp * 10, buf); Lcd_Custom_Out(1, 1, buf); // ad = (measurement(4) / 1000) * 2.4365234375; tmp = ad / 10; if ((ad - (tmp * 10)) >= 5) tmp++; WordToStr(tmp * 10, buf); Lcd_Custom_Out(1, 9, buf); // ad = ((measurement(1) / 1000) * 2.4365234375) * 11; tmp = ad / 10; if ((ad - (tmp * 10)) >= 5) tmp++; WordToStr(tmp * 10, buf); Lcd_Custom_Out(2, 1, buf); } } //**********************************************************************