Это видео недоступно.
Сожалеем об этом.

How to create very fast square pulses with Arduino ( up to 4 MHz with Arduino NANO, UNO, & MEGA2560

Поделиться
HTML-код
  • Опубликовано: 21 ноя 2020
  • digitalWrite command of Arduino is very slow and with that you can only achieve 150 kHz signals (full period, ON and OFF) at best.
    In this video I show you that using port manipulation and while loop you can get up to 4 MHz signals (ON period less than OFF period) and 2.66 MHz with 50% duty cycle.
    Also you will learn how to produce multiple signals at exactly the same time. this is something which is useful if you want to make a pulse with a multilevel converter, I mean at sometimes you want to drive the switches independently to make sine wave or other waveform, but if you want make a lightning impulse with the multilevel converter, it is necessary to turn on all switches at the same time.
    At the end I summarized the results and based on this experimental work I concluded the number of clock cycles that it takes to run each command. If you see some mistake somewhere, let me know.
    The probe and scope should have sufficient bandwidth to capture the signals properly. I used the probe at 10X to increase the bandwidth. Even so steel the signal is filtered a bit.
    The following pages/videos are good references to look at:
    www.arduino.cc...
    roboticsbacken...
    • Port Register Control ...

Комментарии • 61

  • @anotherviewer614
    @anotherviewer614 8 месяцев назад +2

    Highly underrated video. thank you for the info!

  • @wernerpeter9706
    @wernerpeter9706 8 месяцев назад

    When you work with Timer/Counter and Output Compare Register you have less code, full control of PWM times and faster frequency. The best part is, that the Arduino processes this internally and can continue to execute any other code. Inverted outputs and even dead times between PWM signals are also programmable without blocking the MC.

  • @Francesco-bu1hh
    @Francesco-bu1hh Год назад

    I am new to the Arduino ( i normally use PIC micros) and was looking for a good explanation on PWM. I have found this excellent video. Well done!

  • @rockryu83
    @rockryu83 2 года назад +7

    Very useful ,Thank you...
    How to change frequency? (10kHZ- 20Khz - 40khz) to achieve frequency adjustment?

  • @markflint9089
    @markflint9089 Год назад +1

    High quality information and well presented. Thank you.

  • @mantookaibarta3073
    @mantookaibarta3073 2 года назад +1

    Nice Explanation, very informative. I am interested in how to use ASM code in C, Please refer some tutorials and books. Thank you.

  • @sambitprakashmohanty4103
    @sambitprakashmohanty4103 2 года назад

    Continue this series sir. That is amazing.

  • @martinryser5439
    @martinryser5439 Год назад

    Thank you so much! This is very helpful also for my projekt.

  • @jack91522
    @jack91522 Год назад

    Bit banging really depends on the rest of the code and will make if difficult to control your duty cycle

  • @icarossavvides2641
    @icarossavvides2641 3 месяца назад

    I think if the XOR operation is implemented a higher toggling frequency could be attained?

  • @mosquid
    @mosquid Год назад

    This is crazy. Much much appreciated

  • @diptanshumalviya7547
    @diptanshumalviya7547 3 года назад

    Thank you, sir, for making such an information video, Please Sir, Continue the series of Arduino Video. Please Please Sir, Make such Video like that. I love your channel. make more video sir.

  • @superprojb
    @superprojb 2 года назад

    Really great video. Thank you!

  • @aminkadi-haja569
    @aminkadi-haja569 6 месяцев назад

    For a project of mine, i need to create high frequency soundwaves through a transducer. My main problem is that I dont have any idea how to accurate supply my transducer with these high frequency signals and still know what frequency I am providing to it. Basically I want to supply frequency range from 1.6MHz to 2.5MHz in steps of 0.1MHz. Is there any way to know beforehand what kind of frequency I am supplying?
    I can get to 4.05MHz(Max) and I want to accurately delay this to the range of 1.6MHz to 2.5MHz, how to do that?

  • @jamespohlmann3246
    @jamespohlmann3246 Год назад +1

    Wonderful and very helpful video! One thing that doesn't make sense to me: why is the high value only ~600mV? I replicated this on my Arduino Mega and had a dV of 576mV. I would have expected the high value to be 3.3V or 5V depending on the board. Thank you!

    • @HVE
      @HVE  Год назад

      I used a 1:10 ratio probe in my measurements

  • @moinshaikh6684
    @moinshaikh6684 Год назад

    Jabraad be bhaiwa!

  • @endremurti
    @endremurti 9 дней назад

    But, can in out complementary in that speed..?

  • @Riddle-Me-This-Puzzles
    @Riddle-Me-This-Puzzles 3 года назад

    WOW! Well done!

  • @protorbs_nft_clubofficial141
    @protorbs_nft_clubofficial141 3 года назад

    you are doing a great job

  • @BaudirenergieDe
    @BaudirenergieDe 2 года назад

    Great Tutorial!!! Thanks a lot.

  • @alexlo7708
    @alexlo7708 Год назад

    I wonder now what will happen if we do the same to uno r4.

  • @RHV2601TW
    @RHV2601TW 2 года назад

    Great help man, thx!

  • @charithajayasooriya4899
    @charithajayasooriya4899 Год назад

    thank you soo much you explain it so so good

  • @FalconSmart
    @FalconSmart Год назад

    Do you know how to generate a same frequency PWM pulse with an external trigger using Arduino Uno? So basically want to realize a digital delay generator. For example, I have a sync signal of 120Hz, and I hope to use this feed into the Arduino, then I can change the delay (0.1ms - 5ms range), and then output a 120Hz, 50% duty cycle signal. Thank you.

  • @dr.kaganayanoglu2656
    @dr.kaganayanoglu2656 2 года назад

    great job, thanks a lot

  • @taiwosanyaolu8276
    @taiwosanyaolu8276 2 года назад

    Thank you.. Please can you help with the oscilloscope setup? Thanks.

  • @cargames4885
    @cargames4885 2 года назад +1

    in which software you done the oscilloscope simulation

    • @HVE
      @HVE  2 года назад

      It is the software of the oscilloscope. It is not a simulation, there is a real scope and this software is the interface to see the data.

  • @georgeklitsiotis1517
    @georgeklitsiotis1517 2 года назад

    I am working on a project that needs to push even faster. For that reason I am using an ARM powered arduino due. Should I use the same commands or are the ports different for the DUE (Cheers by the way. Nice tutorial)

    • @HVE
      @HVE  2 года назад

      DUE needs completely different commands, the chip is different.

    • @adelamrouche3842
      @adelamrouche3842 2 года назад

      @@HVE
      I am working on a project that needs to send 3 ID over 3 carriers frequencies via 3 LED
      These code is it useful for my project
      Thank you.nice tutorial

  • @darkstatehk
    @darkstatehk 2 года назад

    Is it possible to poll an input pin using the same primordial code, at higher frequencies?

  • @Impulsetech36
    @Impulsetech36 6 месяцев назад

    is it same port number for Uno R4 minima as the one you show for uno?

  • @hosseinashkboos5188
    @hosseinashkboos5188 2 года назад

    Very Good thank you.

  • @roshankhanal9364
    @roshankhanal9364 2 года назад

    can i get 1mhz signal using arduino uno. what is the procedure?

  • @Buciasda33
    @Buciasda33 2 года назад

    Thank you, very useful.
    Can you show us Fast PWM? (More than 65kHz)
    I can't figure out the prescalers and pins assigned

    • @HVE
      @HVE  2 года назад +1

      I will give it a try and when it is ready will make a video about it. do you want to make a sine wave after PWM filtering or you mean something else ?

    • @Buciasda33
      @Buciasda33 2 года назад

      @@HVE
      Thanks, I think I have tried everything, but give it a shot anyway.
      No need for sine wave.
      If you can get 125kHz or 250kHz PWM on the 328p it would be amazing.
      So far, I have succeeded, up to 4MHz output without PWM, on pin 8, the Following:
      DDRB = B11111110; // I think this puts pin 8 as output, but double check, it might have all the bits flipped.
      void loop() {
      while(true) { // faster than void loop() from what I've heard, but I'll double check.
      // Port Manipulation:
      PORTB = B00000001;
      PORTB = B00000000;
      }
      }
      Then add or remove delays with the following:
      __asm__("nup
      \t");
      You can add or remove those NOP operations to get close to what you want, but they will affect both frequency and duty cycle.
      I'm still trying to mix and match frequencies and duty cycles, but it's a mess.
      I'll probably have to rely on internal timers and comparators instead of throwing NOP's at the problem.

    • @roshankhanal9364
      @roshankhanal9364 2 года назад

      @@HVE can i get 1mhz signal using arduino uno. what is the procedure?

  • @thabangcoleen3739
    @thabangcoleen3739 2 года назад

    How to achieve a 100KHz with 0.44 cycle?

  • @bossrx4067
    @bossrx4067 8 месяцев назад

    What is the name of the program used to display the signal?

  • @sarwarn2107
    @sarwarn2107 Год назад

    Is this port manipulation possible with Blue Pill STM32?

  • @nin1ten1do
    @nin1ten1do 2 года назад

    can i get sample code for 1MHZ 2 signals 180¨ Phase shift and duty 50%,49%,48%,47%?

    • @HVE
      @HVE  2 года назад +1

      For 50% duty cycle it is possible but for the other numbers at 1Mhz, you need a faster processor. To write the code you can watch the video again from 15:30.
      probably you need something like this (I have not tested it):
      void setup() {
      DDRD=B00001100;
      }
      void loop() {
      while(true){
      __asm__("nop
      \t""nop
      \t""nop
      \t""nop
      \t""nop
      \t");
      PORTD = B00000100;
      __asm__("nop
      \t""nop
      \t");
      __asm__("nop
      \t""nop
      \t""nop
      \t""nop
      \t""nop
      \t");
      PORTD = B00001000;
      }
      }
      ----------------------------------------
      PORTD = B00001000 --> 1 cycle
      while loop: 2 cylces
      5 cycle delay
      ---------------------
      PORTD = B00000100 ---> 1 cycle
      2 cycles delay
      5 cycles delay
      in total 16 cycle each, which gives you a 1 Mhz frequency.

  • @josesosa7796
    @josesosa7796 2 года назад

    Thanks

  • @dr.kaganayanoglu2656
    @dr.kaganayanoglu2656 2 года назад

    How should I think to set the dutycycle? How much will this frequency change with another command?

    • @HVE
      @HVE  2 года назад

      Depending on the code you have, you should see how many commands you used in your code and where there are placed. in general to get high frequency you do not want to add many instruction in your code. the duty cycle can easily be set based on the on/of time of the time of the output pin.

  • @HS-hz4fx
    @HS-hz4fx Год назад

    is it possible to delay in nano second

  • @warrior7740
    @warrior7740 6 месяцев назад

    yes, it’s very fast and use low memory space

  • @mipa3868
    @mipa3868 Год назад

    what are you using to view thw waveform?

  • @georgealbo
    @georgealbo 3 года назад

    can i reach 5 MHz frequency and use it to control Mosfet to driver load 12v 1 A thanks

    • @HVE
      @HVE  3 года назад

      Which type of mosfet do you want to drive ? Arduino can not supply much current, so you must use a proper gate driver most likely. And anyway 5 Mhz with Arduino nano you probably will not be able to achieve. Maybe try Arduino DUE, but that requires different coding to achieve high speed.

  • @ravirao5798
    @ravirao5798 2 года назад

    Hi,
    Gr8 Video.
    Pl Can you share the Simillar Video For DUE ...
    Thanks in Advance

  • @georgealbo
    @georgealbo 3 года назад

    iam asking about this oscilloscope how you connected to arduino

    • @HVE
      @HVE  3 года назад

      Scope has a probe and you can connect the probe to Arduino pins

  • @user-wf9zj1pn1w
    @user-wf9zj1pn1w 3 года назад

    What is the name of program you used it for osillscope

    • @HVE
      @HVE  3 года назад +1

      It is Hantek6022BE, you need to have this digital scope, connect it with usb cable to your computer, install its program on your computer, and then you will be able to see the waveforms on in that software

  • @the-beneficiary1809
    @the-beneficiary1809 Год назад

    Hi Sir great video very information, Would you be so kind as to let me know what software you are using for the simulation you are displaying?

    • @HVE
      @HVE  Год назад +1

      Thanks, this is the software of the digital oscilloscope that i have. What is demonstrated is not a simulation, it is an actual measurement.

  • @andracarotta3351
    @andracarotta3351 3 года назад

    great job, thanks a lot