Generate this waveforms from arduino uno

Hello i want to generate this waveforms as shown below from arduino uno : -

in these waveforms, I want to control the duty cycle or width of these pulses from a potentiometer by analog pin for both waveforms and also I need to have it on high frequencies such as 100-200khz. it would be of great help for me. Thankyou in advance.

which arduino are you planing to use?

Hi, @superman72
Welcome to the forum.

What is the application that needs this timing?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

arduino uno

hello tom, this is for dc-dc converter that needs such gate pulse

So you are making a DC-DC converter?

Tom.. :smiley: :+1: :coffee: :australia:

yes have you any idea about how to generate this waveforms?

a good start is to read https://docs.arduino.cc/tutorials/generic/secrets-of-arduino-pwm

if you use analogWrite() to play with PWM, the frequency is described here

1 Like

The UNO is not fast enough

I already tried a lot to make this waveform, but I have little to no knowledge of using timers for this Arduino check out the code below: - and the waveform that is generated.


void setup() {
  pinMode(13, OUTPUT);
  pinMode(12,OUTPUT);
}


void loop() {
  digitalWrite(13, HIGH);
  digitalWrite(12,LOW);
  delay(5);  
  digitalWrite(13,LOW);                     
  digitalWrite(12, HIGH);    
  delay(3);
  digitalWrite(12,LOW);
  delay(2);
}

image

but the problem is, that this waveform is set for a 50% duty cycle which means if I try to increase or decrease its width it will go out of phase from each other which is undesirable.

Hi,
Is this a school/college/university project?

You have to be very careful with values of your components and their placement to get a DC-DC converter to work.
Hence SMPS ICs. and their suggested component layouts.

Tom.. :smiley: :+1: :coffee: :australia:

also as you can see that time is in "ms" which means the frequency is very low, meanwhile i need it in microseconds and this is the output waveforms when I try the delayMicroseconds function.
image

now my problems in this waveforms are: -
1st as you can see the yellow and blue waveforms are apart from each other and not turn on and off simultaneously which means when yellow is falling at same time blue must be rising .

2nd when i used this delaymicroseconds function the delay increased beyond the need value which inturn reduced the overall timing of the cycle.

3rd the gap between yellow and blue waveforms keeps on increasing without their starting condition in consideration.

kindly ask me any doubt related to this, i'm free and in need to make this work so the more we are is the more better. Thanks

everything is set Tom, i just need gate pulses to my MOSFET's to let them work. :smiley:

Hello sir, I already used UNO upto 400khz without problem for simple pulses, I respect your opinion on the note that uno is not good at variable pulses for high frequency

you want 100-200khz frequencies ➜ 200KHz means 5µs for a period in which you need to change state...

If you want on top of that to keep multiple pins in sync, that's not something you'll reach by using blocking codes with delays (the delayMicroseconds function is not suitable for less than 3µs)

given the Uno runs at 16MHz, You will have to explore timers and register level stuff

yes you are right, that's why I am not able to generate the required waveforms with my needs, can you just direct me to where can I learn the timers and registers level stuff, I even tried to learn that from Arduino timers pdf but everything went off my head and then i was looking for alternate solutions, I think Interrupts will work than delays, I haven't tried that yet!!!

see post 8 for a link on the timers

take it slowly. experiment

10% duty cycle at 200kHz is only 500ns
NOT possible with 16MHz processor

You have register access to flip a pin executed in 1 clock cycle (touching the PINx registers) and the clock period is 1 / 16M = 62.5 ns

500ns is 8 x 62.5. So I would not say it's not possible to go fast, but it is quite challenging to be precise and not every precise duty cycle will be achievable

You can also play with timers and Fast PWM Mode

1 Like

Hi,

How do you mean, you are still at the prototyping stage?

Can you please post some images and circuitry involved?

As has been shown, doing the maths, you will need a faster controller.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia: