View previous topic :: View next topic |
Author |
Message |
dani
Joined: 02 Jun 2004 Posts: 16 Location: Pakistan
|
how to detect lower edge of sine wave at 100Hz..? |
Posted: Wed Sep 28, 2005 5:06 am |
|
|
Hi all,
I need to start a timer after detecting every lower edge of a ac standerd sine wave of 50HZ.
I have changed these waves to fully rectified sinewave.
..............................*........*.......... ..........................*.......*..............
.....................*........................*... ..................*.....................*........
................*................................. .*...........*...............................*...
.............*.................................... ....*....*......................................*.
.. --->..*............................................*<---................................-->...*
...here........................................... .......here................................here
can any one give me idea how to do this and if any one can share some sample code.
Regards |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Wed Sep 28, 2005 8:00 am |
|
|
There are many people more qualified to answer this but...
I would try a opamp compairitor. above a certain level it outputs a 1 below the level it outputs a 0.
Then time between rise and falling edges.
I think that should work for that freq.
What rate is the uP running at? |
|
|
dani
Joined: 02 Jun 2004 Posts: 16 Location: Pakistan
|
Is this a right track or not |
Posted: Wed Sep 28, 2005 8:09 am |
|
|
thanks for reply
I am runnig PIC16F877A at 20Mhz
what you have said i have tried it i have used a comparator and got good results.
Actually i want to measure the angle of fully rectified ac wave.So i want to detect the start angle means pulse start at 0V using pic. then my idea is to use timer as these pulses are comming at 100hz so idea is to find angle with help of timer.
Is this a right track or not.... |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Wed Sep 28, 2005 8:27 am |
|
|
I think i'm out of my league. I never tried to measure angles.
PCM programmer or asmirili might be able to help tho. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Sep 28, 2005 9:23 am |
|
|
Hardware:
You didn�t mention the voltage of the full wave rectifier you are dealing with, but I assume
you are using an isolated low voltage transformer with a secondary less than 40Vac
to be able to pick up a pulsating shape wave in a safe way.
There are tons of zero-crossing detectors circuits, but this is one of the simplest you
can build, not the best. Using a 15-22K resistor pick up the output of the rectifier
- before filtering - in your power supply.
The another end of the resistor connected to the base of an NPN transistor
(2N2222 or similar) in common emitter mode (emitter grounded) and the collector
connected to +5V through a 2K2 resistor. In the collector you will get the signal that you
need, a clean and sharp going up pulse every time the line voltage is close to zero (10ms).
Software:
Once you get a clean 5V pulse every 10ms:
1) Wire it to EXT_INT pin and set the trigger for H to L transition.
2) In the INT_EXT handler raise a flag every time it generate an interrupt.
3) In main() increment the counter if the flag is set.
4) First task inside the the isr_handler is to save the counter value before to clean it.
Also, read this Application Note from Microchip
http://ww1.microchip.com/downloads/en/AppNotes/00521c.pdf
Hope you understand the idea.
Best wishes,
Humberto |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Sep 28, 2005 10:45 am |
|
|
Does your application require you to be in sync with the zero crossing point as implied by you diagram or are you just interested in measuring the period? In other words, in you diagram what if you were to time when your input transitions (from low to high) the middle horizontal line instead of the bottom line? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Sep 28, 2005 10:58 am |
|
|
Are you trying to use a triac or similar device? Maybe zero crossing closing for a relay? What is your application? |
|
|
Guest
|
Thanks for response |
Posted: Thu Sep 29, 2005 1:46 am |
|
|
Hi all,
Thanks you all for this kind respose which i was not expecting from this forum.
As far as my application is concerned at the moment it is just a task that detect every 0 crossing edge and start counting thes pulses. I need to calculate time from these pulses and upon completion of certein cycles of these pulses(i.e. fully rectified sine wave voltage not more then 40v) i have to opreat a relay.
Mean while i need to know the angle of these waves after a perticular condition is met.
What i have done so far..
I have used a comparator to detect zerocrossing i.e. whenever this fully rectified waves coross below 200 mv it gives me high output and low when it goes up then 200mV.
so from this output i m generating interuupt high to low ....
Now my idea is to count these interrupts to get cycles(interms of time) and for other task i.e for angle as i know the pulses are at the frequency of 100hz so fixed delay can be calculated perportional to angle.
On a certain angle i have to generate PWM of 10KHZ untill the next zero crossing interrupt occure.
I am not sure that if this is an efficient way of doing this or not .....
any how i will also try as Humberto told me as i think he is very close to understand what i want to do..
As i m more on programming side and less on electronic side so at the moment i m not sure for what application this machanisim is going to be used. but the idea is similer to the phase controller for some industrial application.
Thanks u all once again i will tell u my progress.
Regards..
regards.. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Sep 29, 2005 9:24 am |
|
|
The H11AA1 optocoupler mentioned by ljbeng in the other copy of this thread is really the way to go. It gives you zero crossing and optoisloation for under $0.25 if you buy enough, or $0.75 for one. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Sep 29, 2005 10:56 am |
|
|
Quote: |
The H11AA1 optocoupler mentioned by ljbeng in the other copy of this thread is really the way to go.
|
@SherpaDoug I�m agree with you.
The poster didn�t give us details of what/how he is trying to do, we doesn�t know
his electronic knowledges nor skills, just suggested an easy way to start with using
components of the trash box.
Humberto |
|
|
Guest
|
|
Posted: Fri Sep 30, 2005 2:29 pm |
|
|
A couple of quick thoughts here. You mentioned a zero crossing threshold of 200mV. Is the problem that your comparator trips at 200mV and you cannot tell if it is the rising or falling edge of a waveform?? I assme that is what you meant by "angle". (The only other "angle" is a phase difference between two signals.) If that is correct then it is just a matter of detecting a raising(unless you need falling) edge. OK, lets say you need to catch each raising edge of the signal, to determine when to fire off your 10kHz Pulse Width Modulator. The easiest way I can think of since you say you have recitifed the 50Hz signal, is to use a D-type flip-flop. Forget the 200mV zero crossing, the flip flop will latch on a rising edge, so the output would toggle on every rising edge. You can then use the output toggling to fire off your PWM. I may not have understood your problem clearly, so this may not be the solution. Feel free to PM me and we can discuss your problem in detail.
Tim Moody |
|
|
Tim Moody
Joined: 30 Sep 2005 Posts: 17
|
|
Posted: Fri Sep 30, 2005 2:35 pm |
|
|
The last Guest post was me. I thought I was logged in.
Tim Moody |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Sat Oct 01, 2005 9:02 am |
|
|
Are you using a 12vac transformer that you rectify and put thru a voltage regulator to get your 5V? If so, then you can take the output of the transformer and connect it through a 100K resistor to RB0.
This will give you a (semi)square wave that is 'low' for 10ms, and 'high' for 6ms (due to RB0's schmitt trigger threshold characteristics) |
|
|
|