我编程了PIC的最低功率(我认为),但仍然只有2.35 VDC上的VDD和VSS的设备,与LED和249K电阻到40伏直流电。我认为它应该只画出20个UA典型和40个UA最大值,这对应于一个5/40=125K的电阻,所以它将是大约13伏作为分压器。但是,LED可能具有低于阈值的显著泄漏电流。它们在12 UA上下降4.88伏,相当于406K,在140 UA,5.13V,这是128K。这是我的代码(借用另一个项目):
以上来自于百度翻译
以下为原文
I programmed the PIC for lowest power (I think), but there was still only
2.35 VDC on the Vdd and Vss of the device, with the LEDs and a
249k resistor to
40 VDC. I would think it should draw only
20 uA typical and
40 uA maximum, which corresponds to a resistor of
5/40 = 125k so that would be about
13 volts as a voltage divider. But perhaps the LEDs have a significant leakage current below threshold. They drop
4.88V at 12 uA which is equivalent to
406k, and
5.13V at 140 uA, which is
128k.
Here is my code (borrowed from another project):
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = ON // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is disabled)
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = OFF // PLL Enable (4x PLL disabled)
#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include
#include
#include
#define DS3 LATAbits.LATA5 //pin2 GP5
#define DS2 LATAbits.LATA2 //pin5 GP2
#define TAP ANSA4 //pin3 GP4
#define _XTAL_FREQ 4000000
#define ERROR 51 // 3.2V/20=160 mV
/*
*
*/
void main(void) {
int ADCvalue = 0;
OSCCON = 0b00000000; // 32 kHz LF
TRISA = 0; // 0b00011011; //GP2, GP5 output
// ANSELA = 0b00010000; //AN3 GP4
LATA = 0b00000000;
// ADCON0 = 0b00001101; // AN3 ADC ON
// ADCON1 = 0b10001000; // Right Just, Osc/8, Vref=Vdd
// __delay_ms(1000);
while (1) {
sleep();
ADCON0bits.ADGO=1;
while(ADCON0bits.nDONE);
ADCvalue = 256*ADRESH+ADRESL;
if(ADCvalue > 512+ERROR) {
LATAbits.LATA2 = 1;
__delay_ms(50);
}
else if(ADCvalue < 512-ERROR) {
LATAbits.LATA5 = 1;
__delay_ms(50);
}
LATA = 0;
__delay_ms(1000);
}
}