CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PWM, induction Motor, with PIC18F1230

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
adel85



Joined: 17 May 2011
Posts: 1
Location: Mexico

View user's profile Send private message

PWM, induction Motor, with PIC18F1230
PostPosted: Tue May 17, 2011 12:42 pm     Reply with quote

HI, I'm new on the world of the pics and pwm too, i take the pic18f1230 because have 6 PWM outputs and i thinks i can control the speed of a induction motor, the problem is that i don't know how, I use an example of CCS and modify change the duty cycle of each pwm module with a for, but when i simulated the change of cycle is too slow, i put the code that i use. the example of CCS was with 18f2431 and only with one PWM output, the problem that i think i have is that i manipulate the 3 pwm modules like independent and i need to control a Full bridge of mosfets but i don't know how to program it. I appreciate your help and sorry by my english :S


Code:
#include <18F1230.h>
//#include <18f2431.h>
#device adc=10
//#fuses  HS,NOWDT,NOPROTECT
#use delay(clock=20000000)
// #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

void main()
{
   long int adc_val, period,X,i,p;

   period = 1024;
   setup_power_pwm_pins(PWM_COMPLEMENTARY,PWM_COMPLEMENTARY,PWM_COMPLEMENTARY,PWM_OFF);
      //PPWM channels 0 and 1 are both on and always opposite values
   setup_power_pwm(PWM_FREE_RUN,1,0,period,0,1,0);
      //add dead time for reactive loads

   setup_adc_ports(AN0);   //continuously sample and sync with PPWM
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(0);

   while(true)
   {
      X = read_adc();         //connect to pot to adjust duty cycle
     // X=adc_val;
      for (i=1;i<4;++i)
      {
      if (i==1){
      set_power_pwm0_duty(2047+X);
      set_power_pwm2_duty(2047-X);
      set_power_pwm4_duty(2047-X);
      }     
     
      else if (i==2){
      set_power_pwm0_duty(2047-X);
      set_power_pwm2_duty(2047+X);
      set_power_pwm4_duty(2047-X);
      }
      else {
      set_power_pwm0_duty(2047-X);
      set_power_pwm2_duty(2047-X);
      set_power_pwm4_duty(2047+X);
      }
     
      }
     
      //max duty cycle is (period+1)*4-1
                                                      //basically the same as max_adc * period/256
   }
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group