Problem to generate burst mode pwm signal using pwm.h library

Hi everyone,

I am facing difficulties in generating burst mode PWM signal using PWM.h library. I want to generate the following signals.

Can you please help me with my code? I am attaching code.
Is there any alternative way to generate it?

Any help is appreciated. Thanks.

[code]
#include <PWM.h>

int32_t frequency_half = 10000; //frequency (in Hz)
int32_t frequency_buck = 60000;
int VG1 = 9;
int VG2 = 10;
float a;

void setup()
{
  InitTimersSafe();
  Serial.begin(9600);
  Serial.println("I am ready");
  bool success_1 = SetPinFrequencySafe(VG1, frequency_half);
  bool success_2 = SetPinFrequencySafe(VG2, frequency_buck);
  if (success_2) {
    pinMode (13, OUTPUT);
    digitalWrite (13, HIGH);

  }
}

void loop()
{
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  pwmWrite(VG1, sensorValue / 4);
  a = digitalRead(VG1);
  Serial.println(a);

  if (digitalRead(VG1) == HIGH)
  {

    pwmWrite(VG2, 64);
    delay(30);


  }
  delay (30);


}
[/code]

Please describe the problem, and the timing ranges over which the combined signal might vary.

A much simpler approach would be to use an AND gate, with one input connected to the high frequency PWM output, the other to the lower frequency gating signal output.

1 Like

Basically I need two pwm signal to drive mosfet.
1st signal will be a normal pwm signal with frequency,f1=(lets say 20khz) with D1=50% duty cycle.
2nd one will be pwm pulse skipped signal (burst mode) .That means when the fiist signal is high ,2nd signal will be activated with frequency f2=(lets say 100khz),duty cycle D2=(lets say 40%)and when 1st signal is zero, 2nd signal will be zero.

I need to implement this with arduino or any other microcontroller .I am not allowed to use AND gate.

Is this a classroom assignment?

Please post the actual requirements, not hypothetical ones. The details for generating the actual signal will depend on those requirements, and very much on which processor you choose.

This is not an assignment by the way.
Requirements:
1st signal : f1 =20khz ,D1=50%
2nd signal(burst mode) : f2=100khz ,D2=41%

"arduino" is not a microcontroller. "Arduino" is a company and brand name, with many products, based on several different microcontrollers.

Sorry!my bad.
Edited.

Greetings to you sir/mam,
My mini project is to generate pulses at high frequency in a dual active bridge full bridge converter through an algorithm/code.
I have zero knowledge in it sir,could you please help me out sir.

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