So different of electronics I earned in the late sixties. Have tried to keep up to date on my own. Learned how to fix digital tv's and am now interested in microprocessors .I have ordered a full arduino kit with sensors and learning Python and Linux. Plus I have been following you on You Tube for the great projects you explain. Keep up the great work, You are a good teacher.
Pesterenan the stuff he's doing is basically what you do when you use the atmega on its own without the arduino ide and its libraries (but with atmel's libraries), its mostly just writing data to registers and reading from them. In the video he goes kinda fast so you will find it overwhelming, but take the time to look at other videos and tutorials about the 328p's timers, its not that hard. The datasheet gives you what bits you need to set in which registers to configure the timers how you want. Obviously you need to look at tutorials and read up on them to understand them well. But once you have an idea of how to configure timers and what registers to use and a few basic modes, figuring out other modes isn't that hard and you can refer to the datasheet. You will need to look up stuff online but its not that hard. I don't know everything about the atmega 328's timers but from what I know its pretty easy. I've moved on from the atmega though.
@@nishadnadkarni7874 what other boards have you moved on to? Just curious. I'm just getting started with the arduino platform but do not know if i should start with the arduino IDE or using atmel studio.
Having worked with electronics a lot in my life, I always found timers and interrupts to be kind of a dark art, especially before Arduino and when dealing solely with AVR or PIC. Thanks for addressing this :)
Embedded Micro controller Technical Jargon didn't make sense to me at first time I heard it. interrupts, timers etc are just a bunch of built in useful peripherals that does a particular function for a programmable logic device.This stuff is around the second layer of electronic and computer systems you'd have to study the basics of electrical and digital electronics.
I feel like you would want to know this: "Mandatory" is usually only used for things that come from human rules, and usually a better word to use is "necessary". Consider "using a precise timer here is mandatory under EEC regulations for electronic products", vs "using a precise timer here is necessary if you want your alarm clock not to drift a lot over time". Like, wearing a motorcycle helmet is always necessary if you want to be safe, but in some parts of the world it is not mandatory. I normally wouldn't point that kind of thing out but your English is already pretty excellent so I thought you'd want to perfect it.
Robert Miles I read your comment and understood that you are not nitpicking, but genuinely want to help a good RUclipsr improve his English. So, I checked out your channel, noticed that you produce some excellent content, and I subscribed to you. The comment sections to videos like this are a goldmine of extraordinary RUclipsrs.
I have been struggling to understand timer interupts. THIS IS THE BEST EVER! I can now control my steppers using either overflows or compare timers. THANK YOU!
I'm about to build a 500 Watt 30V - 42V motor controller for a project I'm working on. I had not yet looked into how to generate stable PWM signals in code without spinning the Arduino in busy waits that eat battery. You've given me some great ideas in this video, so thanks for your time and effort making this.
I'm writing an arduino sketch to control a stepper while monitoring some sensors. The accelstepper library did not really cut it, for my application. Using this new timer knowledge I was able to make the hardware act exactly as I intended. HUGE THANKS for this tip. Awesome GreatScott.
Thank you for this video! I made a arduino alarm clock a while ago, but because I didn't use a timer, the clock "lost" about 10 minutes every week. With this information I can finally fix the clock! Thank you!
Hey, the drift off of the millis() function is caused by the Serial.println which takes some clock cycles (depends on baud rate ofc) - the timer is precise in this situation
delta I think that's the point he was making. Delay causes drift because the other code takes some time to execute, so your loop time is delay time + code time.
i use an RTC for my clock project i did with the arduino(binary and lcd clock). its the DS3231(M) and its very precise and really cheap(the whole board is literally $1 on ebay). it makes a whole lot of things a whole lot easier. and it has a battery backup. And the arduino itself drifts off a lot faster than an RTC.
Great video! I really like how you get straight to the point, and pack in as much info as possible. Lengthy videos aren't as entertaining, and even if I have to watch this one a couple times to really get it, I would much rather prefer a shorter video than a longer video. Keep up the good work!
For all those commenting that they didn't understand anything, read the datasheet. It's all there, in unintuitive locations, using awfully confusing and cryptic language. You'll have to go back and forth and reread the same stuff several times to get something to work, you can't expect to watch a 10 minutes video and have everything in your head by the time in ends. If you're planning to stick to this device, the best thing you could do is print a physical copy of the datasheet, you can remove unnecessary segments like electrical characteristics and such in order to reduce the printing cost. Or you can even print the datasheet of some more complex controller that you think you'll use in the future, the common modules like timers 0-2 or A/D converters are usually the same for the whole family. The more I learn about Arduino, the more I like pics, everything is way more clear and straightforward.
A step inside the arduino functions. Lot of thanks for such detailed explanation. No body cares to explain these basic stuffs only you are the saviour for beginners as well as advance users. as always Love from India. thank you for your time and efforts. keep up the good work.
Hello Scott! Remember the clap circuit project? I build it from the first time and put it under my desk and plugged in my pc I enjoy it so much when i come home with one clap I turn on my pc!Greetings from my electronics teacher I showed some your projects to him and he sad:You can learn so much from him.
Great video! These more advanced videos are great since the amount of videos on how to blink leds is so high and no one really goes that much into advanced arduino / ucontroller functions. Keep at it!
This cleared up a lot of how to understand the timers & documentation about them for me. I was just getting to the point in some projects where I need them too!
Great Video, but keep in mind. (Why inaccuracies can still occur?): Clock Source: The accuracy of the microcontroller's internal clock can vary. For precise timekeeping, consider using an external quartz clock source or another stable clock signal. CPU Clock Variations: Variations in the microcontroller's CPU clock frequency, not precisely at 16 MHz, can lead to deviations. External factors like temperature changes can influence this. Timer Resolution: Microcontroller timers have limited resolution. In your case, using a 16-bit timer means that the smallest time unit you can measure is constrained by the timer's resolution, potentially causing small discrepancies. Interrupt Delay: The timing of interrupt processing can introduce slight delays. Other interrupts or additional tasks within your ISR can affect the time it takes for the timer to trigger accurately.
Oh I see what you did there...this is just a guide, but I find it very usefull because you managed to put all the information in 9 minutes so we can see the video search for the information to complement it ans continue watching. I guess that's not the format everybody likes, but I find it very interesting because it "forces" me to do more research and learn more than if you just give me the recipe, but that's just my opinion. Thanks for the video, nice job.
been driving a large matrix of LEDs from an LED sign I reverse engineered. Using the timer helps to keep the display showing something and still execute other code without having to call the routine regularly, had to use a different prescale value and pre-load the counter to tweak the refresh rate but works great now
I have so much still to learn, sigh... This is one of those videos where I need to do some research and then come back to to watch the video again to get a much better understanding. Thanks for challenging me with your great videos.
Thanks for that, very informative. I was looking to create a variable duty cycle at a fixed frequency, and figured I wanted fast PWM mode. Your tutorial helped me put a few things in place.
I have been working on a project using LCDs and Stepper Motors for the past two weeks and this is the exact video I have been looking for; of course it comes from one of my favorite youtubers. Keep it up!
You have the perfect timing, always if I finish a project you explain exactly that in a video and it's really easy to understand the little things I didn't know already :) Also keep up the great work, I'm always really happy when the "New Video" notification pops up.
Thank you for doing these videos. I keep coming back and watching and now I even bought a ton of arduino stuff to have a go at some simple stuff. Totally subscribed!
you are a mind reader...I was just thinking that there has to be a better way for my IOT home automation devices to poll the server without clogging the loop function...this is pretty awesome!!! thanks for the help
It is a great video. AVR timers even after explanation are still mysterious and confusing because of how they can interconnect. Respect on a next level! PWM to 8MHz?! Awesome!
I recently completed my Microprocessor course in my btech Electrical engineering!! So relatable!! Have you studied for the Microprocessor in your Undergraduation???
I studied Electrical Engineering at McGill university in Montreal, and we had the 6809 Microprocessor course back in 1982! I am surprised that in this day and age, they are not teaching µCs !
hey dude. just wanted to say thanks for all the vids. when i started my degree 2 years ago i found your channel. its been a great resource and ur perfect as far a host. you get all the info across well and you provide schematics and downloads and everything. so i just wanted to say tx. would've msgd you but couldve find that on this channel. thanks for providing such an incredible FREE resource for education man.
Great video Scott! I use the atXMEGA series of processors, and always run a 1ms interrupt which does just two things: it sets a sync flag, so I can synchronise main loop processes to the timer without having interrupts disabled for a long time in the ISR; and increments a signed long value called time, which I use to keep track of timeout conditions for processing. Very powerful, takes very little processor resource and ties up the processor in ISRs (which block other interrupts) the least.
I think because the frequencies are equal, so if it overflows after 16 million cycles, and it runs 16 million cycles a second, then it will overflow every 1 second
no. it is not equal to 1 sec. He kept it equal to 1 sec to know the number of times it would need for the timer to overflow to create a 1 second timed event. (1/16M)*(2^16)*(no. of overflow) = 1 sec no. of overflow = 244. It would take 244 overflows to make 1 second.
please note he used a prescaler of 256. Which is pretty close to 244 I calculated above. So using a prescaler of 256 can create an approx 1 second timed event.
That's why claiming that Arduino is great "for beginners" is BS. If you learn and get used to all those high level abstractions the platform provides, you'll get things to work (with a very poor efficiency) but you'll never learn anything.
if I'm not wrong there is an included library for timers in Arduino IDE. I used a timer in the past with ESP8266 as micro controller and I did not alter registers directly. Pretty sure you can do the same on Arduino
Finally! I had to do his very complex and unnescessary before ... Would be nice if you said whats the slowest possible timer (where you dont have to count the ticks).
I really enjoy this kind of arduino stuff. It's really hard to find someone willing to poke the control registers directly and go around the arduino's standard library.
The best definition I heard of processors (or computers if you will) so far was at the beginning of my Physics studies and is the following: Computers are basically just very complex clocks. They keep track of time and act in a defined way at defined events (e.g. amount x of time passed)
Thank you for proving useful content. Would you talk about Phase-Correct PWM later maybe? By inverting one output you can create a pair of half bridge driving signal withadjustable dead time which could be useful in a low cost arduino based switching power supply project. Or, just replace the potentiometer with some sort of feedback and with a simple buck boost converter circuit you can step up or down the 12v output of a cheap second hand power supply making a great project. Thank you.
How I understand it: to use a peipheral you have to St bits in some ready made registers. The counter sets different kind of registers on overflow and compare with other registers, to use these registers you have to set bits again in some registers. And should you need to use pins you still have to set bits in some registers.
I didn't understand a thing, but great video! I know what a Timer Register is. My project depends on it but I can't get a thing from the video and of course I am trying at least run an example on my arduino.
thanks so much for this. i understand how timers work on microcontrollers and how pwm is generated, this is awesome. I just made a pwm on AT89C2051 chip :))
Have you ever used a pic? I clearly prefer them in comparison to the atmega, although i haven't really done anything useful with the avr-gcc compiler. It might just be the image the arduino has gotten, as in used by teachers to teach people who knows nothing about microcontrollers or by people who doesnt know a lot about electronics in general. Its a good place to start, i just cant help but think it is a "amateur platform" when you know more about electronics, like you and me, and a lot of others. Anyhow, ramble over, please do more videos like this, i really liked the fact that you went "deeper" than the arduino layer and taught us a little about how the microcontroller is build and which peripherals is used behind the scenes :)
I started with Atmel chips (Arduino) and recently have been using STM32 and STM8 chips on a few projects. The Atmel datasheets, standard library/headers and toolchain are by far the most approachable, understandable and friendly I've come across - it's night and day compared to STMicro (and from what I've read, Microchip too). The software/toolchain side of Atmel/AVR is incredibly good, so I wouldn't dismiss it as an amateur platform - Atmel was born out of frustration with how poor the development experience was with existing MCUs, and it really shows.
Stephen Holdaway interesting, I have never heard about that. I know it is wrong to call it an amateur platform, I just can't help it, I once made a little project to test the atmega, made a pcb for it and showed one of my colleagues. The first thing he said? "Oh, so you are using an arduino?". That irritated me, as more people did the same, that's why I judge it that way and use Pic instead. But in these days, when atmel is microchip, is there really that big a difference?
Fiskelord I use both. Also got STM32 and ESP to play with. In 2011 Atmel was 3rd in microcontroller revenue after Renesas and Freescale. Microchip was 4th. Atmel was definitely NOT an amateur company.
We have benefited a lot from what you offer in this channel.. Can you provide a method for controlling a stepper motor through the micro-steps that we control through timers in Uno Arduino.. thanks
I would appreciate it so much if you could do a big favor for me. I bought a QFX PBX-BF12 Bluetooth speaker with a 12 Inch woofer and a 1 inch tweeter. The main problem is, is that when the woofer is engaged into more lower frequencies of bass in which actually cause the woofer to move noticably, the woofer will be vibrating against something as if the woofer is meant to be barely moved at all. Also there is distortion for sure at high(er) volumes when the bass is in at least decent use. Please help me fix this and I will give you future video ideas, but not based on what I want really of course.
Hey Scott, I usually don't leave RUclips comments, but i gotta say that i really enjoy your videos. As a software engineer who loves to play around with electronics your video's are always educational, entertaining and inspirational to me. I hope you keep making video's and that you'll have fun doing so! Kind regards, Some guy on the internet
The Atmega is going to execute the code in a bracket first. So in your example you`ll get a bitmask of 8 bit with a 1 at CS10. All other bits in the bitmask will be zero. Since CS10 is only a "placeholder" for the number 0 you`ll get the following bitmask: 0b00000001. So you could write TCCR1B |= 0b00000001; as well. The shift operator only moves the one to a certain position in the bitmask (in this case bit zero). If you would instead use CS11 your bitmask would look like this: 0b00000010 In the next step the controller reads the content of TCCR1B and uses a logical or with the content and the bitmask. The or gives you a one at the output if one of the inputs is one. Lets say the TCCR1B Register is: 0b00000000 you`ll get the following equivalent statement: TCCR1B = 0b00000000 | 0b00000001; That is equal to: TCCR1B = 0b00000001; Of course you could just write TCCR1B = 1; but then you would overwrite all other bits in the register as well. So to just set the one bit you want and keep all other bits of the register untouched you`ll have to use TCCR1B |= (1
@@arvindhram5964 I`m not completely sure what you mean but I think it is how I get to set or clear certain Bits? The functionality of a certain bit is specified in the Datasheet. Just Look at the AtMega328Ps datasheet under Timer1. I hope I could help you.
So different of electronics I earned in the late sixties. Have tried to keep up to date on my own. Learned how to fix digital tv's and am now interested in microprocessors .I have ordered a full arduino kit with sensors and learning Python and Linux. Plus I have been following you on You Tube for the great projects you explain. Keep up the great work, You are a good teacher.
I am interested in old electronics can please share what type of electronic were in 60s
That's great seeing you still learning sir please reach out to me if you require any help also btw they are called microcontroller 😊
This is the basics? wow! And here I was thinking that I was smart by using a previousmillis(); function xD
Pesterenan the stuff he's doing is basically what you do when you use the atmega on its own without the arduino ide and its libraries (but with atmel's libraries), its mostly just writing data to registers and reading from them. In the video he goes kinda fast so you will find it overwhelming, but take the time to look at other videos and tutorials about the 328p's timers, its not that hard. The datasheet gives you what bits you need to set in which registers to configure the timers how you want. Obviously you need to look at tutorials and read up on them to understand them well. But once you have an idea of how to configure timers and what registers to use and a few basic modes, figuring out other modes isn't that hard and you can refer to the datasheet. You will need to look up stuff online but its not that hard. I don't know everything about the atmega 328's timers but from what I know its pretty easy. I've moved on from the atmega though.
@@nishadnadkarni7874 what other boards have you moved on to? Just curious. I'm just getting started with the arduino platform but do not know if i should start with the arduino IDE or using atmel studio.
@@SuperNesmaster Start with arduino IDE then move on to atmel studio
Having worked with electronics a lot in my life, I always found timers and interrupts to be kind of a dark art, especially before Arduino and when dealing solely with AVR or PIC. Thanks for addressing this :)
I didn't understand a thing, but great video! ahah
Embedded Micro controller Technical Jargon didn't make sense to me at first time I heard it. interrupts, timers etc are just a bunch of built in useful peripherals that does a particular function for a programmable logic device.This stuff is around the second layer of electronic and computer systems you'd have to study the basics of electrical and digital electronics.
+1
Me too!
I watch this for scool haha
feel it
I feel like you would want to know this: "Mandatory" is usually only used for things that come from human rules, and usually a better word to use is "necessary". Consider "using a precise timer here is mandatory under EEC regulations for electronic products", vs "using a precise timer here is necessary if you want your alarm clock not to drift a lot over time".
Like, wearing a motorcycle helmet is always necessary if you want to be safe, but in some parts of the world it is not mandatory.
I normally wouldn't point that kind of thing out but your English is already pretty excellent so I thought you'd want to perfect it.
Robert Miles Wasn't expecting to see you here! Love your videos on Computerphile and big fan of your channel!
I also didn't know that. Thanks!
Robert Miles
I read your comment and understood that you are not nitpicking, but genuinely want to help a good RUclipsr improve his English. So, I checked out your channel, noticed that you produce some excellent content, and I subscribed to you.
The comment sections to videos like this are a goldmine of extraordinary RUclipsrs.
There better option with timer
I have been struggling to understand timer interupts. THIS IS THE BEST EVER! I can now control my steppers using either overflows or compare timers. THANK YOU!
I'm about to build a 500 Watt 30V - 42V motor controller for a project I'm working on. I had not yet looked into how to generate stable PWM signals in code without spinning the Arduino in busy waits that eat battery. You've given me some great ideas in this video, so thanks for your time and effort making this.
u can feel the illumunation after watching this 50 time. It is more brighter than the edison's and I'm understanding them now. I loved it!
I'm writing an arduino sketch to control a stepper while monitoring some sensors. The accelstepper library did not really cut it, for my application. Using this new timer knowledge I was able to make the hardware act exactly as I intended.
HUGE THANKS for this tip.
Awesome GreatScott.
Thank you for this video! I made a arduino alarm clock a while ago, but because I didn't use a timer, the clock "lost" about 10 minutes every week.
With this information I can finally fix the clock! Thank you!
This is perfect! I have an exam on this today! Thanks for the review Great Scott!
How did the exam go ?
Excellent companion to your previous "Arduino Basics 102: Control Structures, Variables, Interrupts" - Love Your Work...
Hey,
the drift off of the millis() function is caused by the Serial.println which takes some clock cycles (depends on baud rate ofc) - the timer is precise in this situation
delta I think that's the point he was making. Delay causes drift because the other code takes some time to execute, so your loop time is delay time + code time.
i use an RTC for my clock project i did with the arduino(binary and lcd clock). its the DS3231(M) and its very precise and really cheap(the whole board is literally $1 on ebay). it makes a whole lot of things a whole lot easier. and it has a battery backup.
And the arduino itself drifts off a lot faster than an RTC.
Holy cow... that is another one of your videos i'm gonna need repeat a lot of times to understand
This is a great video. Thanks for putting these timers into context with good examples, they make much more sense to me now!
best Explanation to that topic I've ever heard
Great video! I really like how you get straight to the point, and pack in as much info as possible. Lengthy videos aren't as entertaining, and even if I have to watch this one a couple times to really get it, I would much rather prefer a shorter video than a longer video. Keep up the good work!
I think the same way :-) Thanks for the feedback.
For all those commenting that they didn't understand anything, read the datasheet. It's all there, in unintuitive locations, using awfully confusing and cryptic language. You'll have to go back and forth and reread the same stuff several times to get something to work, you can't expect to watch a 10 minutes video and have everything in your head by the time in ends.
If you're planning to stick to this device, the best thing you could do is print a physical copy of the datasheet, you can remove unnecessary segments like electrical characteristics and such in order to reduce the printing cost. Or you can even print the datasheet of some more complex controller that you think you'll use in the future, the common modules like timers 0-2 or A/D converters are usually the same for the whole family.
The more I learn about Arduino, the more I like pics, everything is way more clear and straightforward.
A step inside the arduino functions. Lot of thanks for such detailed explanation. No body cares to explain these basic stuffs only you are the saviour for beginners as well as advance users. as always Love from India. thank you for your time and efforts. keep up the good work.
Thanks mate :-)
Great video as always. I didn't realise just how capable the Arduino was, but please forgive me when I just buy a RTC module for my next project.
Hello Scott! Remember the clap circuit project? I build it from the first time and put it under my desk and plugged in my pc I enjoy it so much when i come home with one clap I turn on my pc!Greetings from my electronics teacher I showed some your projects to him and he sad:You can learn so much from him.
Great video! These more advanced videos are great since the amount of videos on how to blink leds is so high and no one really goes that much into advanced arduino / ucontroller functions. Keep at it!
Finally! I miss in-depth videos like that. Keep going :)
An advanced topic but u make it so easy to understand. Thank u.
This cleared up a lot of how to understand the timers & documentation about them for me. I was just getting to the point in some projects where I need them too!
I had problems learning the timer counter , but this video helped me enough ... Thank you sir
Great Video, but keep in mind. (Why inaccuracies can still occur?):
Clock Source: The accuracy of the microcontroller's internal clock can vary. For precise timekeeping, consider using an external quartz clock source or another stable clock signal.
CPU Clock Variations: Variations in the microcontroller's CPU clock frequency, not precisely at 16 MHz, can lead to deviations. External factors like temperature changes can influence this.
Timer Resolution: Microcontroller timers have limited resolution. In your case, using a 16-bit timer means that the smallest time unit you can measure is constrained by the timer's resolution, potentially causing small discrepancies.
Interrupt Delay: The timing of interrupt processing can introduce slight delays. Other interrupts or additional tasks within your ISR can affect the time it takes for the timer to trigger accurately.
Oh I see what you did there...this is just a guide, but I find it very usefull because you managed to put all the information in 9 minutes so we can see the video search for the information to complement it ans continue watching.
I guess that's not the format everybody likes, but I find it very interesting because it "forces" me to do more research and learn more than if you just give me the recipe, but that's just my opinion. Thanks for the video, nice job.
been driving a large matrix of LEDs from an LED sign I reverse engineered. Using the timer helps to keep the display showing something and still execute other code without having to call the routine regularly, had to use a different prescale value and pre-load the counter to tweak the refresh rate but works great now
This is certainly the best kind of videos you make
You are a very smart man and although I don't understand everything I still enjoy your videos. Thank you.
So much information packed in one video. Error data limits exided
SUCH a good explanation of how to use Arduino style interrupts. You're officially AWESOME.
Great tutorial. I have used timers on the Arduino before. But only through libraries. That was a great overview on how that works under the hood.
I have so much still to learn, sigh... This is one of those videos where I need to do some research and then come back to to watch the video again to get a much better understanding. Thanks for challenging me with your great videos.
Thank you so much, for helping me tackle this daunting topic.
Thanks for that, very informative. I was looking to create a variable duty cycle at a fixed frequency, and figured I wanted fast PWM mode. Your tutorial helped me put a few things in place.
Scott. Fantastic video. I would not have even known about this without either reading the docs or watching your video. Keep 'em coming.
I have been working on a project using LCDs and Stepper Motors for the past two weeks and this is the exact video I have been looking for; of course it comes from one of my favorite youtubers. Keep it up!
You have the perfect timing, always if I finish a project you explain exactly that in a video and it's really easy to understand the little things I didn't know already :)
Also keep up the great work, I'm always really happy when the "New Video" notification pops up.
Thanks for the feedback :-) I will try to keep it up.
does it happen to you too? thought it was only me ;D
I am from Bangladesh, Your working is great for new learner.
excellent video. i learned a lot about how to use an arduino beyond the included libraries
Awesome!
Thank you for doing these videos. I keep coming back and watching and now I even bought a ton of arduino stuff to have a go at some simple stuff. Totally subscribed!
you are a mind reader...I was just thinking that there has to be a better way for my IOT home automation devices to poll the server without clogging the loop function...this is pretty awesome!!! thanks for the help
Im prettty sure theres many libraries available for this threading/timing approach.
Very informative, I didnt know much about this. Thanks.
It is a great video. AVR timers even after explanation are still mysterious and confusing because of how they can interconnect. Respect on a next level! PWM to 8MHz?! Awesome!
digger ich hab keinen plan wovon du redest, aber ich schau jedes video! weiter so
Well done, this video has cleared a lot of the confusion I had thinking about timers. Now I know how CTC mode works, thanks for informative video!
Great video. Some was little over my head, but if I watch things I already know, I'm not gaining anything. Thanks again for another excellent video.
I recently completed my Microprocessor course in my btech Electrical engineering!! So relatable!! Have you studied for the Microprocessor in your Undergraduation???
No, µCs are actually not part of the electrical power engineering course. But I think you need them very often, so I studied them by myself.
GreatScott! Nice talking with you Expect to see more cool projects!!!!!!!!
I studied Electrical Engineering at McGill university in Montreal, and we had the 6809 Microprocessor course back in 1982! I am surprised that in this day and age, they are not teaching µCs !
UFOhunter Yeah In India Undergraduation courses generally teaches us the 8085,8086 MPs and 8051 MCs. We come to RUclips for Aurdino and other's.
hey dude. just wanted to say thanks for all the vids. when i started my degree 2 years ago i found your channel.
its been a great resource and ur perfect as far a host.
you get all the info across well and you provide schematics and downloads and everything.
so i just wanted to say tx.
would've msgd you but couldve find that on this channel.
thanks for providing such an incredible FREE resource for education man.
No problem :-)
You need to revise the captions. I saw an "Admirer Predator 8 p" microcontroller in place of an Atmel "ATMega328P" Microcontroller.
Ooookey, first GreatScott video that i dont understand completly.
isn't it the wrong intro for electronic basics? :D
No, the old basics intro got canceled.
GreatScott! Oh, I didn't know that 🙈
holy, finally found my mistake after hours. thank you, good sir.
Amazing video. This video with Arduino documentation go perfect together. Thank you!
Great video Scott! I use the atXMEGA series of processors, and always run a 1ms interrupt which does just two things: it sets a sync flag, so I can synchronise main loop processes to the timer without having interrupts disabled for a long time in the ISR; and increments a signed long value called time, which I use to keep track of timeout conditions for processing. Very powerful, takes very little processor resource and ties up the processor in ISRs (which block other interrupts) the least.
The xmegas support multilevel interrupts so you can always interrupt an ongoing ISR. Perfect for ultra time critical task
Why 16 Mhz would equal to 1 Sec. ??
I think because the frequencies are equal, so if it overflows after 16 million cycles, and it runs 16 million cycles a second, then it will overflow every 1 second
no. it is not equal to 1 sec.
He kept it equal to 1 sec to know the number of times it would need for the timer to overflow to create a 1 second timed event.
(1/16M)*(2^16)*(no. of overflow) = 1 sec
no. of overflow = 244.
It would take 244 overflows to make 1 second.
please note he used a prescaler of 256. Which is pretty close to 244 I calculated above. So using a prescaler of 256 can create an approx 1 second timed event.
256 - 244 = 12 timer over flow
(1/16M)*(2^16)*((256 overflows, prescaler) -(244 overflows)) = 1sec
bingo! we created an exact 1 sec timed event
Glad I did not watch this at first because a beginner can't understand this. Now that I have more knowledge then it is a great tutorial
That's why claiming that Arduino is great "for beginners" is BS. If you learn and get used to all those high level abstractions the platform provides, you'll get things to work (with a very poor efficiency) but you'll never learn anything.
I thougt i knew everything about arduino, then i saw this.
Wonderful my friend youre a hacker
Boy that was quick I had to replay many times lol great video I appreciate it
Thanks a lot dear Scott for your knowledge
if I'm not wrong there is an included library for timers in Arduino IDE. I used a timer in the past with ESP8266 as micro controller and I did not alter registers directly. Pretty sure you can do the same on Arduino
Great explanation as always, I like the way you present.
Finally! I had to do his very complex and unnescessary before ... Would be nice if you said whats the slowest possible timer (where you dont have to count the ticks).
I can't tell you how helpful this video is. thanks!
This is amazing! Thanks for doing these!
Man you are so good at electronics! Wish you were my physics teacher!
well honestly i didnt understand anything but still love watching your video .....
This is just what i need. Thank you Mr. Scott
thank you for the analysis...This topic has always been fuzzy for me even when reading the datasheet...
Thank you for this video, it's exactly what I needed to get it 👍
I really enjoy this kind of arduino stuff. It's really hard to find someone willing to poke the control registers directly and go around the arduino's standard library.
Great video, you've made it so easy to understand, Thank you.
The best definition I heard of processors (or computers if you will) so far was at the beginning of my Physics studies and is the following: Computers are basically just very complex clocks. They keep track of time and act in a defined way at defined events (e.g. amount x of time passed)
GreatScott is really great, Keep up the good work. Thumbs up!
Great video, was easy to follow! (as an embedded systems student)
U r insane,wowww..... How would u able to know these this sir.........
Ur explanation was so good sir, u r truely great Scott
hey great scott say hello from Brazil!!
Nice video!!! Has been a fan for long time!!
Thanks mate :-)
GreatScott! Have you read Microprocessor in your Undergraduation!!??
I loved this explanation...I'm presently working on a project with atmega 8a :')
Thank you for proving useful content. Would you talk about Phase-Correct PWM later maybe? By inverting one output you can create a pair of half bridge driving signal withadjustable dead time which could be useful in a low cost arduino based switching power supply project. Or, just replace the potentiometer with some sort of feedback and with a simple buck boost converter circuit you can step up or down the 12v output of a cheap second hand power supply making a great project.
Thank you.
How I understand it: to use a peipheral you have to St bits in some ready made registers. The counter sets different kind of registers on overflow and compare with other registers, to use these registers you have to set bits again in some registers. And should you need to use pins you still have to set bits in some registers.
You broke my brain on this one!🤕
A very hart topic explained very simple! Good work!!!!
Thank you
Great video, found it really helpfull while programming the arduino uno in pure C
I didn't understand a thing, but great video! I know what a Timer Register is. My project depends on it but I can't get a thing from the video and of course I am trying at least run an example on my arduino.
Ah, as I come home from church I run to my room grab a snack and click my RUclips subscription list for great scotts new video
You are my idol, keep ON with gr8 videos, these are diamond.
thanks so much for this. i understand how timers work on microcontrollers and how pwm is generated, this is awesome. I just made a pwm on AT89C2051 chip :))
Superb explanation about the uses of timer great scott !
Thank you for this video, it helps me lot.
Have you ever used a pic? I clearly prefer them in comparison to the atmega, although i haven't really done anything useful with the avr-gcc compiler. It might just be the image the arduino has gotten, as in used by teachers to teach people who knows nothing about microcontrollers or by people who doesnt know a lot about electronics in general. Its a good place to start, i just cant help but think it is a "amateur platform" when you know more about electronics, like you and me, and a lot of others.
Anyhow, ramble over, please do more videos like this, i really liked the fact that you went "deeper" than the arduino layer and taught us a little about how the microcontroller is build and which peripherals is used behind the scenes :)
Yes, I "tried out" PICs a couple of months ago. And thanks for the feedback, I will see what other topics of a µC are worth talking about.
I started with Atmel chips (Arduino) and recently have been using STM32 and STM8 chips on a few projects. The Atmel datasheets, standard library/headers and toolchain are by far the most approachable, understandable and friendly I've come across - it's night and day compared to STMicro (and from what I've read, Microchip too). The software/toolchain side of Atmel/AVR is incredibly good, so I wouldn't dismiss it as an amateur platform - Atmel was born out of frustration with how poor the development experience was with existing MCUs, and it really shows.
Stephen Holdaway interesting, I have never heard about that. I know it is wrong to call it an amateur platform, I just can't help it, I once made a little project to test the atmega, made a pcb for it and showed one of my colleagues. The first thing he said? "Oh, so you are using an arduino?". That irritated me, as more people did the same, that's why I judge it that way and use Pic instead. But in these days, when atmel is microchip, is there really that big a difference?
Fiskelord I use both. Also got STM32 and ESP to play with.
In 2011 Atmel was 3rd in microcontroller revenue after Renesas and Freescale. Microchip was 4th. Atmel was definitely NOT an amateur company.
We have benefited a lot from what you offer in this channel.. Can you provide a method for controlling a stepper motor through the micro-steps that we control through timers in Uno Arduino.. thanks
I would appreciate it so much if you could do a big favor for me. I bought a QFX PBX-BF12 Bluetooth speaker with a 12 Inch woofer and a 1 inch tweeter. The main problem is, is that when the woofer is engaged into more lower frequencies of bass in which actually cause the woofer to move noticably, the woofer will be vibrating against something as if the woofer is meant to be barely moved at all. Also there is distortion for sure at high(er) volumes when the bass is in at least decent use. Please help me fix this and I will give you future video ideas, but not based on what I want really of course.
Hey Scott, I usually don't leave RUclips comments, but i gotta say that i really enjoy your videos. As a software engineer who loves to play around with electronics your video's are always educational, entertaining and inspirational to me. I hope you keep making video's and that you'll have fun doing so!
Kind regards,
Some guy on the internet
Thanks mate :-)
It was a great video with a flawless explanation. My only question though is could you define how the
TCCR1B | = (1
The Atmega is going to execute the code in a bracket first. So in your example you`ll get a bitmask of 8 bit with a 1 at CS10. All other bits in the bitmask will be zero. Since CS10 is only a "placeholder" for the number 0 you`ll get the following bitmask: 0b00000001.
So you could write TCCR1B |= 0b00000001; as well. The shift operator only moves the one to a certain position in the bitmask (in this case bit zero).
If you would instead use CS11 your bitmask would look like this: 0b00000010
In the next step the controller reads the content of TCCR1B and uses a logical or with the content and the bitmask. The or gives you a one at the output if one of the inputs is one.
Lets say the TCCR1B Register is: 0b00000000 you`ll get the following equivalent statement:
TCCR1B = 0b00000000 | 0b00000001; That is equal to: TCCR1B = 0b00000001;
Of course you could just write TCCR1B = 1; but then you would overwrite all other bits in the register as well. So to just set the one bit you want and keep all other bits of the register untouched you`ll have to use TCCR1B |= (1
@@Boen466 how do we know cs10 is 0, cs11 is 1, and so on. I mean, where is it defined? Could you please explain?
@@arvindhram5964 I`m not completely sure what you mean but I think it is how I get to set or clear certain Bits?
The functionality of a certain bit is specified in the Datasheet. Just Look at the AtMega328Ps datasheet under Timer1. I hope I could help you.
Hello. Good video, greetings from Colombia
Thanks mate :-)
YOU FINALLY MADE IT, DOPE!!! (in regards to making an arduino video that uses code)
Really, really nice!