هذا المشروع لمقياس فولت وحتى 24.1 فولت باستخدام لغة mikroBasic ومتحكم pic16f88 و يعرض الناتج على 3 قطع سيفن سيجمنت
نص البرنامج :
program voltametr
dim T as byte ’ the 3 parts as 7-segment as +c
T2 as longint
T3 as word
[ U as byte [ 11
:main
U[0] = %1000000
U[1] = %1111001
U[2] = %0100100
U[3] = %0110000
U[4] = %0011001
U[5] = %0010010
U[6] = %0000010
U[7] = %1111000
U[8] = %0000000
U[9] = %0010000
trisa = %1000
trisB = 00
option_reg = $80
ADCON1 = $82
while true
T3 = adc_read(3) ’ read from RA.3
T2 = T3 * 241 ’ 241 for 24 volt for show as 24.1
T3 = T2 >> 10
T = ( T3 div 100 ) mod 10
porta = 7
[ portb = U[ T
porta = 6
delay_ms(3)
T = ( T3 div 10 ) mod 10
porta = 7
[ portB = U[ T
porta = 5
(delay_ms(3
T = T3 mod 10
porta = 7
[ portB = U[ t
porta = 3
(delay_us(2700
wend
.end
at the first i am sorry for writing in english and this is because my keyboard is english, anyway
I do not know the circuit but as far as i know the PIC cannot stand voltage more than 5 voltge.
I gues that there is a voltage divider circuit infront of the input pin Porta.3
for build such a project we should specify the range of voltage such as 24 volt.
then we should specify the voltage divider at the input of the analog to digital pin ( we should keep in our mind thet the voltage should not be more than 5 volt) in our case if the max voltage is 24 volt then we should use R1=2.5k and R2=10k ( the max voltge will be 4.8 if the input volt is 24 volt)
after that we should know how many bits in my digital to anlog converter assume that we have 10 bits then we have 1024 steps each step will represent the value of Vmax/ 1024 which is 24/1024
in our case the resolution is 0.0234375 volt
then after that u write the program
as the following
1- read the ADC in x ( x as float)
2-Temp = x *0.0234375
3- display the result in 3 digit (7 segment )
if i have time i will write the program in PICBASIC with the simulation in PROTEUS