Hello sangaboy,
1) Download the file then rename it SIN-table.xls (or whatever ending with .xls) then open it with EXCEL 2003 - or compatible software. I just tried that here and it works fine. If you don't have Excel 2003 perhaps you can find a free viewer or converter online.
2) The first code snippet you posted is a setup section of DT-Ints which are a set of files making interrupts with PBP a whole lot easier. The second code snippet sets up TMR1 to operate in a specific way and then preloads it with 65534 (which seems a bit strange) but that's what you get when you just copy code. You really need to start a bit further back here. Before taking on a project a like a 3-phase inverter you need to understand the basics of PIC and PBP - at least. How the timers work, how interrupts work and so on.
Read up on the DT-Ints routines, there are several threads on this forum. Read up on how TMR1 operates, there's a lot of info in the datasheet and a bit of searching here will give a lot, I mean a LOT, of usefull information and examples. Start small otherwise you'll never learn how it works.
If you get stuck ask specific questions regarding the particular task at hand and tell us what the actual problem is and what you've tried, post the code and so on.
I really don't want to sound like a smart-ass but if you can't figure out the formula to create a SIN-lookup table then designing and programming a 3-phase inverter drive is going to quite a challange.
Hii! to all
I read DT-Ints routines from ttp://darreltaylor.com/DT_INTS-14/order.html here are some problems I faced any one can help me.
(1)the difference between PBP AND ASM interrupt handler is not clear to me.
(2) what the effects of ResetFlag on this code definition.
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
Thankx
Hi,
1) Internally PBP works with a bunch of system variables in RAM. These are used to store intermediate results when doinf calculations and comparisons, loop counters etc etc. When you define the type of handler as PBP in the interrupt declaration DT-Ints saves all the PBP system variables on entry of the interrupt service routine and restores them on exit. This allows the code the in interrupt handler to be written in PBP just like any normal PBP program and execute without destroying the content of the system variables for the code that was executing when the intterupt occurs. When the execution returns from the interrupt handler the system variables looks exactly as they did when the interrupt occured and the "normal" program can continue to execute.
If you define the type of handler as ASM DT-Ints does not save and restore the PBP system variables. This means that if you have code in the interrupt handler which happens to use any system variables it's very likely that you'll run into trouble. So, type PBP write the handler in PBP. Type ASM, write the handler in ASM.
The difference is that it takes time for the system to save and restor all the PBP system variables (and the take up space i RAM). No you should not declare the type as ASM and still write the handler in PBP if you don't konw and understand exactly what's happening and what system variables your code uses.
2) When an interrupt occurs the hardware in the PIC sets the interrupt flag for the particular interrupt. The ResetFlag option tells the interrupt system if IT should reset the flag after it's handled the interrupt or if it should leave it alone. Generally you set this to YES but for USART interrupt, for example, the flag is automatically cleared by the hardware when the RCReg is read so there's no need for the code to clear it as well.
Hi HenrikOlsson
I now I understand to gerate sine lookup table using excel sheet , thi is after working on the sheet you upload to me, The sheet contain the formular
(SIN(Ai*PI()/180)+1)/2 from what I know the portion (Ai*PI())/180)change degrees into radians. but there to thing I need to understand so that I can generate my 32 steps sine look up table for 3 SPWM.
(1) why (sine results+1)
(2) why (sine results+1) is diveded by the factor of 2
(3) why the (sine results+1)/2 are multiplied by 255 to get the scale value.
THANKX
Hi,
Yes, convert from degrees which is the number in column A to radians which is what Excel wants.
1) The SIN of an angle of 0-360° varies from -1 to +1 since we're going to use the values to set a PWM dutycycle we can't have negative numbers, we can't have a dutycycle of LESS than 0. So we add 1 to get a value ranging from 0 to 2 instead of +/-1.
2) Then we divide that by 2 to get the value ranging from 0 to 1 to make the next step more logical...
3) Again, since we're going to use the final value to set the dutycycle produced by the PWM generator we can't have the value ranging from 0 to 1, we need to scale the value up to match the number of bits of resolution we have in the PWM generator. If it's 8 bits multiply by 255 to get a value ranging from 0 to 255 (0 is 0% dutycycle, 255 is 100% dutycycle). If you have 9 bits resolution multiply by 512 and so on.
/Henrik.
Hi,
The Standard Hardware PWM modules on the PICs are generally 10 bits CCPRxL (8 bits) plus the 2 LSBs being in the CCPxCON<5:4>. How many bits you can obtain from the PWM module is dependent on the frequency. Sometimes updating the registers could be a bit troublesome and not within a single instruction cycle. What I do personally is select a 10 bit resolution and use only the higher 8 bits. A straight loading of the CCPRxL does the job with the benefit of not hitting 100% duty cycle which is required for the bootstrap gate drivers.
For the PICs with the PowerControl PWM module (sometimes also referred to as a motor control PWM) you can get upto 14 bits of resolution with a dedicated register pairs. And generally they at least have 3 PWM units with complementary outputs / dead time / Fault Input which simplifies the design and control of 3 phase systems greatly.
My choices are the PIC18F1330 and PIC18F4431(has 4 channel sequential sampling capability like the 16bit PIC24/dsPICs).
Regards
Sougata
Bookmarks