Improve your Arduino programming skills - Using the ATmega328P registers.

Поділитися
Вставка
  • Опубліковано 28 сер 2024
  • Other “Improve your Arduino programming skills” videos:
    • Improve your Arduino p...
    In this video I explain what a register is and how you can use it to further optimize your Arduino code.
    When using Serial.begin() for example the registers are set automatically and there is a lot of code generated to get the serial port to work. A lot of code that you probably don’t need for every project. Watch what happens if you set the registers manually and thereby exclude the unwanted code.
    In a few simple steps a 2632 bytes Arduino example program is reduced in size to 682 bytes. By using Atmel Studio the same functionality can be achieved with only 194 bytes.
    Download the datasheet of the ATmega328P here:
    www.brokking.ne...
    Video about uploading the program via the bootloader:
    • Atmel Studio 7 - Progr...

КОМЕНТАРІ • 174

  • @roidroid
    @roidroid 8 років тому +77

    Wonderful video. I love how you don't immediately discard the Arduino environment - but instead slowly upgrade it in steps, and no step is itself too far.
    You're doing this series very well.

  • @MrCrystan
    @MrCrystan 8 років тому +41

    This is the best thing I've seen on the topic. Could never have learned so much in so little time. Kudos!

    • @MrCrystan
      @MrCrystan 8 років тому +5

      this also helps allot for programming attiny13a of 1k memory and now I can do so much more than just a blink and a sensor.

  • @GGAbi2012
    @GGAbi2012 7 років тому +15

    Every crucial point is thoroughly thought out and implemented in this excellent video. In addition to that it's even perfectly explained with the help of an oscilloscope, sequentially added code sections for better understanding of "code-upgrades" and in my case what I appreciate most is the cross reference to the datasheet. Keep up the good work, I enjoy all your videos

  • @georgeorwell7607
    @georgeorwell7607 6 років тому +1

    AWESOME! WOW! This is my second tutorial by Joop Brokking and I am blown away by the clarity, the depth, and the detail, indicating someone with not only deep knowledge of the subject, but also the ability to teach convincingly and effortlessly. kudos

  • @dparson
    @dparson 8 років тому +5

    Totally loved this tutorial, first time I've seen serial data transfers done with the low level UART registers. I would watch one of these for every chapter of the data sheet :) Thanks a ton for making this!

  • @zxlee1
    @zxlee1 7 років тому

    Thanks for creating this "improve your Arduino programming skills" series. I like the way you guide viewer step by step to understand all the details that shows the big improvement using Atmel studio.

  • @hrnekbezucha
    @hrnekbezucha 7 років тому +9

    Sure, optimization. But I had no idea you can make such a significant difference. That's amazing.

    • @TheSehaa
      @TheSehaa 7 років тому +2

      its the serial.begin and serial.write function. it eats memory

    • @danielday3162
      @danielday3162 7 років тому +3

      The code for the Arduino IDE is C++ which is an object oriented language. Using C or even a lower level language like the AVR instruction set can greatly impact the size of your code.

  • @dinkarjain7489
    @dinkarjain7489 3 роки тому

    The datasheet is the only thing why normal people were reluctant to program controllers, it seems complex and requires a knowledge of what peripherals and registers are. But this video clarified why serious microcontroller projects use the bare coding style and a great programmer would rather dabble in a datasheet than producing a cheap code that will have an "amateur hour" label. This is something that hobbyists should add to their must-watch list to step up their game. Great work pal, keep it up!!

  • @izzyblackout1090
    @izzyblackout1090 6 років тому +1

    This reminds me of my days with Microchip PIC. Every single bit has to be set up manually. Thank for the infos. Great tutorial. Best method to optimize programming memory

  • @TheExplant
    @TheExplant 5 років тому +1

    Fantastic tutorial, really clear! Using this in my project, it also operates much faster now that I use this method. Before I followed your video, the Arduino couldn't keep up with the clock speed of the device from which I'm taking input, and now I can just about match it. Thanks for sharing your expertise!

  • @hasithaeranga5589
    @hasithaeranga5589 Рік тому

    perfect teaching style from what we know to what we dont know

  • @Fredovsky
    @Fredovsky 7 років тому

    Ok, I rarely comment but this is one of the most useful and clear video on code optimization. Thank you for taking the time to make such quality videos !

  • @DailyWalk365
    @DailyWalk365 5 років тому

    Nice to know that the "void setup(void) {}" in the Arduino IDE is actually part of the "int main(void){}" function just before the "while (1) { }" loop. Again I found an answer to a question I had using AtmelStudio7. Thank you.

  • @freeelectron8261
    @freeelectron8261 5 років тому

    Real quality here. Joop knows his stuff and explains it really well.

  • @PiefacePete46
    @PiefacePete46 8 років тому +53

    Your series really is great! You are taking us into the area of 'dark arts' and switching the lights on. :o)

    • @Joop_Brokking
      @Joop_Brokking  8 років тому +1

      Thank you for the compliments!

    • @BustersCNCchannel
      @BustersCNCchannel 8 років тому +1

      Thank you, your videos are excellent. You make it look too easy :)

    • @bmistry5
      @bmistry5 7 років тому

      Great video!
      How about other UART functions?
      i.e. How to write String using Registers?How to read a character?How to read String?
      Please make one video...really interesting topic!

  • @leofranssen
    @leofranssen 3 роки тому

    Lekker accentje Joop.
    Dank je wel voor het zo gul delen van je kennis.
    Groet Leo.

  • @thanasisathanasi4965
    @thanasisathanasi4965 3 роки тому

    I would also say it is a wonderful video. Smooth transition from the Arduino Environment to the machine language environment of atmel studio.. Wooowww. Masterpiece. I wish I had a friend like you !!!

  • @acertivedude4956
    @acertivedude4956 7 років тому

    This video and the O-scope one have opened my eyes as to how advanced it is possible to get with arduino project code. Thank you!

  • @Anaeijon
    @Anaeijon 6 років тому

    Another benefit of using the registers when working with multiple digital I/O pins, is, that it ensures all bits in the register are read/written at the same time.
    For example if you have many different LEDs connected to the Arduino Mega and switch them on and of rapidly, while relying on the persistence of vision (for example when building a LED Matrix or Cube), you need to handle the on/off switching off all pins extremely fast.
    If you are using digitalWrite for each pin, it will basically change one pin after another.
    This takes a high number of instructions (including counter etc.) for switching 8 I/O pins.
    Using the output registers instead on the other hand just uses some simple logic to precalculate the whole register and set all pins at once, by putting the precalculated uint8_t onto the Register.

  • @edexnorth123
    @edexnorth123 6 років тому +1

    this tutorial right here is far superior than the lecture I had taken at collage. By the way *"don't go a shitty collage."* go make a nice cup of coffe and surf the internet for threasures like this one.

  • @kid-vf4lu
    @kid-vf4lu 8 років тому

    This is the simplest avr uart tutorial I have seen. Thank you!

  • @mirkomueller3412
    @mirkomueller3412 8 років тому +15

    I wish there would be a possibility to press a "big thumbs up" Button - i definitely would press it. Thank you so much !!!

  • @zaprodk
    @zaprodk 7 років тому +2

    Very good explanation. Well done - I'm inspired to go read the datasheet as night time reading now :D

  • @jamest.5001
    @jamest.5001 7 років тому

    thanks so much for making this video. I am needing to get a arduino to control a DC boost converter . the boost stage for a inverter project for my offgrid home. I don't do computers. I haven't programmed anything since VCRs was common. I have watched many videos. trying to learn how to program arduinos. But your video is the best I have seen so far. it has been a great help. to get my mind wrapped around how this process works. I guess in a week or so if any of your teaching took! when I buy my first arduino. thanks again this video has been a big help.

    • @4.0.4
      @4.0.4 7 років тому

      James stranger Just wanted to motivate you by saying Chinese clones are just as good. You need to get a driver in Windows but there's a version that is signed (can be downloaded from Microsoft servers, so probably safe). The driver is because the serial to USB converter is a cheaper knockoff, but the microcontroller itself (including its serial capabilities) is the same as genuine Arduino.
      The point in Chinese clones is they cost $2. Having a full bag of Arduinos is empowering! Have a look at sites like AliExpress, eBay, DealExtreme, BangGood... whichever has the right prices/shipping (I used three of these already). Also get some modules! Super fun stuff.

  • @rootbeard5449
    @rootbeard5449 8 років тому +2

    Very informative video! Moving your code to pure C environment frees up so much space!

  • @EEBBSamarJain
    @EEBBSamarJain Рік тому +1

    Hey there, Great explanation on the topic, I just wanted to ask two things,
    1. How and where to print that variable 'inputs', like do we have something like a serial monitor on atmel where we can print the value 'inputs'?
    2. What should we do when we want to send more than 1 byte of data?

  • @raymunyaka5409
    @raymunyaka5409 4 роки тому

    awesome tutorial on AVR micro controllers using arduino and atmel studio. Thankyou very much. From Kenya.

  • @LearnElectronicsCanada
    @LearnElectronicsCanada 7 років тому

    Your videos are quite good. It's nice to see someone preaching the transition to Atmel Studio to improve code/size. You really want to mess with everyone's head... show one last transition to ASSEMBLY. I still have nightmares about trying to debug Assembly on a 6809 processor in the 80's. With the tools available now, it's much easier to debug assembly code.

  • @vijaykumarkanchukommala2183
    @vijaykumarkanchukommala2183 5 років тому

    Good video for new learners to start their experience with AVR microcontrollers

  • @JeanDAVID
    @JeanDAVID 6 років тому

    Amazing optimization of size at low level of programation

  • @HandfulOfTranquility
    @HandfulOfTranquility 7 років тому

    You are an excellent teacher! I don't understand programming well (I've only piddled around with Arduino a small amount), but you make the concepts easy to understand and apply, more so than other UA-camrs I've seen.

  • @sergiocastellani9823
    @sergiocastellani9823 7 років тому

    Speechless. feel guilty that now i got obsessed with registers and things.... Bravo

  • @ChathuraJayasundaraIMD
    @ChathuraJayasundaraIMD 6 років тому

    thumbs up if I learn something???? this is like the most amount of knowledge I got about Arduino in one video!!!! thank you sir!!

  • @elfkind5590
    @elfkind5590 7 років тому

    THANKS! Please keep them coming! This is one of the best learning channels.

  • @mcorrive12
    @mcorrive12 7 років тому

    Fantastic series Joop! Thanks for all your efforts in producing these videos!

  • @holdengreene9717
    @holdengreene9717 7 років тому

    Great vid!. One suggestion, you should increase the font size in the IDE to make it easier to read. Keep up the great work.

  • @lostname605
    @lostname605 8 років тому +1

    If you want to practice in setting registers, check out the ds3231 real time clocks. they are cheap and have a great datasheet to get started

  • @kevinowenburress2435
    @kevinowenburress2435 7 років тому

    if you use the right gpio pins you can read them as a register iirc. then you don't have to poll each gpio pin you can just read them all into a register in one clock cycle. I haven't done benchmarks recently but it is significantly faster than polling each bit.

  •  8 років тому +1

    Your videos are great. But you have a great responsibility now, I'll get addicted...and I'm going to need more and more.

  • @vizmohanan
    @vizmohanan 8 років тому

    Great tutorial ! You just demystified the datasheet and gave me confidence to make use of it. Thanks. :)

  • @Walkofsoul
    @Walkofsoul 8 років тому

    Wow, the difference is huge !

  • @adochshanov
    @adochshanov 4 роки тому

    Always a great pleasure to go deeper and expand the limits of Arduino IDE. Being absolutely new to atmelstudio I wonder whether the software is free to use?

  • @vipinkarhana4030
    @vipinkarhana4030 6 років тому

    your video is very helpful and well explained. It shows your deeper understanding. (rarely seen such liked ratio i.e 98%)

  • @3dw3dw
    @3dw3dw 7 років тому

    Always learning so much great material from you.
    Thank you so much Joop!!!

  • @photonthief
    @photonthief 8 років тому +1

    This is a fantastic tutorial Joop! Thank you so much!

  • @mandelbro777
    @mandelbro777 4 роки тому

    awesome stuff dude. Thank you so much for the time you've invested sharing this knowledge. It is most appreciated.

  • @FranzStrasse
    @FranzStrasse 8 років тому

    Absolutely wonderful. I really did learn something and am inspired to use some of your techniques.

  • @photon2724
    @photon2724 5 років тому +2

    improving our Arduino programming skills?!?!?!?!! im a first year engineering student, and we are immediately given an assessment that requires Atmel. Mind you, we have never even touched the Arduino software before. We just left high school. WHAT DO THEY EXPECT FROM US!!!

    • @masaratech
      @masaratech 5 років тому

      to be fucking geniuss ???!!!!
      Fuck school and long live UA-cam!

    • @martinmartinmartin2996
      @martinmartinmartin2996 5 років тому +1

      Electronics involve many technologies : optics, lenses, fibre optics, nano-tech, ...Engineering a x100 more!
      Plan for the next 10 yrs
      IMPOSSIBLE to become learned in many technologies ... IMPORTANT to accumulate some idea of 4 or 5 unrelated technologies.
      To learn arduino: read and follow simple UA-cam videos . Spend 1/2 hour/day on SIMPLE program explanations. Understand the meaning of 3 to 5 different commands every day , but review the previous commands you learned.
      high school is over ...now its time to Work and Learn !

  • @scottbechtel7915
    @scottbechtel7915 7 років тому

    Mind blown! Didn't know you could use assembly in the Arduino Studio.

    • @ratchet1freak
      @ratchet1freak 7 років тому

      Here's something to really blow you mind. It's not assembly. Instead those are really just volatile globals bound to the registers.

  • @VentoRacing1
    @VentoRacing1 7 років тому

    Great stuff! You have inspired me to work on my arduino coding.

  • @freddiesnijman
    @freddiesnijman 8 років тому

    Thanks Joop, excellent. I also have to go and figure it out,but looking forward to go and study your info.

  • @akshayjha9605
    @akshayjha9605 8 років тому

    Sir can you please make more videos like this or you can make a complete tutorial series of such programming tutorials because first time fortunately I found this kind of video first time I really came to know where to learn arduino programming and
    improve it more can you please make more videos from programming basics
    Thanks alot :-)

  • @chickenbonelives
    @chickenbonelives 6 років тому

    This is so new to me it's really rather intense. +1 internets

  • @EMandMORE
    @EMandMORE 7 років тому

    Thank you for the excellent video, I'm really impressed. Just a little question: considering Arduino IDE lets you program at "low level" as you show in this video, is it really necessary to move to Atmel IDE? Is maybe because Arduino IDE has other problems? (except the setup and loop functions which take some memory)

    • @Joop_Brokking
      @Joop_Brokking  7 років тому

      No, you don't have to move to Atmel. You should use whatever suits your needs.

  • @massimogiardina9138
    @massimogiardina9138 6 років тому +1

    Thank you soooooo much. I neve4 understood how those registers worked

  • @yaserbatal6474
    @yaserbatal6474 8 років тому

    very informative series of videos. Keep the good job

  • @meme-hj5rs
    @meme-hj5rs 7 років тому

    Great explanation
    Keep up the good tutorials

  • @Stanh11
    @Stanh11 7 років тому

    More tutorials like this please !

  • @niyo7803
    @niyo7803 7 років тому

    Sir your video are best, I understand use of register .

  • @danielbycinskij3685
    @danielbycinskij3685 3 роки тому

    Great video!!! What program do you use to read the datasheet?

  • @faisalal-jariry5665
    @faisalal-jariry5665 8 років тому

    An excellent tutorial , would you please zoom in the IDE and text. It is very small to see. Thanks

  • @jstro-hobbytech
    @jstro-hobbytech 3 роки тому

    I understand what you're saying but how do we put this in practice if we (for simplicity sake) say had a 1602 i2c display showing temp and humidity using a dh11.

  • @zyxwvutsrqponmlkh
    @zyxwvutsrqponmlkh 7 років тому

    I have to wonder why the arduino ide and compiler would not compile to the same code as your optimized code.

  • @gideonjonkers2683
    @gideonjonkers2683 3 роки тому

    Did you know you dont have to use setup and loop in the arduino ide you can directly code int main with a while loop and it will work and atmels version of delay works in arduino ide aswell.

  • @BuildItnow
    @BuildItnow 8 років тому

    very informative, thank you!

  • @tonyhoff86
    @tonyhoff86 3 роки тому

    I am a noooob. So... is the idea here that I would build a program in the IDE and then streamline it later, or should the work really be done at the lower level from the beginning?

  • @BernhardHofmann
    @BernhardHofmann 7 років тому

    Ninja level unlocked.

  • @__cm__
    @__cm__ 7 років тому

    wow!! beautifully explained!

  • @incxxxx
    @incxxxx 4 роки тому

    I do not have in Tools of Atmel Studio any Arduino Bootloader. How you got it?

  • @youreale
    @youreale 7 років тому

    Amazing content bro! subscribed.

  • @abdoo_almyhob184
    @abdoo_almyhob184 5 років тому

    just use "char x " instead if "byte x " in variable declaration, both are 8 bits size and works exactly the same.

  • @glidermike1
    @glidermike1 6 років тому

    Joop, Thank you for this video that explained a great deal to me. However, I am using the ATmega 2560 processor which has multiple USARTs and I am finding it difficult to apply the same register manipulations described in your video. I know you have moved on to more exciting things, but is there any chance for a video on this processor, or at least some guidance.

  • @bdureau1
    @bdureau1 6 років тому

    very interesting video, can be usefull if your are short of memory. However not really good if you want your code to be portable

  • @randysonnicksen9475
    @randysonnicksen9475 5 років тому

    Joop, I am wanting to learn how to use a programmer with the arduino uno so that I can debug (monitor variables) without inserting extra print commands which affect the speed of my program. Do you have any experience with this, and how to get started. I can't seem to find an information source that walks through all the steps with good explanation.

    • @Joop_Brokking
      @Joop_Brokking  5 років тому

      I used the Atmel Ice for one of my videos: ua-cam.com/video/o3dcmo-hbQw/v-deo.html
      Works very intuitive and there are useful videos available for the ICE.

  • @makesolareasy
    @makesolareasy 7 років тому

    Hi Joop Brokking. This is completely off your topic on the video. I have code on different steps controlling 3 relays, that must be controlled for different periods of time. What code do I use to to select certain section of my code, if an input is triggered?

  • @bastian9945
    @bastian9945 8 років тому +1

    one thing bothers me really hard did he really printed the whole datasheet just to show it in the video?

  • @rutherford16
    @rutherford16 5 років тому

    The link for datasheet is broken, can you fix it??

  • @briankoton845
    @briankoton845 2 роки тому

    the pdf link for downloading the file isn't working

  • @zulfqarali8603
    @zulfqarali8603 6 років тому

    Hi Joop, could you please share an SPI optimize program example?
    BTW: Greate way to teach.

  • @Artezko1
    @Artezko1 7 років тому

    Does this make any significant impact on the power consumption or just increasing the available memory?

    • @jmullentech
      @jmullentech 7 років тому

      Atmel Studio has a profiler built in that can check power consumption but I've never played with it. I'd imagine you'd see a difference but I can't imagine it being anything substantial.

  • @Wildcats1266
    @Wildcats1266 8 років тому +1

    Arduino based quadcopter using Atmel studio feasible? significant gains in stability and response ?

    • @Joop_Brokking
      @Joop_Brokking  8 років тому +2

      It's feasible. The difference in stability is mainly gyro / accelerometer depending.

    • @AndersJackson
      @AndersJackson 8 років тому

      It will allow you to write more C-code before the program memory runs out of Arduino. And you probably need to write the code for the libraries that Arduino IDE has for you.
      You gain some and loose some.

  • @wafikiri_
    @wafikiri_ Рік тому

    Not so intimidating a manual as one I had to use once to modify a mainframe for its remote shutdown. I found the desired schematics portion in Volume 76 of 130.

  • @jeanpierredaviau7478
    @jeanpierredaviau7478 4 роки тому

    I wonder if there is a book on that for the esp32?

  • @erygion
    @erygion 5 років тому

    New sub here :) great channel, I'll be using many videos for studying.

  • @AxelWerner
    @AxelWerner 7 років тому

    Excelent Topic! Excelent Video!!

  • @ddxxbb1
    @ddxxbb1 7 років тому

    Amazing video !

  • @lw8661
    @lw8661 6 років тому

    Awesome. THANK YOU!

  • @BubbaCZekLP
    @BubbaCZekLP 8 років тому

    Great video Joop! Could you do one on faster reading of ADC?

    • @AndersJackson
      @AndersJackson 8 років тому

      The speed you can read are mostly decide by the ADC you use, not by the programs.
      That said, the program code will be less without the Arduino IDE.

  • @teiko142
    @teiko142 6 років тому +1

    Instant like + sub, great stuff!!

  • @EngineerNick
    @EngineerNick 7 років тому

    wow that was a really useful video :)

  • @sonnguyenxuan685
    @sonnguyenxuan685 6 років тому

    i'm working on atmega328p project. i use fast pwm at the 16 bit timer. so i want to output 2 pwm at OCnA and OCnB. both of them have a same top value and same OCRnA and OCRnB. does anyone how i can toggle OCnA and then OCnB repeatedly

  • @vidanatural_oficial
    @vidanatural_oficial 8 років тому +1

    Nice try Joop, leaving people from Arduino IDE to Atmel Studio, unfortunately with the size increase, we have too a standard ambient to develop with arduino microcontroler you choose. Inclusive the ARM ones.
    it is true, there are not code optimization in arduino IDE, but it is a exaustive work program with the Atmel book in one hand and the keyboard in another. To you became good, you need to became a especialist in one especific AVR, not a good ideia too.

  • @tvoverip
    @tvoverip 7 років тому

    Great video!

  • @o_-_o
    @o_-_o 5 років тому

    How Atmel Studio
    achieves smaller binary?

  • @micaiaskauss
    @micaiaskauss 3 роки тому

    Great vid again

  • @laureven
    @laureven 3 роки тому

    Great video. Thank You but :) If You had smaller font YOu could fit more text on the screen. :) Regards

  • @AJ-qn9wz
    @AJ-qn9wz 7 років тому

    Well done!

  • @AllanKobelansky
    @AllanKobelansky 7 років тому

    Well done. Thank you.

  • @Patillac123
    @Patillac123 8 років тому

    Awesome video. Awesome name.

  • @AJB2K3
    @AJB2K3 7 років тому

    Cool, thanks for this.