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.

Help me with schematics and program for PIC based LCD/LED voltmeter in Basic

Status
Not open for further replies.

tariq javid

Newbie level 1
Joined
Sep 5, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
Friends
I want to make PIC16f876 or PIC16f628 based led display or LCD voltmeter in basic. I have no more knowledge about it. (How can read from ADC and convert it LED or LCD display?) Please any friend helps me about its schematics, and how can we write its program in basic or any example for it but I need in basic.
Thanks
Tariq Javid
 

pic16f628 voltmeter

have u seen data sheet for pic16f628. i cant see any adc.

'******************************************************************************
' microcontroller P16F877A
'
' Project ADC_on_Leds
' This project is designed to work with PIC 16F877A
' with minor adjustments, it should work with any other PIC MCU
' that has ADC module.
'
' This code demonstrates using library function for ADC conversion
' (10 bits) result is displayed on portd and portb
' (two most significant bits are displayed on portb).
'******************************************************************************


program ADC_on_Leds

dim temp_res as word

main:
ADCON1 = $80 ' configure analog inputs and Vref
TRISA = $FF ' designate PORTA as input
TRISB = $3F ' designate RB7, RB6 pins as outputs
TRISD = $0 ' designate PORTD as output
while true
temp_res = ADC_read(2)
'now you can use temp_res ...'
PORTD = temp_res ' send lower 8 bits to PORTD
PORTB = word(temp_res >> 2)
' send two most significant bits to PORTB, pins RB7,RB6
wend
end.


'******************************************************************************
' microcontroller P16F877A
'
' Project: adconlcd
' This project is designed to work with PIC 16F877A
' with minor adjustments, it should work with any other PIC MCU
' that has ADC module.
'
' This code demonstrates how to use library function ADC_read, and library
' procedures and functions for LCD display (4 bit interface)
'
'******************************************************************************
program adconlcd

dim ch as byte
dim t as integer
dim a as string[20]
dim tlong as longint

main:
PORTB = 0 ' clear portb
TRISB = 0 ' designate portb as output (LCD is connected to portb)
intcon = 0 ' disable all interrupts
Lcd_init(PORTB) ' initialize (4-bit interface connection)
lcd_cmd( LCD_CURSOR_OFF) ' send command to LCD (cursor off)
lcd_cmd(LCD_CLEAR) ' send command to LCD (clear LCD)
a = "mikroElektronika" ' assign text to string a
lcd_out(1,1,a) ' print string a on LCD, 1st row, 1st column
a = "LCD example" ' assign text to string a
lcd_out(2,1,a) ' print string a on LCD, 2nd row, 1st column
OPTION_REG = $80
ADCON1 = $82 ' configure VDD as Vref, and analog channels
TRISA = $FF ' designate porta as input
Delay_ms(2000)
a = "voltage:" ' assign text to string a
DoAdc:
t = ADC_read(2) ' get ADC value from 2nd channel
lcd_out(2,1,a) ' print string a on LCD, 2nd row, 1st column

tlong = t*5000
t = longint(tlong >> 10)
ch = t div 1000 ' prepare value for diplay

lcd_chr(2,9,48+ch) ' write ASCII at 2nd row, 9th column
lcd_chr(2,10,".")

ch = integer(t div 100) mod 10
lcd_chr(2,11,48+ch)

ch = integer(t div 10) mod 10
lcd_chr(2,12,48+ch)

ch = t mod 10
lcd_chr(2,13,48+ch)
lcd_chr(2,14,"V")

delay_ms(1)
goto DoAdc
end.
 

Re: pic voltmeter

Hai tariq javid,

Try this project. i think its is usefull to you......Good luck
 

Attachments

  • DVM.rar
    112.4 KB · Views: 136
Last edited:

Re: pic voltmeter

Hai tariq javid,

Try this project. i think its is usefull to you......Good luck
Looking at the PDF file in there your readings are 300Mv out, You should be able to make it closer by using floating maths
 

Re: PIC based voltmeter

i posted this code of mine for the same purpose but using PICC lite. The LCD reading and adc are working. only issue was that i want to put in the C# GUI i created.
Check the thread here:
https://www.edaboard.com/threads/211669/#post894446

hope it will help.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top