PWM 3.3V to 5V for an inverter

Dear all,

I have an inverter whose output power depends upon the DC voltage between 0.25V to 2.55V supplied. At 0.25V it discharges the battery with maximum power of 500 watts while at 2.55V the output is zero. Similarly, supplying different voltages between these two extremes the output could be 50, 100, 150 and so on watts.

From 2.6V to 5V, it starts charging the battery. For instance, at 2.6V the charging current may be 1A and at 5V the charging current may be 10A.

If I use an Arduino with 5V, it would be easy to control the inverter for charging or discharging the battery but the problem is, I am using an MKR board whose operating voltage is only 3.3V. So, in this case, I can discharge the battery and even charge the battery but not with maximum current. At 3.3V, the charging current is around 3-4 amps.

My question is it even possible to use a PWM signal with 0.25 to 3.3V and make a 0.25 to 5V signal? Assistance in this regard would highly be appreciated. Thank you!

Easy.

Step 1. Produce a PWM signal of the desired duty cycle. 3.3V = 100%, 0.25V = 7.6%. Well, make that 0.165V or 5% duty cycle. That'll do better in step 3.

Step 2. RC low pass filter. 470Ω & 1µF would be ballpark values for this. Depends on acceptable ripple - larger values for less ripple but slower response.

Step 3. OpAmp with 1.5x gain. 3.3V becomes 5V; 0.165V becomes 0.25V. If you power the OpAmp at 5V, make sure it's a rail to rail OpAmp, e.g. the MCP6002.

But please note: a PWM signal is not a 0.25V or 1V or 2.32V signal. It's a block wave, so it's either at gnd or Vcc level, with very fast transition between the two.

Thank you @wvmarle.
Can I use LM358N Op Amp or the LM358D? Also, if I want to use the optocoupler, can I go with 6N137 as you recommended me the last time?

bilal40:
Thank you @wvmarle.
Can I use LM358N Op Amp or the LM358D?

Are they rail to rail? Able to output 5V when supplied 5V? (the answer is in the datasheet).

Also, if I want to use the optocoupler, can I go with 6N137 as you recommended me the last time?

It severely complicates the DAC conversion, as an optocoupler gives an open collector signal while the Arduino produces a push-pull signal.

wvmarle:
Are they rail to rail? Able to output 5V when supplied 5V? (the answer is in the datasheet).

As much as I understood, they are not. The Voh values are not equal to the Vol values. Excuse me if I didn't rightly understand the rail to rail term.

Exactly. So... not suitable, as you never get to the full 5V you want. Unless you power them at a higher voltage.

Rail-to-rail OpAmps usually have this mentioned in the summary at the top of the datasheet.

Microchip do a whole range of 5V-only rail-to-rail opamps.

LM358 is ancient technology, single-supply, but certainly not rail-to-rail.

There's a simpler way to do the conversion.

Level shift the PWM signal to 5V using, say, a 74HCT series logic gate (note, HCT, not HC),
then have the RC low-pass filter. No opamp needed. This does presuppose the
inverter has a high input impedance on that control voltage signal.

wvmarle:
Exactly. So... not suitable, as you never get to the full 5V you want. Unless you power them at a higher voltage.

Okay, so that's what I learned and please correct me if I am wrong. Ideally speaking, as the Op Amp has very high gain so we can get a huge output signal even if we supply a very small input. Nevertheless, in reality, the output is limited by the voltage we supply. For instance, in a simple Op Amp, if the supply voltage is 5V, so the output signal will always be lower than the 5V but higher than the 0V (as I am supplying 5V and 0V) no matter how we adjust the gain. On the other hand, in rail-to-rail Op Amp, the output signal could be equal to supply voltage. So, in LM358, no matter how I adjust the gain I will never be able to reach to 5V. It can only be possible if I supply higher voltage i.e. 12V or more but of course lesser than the maximum limit of the Op Amp.

Thank you Mark for the useful suggestion.
One question regarding the low pass filter, do we put it before or after the Op Amp circuit? And why is it important when the input is a PWM signal?

The filter is to turn the PWM block wave into a steady voltage, so comes before the OpAmp. If you use one - using that gate as level shifter indeed means you don't need the OpAmp.

Ok, so I made and tried my first low pass filter using a 470 ohm and 1uF capacitor. I supplied different PWM values to see the flat DC. However, I couldn't achieve it. I used PWM pin 5 of UNO whose frequency is 980 Hz. While studying the low pass filter, I can across the equation f0 = 1 / 2pieR*C. So, I need to determine this cut-off frequency that I am not able to figure out, unfortunately. I can then choose a resistor value and calculate the capacitor value for it but how do we set this cut off frequency?

Furthermore, I can supply the voltage made by the PWM signal to (inverter in my case) but is it a bad idea? Do devices react differently to the voltage made up of PWM and flat DC signal? Additionally, the pins of microcontroller have different frequencies, so how do these different frequencies play a role in our signal? For instance, the PWM from pin 5 and pin 3 will give same voltage with different frequency, so what and when do we need to be cautious about?

You can increase the PWM frequency quite drastically (by timer register manipulation, there are some libraries for this as well that can help out) and the result should improve (mostly the ripple will go down - as you can see on a scope, a tool that's maybe not essential but extremely useful for a project like this).

You have to see for yourself what ripple you find acceptable, and play around with values until you have the signal stability you need.

That's right. I played with the values of R and C and finally came up with a much better looking flat DC line :). Of course, oscilloscope was really handy to see the input and the output graphs.

This link is also very useful where one can change the values of frequency, duty cycle, R and C to see the corresponding output graph. One can also notice that how bigger values of R and C can make the graph look better but with a slower response, a trade-off indeed.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.