Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Harmonic Analysis in 8051

Status
Not open for further replies.

upasana2007

Junior Member level 1
Joined
Mar 20, 2010
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
india
Activity points
1,414
Hi all,

I am trying to find the harmonic content of power signals. This is a part of a larger project and so I am looking for an easy way out. The problem is I am restricted to use 8051 as my main microcontroller(however a co processor may be used if all else fails)As of now, I have determined 3 ways to do this:
1)using goertzel algorithm(i just need to find 1st and second harmonic content)
2)using FFT - but that will mean using a co-processor
3) Interfacing with MATLAB- this is the last resort since I dont want to carry my computer to the industrial setting(I am trying to protect a Transformer)


So, My main query is, Can I USE GOERTZEL ALGORITHM IN 8051? I mean will it be fast enough? the rest of the code is not to complex....around 60 lines of assembly coding in keil ...mainly dealing with additions,subtractions and comparisions. Please help. My project is due in 10 days!

Also if someone has a code for the goertzel it would be great :D :p
 

that would depend upon the XTAL you use on the 18, 19 pin.

time for each instruction to complete:


((1/xtal value in mhz)*12) *1000
which gives the result for time interval for each instrcution (in microsecond)

rest of other depends on your code
 

for similar applications I have used an FFT either running on a dsPIC or having data transmitted via Ethernet to a PC and run thru Matlab or Octave. The advantage of the dsPIC is there are APIs etc downloadable free from Microchip
**broken link removed**
**broken link removed**
 
for similar applications I have used an FFT either running on a dsPIC or having data transmitted via Ethernet to a PC and run thru Matlab or Octave. The advantage of the dsPIC is there are APIs etc downloadable free from Microchip
**broken link removed**
**broken link removed**


Hi....thanks for your reply....i will try this... :)

---------- Post added at 08:16 ---------- Previous post was at 08:07 ----------

If standard 12-clock/instruction 8051 micro is slow for your application, use a faster 6-clock/instruction variants of 8051 like P89V51RD2. If you need even faster, use 1-clk/instruction micros from Silicon Labs Silicon Labs - leader in high-performance, analog-intensive, mixed-signal ICs.


Hi....the only available 8051 microcontroller board in my lab is one that is using Atmel 89c51ed2 or intel 8051....cant really change the clock frequency....
 

Determining 1st and 2nd harmonic sounds feasible even with a slow (1 MIPS) standard 8051, e.g. using Goertzel algorithm. It depends however on the sampling frequency and bit resolution, which hasn't been told at all. You would want a low sampling rate not much above the minimal (Nyquist) rate. A good analog filter would be required to avoid aliasing of higher order harmonics.
 

Determining 1st and 2nd harmonic sounds feasible even with a slow (1 MIPS) standard 8051, e.g. using Goertzel algorithm. It depends however on the sampling frequency and bit resolution, which hasn't been told at all. You would want a low sampling rate not much above the minimal (Nyquist) rate. A good analog filter would be required to avoid aliasing of higher order harmonics.

The sampling frequency is 12 khz... it follows the Nyquist theorum...N=250, required frequencies are 50 Hz(fundamental) and its second harmonic.......this gives k=1.04(k=N*Fs/Fk)
This is the Goertzel code being used(not running)

static int N=0;
static int goertzel value=0;
int I,prod1,prod2,prod3,sum,R_in,output;
short input;
short coef_1=0x7ff5;

R_in=mcbsp0_read();

input=(short)R_in;
input=input>>4;

prod1=(delay_1*coef_1)>>14;
delay=input+(short)prod1 - delay_2;
delay_2=delay_1;
delay_1=delay;
N++;

if (N== )
{
prod1=(delay_1 * delay_1);
prod2=(delay_2 * delay_2);
prod3=(delay_1 * coef_1)>>14;
prod3=prod3*delay_2;
Goertzel_value=(prod1 + prod2 - prod3)>>15;
Goertzel_value <<=4;
N=0;
}
output=(((short)R_in)*((short)Goertzel_value))>>15;
mcbsp_write(output& 0xfffffffe);
return;
}
 

12 kHz most likely won't allow real time analysis, so the samples have to be processed from memory. 250 samples isn't more than one 50 Hz period, so the frequency resolution will be bad. In addition, the goertzel coefficient can't be represented with sufficient accuracy for this high sampling rate.

To check the algorithm and effects of numerical accuracy, limited sample length etc., you should simulate the calculation with Matlab or a spreadsheet calculator. Preferably a sample sequence acquired by the real hardware should be used for the test.
 

12 kHz most likely won't allow real time analysis, so the samples have to be processed from memory. 250 samples isn't more than one 50 Hz period, so the frequency resolution will be bad. In addition, the goertzel coefficient can't be represented with sufficient accuracy for this high sampling rate.

To check the algorithm and effects of numerical accuracy, limited sample length etc., you should simulate the calculation with Matlab or a spreadsheet calculator. Preferably a sample sequence acquired by the real hardware should be used for the test.

Yes, I agree....for better resolution N should be higher....but too high valuhat of N will slow down my microcontroller,,,,as the end application is for fault detectin and clearing of power circuits...time is crucial....
Having to take care of time delay, accuracy, and bound to use 8051...is proving to be difficult.....

---------- Post added at 20:19 ---------- Previous post was at 20:13 ----------

I chose 12 Khz because again, I am restricted by the ADC I aam using in the circuit.....the conversion time is 100 us....which means the freq of sampling should be suffeciently more than 10khz so that the processing and subsequent output from microcntroller is achieved within the 100microsecond
 

Hi....the only available 8051 microcontroller board in my lab is one that is using Atmel 89c51ed2 or intel 8051....cant really change the clock frequency....

Are you using 89C51ED2 in X2 mode? If not try putting it in X2 mode when programming or by setting Bit-0 of CKCON0 register at run-time. This will double the execution speed. Note that doing so will affect delay functions and UART baud-rates so the counters/registers need to be adjusted for this.
You have not specified the crystal frequency. If it is 30MHz, you could get speed up to 5 MIPS which may be sufficient for your application.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top