FPGA zero-pass Detection Algorithm

Source: Internet
Author: User

The zero crossing detection method is the function of the comparator. It can convert a sine wave of a certain frequency into a square wave or a pulse wave. This is necessary in the test frequency and other places, because FPGA only recognizes the edge, but does not recognize the sine wave.

The algorithm is divided into two parts: the determination of the zero point and the generation of the pulse wave.

Why do we need to determine the zero point. We know that the general ad is like 0 ~ Convert 5 V to 0 ~ 255 or something like that, or-2 ~ 2 V input, there will be an internal conversion circuit. Therefore, the normal zero point is not 0, but more likely 125 or 126. However, to be more accurate, the real zero point should be (MAX + min)/2. It is common to collect the maximum and minimum values, that is, to continuously update a register and assign the value to Max or min after a period of time.

For example:

If (AFT> maxtmp) Then maxtmp <= aft; endif;

If (AFT <mintmp) Then mintmp <= aft; endif;

The pulse wave produces two data points before and after comparison. if the first one is less than zero and the last one is greater than zero, an over zero pulse is generated.

Here is a trick. We used to detect the first and second values by using the concatenation operator. However, ad outputs are usually multi-bit and it is inconvenient to use the concatenation operator. Therefore, we can use the features of non-blocking assignment:

Aft <= sin_in;

Prev <= aft;

In this way, AfT is the next value, and Prev is the previous value. In fact, this method should be a general method. The following is simple:

If (prev <= zero) and (AFT> = zero) then

Pulse <= '1 ';

Else pulse <= '0 ';

Endif;

FPGA zero-pass Detection Algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.