Тёмный

35. Arduino for Production! AVR ADC How to use multiple channels on the analog to digital converter 

BuildYourCNC
Подписаться 100 тыс.
Просмотров 49 тыс.
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 Webpage for this Video:
newbiehack.com/Microcontroller...
In this video, I demonstrate the use of two channels or the ADC. Channels are used to read analog voltages, and if you have more than one analog voltage to read (i.e. sensor), the you can use other ADC channels. The two ADC results are shown on 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
The cheap oscilloscope that I use (because it's cheap and will work all of the projects in these tutorials): amzn.to/2rSHnBa
A better oscilloscope and the one I would recommend: amzn.to/2qizK5M
The brand of multimeter that I use and the one I recommend: amzn.to/2qicUez
Want to have your own Patreon campaign? / wpllxz

Наука

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

 

16 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 53   
@OwlingBishop
@OwlingBishop 11 лет назад
Using a bitwise mask to blankout the higher bits of ADMX helps keep the switch cases clear of unrelated bits : switch(ADMUX & 0x0F) { case 0x00 : // ... break; case 0x01 : // ... break; } These tutorial series are GRRRREAT ! Its about half a year I'm wandering around this MC topic ... Now I'm started the right way. Thanks !!
@kemicallx
@kemicallx 9 лет назад
Very good tutorials man, I Gave myself a mini-project that was intended to help me with a much bigger project. I essentially ended up branching out to use ADC, LCD, PWM and USART. I created a Proteus ISIS simulation file with the schematic and hex code loaded on the "virtual" ATMEGA32. I used the USART aspect to send and receive data serially (async) via the RXD and TXD pins. The used Channel 0 of the ADC to read in analogue information from an LM35 Temperature sensor and used some signal conditioning to get the equivalent temperatures to send to the LCD. The ADC value was also used to modulate the power going to a motor/fan that changed speeds depending on the temperature. I printed all the data to the 20x4 LCD (Temperature, Duty cycle, etc.) With the help of this video, i figured out how to include a POT on another ADC channel and just displayed its ADC value to the LCD. **I have a few questions though: 1. How do you know what resolution to use when reading sensor data ? For example: Using the AVCC gives arguably the best full-scale resolution but for the ACCELEROMETER you said something about using the internal. Does that not low your accuracy and precision ? due to you not having a large enough resolution ? 2. Why do you always use "lowADC = ADCL" then "thenBitADC = ADCH
@duduy1963
@duduy1963 5 лет назад
wow ur an angel
@PatrickHoodDaniel
@PatrickHoodDaniel 11 лет назад
Thanks. That is a good comment. I will try that method to see if it improves.
@marcfeyzeau
@marcfeyzeau 12 лет назад
Great I was going to ask for it :P thanks for all these tutorials. It help me getting back on microcontrollers
@hobbyelectronics2121
@hobbyelectronics2121 4 года назад
Hi Patrick! You can use the & operator to check the channel number in the ADMUX which is an easy way and need not to also check the REFS bits. Thanks a lot for making these interesting tutorials :)
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
@marcfeyzeau Very good idea. I will add annotations on the video to show this option.
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
@pcangeldust Yes, I will be doing the 4-bit interface very soon.
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
@pcangeldust You need to see the LCD tutorials where we construct that routine.
@imon4mRUET
@imon4mRUET 2 года назад
Thank you. very helpful.
@dumle29
@dumle29 10 лет назад
Hey there. Even after this much time, these videos are still awesome! :D Just wanted to give you a heads up, and tell you that, just as ADCL and ADCH will give you the low and high results, and combining them will give you a 16 bit result, so will just ADC. ADC is mapped as a 16bit value, to the address of ADCL, and will therefore include the next 8 bits right after, which happens to be ADCH :) Take a look at iotnx5.h (might be different which header file your chip is referenced in, this is an attiny85)
@PatrickHoodDaniel
@PatrickHoodDaniel 9 лет назад
Nice. Thanks for that.
@Olavotemrazaodenovo
@Olavotemrazaodenovo 4 года назад
Excellent
@learnbox3783
@learnbox3783 4 года назад
Thank you Sir problem solved.
@pcangeldust
@pcangeldust 12 лет назад
@anajonesr Yh I went back and saw that I missed that thanks for your efforts, one question when will you do the 4-bit interface tutorial if you are still planning to do it?
@Azlateen
@Azlateen 12 лет назад
Thanks for the tutorial! so if i wanted to use multiple inputs, I could do sensor1 = ADMUX | 0b0000001, sensor2 = ADMUX | 0b00000010 ? then that will assign the respective pins to a variable?
@joshgunkerimli
@joshgunkerimli 4 года назад
Super
@slendertall
@slendertall 7 лет назад
so i followed this tutorial and adopted it to my project... trying to connect three sensors. however, i keep getting this error "error: expected identifier or '(' before numeric constant ISR(ADC_vect) //selecting between multiple adc channels" what could be the solution.
@ghostog88
@ghostog88 11 лет назад
Hi Patrick, I have a problem about this topic. When I want to test the circuit, the microcontroller reset itself before going into the while loop, I don´t know if this problem is caused for a hardware or a software issue. I'm using an ATmega164P.
@launama1480
@launama1480 6 лет назад
What program are you using to code?
@marcfeyzeau
@marcfeyzeau 12 лет назад
Hum would be better to filter ADMUX into another variable to only keep the MUXs values and not have to change them if you change ADMUX at the setting. mux = ADMUX | 0b00011111; (0x1F) and do the switch with mux (case 1/ case 2 etc...) Thanks again for you work. this is great !
@pcangeldust
@pcangeldust 12 лет назад
where did you get a send an interger to lcd, I thought you had to covert it to char and then send string
@merden102
@merden102 4 года назад
Hi. How do I make three input ADC Channel? for example 2 pot 1 temp sensor and 3 hall sensor ınput etc.. Thanks.
@ElectronicMarine
@ElectronicMarine 11 лет назад
two ways: use an op amp or a voltage divider with 2 resistors if you don't need high acuracy.
@MNanme1z4xs
@MNanme1z4xs 12 лет назад
Im getting error results if I switch between channels, I did not use ISR, but I manually waited until the ADSC bit is clear, I don't know how ISR made a difference. What could gone wrong?
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
I would probably be easier to adjust the 0-10v to 0-5v in the circuit.
@PatrickHoodDaniel
@PatrickHoodDaniel 12 лет назад
@marcfeyzeau Great. Nice coincidence.
@milek021
@milek021 12 лет назад
Yes, I meant that, how to accept 10v by discrete components and adjust it to max. 5v for AVR adc pin ? If I put voltage divider with two same value resistors (10K) than I will loose range from 0-5v on input , if I understand good ? O.o
@milek021
@milek021 12 лет назад
How can I "expand" ADC "range" for voltage 0-10v ? :)
@staticshiv_
@staticshiv_ 6 лет назад
hey sir, do you need x and y table to read the value from the Accelerometer
@PatrickHoodDaniel
@PatrickHoodDaniel 6 лет назад
X and Y table to read the data? Or to record the data?
@TheAndro21
@TheAndro21 10 лет назад
i used your program to read two rotary pots....and it works thanks! ..i wished to modify it so that when one value is greater than the other then a certain led should glow..it tried various logics....using variables but am not getting the results...can you help?
@AbdulRafay7
@AbdulRafay7 7 лет назад
Did u get a solution for this problem ?
@edocam4806
@edocam4806 9 лет назад
On your conversion ,what is your refence value?i think the microcontroller need a range of values to ratio to the analog value
@PatrickHoodDaniel
@PatrickHoodDaniel 9 лет назад
Yes it does. Take a look how I use the avref pin. Also, in code, I use the control register to set this up.
@edocam4806
@edocam4806 9 лет назад
I din't see the range .cause u are reading 0-5v but it needs a range of value u are ratioing the adc to
@PatrickHoodDaniel
@PatrickHoodDaniel 9 лет назад
I'm using the internal setting of 2.56 volts as a reference. It's not perfect but it handles most of the range for the accelerometer. A better voltage reference would be the voltage established for powering the accelerometer.
@Chr0nalis
@Chr0nalis 10 лет назад
for two channels you can just ADMUX |= ( 1
@ericalfonsosilvalagos5019
@ericalfonsosilvalagos5019 7 лет назад
and as is done to use the 8 channels?
@mohamedhossamtealeb8682
@mohamedhossamtealeb8682 5 лет назад
I think you mean ADMUX ^= (1
@motormadness9975
@motormadness9975 5 лет назад
@@mohamedhossamtealeb8682 almost correct, XOR is the correct method for toggling a bit. In that case, we would need to make sure we initialize ADMUX = 1
@arcrobotics9982
@arcrobotics9982 7 лет назад
Hello sir :D , if i may ask , what if i want to tie more than 2 sensors to the ADC in the video u said we go back and forth between the channels but how does that apply to three channels do i go one by one , and what if i want to make for some reason only pin 0 and pin 2 work as an analog pins what should i do in that case ? Thank u so much for your tutorials and your kindness.
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
Yes, if you want to have 3 sensors to the microcontroller, you will proceed in the same way as in the video, just adding one more case in the switch statement will do it. To skip a pin, just don't use that case value in the switch statement.
@arcrobotics9982
@arcrobotics9982 7 лет назад
I dont quite get it so C0 go to C1 in the next conv and C1 go back to C0 but when i add C2 does it go back to C0 or it goes C1?
@PatrickHoodDaniel
@PatrickHoodDaniel 7 лет назад
Test with three known voltage inputs and you will be able to determine this. Testing and experimentation is the best way to learn.
@arcrobotics9982
@arcrobotics9982 7 лет назад
I tried a lot of things but i got everything messed up,I am also trying to make a library where i could select to read a certain pin and read it's value without having to move to read the next pin , I also tried to make C0 move to c1 and c1 goes to c2 and C2 to C0 again the output of A0 was displayed as C2 and C2 was on C0 ,I am also wondering can i change the readings size from 8 to ten bit within the main just by changing the value of ADLAR ? ,Thank u
@arcrobotics9982
@arcrobotics9982 7 лет назад
am i asking too much ?
@MilanKarakas
@MilanKarakas 7 лет назад
Why messing with ADCL and ADCH, when C compiler take care of it as ADC. If you build assembler program, then it is your task. Else C compiler take care of everything else. Just: int value=ADC; .
@MilanKarakas
@MilanKarakas 7 лет назад
Or better value=ADC; where int value; should be somewhere else so that it become global variable.
Далее
Isolated ADCs Deep Dive
13:46
Просмотров 4 тыс.
How to Use an Oscilloscope
12:32
Просмотров 1,1 млн
120/240V to logic level optoisolator (with schematic)
20:21
Здесь упор в процессор
18:02
Просмотров 344 тыс.
Игровой Комп с Авито за 4500р
1:00
Я УКРАЛ ТЕЛЕФОН В МИЛАНЕ
9:18
Просмотров 118 тыс.