Тёмный

31. Arduino for Production! How to use the ADC with Interrupts 

BuildYourCNC
Подписаться 100 тыс.
Просмотров 103 тыс.
50% 1

Purchase my new book: Arm Microcontroller Programming and Circuit Building Volume 1
www.amazon.com/dp-B09PHBT859/...
Please watch: "Buildyourcnc CNC Router on Love Yurts"
• Buildyourcnc CNC Route... -~-
Official Page with More Information:
newbiehack.com/Microcontroller...
In this video, I explore the use of the ADC using interrupts using the Atmega32 microcontroller. The circuit consists of a potentiometer being used as a voltage divider to demonstrate an analog voltage output between 0 volts and the voltage reference (5 volts in this case). 8-bits (0 to 255) is captured and outputted onto the LCD.
Equipment that I use to make videos:
Canon EOS Rebel: amzn.to/2rJSeh0
Macro Lens: amzn.to/2qaSKmK
Microphone: amzn.to/2qO2RB4
3D Mouse to rotate/zoom/move the object (Must have for CAD!!!): amzn.to/2ruFnSn
The drafting pencil I use on these videos: amzn.to/2qioYg2

Наука

Опубликовано:

 

29 ноя 2011

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 92   
@arcrobotics9982
@arcrobotics9982 7 лет назад
can i covert directly the ADCH to an intger ?
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
Yes, absolutely, but you will not get the detailed information from the ADCL. Let's take a standard decimal number as an example. Imagine the number 25. The number 2 (representing 20) would be in the 10's place. And you have the 5 in the ones place. It's like omitting the 5 in the ones place, so the granularity is removed.
@arcrobotics9982
@arcrobotics9982 7 лет назад
first of all i am very surprised by how fast u replied to my question and i would like to thank u for this tutorials i have learned a lot from u and am still doing so , So is there is a way to get the whole conversion stored in a variable (int,float,etc..) to use it later on in the code?
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
Yes, you can do that with the shift operator. You create a variable, like an int, and you make it equal to the ADCL and then shift the ADCH to the portion of that variable that it belongs. I do explain this in a video. Are you watching this as a part of the playlist. I can't remember which video it is; however. Check out the playlist: ru-vid.com/group/PLE72E4CFE73BD1DE1 If you can't find the video, I will take a look and find it. Thanks
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
Found the video where I explain it: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-v0G-ddUeWpo.html
@arcrobotics9982
@arcrobotics9982 7 лет назад
ok thank YOU :D a lot
@iammarkjones
@iammarkjones 10 лет назад
I have watched hundreds of videos online learning electronics and embedded programming. Yes I've been bitten by the bug. Your videos are by FAR the clearest and best executed of any I've seen. Please keep up the good work sir!
@derr2987
@derr2987 8 лет назад
This guy knows what he's talking about. With out a dought one of the best presented tutorials I've watched. By referencing the data sheet while constructing his code, he gives a much more in-depth explaination and understanding, this is far beyond most tutorials found online. A must watch video for anyone working with Atmel microprocessors.
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
Thanks for the input. I did make an error in the lcd library, but I corrected it in the latest vacuum pressure switch videos. I will update the program listing on the main page soon.
@scaraproject86
@scaraproject86 9 лет назад
Thank you for your tutorials. The best set of tutorials I have seen so far
@Rancidsb
@Rancidsb 8 лет назад
Thank you so much! You've made this process so much easier to understand for an avr newbie like me!
@srivamsimalladi5577
@srivamsimalladi5577 8 лет назад
well explained!! thanks for providing such a beautiful tutorial
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
The vref is a max that the ADC will consider, but not necessarily the max that the adc will have as input.
@hashimalsakkaf774
@hashimalsakkaf774 7 лет назад
I just saw this channel by pure luck, and what a good luck I have! you are amazing, thank so much for sharing such amazing tutorials!
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
You are very welcome!
@naveennavaneethan1124
@naveennavaneethan1124 11 лет назад
thanks a lot...u helped me a lot..i am a fan of your all yours avr microcontroller series,.. great understandable explanations,.thanks daniel..
@Normie_dog
@Normie_dog 12 лет назад
You do some great tutorials, thanks a bunch for them.....
@naveennavaneethan1124
@naveennavaneethan1124 11 лет назад
thanks you very very much,u helped me a lot...i am a fan of your series of avr micro controller series....nicely explained..
@prinspatrick1571
@prinspatrick1571 8 лет назад
Great tutorial! Thank you!!
@Yankee14ed
@Yankee14ed 7 лет назад
Hi, Patrick. I ran into an issue with ADC on my microcontroller, and it turns out that the internal pullup was to blame: I'm experimenting with ADC on an ATmega328P, but didn't have any pots on hand, so I just laid out resistors in series to use as voltage dividers for testing, and used a multimeter to verify the voltage at each node. I connected the ADC pin to my divider nodes one at a time, and the (ADCH cat ADCL) register more or less gave the correct results, but a bit higher than I expected. I also was unable to get (ADCH cat ADCL)=0 by connecting the ADC pin directly to ground. For the heck of it, I replaced each resistor with it's own value/10, so that the divider was pulling each node to the same voltage as before, just more "strongly." Connecting the ADC pin to each of the nodes now yielded different values than the first time around, much more close to what I calculated/expected to see, but still with significant error. I suspected that the internal pullup was the cause of the trouble, so I disabled it. That was the whole problem; my ADC values were spot on what I calculated on paper. So, it looks like tri-state has to be set on ADC pins on my micrcontroller. Does the AVR you use in the video do this automatically? I don't think I saw you mess with PORT pullup/tri-state...
@ishmeetbindra3481
@ishmeetbindra3481 9 лет назад
Great tutorial Can you also make a video on ADC in which we implement it without using interrupts?
@PatrickHoodDaniel
@PatrickHoodDaniel 11 лет назад
Thanks!
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
Thanks for the suggestion. Can you add a link for the COM-programmer?
@Azlateen
@Azlateen 12 лет назад
@anajonesr Oh thanks! I hadn't gotten that far in the playlist yet. Thanks a lot! You're a huge help!
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
Thanks.
@amikhimji
@amikhimji 10 лет назад
Great video thanks
@PatrickHoodDaniel
@PatrickHoodDaniel 11 лет назад
Thanks
@MilanKarakas
@MilanKarakas 7 лет назад
Instead messing with ADCH/ADCL, you may just use ADC, which will give you 10 bit value, but then rather chose ADLAR=0 in ADMUX. For 5V Vcc referent voltage, and ADLAR=0, just use: ADMUX = (1
@PatrickHoodDaniel
@PatrickHoodDaniel 11 лет назад
Thanks! :)
@manticore0x80
@manticore0x80 11 лет назад
thanks for this!
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
@Nathanxiangdarby Thanks!
@nsutahmid
@nsutahmid 10 лет назад
thank you sir... can you plz tell me how to send adc result for servo controll
@studymatterialforengineeri4323
when changing the frequency of the sine wave , amplitude( LOWER TO UPPER voltage ) also changing with respect frequency but my application is - how do constant amplitude ( voltage ) from different frequency in sine wave . I have number of sample is 64 and crystal frequency is 11 Mhz.
@VictorMbumbaSopranoihuk
@VictorMbumbaSopranoihuk 10 лет назад
Hi Patrick, thanks a lot for all your tutorials which are very helpful. I have followed this Adc tutorial step by step and it helped me in understanding how to configure the ADC OF ATMEGA16. my problem is I am trying to use the result of the conversion and send them to the pin of the mcu and turn on and off an LED. I wil appreciate it if you can help. I looked at the internet most of them are imcomplete. Thanks
@agongaziz
@agongaziz 10 лет назад
is it possible for you to do a tutorial on ADC interrupts for the SAM3x8e. I am trying to program an arduino due. Cheers!
@tranngockhanh9836
@tranngockhanh9836 7 лет назад
thank you very much!
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
You are welcome!
@94vujke
@94vujke 11 лет назад
Can you make a tutorial about MCU communicating with some other visual program on PC via ports?
@chinmaykulkarni7835
@chinmaykulkarni7835 4 года назад
Hey dose the interrupt library change for controller to controller like arm ,atmega series ,pic?
@brianblasius
@brianblasius 5 лет назад
Hey sir, I suggest you start teaching about using FreeRTOS on the STM32
@ragaramesh609
@ragaramesh609 11 лет назад
pls sir can tell interfaceing GSM with atmega32..... and also 4 sensors interfaceing with atmega32. and one more connection of relay and motor........
@TheDataXOR
@TheDataXOR 12 лет назад
Thanks for video! Made some things look much more clear for me. Also you could use adcResult[2]=(ADCH
@Omcsesz
@Omcsesz 7 лет назад
Is it possible to make a video on using ADC in freerunning mode?
@vovanikotin
@vovanikotin 12 лет назад
anajonesr, do you have videos how to watch ADC data on PC? and thx for very useful videos.
@JanChodorowski
@JanChodorowski 9 лет назад
great!
@donskanone
@donskanone 12 лет назад
Very cool tutorials, thanks a lot! I tried to run the ADC-Programm on a atmega8 but there is the warning: "../ADC.c:35: warning: 'ADC_Vect' appears to be a misspelled signal handler " What could be the Problem?
@MrBestKenny
@MrBestKenny 11 лет назад
Is there will be a tutorial for dimming led?
@Azlateen
@Azlateen 12 лет назад
Hey so if I wanted to turn more than one pin on for analog input, would I do multiple ADMUX |= (select MUX bits)?
@alanalvarez4649
@alanalvarez4649 10 лет назад
hello, how implement measure of voltage from a battery? tks
@fijabo
@fijabo 7 лет назад
I would recommend not to delete the pseudocode in place and type its corresponding instructions below it. It would be easier for us (beginners) to review it without having to play the video back and forth.
@gofent
@gofent 10 лет назад
Hi if I want to alter the range so it shows numbers from 0 to 99 what would I need to change.
@ignaspranckevicius5520
@ignaspranckevicius5520 10 лет назад
How to connect chematic? Where I can find it?
@BluCasper
@BluCasper 5 лет назад
i have done the same. but it is showing error. could you please help me?
@PatrickHoodDaniel
@PatrickHoodDaniel 11 лет назад
I can. This is just using pwm. Check out my pwm videos to do this.
@pimpekism
@pimpekism 10 лет назад
24:26 Why don't you fill initial string with spaces and then calculate value? Because if we go from 3digit value to 1 digit value won't that bug occur again?
@donskanone
@donskanone 12 лет назад
@donskanone ok i should write ADC_vect ^^
@uelman7657
@uelman7657 10 лет назад
thank you also Sir for your immediate HELP ! I really do appreciate it...i'll gice you feedback as soon as possible. more power to you !
@alexgray552
@alexgray552 7 лет назад
Nice methodical approach, but why on earth delete the comments as you code them up? They could be really valuable later, especially if anyone else has to understand/update your code, or is trying to learn from it. Good practice to leave in a good comprehensive set of comments.
@32docholiday
@32docholiday 11 лет назад
"Were using base 10 so we can read the number as Humans" hahah good one!
@saviramya7262
@saviramya7262 5 лет назад
hi sir i have some doubts can u help me sir
@sutoable
@sutoable 11 лет назад
hy! what is sei()?
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
@Azlateen Watch this video to use multiple channels: QouXLz-si0A
@arcrobotics9982
@arcrobotics9982 7 лет назад
another question if i may but it's related to the LCD I have changed the char of the adc result from char adc result [4] to char adc result [2] and it still works displaying numbers from 0 to 1023 how is that possible ?
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
A char data type has a size of 8 bits. Two of them are 16 bits which will give you a maximum value of 65535 unsigned, or -32766 to 32767 as signed. I use four of them just fro fun.
@arcrobotics9982
@arcrobotics9982 7 лет назад
okay now I get it , again thank you very much :D ,Are you going to add more videos about the EEPRom of the avr and how to deal with it and how to change it's contents with reprogramming the whole chip?
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
Not sure. I am pretty deep in doing the ARM Microcontroller tutorials at the moment. I may go back, but the ARM chips are less expensive and far more powerful.
@TheDataXOR
@TheDataXOR 12 лет назад
No, youtube does not allow me to post with link in it, for some reason. Here, remove all the spaces: ht tp://avr.nikolaew.o rg/progr Fist image is the UNIPROF's GUI and a link to archive with program itself. On the bottom there is an image of circuit itself.
@nahomnigatumengiste9199
@nahomnigatumengiste9199 11 лет назад
thank you very much for your adc tutorial . have you idea to convert adc value in kg ? thanks
@studymatterialforengineeri4323
sir I want to generate a sine wave from PWM , which frequency is 300 h
@PatrickHoodDaniel
@PatrickHoodDaniel 6 лет назад
300 hz?
@studymatterialforengineeri4323
300 hertz frequency
@hurrdurr25
@hurrdurr25 8 лет назад
But how do you get the value of the ADC into the main ?
@MilanKarakas
@MilanKarakas 7 лет назад
"adcResult" is global variable, so from ISR to main, it is already there available.
@MilanKarakas
@MilanKarakas 7 лет назад
Any variable which is within the same curled brackets (main, for example) is available within this brackets, even if there are 'nested' brackets, for example: void main(void) { int a=0; void SomeFunction (void) {//here integer 'a' is available} //but also here too} But not here outside function 'main'. For this integer to be available everywehere, then: int a=0; void main(void){ //other codes}... and if then some other function is below or above, as is: ISR(ADC_vect){//some function using integer 'a'} then it is also available. Not intuitive, but...
@darshanamaduranga7684
@darshanamaduranga7684 7 лет назад
Instead of using LCD can I get output using LED?
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
Yes, absolutely!
@darshanamaduranga7684
@darshanamaduranga7684 7 лет назад
can you help me to do that code
@studymatterialforengineeri4323
Hello sir , I want to know how can generate sine wave with respect pwm timer1
@PatrickHoodDaniel
@PatrickHoodDaniel 6 лет назад
Did you see my PWM videos?
@studymatterialforengineeri4323
yes sir , I saw your all video of PWM but actual generation of sine wave not complete,
@PatrickHoodDaniel
@PatrickHoodDaniel 6 лет назад
I've provided the fundamentals. It's up to you to do the rest. It's actually pretty easy, just assign the duty cycles in sequence and put in a time delay between them until you have your overall sine wave frequency.
@studymatterialforengineeri4323
I put OCR1A0 in interrupt which timer is running 3.33333 milisecond for 300 hertz frequency and also changing duty of cycle .
@studymatterialforengineeri4323
hello sir I want to talk ,how can talk to you give me, your contact facebook ID , what's up Number & other any contact detail , can me provide
@stianmoltubakk232
@stianmoltubakk232 9 лет назад
what if? ADCSRA |= 0xCC; ADMUX |= 0x60;
@EdwinFairchild
@EdwinFairchild 9 лет назад
Stian Moltubakk same thing but if 5 months from now you read the code your going to have to look at the data sheet to figure out what bits your setting , in other words its less readable
@jobaptist
@jobaptist 7 лет назад
boring and too much of detail explanation
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
Thanks for the feedback. What detail do you think I should remove and still convey the same message to engender the best possible tutorial for beginners? In your opinion, is there any specific changes I can make to help the video become more exciting? Thanks and eager to hear your opinion.
Далее
▼ЕГО БОЯЛИСЬ МОНГОЛЫ 🍣
32:51
Просмотров 451 тыс.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
Лайфхак для дачников
00:13
Просмотров 17 тыс.
Сколько метров чернил в ручке?
16:35
How to Use Arduino Interrupts The Easy Way
33:28
Просмотров 78 тыс.
Op-Amps  - Using Operational Amplifiers
44:21
Просмотров 273 тыс.
Arduino Workshop - Chapter 5 - Interrupts
10:46
Просмотров 182 тыс.
HAL #12: ADC with IT
11:31
Просмотров 17 тыс.
Pin Change Interruptions ISR | PCINT | Arduino101
14:19
Running an SQL Injection Attack - Computerphile
17:11
#engineering #diy #amazing #electronic #fyp
0:59
Просмотров 914 тыс.
Acer Predator Тараканьи Бега!
1:00
Просмотров 483 тыс.
😮Новый ДИРЕКТОР Apple🍏
0:29
Просмотров 40 тыс.