How to make two PWM without overlap

I use pwm.h libery to make PWM1 and PWM2.

This two pwm have the same frequency and duty.

How to adjust the code to make PWM1 and PWM2 without overlap area?

On the atmega mcus used in Arduinos, I don't believe you can do this using hardware pwm. You could do it by generating the PWM signals in software.

Some members of the ATtiny family do include hardware that has this feature.

Its actually perfectly easy - each pin's output can be inverted, the pins are driven in pairs (5,6), (9,10), (11,3). Invert one of the pairs,
set both to the same analogWrite value.

For the pair 5,6 you'll need this after each call to analogWrite() on the relevant pins:

  TCCR0A = 0xB0 | (TCCR0A & 0xF) ;

For the pair 9,10

  TCCR1A = 0xB0 | (TCCR1A & 0xF) ;

For the pair 11,3

  TCCR2A = 0xB0 | (TCCR2A & 0xF) ;

Actually, thinking about this a little more perhaps you don't want inversion, you want both at the same duty cycle w.r.t ground - can't
be done in general as if the duty cycle > 50%, they must overlap. For inversion the above should work

You might be able to do it, if you can get the PWM to work in the method that the
centre of the pulse is always in the same place.

Then you can generate 2 signals with, say, 15% and 85% duty cycle, and invert the latter,
and you will have 2 15% duty cycle signals that don't overlap.

nelvion:
I use pwm.h libery to make PWM1 and PWM2.

This two pwm have the same frequency and duty.

How to adjust the code to make PWM1 and PWM2 without overlap area?

It's very possible, and I do it with my toneAC library. While toneAC was designed to be used to drive a speaker, it can also be used to drive anything else you want to be out of phase. For example, it includes an example sketch that drives a bi-color 2 wire LED. All of the switching is driven by the ATmega, so it's perfectly out of phase. It does allow you to adjust the load, but it's done so with speaker volume in mind to keep a linear volume control.

What do you want to drive out of phase like this? I've been considering making a different version of toneAC that would be used for other things. The main difference being the volume parameter being load and the selection of the prescaler a little more suited for highly variable loads. Driving a bi-color 2 wire LED first comes to mind, but I'd like to know what you're trying to do as it may give me some inspiration as well as desire to make this derivative library.

Tim

Dear sir

i try to contorl positive and negative voltages

so i need two set fast pwm without overlap area


digitalwrite(pin1,high)
delay(width)
digitalwrite(pin1,low)
digitalwrite(pin2,high) ==>pin1 must be low first
delay(width)
digitalwrite(pin2,low)
delay(20-width- width)

nelvion:
Dear sir

i try to contorl positive and negative voltages

so i need two set fast pwm without overlap area


digitalwrite(pin1,high)
delay(width)
digitalwrite(pin1,low)
digitalwrite(pin2,high) ==>pin1 must be low first
delay(width)
digitalwrite(pin2,low)
delay(20-width- width)

That won't be fast, controlled, nor accurate. You need to use lower-level PWM control, like the toneAC library does. You can't do it with conventional HIGH/LOW digital writes.

Tim