Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] PIC Volt Meter and Battery Charging Techniques

Status
Not open for further replies.
I think i know your problem.
Your internal Resistance of fluke is much much higher than your pic circuit,so there is some drop out in the leads from batt to the pic.
So its extremly important that u get your readings on the fluke : pic input: with load ,at the same checking point and i mean exactly not a mm before or after and all checks should be done at the same time in parallel.
 

dear kg300,
very nice information. pl mentiion which kind of CT is used? if possible post the schematic. thanks
95_1328540863.gif

CT
 
thanks pnjbtr and kg300. can u please post the hex code of ups card pic16F72 famous in Pak?
 

Hex file for 16F72 UPS (16MHZ crystal) F.2.0
 

Attachments

  • UPS_16F72_16MHZ_f2.rar
    2.9 KB · Views: 344
  • Like
Reactions: kif123

    kif123

    Points: 2
    Helpful Answer Positive Rating
dear Imtiaz Sab(kg3oo),
thanks for upload the hex code for pic16f72. kindly share the the schematic and pcb design for this ups on my E-mail:javed4004 at yahoo dot com.

thanks

javed
 

Thanks for ur code but i will be more helpful is you post the schematics,
 

AoA
Please javed sahib publish here your schematics of charger and ups so that we can use it
 

here is modify files for 16f676 chg
 

Attachments

  • img-1.png
    img-1.png
    89.6 KB · Views: 275
  • 16f676-chg.rar
    121.4 KB · Views: 494
Thanks kg300 for uploading the files. it will be very helpfull. if possible please share the schematic and pcb design for ups pic16f72.
best regards,

javed
 

It must be PIC or can be Atmel ?


This is nice project with lcd. Monitoring voltage up to 30V, current up to 100A, internal resistance of circuit very useful to see battery health and status, and fourth option is to show delivered amp hour to battery.

DIP_lcd_res_capa_litle.jpg P1010060.JPGP1010063.JPG

Project is with ATMega8 and LCD. Circuit is very simple and placed on back of LCD like small panel meter.

TQFP32 version :
https://www.elfly.pl/multimetr/multimetr_en.htm

DIP28 version :
https://www.elfly.pl/multimetr/multimetr_en_DIP.htm
 
Last edited:

PIC16F72 based LCD(16*2 digit) meter for up to 304v ac.
 

Attachments

  • 16f72meter_micro_c.rar
    13.6 KB · Views: 397
  • Like
Reactions: dselec

    dselec

    Points: 2
    Helpful Answer Positive Rating
Thanks kg300 for uploading Pic16f676-chg.rar files. it will be very helpfull. if possible please share the Sourcecode, schematic and pcb design files. So we can alter it for our purpose.
best regards.
 

DC Voltmeter up to 30V with PIC16F676.

You can easily modify code and adjust to other voltage range.

Compiler is MPLAB XC8 Compiler.

You have circuit, source file, hex file, PCB files, photos, description,...



PCB Top Print.png PCB Bottom Print.png

PCB Top View.jpg PCB Bottom View.jpg

DSCF0461.JPG DSCF0464.JPG DSCF0466.JPG
 

Attachments

  • 30V DC Voltmeter PIC16F676.RAR
    587.8 KB · Views: 377

DC Voltmeter up to 30V with PIC16F676.

You can easily modify code and adjust to other voltage range.

Compiler is MPLAB XC8 Compiler.

You have circuit, source file, hex file, PCB files, photos, description,...



View attachment 88571 View attachment 88569

View attachment 88568 View attachment 88570

View attachment 88572 View attachment 88573 View attachment 88574

i want it modified up to 60 !
so change in C code
change as
i'm doing right ?
 

0-99,9V Example :

Code:
#include <htc.h>
__CONFIG (FOSC_INTRCIO & MCLRE_OFF & BOREN_ON & CP_OFF & CPD_OFF & WDTE_OFF & PWRTE_ON ); 



#define SPORT PORTA
#define DPORT PORTC
const char SegCode[11] = {0x40,0x57,0x22,0x06,0x15,0x0C,0x08,0x56,0x00,0x04,0xFF};
	//                       0    1    2    3    4    5    6    7    8    9
const char Column[3]   = {0x02,0x01,0x04};
static char Segment[3] = {0x7f,0x7f,0x7f};	
static unsigned char ColCount=0x00;
void CPU_SETUP(void);
void Display(void);
void HTO7S(unsigned int Num);
void delayMs(int x);

unsigned int result;
unsigned int readAdc(void);
void interrupt  timer1_isr(void)
{
if(PIR1bits.TMR1IF==1)
{
PIR1bits.TMR1IF = 0;
	TMR1H=0xDF;
Display();
}
}
void main()
{		
	unsigned char i;
	
	CPU_SETUP();
	while(1)
	{			
		result=0;
		for (i=0;i<3;i++)
		{
			
			delayMs(1); 
			result=result+readAdc();
		}
				HTO7S(result/3);								
		
		delayMs(200);		    
	}
	
}

