Page 1 of 1

three level pwm using pic

Posted: Wed Feb 11, 2009 4:54 am
by nur3
hi...
can anybbody pls help me...
how to generate three level pwm using pic 16f628...
how to actually create triangular and sine lookup table...
i'm new to pic...and trying so hard to learn how to program it!!!

Re: three level pwm using pic

Posted: Wed Feb 11, 2009 10:11 am
by Benj
Hello

Here are some examples of look up tables using Flowcode.

http://www.matrixmultimedia.com/mmforum ... =LUT#p5509

Hope this helps.

Re: three level pwm using pic

Posted: Thu Feb 12, 2009 1:48 am
by nur3
Yeah..thanks a lot...
does the triangle lookup table also use the same method as sine table.
how to program it using assembly language?
and one more thing..what is actually flowcode... :?: :!:

Re: three level pwm using pic

Posted: Thu Feb 12, 2009 10:41 am
by Benj
Hello

Yes any look up table can be performed using the method shown. Good luck in assembler!

Flowcode is a high level graphical language for PICs, AVR and ARM. You can download a demo from here.

http://www.matrixmultimedia.com/Flowcode3a-X.php

Re: three level pwm using pic

Posted: Mon Feb 23, 2009 6:31 am
by nur3
hi..
if we use the comparator to generate pwm,it is possible that we use external source rite...for instant if we use sine voltage,then we dont need sine lookup table anymore rite??
:roll:

Re: three level pwm using pic

Posted: Mon Feb 23, 2009 11:10 am
by Benj
Hello

This search may prove useful to you.
http://www.google.co.uk/search?hl=en&q= ... arch&meta=

Example of assembler look up table.
http://web.hazmat.com/~mjb/projects/rswg/

The comparitors compare two analogue signals to provide greater then, less then or equal. Not quite sure how this would help the PWM operation. You could use analogue readings to take in your external signal but you will then have the problem of synching the readings with a full period of the wave.

Re: three level pwm using pic

Posted: Wed Feb 25, 2009 4:11 am
by nur3
hi..
thanks a lot for the link...
the project that im doing rite now requires me to use the pic for the switching scheme for my inverter...
so..in order to 'on' or 'off' the switches, i need to use the pwm method...i need to generate 3 level pwm by using sine wave and two triangular wave...
currently im using pic16f628...but i dont know whether to use timer1 or timer2...
sorry...im a bit slow in programming.. :cry:

Re: three level pwm using pic

Posted: Tue Mar 03, 2009 4:34 am
by nur3
hi..
if i want the output to be analog, what pic that i should use?
anybody knows???

Re: three level pwm using pic

Posted: Tue Mar 03, 2009 9:20 am
by Benj
Hello

There are a couple of ways of outputting analogue using the PICmicro devices.

1) A 8-bit R2R ladder network.

2) PWM with a stabilizing cap.

The PWM method seems to be less noisy and also less costly as you only need a capacitor instead of around 24 resistors.

Re: three level pwm using pic

Posted: Wed Mar 11, 2009 4:37 am
by nur3
hi....
what is stabalizing cap means??
and one more thing, how does the output of the p16f628 is like,i.e is it in 8 bit output or its output in serial bit....
im doing the lookup table....does each of the data occupy one memory add???or the memory location is replaced from one data to another;
this is the sample of my lookup table:

sinetable equ 0x20
lookup1 movf sinetable,w
addwf PCL
retlw 1
retlw 3
retlw 4
retlw 6
retlw 7
retlw 8
and many more data following this...approximately there are 180 data....
so...how does the output of this data will come out...i mean after it goes through comparator...

Re: three level pwm using pic

Posted: Wed Mar 11, 2009 9:52 am
by Benj
Hello

A capacitor can be placed between the PWM output and ground. This will act to smooth out the PWM and give you a nice analogue output signal. The Time constant of the capacitor should be approximatly 3 periods of the PWM to allow for nice smoothing without missing too much information.
how does the output of the p16f628 is like
Depends if your using digital outputs, the UART hardware or the PWM hardware onboard the device.

Yes each data chunk in your lookup table will consume one byte of memory.
how does the output of this data will come out...i mean after it goes through comparator
Depends if your using digital outputs, the UART hardware or the PWM hardware onboard the device.

Re: three level pwm using pic

Posted: Wed Mar 11, 2009 5:12 pm
by KeithSloan
Maybe speaking out of turn here. My understanding of PWM is that you need to pass it through a low pass filter i.e. A resistor in series and Capacitor in parallel. The cut off frequency for the low pass filter is given by 1/(2 * pi * R * C ). The cut off frequency being the frequency that the signal starts to be attenuated. If you want faster attenuation you add another low pass filter in series i.e. you end up with 2 resistors in series and 2 capacitors in parallel. Being naive about such things I would have expected to have the cut-off frequency the same as the PWM frequency to get a sine wave ( Fourier analysis etc ) But for some reason all of the circuits I have seen seem to cut in earlier.

Re: three level pwm using pic

Posted: Thu Mar 19, 2009 2:02 am
by nur3
Hi...
thanks for all your guides....
after read the datasheet, i found out that the pic allows analog input, for the comparator mode...
so this means that i can directly supply analog input to the pic and the comparator will do it works...rite??...
and i just need to do some delay to the pic...the question is...what the purpose of the delay if i use the analog input...