Quote Originally Posted by HenrikOlsson View Post
Hi,
I'm not using a simulator, I just sent the values to the PC and plotted them with EXCEL. Here's the exact code I used to test with:
Code:
DEFINE LOADER_USED 1
DEFINE OSC 20
DEFINE HSER_BAUD 19200
 
i VAR BYTE
T VAR BYTE
uDuty VAR WORD
vDuty VAR WORD
wDuty VAR WORD
 
Main:
For i = 0 to 2   'Make three periods
  T=0
    
   for T=0 to 255
   ' PWM U phase calculation
   uduty=((sin(t)+128)*4)  
      
   ' PWM V phase calculation
   vduty=((sin(t+85)+128)*4)
    
   ' PWM W phase calculation
   wduty=((sin(t+170)+128)*4)
   
   HSEROUT [DEC uDUTY, ",", dec vDUTY, ",", dec wDUTY, 13]
  next
NEXT
WereDone:
Goto WereDone
Try removing C3, C6 and C8 to start with.
In reality, I think that my RC filter in Proteus is bad.

If I watch the raw PWM outputs, it seems perfectly good (with correct phase angles and duty cycles). However, in extreme duty (like 0 or 1023), the PWM "jumps" (like before, I think it's a sim issue, I will try the PIC in the real life with an oscilloscope).

In other words, my code is working quite well now, thanks for the "**", I didn't know this operator before, until now.