Hi guys Im EE student Im doing a project where I need 2 PWM signals: 1 fixed PWM and 1 variable PWM using A/D module.
Im using POWER CONTROL PWM MODULE.
I did fixed PWM and it worked perfect, I tested with some PWM frequencys and some duty cycles, here I dont have troubles.
Variable PWM my analog input is a rectified sinusoidal wave at 60 Hz, Im using AN0, Im working in this project since April and I have troubles here, my output isnt working in the correct way. I was using 8 MHz cristal with HSPLL enabled so Fosc = 32 MHz, I had FPWM = 100 KHz at 8 bits PWM resolution, I was loading the 8 MSB to Duty Cycle register... but I cant get the correctly output, so the last Wednesday I get a 10 MHz cristal now I have Fosc = 40 MHz, and 10 PWM resolution bits at FPWM = 39 KHz.. I loaded the 10 A/D result bits to the 10 PWM duty cycle bits and I still having troubles, the PWM output is working bad, some times the output go to 5 Volts (100% duty cycle) or go to 0 Volts (0 % duty cycle) or stay freeze in a low duty cycle, some times didnt stop.
About my A/D configuration, Im using single shot, Im trigering A/D convertion by software, A/D interrupt disable, my TAD is Fosc/32, and my TACQT = 2TAD, I have followed the A/D configuration steps from datasheet.
Im using PWM free-running mode.
To read the A/D result Im using a PWM interrupt each time that interrupt is active Im reading the A/D result and loading to Duty Cycle registers.
I hope somebody can help me please I need finish it, this project is my thesis from university, its a led ballast, the variable PWM signal will be used for a CD-CD converter Boost to made a PFC, the fixed PWM will be used for a CD-CD converter Buck, Im in darkness in variable PWM since April I dont know what can be the trouble I read my code, read datasheet, Im going to be crazy =P
I show You my hardware connection and my variable PWM output in a video.
I have attached my code.
http://img33.imageshack.us/img33/6127/hardwarepwm.jpg
>>> Hardware connection
http://img5.imageshack.us/img5/4380/pwmanaloginput.jpg
>>> Analog input
http://www.fileden.com/getfile.php?f...able%20PWM.wmv
>>> Variable PWM output video
Note: please copy and paste the url-links to your web browser.
Thank You for Your time.
Regards.
Tom.