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.

Digital voltmeter for a car battery using pic16f690

Status
Not open for further replies.

BETHWEL

Newbie level 3
Joined
Sep 30, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
anyone help

---------- Post added at 14:31 ---------- Previous post was at 14:18 ----------

i'm design the digital voltmeter for a car battery now i want to use pic16f690 to display the values of the voltage,then i used the portc pins as the one that will display in the 7-segment and RA4/AN3 is my input now its quite challenging for me to convert analog to digital your advice will appreciated
 

Check out this link.This might help you.
 

Attachments

  • l03.doc
    149.5 KB · Views: 145

YES i'm i just need for help in the program i want to make RA4 of portA as my input ,portC as an output that will display in the seven segment and the other pins of portA as the digital outputs which is RA0,RA1 and RA3. So i need someone will help me for this program in the MPLAB code
THANKYOU:
:-?
 
Last edited:

I don't have any experience with 16F690, but in most PICs, you cannot take any pin you want as Digital or Analog. There is a pattern which you can find in the AD peripheral of the datasheet.
I suggest you to use port B (instead of C) as this port comes with pull-up resistors that can facilitate the development.

Mahdi.
 

I think what he is asking is for someone to write the code for him 8-O, otherwise if he as struggling with the code he would have put it on here, ;-)

There are plenty of desings out there some are just to idle to look :smile:
 

Ya. Just post the code out here & we can help you to sort it out.
Regards,
Jerin.
 

sorry for replaying later i was steel dealing with other problem.
the following is my code.
;**************************************************************************
;filename voltmeter
;***************************************************************************
#include<p16F690.inc>
digit1 equ 0x21
digit2 equ 0x22
digit3 equ 0x23
OFFSET EQU 0x24
TEMP2 equ 0x25
DELAY5 equ 0x26
SHORTDEL equ 0x27
CNTOUT equ 0x28
CNTMID equ 0x29
CNTIN equ 0x30

;****************************************************************************
INIT
BSF STATUS,6 ;SELECT BANK2
BCF STATUS,5 ;
MOVLW B'00010000' ;TURNS OFF DIGITAL FILTER FOR AN3,WHICH IS MY ADC PIN PORTA,4
MOVWF ANSEL ;
MOVWF B'00000000' ;ALL DIGITAL I/O PINS
MOVWF ANSELH ;
BCF STATUS,6 ;SELECT BANK1
BSF STATUS,5 ;

MOVLW B'00000000' ;PORTC AS AN OUTPUT
MOVWF TRISC ;
MOVLW B'110000' ;SET RA4/AN3 AS AN ANALOG ALL OTHERS DIGITAL OUTPUT
MOVWF TRISA ;
BCF STATUS,6 ;SELECT BANK0
BCF STATUS,5 ;
CLRF PORTC ;MAKE I/O PORTC ALL OUTPUT
CLRF PORTA ;

MOVLW 0x3F ;A2D Clock Fosc/8
MOVWF ADCON1
BANKSEL OPTION_REG
BCF OPTION_REG,7 ;CLEAR OPTION_REG,7; ENABLING WEAK PULLUPS
BANKSEL ADCON0
CLRF ADCON0 ;
MOVLW B'10010000' ;Right, Vdd Vref, AN3[I'M NOT SURE ABOUT THIS]
MOVWF ADCON0 ;
BANKSEL WPUA ;
MOVLW B'100111' ;SET PULLUPS 1 EQU PULLUP ON
MOVWF WPUA ;
BANKSEL INTCON ;
BCF INTCON,2 ;
CLRF INTCON ;

;*****************************************************************************
;***************"My problem is the conversion of anolog input and display the digital output"******
MAIN
test BSF ADCON0,GO ;start conversion
BTFSS ADCON0,GO ;this bit will change to zero when the conversion is complete
GOTO test
swapf ADRESH,w ; Copy the display to the LEDs
movwf TEMP2
;****************************************************************************
Loop
MOVLW B'00100' ;PASS THE SIGNAL TO THE ONE TRANSISTOR(SET 1PIN OF PORTA)
MOVWF PORTA ;THE FIRST DIGIT MUST SWICH ON
CALL LOOKUP ;SEVEN-SEGMENT MUST DISPLAY THE VULUE OF THE VOLTAGE(TESTED VULUE)
CALL SHORTDEL ;1SECOND DELAY
GOTO Loop

;*****************************************************************************
LOOKUP ;Lookup table to display THE CORRECT VALUE

MOVLW high BASEADD ;Get the high base address byte
MOVWF PCLATH ;Store in PC High Latch
MOVLW low BASEADD ;Get low base address
ADDWF OFFSET,w ;Add offset to address
BTFSC STATUS,C ;Test for a possible roll-over
INCF PCLATH,f ;and increment PCLATCH
MOVWF PCL ;change PC to execute jump

BASEADD
RETLW b'00111111' ;7 Seg value to display when 0
RETLW b'00000110' ;7 Seg value to display when 1
RETLW b'01011011' ;7 Seg value to display when 2
RETLW b'01001111' ;7 Seg value to display when 3
RETLW b'01100110' ;7 Seg value to display when 4
RETLW b'01101101' ;7 Seg value to display when 5
RETLW b'01111100' ;7 Seg value to display when 6
RETLW b'00000111' ;7 Seg value to display when 7
RETLW b'01111111' ;7 Seg value to display when 8
RETLW b'01100111' ;7 Seg value to display when 9
RETLW b'01110111' ;7 Seg value to display when A
RETLW b'01111100' ;7 Seg value to display when B
RETLW b'00111001' ;7 Seg value to display when C
RETLW b'01011110' ;7 Seg value to display when D
RETLW b'01111001' ;7 Seg value to display when E
RETLW b'01110001' ;7 Seg value to display when F
RETURN
;*******************************************************************************

DELAY5
movlw .50
goto X1
SHORTDEL
movlw .10 ;Short delay
X1
movwf CNTOUT
LOOPOUT
movlw .100
movwf CNTMID
LOOPMID
movlw .249
movwf CNTIN
LOOPIN
nop
decfsz CNTIN,f
goto LOOPIN

decfsz CNTMID,f
goto LOOPMID

decfsz CNTOUT,f
goto LOOPOUT
RETURN
;***********2 sec. delay**************************

ORG 0x2007 ;select config word
DW 0x30C4 ;settings for external master clear

end

---------- Post added at 15:48 ---------- Previous post was at 15:43 ----------

sorry if its not clear i didn't able to attach this document.Maybe its should copy and pasted to the MPLAB where it will be clear.
thanx for reply.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top