thanx..m working on them
Hi,i've read the Microchip appliction notes for sine wave with the 16F series chip..http://ww1.microchip.com/downloads/en/AppNotes/00655a.pdf together with the examples given in http://www.picbasic.co.uk/forum/content.php?r=229-Sine-wave-using-DT- interrupts and http://www.picbasic.co.uk/forum/showthread.php?t=14359.
there are number of things which i've not understand from these readings and i'm asking for help from anyone who can help me to understand.these things are:
1)how to generate a lookup table for the sine waveforms
2)how to include DT_INTS-18.bas file so that when i compile,the compiler will be able to open it
3)what is the purpose of this piece of code from example of http://www.picbasic.co.uk/forum/cont...-DT-interrupts
asm
__CONFIG _CONFIG1H, _OSC_HSPLL_1H
__CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WDPS_512_2H
__CONFIG _CONFIG4L, _LVP_OFF_4L
endasm
thank you in advance.
1) You could use the 32 location array you pointed at in question 3. I used M.S. EXCEL.
3) Get the data sheet for the PIC in PDF format and search for _OSC_HSPLL_1H or some piece of that. In the first of the 3 you can see these bits setup the oscillator and PLL. Most of the PICs have many modes for the oscillator. Internal/ external, divide by 32/ multiply by 4, etc.
1)how to generate a lookup table for the sine waveforms
2)how to include DT_INTS-18.bas file so that when i compile,the compiler will be able to open it
3)what is the purpose of this piece of code from example of http://www.picbasic.co.uk/forum/cont...-DT-interrupts
asm
__CONFIG _CONFIG1H, _OSC_HSPLL_1H
__CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WDPS_512_2H
__CONFIG _CONFIG4L, _LVP_OFF_4L
endasm
thank you in advance.[/QUOTE]
to bwaxing:
My advice : read this great post with exemples, the sine is stored in an array :
http://www.picbasic.co.uk/forum/cont...-DT-interrupts
Last edited by Ioannis; - 8th May 2011 at 15:32.
thanks for the advice,i read examples from that post and I've not understand how to create the lookup table.From that post sine is stored in the array and i don't understand how the value for a particular step have been determined.for example i want to use 8-bit resolutions (256 steps),how will i determine the value of each step?is there a formula or something?
thanks again.
Last edited by Ioannis; - 8th May 2011 at 15:32.
sine[1]=0
.
.
.
sine[128]=255
Excel can do that. The first number is the angle (1->128, like 0-360°), the second is the result of the sine (0->255, like 0-1).
For each interruption, the command duty=sine[counter] will read the sine value located in the array and the position of this value in the array is determined by the "counter" variable. The result of this command is stored in the "duty" variable.
A little example:
In each loop the counter value is decremented by one, and when the step value equals 0, the counter is reinizialized to 128.Code:counter=128 loop: duty=sine[counter] PWM pin,duty,cycle counter=counter-1 if counter=0 then counter=128 goto loop
So in this case, to make a complete sine, it will take 128 loops. If you want a 1Hz sine, you have to repeat this loop exactly 128 times per second.
Last edited by Ioannis; - 8th May 2011 at 15:33.
Bookmarks