Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

FEEDBACK IN SINE WAVE INVERTER USING PIC16F887.

Status
Not open for further replies.
I have been been working on designing a sine wave inverter using PIC16F887 microcontroller using fullbridge configuration.. The part of the design that seems stressful is implementing feedback in the code.

please i need explanations on how to go about it.

This is an excerpt of the sine wave table.
This is what happens;

The table is a two dimensional array; sinearray[row][column].
The row index ranges from 0 - 6 and the column index ranges from 0-49.

when the value of the row index is between 0-3, the sine wave and the frequency is okay but when the row index start approaching 4 -6,
the sine wave becomes distorted and the frequency is drastically reduced.

what can i do about this, any suggestion or an alternative approach ?
 

Attachments

  • Inverter.txt
    1.3 KB · Views: 199
Just looking at the table only... The distortion is occurring at 4 onwards... The common factor seems to be signed vs unsigned...

0 and 1 only go as high as 120 3 goes to 140 ( has the sine wave has a distorted top!!!)

4 and 5 will be distorted whilst 6 and 7 may appear as double the frequency..
 
Just looking at the table only... The distortion is occurring at 4 onwards... The common factor seems to be signed vs unsigned...

0 and 1 only go as high as 120 3 goes to 140 ( has the sine wave has a distorted top!!!)

4 and 5 will be distorted whilst 6 and 7 may appear as double the frequency..

Didnt get the explanation. please kindly elaborate .
 
Okay... In C const char is signed by default.... Therefore its value is 128 ~ -127.... so lets assume you control something with a unsigned character type ( 8 bits ).... Lets call this variable 'A' .. Then get a variable from the table
A = sinearray[2][14];
'A' will now indeed equal 107...
Now we will fetch A = sinearray[7][25];
Hang on a mo... 'A' should be 200 but you have 56!!!!!!!!
Oooh this wont work!!! to fix it you need to declare the table as const unsigned char... or cast the fetch.

A = (unsigned char) sinearray[x][x]l; Now 'A' will indeed hold 200...
 
I suppose it all depends on the drive... If you are using the inbuilt bridge driver, I would have though the sinearray will be driving the CCPRxL directly, so the const unsigned char is a must... If this isn't your problem then it'll be more than likely a hardware issue..
 
ok, let me explain better.

i have implemented the design on the veroboard
i used a tranformer 7v-240v
i used a battery of 12vdc, it gave an output of 300v, i scope it, it gave a good sine wave.

without the feedback, the inverter works well, but when the feedback is introduced, the wave becomes distorted

The same problem about the feedback that persists on the software design is the same problem that is appearing on the hard ware.

so i believe if i can get it right on the software design, the hardware design wont give any problem again.

i guess i should post the source code.
 
i also notice

if i did something like :
CCPR1L = sinearray[5][dutycycle] ; i get a good wave

if i do something like :
unsigned char index1 = 5;
CCPR1L = sinearray[index1][dutycycle] ; i get a distorted wave

why ????
 
This is still something todo with signed/ unsigned... A constant is an integer in the C environment

If you do this...

volatile int index1=5;
CCPR1L = sinearray[index1][dutycycle] ;
will that work???
Also this line... __delay_ms(0.1); I don't think will work as the macro requires a constant ( whole number ).. I would use its sister __delay_us(100);

Last!! P1M1.... Shouldn't that be CCP1M1?
 
Thanks for your advice
when i used CCP1M1 instead of P1M1, the waveform got worse.
I also changed index1 also to volatile, the problem still persists.
 
Here is your sine wave in Proteus circa 1khz.... This is with a simple filter 330Ω and .33μf..
upload_2017-1-25_19-22-9.jpeg


Here is the same 1khz wave form using Roman Blacks "Harmonized" sine table..
upload_2017-1-25_19-23-13.jpeg


C:
const unsigned char sine[50] = {52,57,62,66,70,74,77,80,82,84,85,86,86,
                                   86,85,83,81,78,75,72,69,65,61,56,52,
                                48,44,39,35,31,28,25,22,19,17,15,14,14,
                                   14,15,16,18,20,23,26,30,34,38,43,48};

The distortion is purely the table...
 
Thanks, so what is your suggestion ?
how can i generate a better 2D array table ?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top