Это видео недоступно.
Сожалеем об этом.
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 ...
Highly underrated video. thank you for the info!
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.
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!
Very useful ,Thank you...
How to change frequency? (10kHZ- 20Khz - 40khz) to achieve frequency adjustment?
High quality information and well presented. Thank you.
Nice Explanation, very informative. I am interested in how to use ASM code in C, Please refer some tutorials and books. Thank you.
Continue this series sir. That is amazing.
Thank you so much! This is very helpful also for my projekt.
Bit banging really depends on the rest of the code and will make if difficult to control your duty cycle
I think if the XOR operation is implemented a higher toggling frequency could be attained?
This is crazy. Much much appreciated
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.
Really great video. Thank you!
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?
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!
I used a 1:10 ratio probe in my measurements
Jabraad be bhaiwa!
But, can in out complementary in that speed..?
WOW! Well done!
you are doing a great job
Great Tutorial!!! Thanks a lot.
I wonder now what will happen if we do the same to uno r4.
Great help man, thx!
thank you soo much you explain it so so good
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.
great job, thanks a lot
Thank you.. Please can you help with the oscilloscope setup? Thanks.
in which software you done the oscilloscope simulation
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.
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)
DUE needs completely different commands, the chip is different.
@@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
Is it possible to poll an input pin using the same primordial code, at higher frequencies?
is it same port number for Uno R4 minima as the one you show for uno?
Very Good thank you.
can i get 1mhz signal using arduino uno. what is the procedure?
Thank you, very useful.
Can you show us Fast PWM? (More than 65kHz)
I can't figure out the prescalers and pins assigned
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 ?
@@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.
@@HVE can i get 1mhz signal using arduino uno. what is the procedure?
How to achieve a 100KHz with 0.44 cycle?
What is the name of the program used to display the signal?
Is this port manipulation possible with Blue Pill STM32?
can i get sample code for 1MHZ 2 signals 180¨ Phase shift and duty 50%,49%,48%,47%?
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.
Thanks
How should I think to set the dutycycle? How much will this frequency change with another command?
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.
is it possible to delay in nano second
yes, it’s very fast and use low memory space
what are you using to view thw waveform?
can i reach 5 MHz frequency and use it to control Mosfet to driver load 12v 1 A thanks
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.
Hi,
Gr8 Video.
Pl Can you share the Simillar Video For DUE ...
Thanks in Advance
iam asking about this oscilloscope how you connected to arduino
Scope has a probe and you can connect the probe to Arduino pins
What is the name of program you used it for osillscope
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
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?
Thanks, this is the software of the digital oscilloscope that i have. What is demonstrated is not a simulation, it is an actual measurement.
great job, thanks a lot