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

Changing Voltage with duty cycle

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



Joined: 05 Aug 2014
Posts: 7
Location: Turkey

View user's profile Send private message Send e-mail

Changing Voltage with duty cycle
PostPosted: Wed Oct 07, 2015 8:23 am     Reply with quote

Hi,

I have used half bridge to create sine wave.
I would like to change voltage and frequency.
Freq was OK, but the voltage was not changed when I changed duty cycle.
Neither increase nor decrease.

How to increase voltage using duty cycle?

Here is my code:
Code:

unsigned int8 i=94; // for voltage
unsigned int8 x=184;  //for freq

setup_timer_2(T2_DIV_BY_16,x,1);      //6,6 ms overflow, 6,6 ms interrupt

setup_ccp1(CCP_PWM|CCP_PWM_HALF_BRIDGE|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L);
 set_pwm1_duty(i);

// i value VOLTAGE, when I push the button;
      if(input(pin_b1)) 
      {       
          delay_ms(10);
          while(input(pin_b1));
          i+=10;
         
          if(i>=254)
          {
              i=94;
              /*write_eeprom(0,i);
              read_eeprom(0);*/
          }
          set_pwm1_duty(i);         
      }
     
      // x value, FREQ
       if(input(pin_b2))
      {
         delay_ms(20);
          while(input(pin_b2));
          x+=10;
         
          if(x>=254)
          {
              x=184;
             // write_eeprom(1,x);
          }
          setup_timer_2(T2_DIV_BY_16,x,1);
      }
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 3:29 pm     Reply with quote

Put a resistor and a capacitor on the output... measure the voltage across the capacitor... vary the duty.

Google PWM.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Ttelmah



Joined: 11 Mar 2010
Posts: 19541

View user's profile Send private message

PostPosted: Thu Oct 08, 2015 12:52 am     Reply with quote

There seems though to be a big 'gap' somewhere in the understanding.

If he is using a PWM, to synthesise a 'sine wave', then the PWM frequency needs to be a lot above the sine wave he is synthesising, and this needs to be being integrated to generate the sine. The frequency of the PWM, will not directly relate to the frequency of the sine.

<http://solar.smps.us/sinewave-inverters.html>

As you say, his circuit afterwards needs to be performing this integration.
The duty cycle will continuously be changing for each cycle of the sine wave, probably using a look up table, and it'll be the contents of the whole table that needs to change to vary the effective voltage....
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