Multimetro digital
Um multímetro criado utilizando o microcontrolador PIC, com poucas linhas de código e fácil montagem. O código utilizado no microcontrolador é mostrado abaixo:
#include <16F877A.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=4000000)
#byte TRISB = 0x86
#byte TRISC = 0x87
#byte PORTB = 0x06
#byte PORTC = 0x07
void main()
{
unsigned int32 pri; unsigned int32 seg; unsigned int32 ter; unsigned int32 quar; unsigned int32 ref = 0; unsigned int32 var; unsigned int32 num[10] = {0b11000000,0b11111001,0b10100100, 0b10110000,0b10011001,0b10010010,0b10000010,0b11111000,0b10000000,0b10010000}; setup_adc_ports(AN0_AN1_AN3); setup_adc(ADC_CLOCK_DIV_16); setup_psp(PSP_DISABLED); setup_spi(SPI_SS_DISABLED); //setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); PORTB = 0b00000000; PORTC = 0b00000000; TRISB = 0b00000000; TRISC = 0b00000000;
set_adc_channel(0); while(true) { ref = read_adc(); var = (ref * 5000); var = var / 1023; pri = var / 1000; seg = var/100; seg = seg % 10; ter = (var / 10); ter = ter % 100; ter = ter % 10; quar = var % 10; PORTC = 0b00000000;