Hi guy;
Am not good english writing skill.
But I want someone to ask for help my problem.
First. I want PWM 2 channel 60kHz-120kHz output at pin 3and5.(same freq. invert)
I use TimerThree.h for drive it.
This's OK. in first Time
But
I codeing PWM 1 channel 10kHz output at pin 11 (variable duty cycle 6-94% )
I found some problem. My wave form is working but every 2-3 second my signal have shot overlap.
eg.When I drive 100kHz have shot overlap around 10kHz.
someone can Help me Please.
Thank You for answer in my topic
Hi,
Welcome to the forum.
We need to see your code.....
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Tom... 
#include <TimerThree2560.h>
#define pwmRegister OCR3A
#define pwmRegister1 OCR3B
const int outPin = 5;
const int outPin1 = 2;
unsigned int value ;
//unsigned int value ;
unsigned int dutybuck ;
long period = 1000;
int duty = 512;
int prescale[] = {0,1,8,64,256,1024};
void setup()
{
Serial.begin(9600);
pinMode(outPin, OUTPUT);
pinMode(outPin1, OUTPUT);
pinMode(12, OUTPUT);
Timer3.initialize(period); // initialize timer1, 1000 microseconds
Timer3.pwm(5, duty); // setup pwm on pin 9, 50% duty cycle
Timer3.pwm(2, duty); // setup pwm on pin 9, 50% duty cycle
TCCR3A |= bit (COM3A0);
}
void loop()
{
inverter();
//buck();
}
void inverter()
{
static long val = 0;
value = analogRead(A0);
val = map(value,2,1020,65000,115000);
Serial.println(analogRead(A2));
period = 1000000 / val;
Timer3.setPeriod(period);
Timer3.setPwmDuty(outPin, duty);
Timer3.setPwmDuty(outPin1, duty);
static char val1 = 60;
duty = map(val1,1,99, 1, ICR3);
pwmRegister = duty;
pwmRegister1 = ICR3 - duty;
}
/* void buck()
{
TCCR1A = B00101000;
TCCR1B = B10001;
ICR1 = 800;
static long dutybuck = analogRead(A2);
dutybuck = map(analogRead(A2),1,1060, 90, 700);
// OCR1A = 500;
OCR1B = dutybuck;
}*/
thx a lot
What exactly means "shot overlap"? Can you show a picture or explain in detail?
If you call inverter() in every iteration of loop(), the PWM control tends to get out of sync. In detail if you program different duty cycles in sequence, in inverter(). First you set both channels to duty by setPwmDuty(), then again with a different duty by writing to the OCR's.
A few comments inside the code were helpful, e.g. which PWM mode is used?
Thank You DrDiettrich
I have some problem.
"setPwmDuty()" can usable in TimerOne.h or TimeThree.h
but We can use TimerOne.h and TimeThree.h in same time?
Because I user pin 11 5 2
And can you get example for me.
Thank you in advance
And other people visit this topic. I edit TimeThree.h for Mega2560. And That Problem.
I don't know what these libraries do, or how they are used.