How to determine the frequency of sine wave collected by microcontroller AD?
[Copy link]
Now, the AC is input to the AD port of the PIC16F877A microcontroller through the op amp. The program code is in assembly, so I don't quite understand it. It seems that the program is written like this to judge whether the waveform is 50HZ or 60HZ by judging the number of acquisitions, and in order to judge the amplitude of the AC, it is compared with a fixed value after accumulation. AD is a 10-bit AD, so the absolute value of the difference between the collected value and 0x7f in the program is accumulated and compared with a value. What is the reason for this? Because AD is 10 bits and the op amp raises the AC waveform to about the midpoint of 5V during sampling, that is, the 0V and 2.5V of the AC coincide, so the collected value 0X7F is subtracted. I can understand, but I don't understand the following: The op amp circuit diagram and the voltage waveform output by the op amp to the AD port are shown in the figure. But the questions are as follows:
1. The AD program is processed once every 400US in the program, and the number of AD acquisitions is compared with 24 to judge whether the waveform is 50HZ or 60HZ. What is the reason for this?
2. Why is the value collected each time accumulated and compared with a fixed value to determine whether the input voltage amplitude is 220V or 380V?
There is a comment in the program as follows
; (half-cycle sampling amplitude accumulated value < #0x0350)
How is 0x0350 obtained?
Our product is a PIC assembly which looks too long. How does the microcontroller determine the frequency and amplitude of the alternating current?
|