|
|
View previous topic :: View next topic |
Author |
Message |
mvliege
Joined: 05 Aug 2014 Posts: 7 Location: Turkey
|
Changing Voltage with duty cycle |
Posted: Wed Oct 07, 2015 8:23 am |
|
|
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
|
|
Posted: Wed Oct 07, 2015 3:29 pm |
|
|
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: 19552
|
|
Posted: Thu Oct 08, 2015 12:52 am |
|
|
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.... |
|
|
|
|
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
|