void CPU_SETUP()
{
	CMCON =0x07;		//Turn off comparator module
	ANSEL =0x8;			//AN3 as analog input
	ADCON1 =0x60; 		//clock/64
	ADCON0 = 0x8D;
   	TRISA=0b00011000;
   	PORTA=0x27;
   	TRISC=0b00000000;
   	PORTC=0x37;
   
   T1CON= 0x00;
  	TMR1H=0xDF;
   	INTCONbits.GIE =1;
	INTCONbits.PEIE=1;
	PIE1bits.TMR1IE =1;
 	T1CONbits.TMR1ON=1;
}
unsigned int readAdc()
{
unsigned int res;
ADCON0bits.GO_DONE =1;
while(ADCON0bits.GO_DONE ==1);
res=ADRESL+(ADRESH*0x100);
return(res);
}
//-------------------------------------
// Display routine
//-------------------------------------
void Display()
{
	PORTA = 0b00100111;	  // off all digits column and Segment G
	PORTC = 0b00111111;   // off segment a-f	

	

	if (ColCount>=3) 
	ColCount=0;
    	
	DPORT = Segment[ColCount];
	SPORT = ((Segment[ColCount] & 0b01000000)>>1) | (Column[ColCount]^0x07);
	ColCount++;				
}	

//--------------------------------------
// Convet HEX 2 byte to 7-Segment code
//--------------------------------------
void HTO7S(unsigned int adcstep)
{
	
	unsigned int res;
	
	// First digit (X)X,X
	res = adcstep * (unsigned long)9900 / 1023;
	Segment[0]=SegCode[res/1000];				// max Vin 99V. Result is ADV voltage (0-5V).
												// Example: Vin 25,3V result is 2,53 and takes 2
	if (Segment[0]==0x40) 						// If first digit is 0 then 
		Segment[0]=0xFF;						// do not show nothing.
		
	// Second digit X(X),X
	res = adcstep * (unsigned long)9900 / 1023;
	Segment[1]=SegCode[(res/100)%10];	// The same as first digit, but %10 takes 5	

	// Third digit XX,(X)
	res = adcstep * (unsigned long)9900 / 1023;
	Segment[2]=SegCode[(res/10)%10];	  
	
}	

void delayMs(int x)
{
int i;
for (x ;x>0;x--)
{
for (i=0;i<=110;i++);
}
}




0-9,00V Example :

Code:
#include <htc.h>
__CONFIG (FOSC_INTRCIO & MCLRE_OFF & BOREN_ON & CP_OFF & CPD_OFF & WDTE_OFF & PWRTE_ON ); 



#define SPORT PORTA
#define DPORT PORTC
const char SegCode[11] = {0x40,0x57,0x22,0x06,0x15,0x0C,0x08,0x56,0x00,0x04,0xFF};
	//                       0    1    2    3    4    5    6    7    8    9
const char Column[3]   = {0x02,0x01,0x04};
static char Segment[3] = {0x7f,0x7f,0x7f};	
static unsigned char ColCount=0x00;
void CPU_SETUP(void);
void Display(void);
void HTO7S(unsigned int Num);
void delayMs(int x);

unsigned int result;
unsigned int readAdc(void);
void interrupt  timer1_isr(void)
{
if(PIR1bits.TMR1IF==1)
{
PIR1bits.TMR1IF = 0;
	TMR1H=0xDF;
Display();
}
}
void main()
{		
	unsigned char i;
	
	CPU_SETUP();
	while(1)
	{			
		result=0;
		for (i=0;i<3;i++)
		{
			
			delayMs(1); 
			result=result+readAdc();
		}
				HTO7S(result/3);								
		
		delayMs(200);		    
	}
	
}

void CPU_SETUP()
{
	CMCON =0x07;		//Turn off comparator module
	ANSEL =0x8;			//AN3 as analog input
	ADCON1 =0x60; 		//clock/64
	ADCON0 = 0x8D;
   	TRISA=0b00011000;
   	PORTA=0x27;
   	TRISC=0b00000000;
   	PORTC=0x37;
   
   T1CON= 0x00;
  	TMR1H=0xDF;
   	INTCONbits.GIE =1;
	INTCONbits.PEIE=1;
	PIE1bits.TMR1IE =1;
 	T1CONbits.TMR1ON=1;
}
unsigned int readAdc()
{
unsigned int res;
ADCON0bits.GO_DONE =1;
while(ADCON0bits.GO_DONE ==1);
res=ADRESL+(ADRESH*0x100);
return(res);
}
//-------------------------------------
// Display routine
//-------------------------------------
void Display()
{
	PORTA = 0b00100111;	  // off all digits column and Segment G
	PORTC = 0b00111111;   // off segment a-f	

	

	if (ColCount>=3) 
	ColCount=0;
    	
	DPORT = Segment[ColCount];
	SPORT = ((Segment[ColCount] & 0b01000000)>>1) | (Column[ColCount]^0x07);
	ColCount++;				
}	

//--------------------------------------
// Convet HEX 2 byte to 7-Segment code
//--------------------------------------
void HTO7S(unsigned int voltage)
{
	
	unsigned int res;
	
	// for 10bit ADC, using Vref=5000mV, result in mV
	res = ((voltage * (unsigned long)5000 / 1023)) / 5;   
	res = res * 9;

	// First digit (X),XX
	Segment[0]=SegCode[res/1000];
	
	// Second digit X,(X)X
	Segment[1]=SegCode[(res/100)%10];	

	// Third digit X,X(X)
	Segment[2]=SegCode[(res/10)%10];	  
	
}	

void delayMs(int x)
{
int i;
for (x ;x>0;x--)
{
for (i=0;i<=110;i++);
}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top