PDA

View Full Version : how to get maximum value(Vmax) of sine wave??



donatelo
- 20th September 2008, 16:09
hello...
i'm using pic16f877a and current sensor (acs754-050) is my analog input...
i do get the Vout value but the value is varied(display on LCD) because i monitored 415VAC...
how can i get the Vmax of sine wave???
any ideas???

my coding:
- - - - - - - - - - -- - - - - --

define osc 4

Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 1
Define LCD_EREG PORTE
Define LCD_EBIT 2
define LCD_BITS 4
define LCD_lines 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50

' Define ADCIN parameters
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS

adcon1 = %00000100
ADCON0 = %11011001
trisd = 0
trisb = %01111100
trise = 0

res var word
volts1 var word
volts2 var word
conv1 con 19
conv2 con 60

Pause 500

main:
adcon0.2 = 1
res = ADRESH

volts1 = res*conv1
volts2 = res*conv2
volts2 = volts2/100
volts1 = volts1 + volts2


pause 100
lcdout $fe,1
lcdout $fe,$80+4, "V=", dec4 volts1


goto main

end

- - - - - - -- - - - -- - - - -- - - -- - - -

when the current sensor sense current,it convert to voltage (1A=40mV)
when zero current,the Vout is Vcc/2(2.5V)
let say current sensor sense 1A,Vout is 40mV max and Vp-p is 80mV
my LCD will display 2460mV varied to 2540mV (which is Vp-p 80mV)
how can i capture the 2540mV value and display it on LCD??

skimask
- 20th September 2008, 16:16
hello...
i'm using pic16f877a and current sensor (acs754-050) is my analog input...
i do get the Vout value but the value is varied(display on LCD) because i monitored 415VAC...
how can i get the Vmax of sine wave???
any ideas???

What program are you using to sample that 'sine wave'? After all this section of the forums is titled PicBasicPro, so I'd assume you have some code...

If you're sampling the Vout and getting some results, then keep track of the maximum value and only the maximum value.

Charles Linquis
- 20th September 2008, 16:39
A lot on how you do this depends on the accuracy you need, and the range over which you need a reading.

A good way is to use a decent AC step-down transformer (the very tiny cheap ones don't work very well). Choose one that has the right input voltage, and an output voltage of 12-24V p-p. Use that output to feed a bridge rectifier and voltage divider. Keep the impedance of the voltage divider below 3K ohms (as seen by the PIC) for best accuracy. Put a small (.1 uF) cap on the output of the divider to kill any spikes. Also note that some of the little transformers have an output waveform that is very load-dependent. Use a scope to make sure yours is putting out an undistorted sine wave and choose your voltage divider accordingly.

And while I have the "floor" - I can't understand why everyone isn't moving over to the PIC 18F series. They have much more capabilities, are better in almost every way,
and don't cost much more. ?????

skimask
- 20th September 2008, 16:51
And while I have the "floor" - I can't understand why everyone isn't moving over to the PIC 18F series. They have much more capabilities, are better in almost every way, and don't cost much more. ?????
(Raising hand)
Oh Oh Oh! I know! I know!
Because it costs more! (i.e. tougher to find a pirated version of the newer PBP!)

tenaja
- 20th September 2008, 17:22
...And while I have the "floor" - I can't understand why everyone isn't moving over to the PIC 18F series. They have much more capabilities, are better in almost every way, and don't cost much more. ?????

I can give you one good answer. Most folks can't even manage to read a 120 page datasheet, much less one that is over 2 or 300 pages.

rmteo
- 20th September 2008, 17:36
It is not so much whether they manage to read the datasheet, as to whether they even bother to download and absorb it. Maybe they should have to take an oath such this before they ask the question. :D

I hereby solemnly affirm that:
a. I have downloaded the datasheet for the device in question.
b. I have read (and have done my utmost to comprehend) the relevant section and/or sections that pertain to my question.
In witness whereof, I humbly submit my question, and where it is deemed to be helpful, I will quote the relevant section of the datasheet.

Charles Linquis
- 20th September 2008, 19:31
Look at the MAX function - it is in the manual.

Vmax = Vmax MAX ADCvalue

As the ADC value rises the value of VMAX rises. When the ADC value falls, the value
of Vmax stays the same. If you sample for more than a full cycle VMax has the peak value of the sine wave.

If you are looking at the sine wave cycle-by-cycle, you will have to clear Vmax at zero crossing.

donatelo
- 20th September 2008, 19:42
thnx for the reply....
i'll figure it out tomorrow...