# Voltage control using PWM

1. ## Voltage control using PWM

I having an test panel in that their is an stepup transformer which produce 270VAC from 230VAC.

I have to use variable voltage from 170VAC TO 270VAC for my operation in specified time.So I tried to bulit an automatic voltage converter to change the voltage from 170VAC TO 270VAC,based on time of operation.

So I tried it by using PWM output from the PIC controller with BT136,IRF540 and MOC3021 but I can't get any output from it...

How to control the voltage by using the PWM from PIC controller..? 2. ## Re: Voltage control using PWM

Hi,

AC voltage control by PWM? Are you sure? Show your circuit.

Klaus •

3. ## Re: Voltage control using PWM

Hi,
I think the solution to your this problem is a little different. If u want to vary your voltage in AC supply, first detect the zero crossing (any) of the voltage waveform and then vary the duration before giving the gating pulse (at each half of the AC supply to vary the RMS value of voltage) to your BT136 (TRIAC) which will control the output terminal voltage across your load. 4. ## Re: Voltage control using PWM Code:
```freq_timer = TMR1L;
freq_timer += (TMR1H << 8);
freq = (int) (60000.0 / (0.008 * freq_timer));```
Output side of this circuit is connected to fluke meter and checked the frequency,it showing 100.01.
Then I connected with CCP1 pin of PIC controller and by using the above calculation,it showing nearly 20000 like.

How to detect the zero crossing..? •

5. ## Re: Voltage control using PWM

Hi,

I'm not familiar with PIC,

But "CCP1" sounds like a capture input.

When using capture feature you need to setup the capture periferal. I don't see this in your code.
Please explain how you set up the capture periferal.

All I see are some values I don't know where they come from.

Klaus •

6. ## Re: Voltage control using PWM Originally Posted by venkates2218 To Detect the zero crossing of the AC supply, follow the following steps:
1. AC supply needs to be rectified via bridge rectifier. {Take a parallel connection}
2. The pulsating DC which you gonna get after step 1 is also having a zero crossing at same position which we need to detect, is given input to the opto-coupler [eg. MOC3043 IC] to protect your micro-controller from over-voltage and over-current from the direct supply.
3.The DC signal which u get in step 2 is given to the voltage comparator to detect the zero crossing.
4. Output from step 3 i.e. O/P of voltage comparator is fed to the micro-controller to know the zero-crossing. 7. ## Re: Voltage control using PWM

Klaus, CCP1 is one of the capture or PWM output pins depending on configuration. In PWM mode it is an output, in CCP mode it effectively becomes a gate input for counting a clock or a counter input itself.

I'm not sure why PWM is suggested at all here and I'm not sure triac control is suitable for producing a variable AC voltage unless chopping parts of the cycles is permissible. If PWM is used, it can only be to either control the phase angle the triac is fired, in which case the waveform will no longer be sinus or it can be used to recreate the entire AC waveform in which case zero crossing isn't necessary.

venkates2218, can you explain which method you are trying to use. From your triac diagram is seems you want to control overall power to a load rather than voltage.

Brian. 8. ## Re: Voltage control using PWM

Are you really attempting to control 270 volts alternating current with a phototransistor? •

9. ## Re: Voltage control using PWM

... I think that was just to detect zero crossing.

However, using PIC PWM module usually implies a relatively fast PWM rate so unless this is a full inverter (creating a new AC voltage via a DC source), the PWM signal is useless as a triac trigger.

Brian. 10. ## Re: Voltage control using PWM

I don't know if the forum rules allow this question and us to comment. If they do, it would be best to use a step up transformer for this purpose. 11. ## Re: Voltage control using PWM

Does your project draw low power? Here is an AC-in-AC-out voltage multiplier. It has positive and negative Villard cells. The transistors feed a true AC sine wave to the load. It allows some room for adjustment (although more effort is needed to create automatic regulation).

Supply is 170V AC. The load gets 270 VAC

By selecting small enough values for C1 C2, it produces large voltage swings. Thus the transistors do not need to dissipate so much heat. Bias resistors should be adjusted so the load gets a sinewave at the desired voltage. Power factor error is high. It can be reduced by installing resistor/ capacitor/ inductor networks inline with the diodes. --[[ ]]--