thx you very much rob !!
I wrote this code. for AC measurment . But i didn't check on real device!
does it work ? It worked with DC :-)
If you can send any cirtuit and detail , it will be help to us !
best regards
Define LOADER_USED 1
;Define OSC 20
'Test Kart LCD
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1
' Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
adval var word ' Create adval to store result
AcVolt var word
Acvolt2 var word
volt1 var word
volt2 var word
Cnt var byte
Cnt =1
ADCON1 = 7 ' Set PORTA and PORTE to digital
Low PORTE.2 ' LCD R/W line low (W)
Pause 100 ' Wait for LCD to start up
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
loop:
For cnt = 1 to 400
ADCIN 0, adval ' Read channel 0 to adval
adval= (adval*10)/204 ' 0 -5 V
volt1 = adval/10
Volt2= (adval - volt1*10)
'LCDout$fe, 1 ,"Value: ",dec(volt1) ,".",dec (volt2), " Say:" ,dec say
ACVolt = Acvolt + (volt1)*(volt1)
AcVolt2= AcVolt2+ volt2*volt2
'LCDout$fe, $c0 ,"Value: ",DEC (acvolt )
'pause 250
pauseus 50
next cnt
acvolt = sqr(acvolt/400)
AcVolt2= sqr(Acvolt2/400)
LCDout$fe, 1 ,"RMS AC V: ",DEC (acvolt),".", dec acvolt2' Display value
' Pause 1000 ' Wait .1 second
adval=0
Goto loop ' Do it forever
End
Bookmarks