Capturing PWM signals (freq 1-160Khz, with varying duty cycle) and then generating the same PWM signals

So it means, 33.3Khz. But I am interested upto 160Khz. This may give a poor resolution of PWM signals.

I would like to ask whether any other version of Arduino can provide the 160Khz good resolution of PWM signals. Please suggest accordingly.

I don't know for sure if any Arduino would work.

No. It means that a cheap, web-based scope simulation of Blink can demo 33kHz. With direct port manipulation maybe an Uno could reach 50x faster.

The more concerning constraints are the unspecified “deadband” and pwm resolution. If you want to handle 10% resolution 160khz pwm you need a pulse width of 625ns. If you need a “deadband” of 10% of that, then you need control at the 62ns level, which is getting close to the limits of the ‘1/16e6=6.25ns instruction cycle time of an Uno.

What are your pwm resolution and deadband requirements?

One with a more advanced processor, for example the SAMD, with higher clock frequency and better peripherals. The timers are much more sophisticated, but much harder to learn to use. There are some decent timer libraries for the Teensy series.

16 bit standard PWM resolution: 1/150M = 6.667ns
Deadband (max : 10percent= 625nS) for 160Khz

https://www.researchgate.net/file.PostFileLoader.html?id=553ac329d2fd64c67f8b4745&assetKey=AS%3A273807296663552%401442292154206

Any link to see this arduino board with spec sheet???

Here is a Teensy 4.1, running the 'button' example, with an input frequency of 160kHz:

( 'button' modified slightly to use digitalWriteFast(), instead of digitalWrite().)

1 Like

Thanks for sharing this. I checked the link and the toturiols. I see the some examples Digital I/O and PWM as well. I am curious about if they could have a deadband settings between two waves. Can we set the deadband setting for the PWM in Teensy4.1?

So you might want to produce something like these traces?

     ->| |<-6.667ns
A: ____/-\_____________...______________/-.....
~Ad: ______________/---...----\____________....
         |<-625ns->|          |<-625ns->| 
       |<----------6250ns---------------|

Where ~Ad is complimentary to A with a 625ns pause between A going low and ~Ad going high, & vice versa?

Using a Teensy 4.1, I've modified the 'button' code to add a second output and the deadband:

/*
  based on:
  http://www.arduino.cc/en/Tutorial/Button
*/

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2;
const int ledPin = 13;
const int outputPinA = 41;
const int outputPinB = 4;
const int deadband = 50; // deadband in nanoseconds

// variables will change:
int buttonState = 0;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(outputPinA, OUTPUT);
  pinMode(outputPinB, OUTPUT);
  pinMode(buttonPin, INPUT);
  digitalWrite(ledPin, HIGH);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    digitalWriteFast(outputPinB, LOW);
    delayNanoseconds(deadband);
    digitalWriteFast(outputPinA, HIGH);
  } else {
    digitalWriteFast(outputPinA, LOW);
    delayNanoseconds(deadband);
    digitalWriteFast(outputPinB, HIGH);
  }
}

Here are the results using a teensy 4.1, with a 160kHz 10% duty cycle input:

And on a faster timebase to show the deadband:

1 Like

Thanks for your observation. I guess i am very close to the last post given by JohnLincoln which explains clearly about the deadband and 160Khz wave. I will figure out if i see any more problem. Thanks for your idea for Button code.

Thanks for this clear observation of my problem. I will let you inform if i see any changes to do. Thanks for this explanation using Teensy 4.1 development board.