Measure peak voltage

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Will643
Posts: 3
Joined: Thu Feb 02, 2012 10:04 pm

Measure peak voltage

Post by Will643 »

Hi

I would like to know how i would proceed to measure the peak voltage of the sine waveform. I am new to programming and flowcode. What i have thought so far is to use:
20MHz crystal/4 = 5MHz and then a prescale value of 8 brings the timer to 625kHz
FCV_COUNT = 625000/(256*tmr1h + tmr1l);
FCV_POS_PK_TM = (1/(FCV_COUNT/4)); //1/F=POS_PK_TM=Positive peak time
Which will give me the time until the peak of the waveform and then use the digital to analog converter to measure the voltage at this time. I have the analog to digital converter operating but cannot think of how to get the analog to digital converter to measure the peak voltage at the time calculated (POS_PK_TM=Positive peak time).

Any assistance would be appreciated.

Regards
Will

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Measure peak voltage

Post by Benj »

Hello Will,

Could you simply sample as fast as possible for a period of time, after each sample check to see if the sample is greater then the last greatest sample. If it is then replace with the current sample value. If your time period covers at least a couple of cycles then you should get fairly good accuracy.

Or do you need to be able to sample the unique peak every cycle?

Will643
Posts: 3
Joined: Thu Feb 02, 2012 10:04 pm

Re: Measure peak voltage

Post by Will643 »

Hi Ben

I would like to sample each peak, both positive and negative. What i have is a scaled mains voltage between 0 and 5V centered at approximately 2.5V. So i need to measure the positive peak and negative peak, add the two peaks and divide by 2 to get the real peak as it may not be centered on 2.5V. I have the frequency measured so a can get the positive peak time and negative peak time. I would like to measure the peaks and update the lcd possibly once a second. Is it possible to measure at a certain point on the wave as i want to at the peak.

Regards
Will

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Measure peak voltage

Post by Benj »

Hi Will,

One way would be to perform multiple samples for an entire cycle. eg 1/50Hz = 0.02s or 20ms. You then do as I suggested above to get the maximum reading. At the same time you perform a similar method to give you the lowest reading. You then have the readings for the upper most sample and the lowest sample for that cycle. You could then print out the results to the display or you could repeat the process 50 times before updating the display to give you a more accurate reading and a display update once per second.

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: Measure peak voltage

Post by STibor »

Hi!
Rectifier, the program simpler and more accurate measurement.
http://ww1.microchip.com/downloads/en/A ... 01353A.pdf
http://ytdp.ee.wits.ac.za/cct.html
The simulation is slow due to the timer interrupt.
Attachments
ac sine.fcf
(10.5 KiB) Downloaded 317 times

Post Reply