Learning AVR-C Episode 8: Analog Input

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ม.ค. 2025

ความคิดเห็น • 44

  • @Zacharias_Andersson
    @Zacharias_Andersson ปีที่แล้ว +8

    Thanks, even 10 years later your work is still helping people!

  • @CullyLarson
    @CullyLarson 8 ปีที่แล้ว +5

    Thanks so much for making these videos! They are one of the best AVR resources I've come across. Also, thanks for making them a reasonable length. It's nice not having to wade through a bunch of extra talk to get to the useful bits. Great work!

  • @humanHardDrive
    @humanHardDrive  11 ปีที่แล้ว +2

    Equals is used if you're setting the register. Or equal is used if you need to add to the register while preserving the other bits.

  • @KingMysion
    @KingMysion 11 ปีที่แล้ว

    Some really nice video's on AVR you have. Pretty much the only good tutorial I've found. Thanks for you hard work!

  • @landonreekstin2617
    @landonreekstin2617 2 ปีที่แล้ว +1

    Definitely heard a minecraft door at 6:21 XD Thanks for making these videos!

  • @GingerNingerGames
    @GingerNingerGames ปีที่แล้ว +2

    For anyone wondering, you can bitshift right (>>) the ADC value by 2 to make it fall into the timer properly. Code would be dutyCycle = ADC>>2;
    10 years old but still very good information and well presented too. Having some fun ditching the arduino IDE and how to directly use the atmega328p, amazing how different some of the logic problems become when the IDE isn't handling all the conversions between input and output for you

    • @BIGRIP87
      @BIGRIP87 ปีที่แล้ว

      thanks

  • @arkann3098
    @arkann3098 3 หลายเดือนก่อน

    Very clear, thank you !

  • @bender7017
    @bender7017 11 ปีที่แล้ว +1

    I'd like to see an I2C tutorial.
    Great info here, thanks for putting these videos together.

  • @kareemhafez6620
    @kareemhafez6620 11 ปีที่แล้ว

    Love these videos! Keep up the great work :D

  • @satvikkethireddy6264
    @satvikkethireddy6264 8 ปีที่แล้ว +6

    How would one would go about using multiple ADC pins?

    • @samuelholm3622
      @samuelholm3622 7 ปีที่แล้ว +2

      You actually have to alternate between pins, only one can go at once

  • @humanHardDrive
    @humanHardDrive  11 ปีที่แล้ว

    The Atmega328P only has 1 ADC. The ADMUX register directs only one analog pin to the ADC. By setting the MUX, you set which analog pin is read.

    • @suyashbutola3844
      @suyashbutola3844 6 ปีที่แล้ว

      can you please send me this pdf ? that will be really helpful

  • @ranitkarmakar8583
    @ranitkarmakar8583 6 ปีที่แล้ว +1

    will u please tell me how to access portc pins of atmega328 as input or output, cause they are multiplexed with ADC, so are not working as the other ports do

  • @MilanKarakas
    @MilanKarakas 8 ปีที่แล้ว +1

    Thank you for this video. I will post here really small code for ultrasonic parametric speaker, an PWM with ADC used. Only, it does not goes from 0 to 100% modulation, but rather some 5% to 85% or so. (too slow) And, it can modulate only in 32 steps, not 255, but it is okay for such good and fun toy. Output pin PB0 should to be connected to the gate of some power MOSFET, output from MOSFET to inverted transformer from CPU PSU (primary 240V is now secondary, and secondary of AC 5V is not primary). Analog input should be feed to ADC0 via electrolytic capacitor. For microphone input, it may be changed so that reference voltage can be 1.1V (internal), instead Vcc (5V). Just change "ADMUX = (1

    • @MilanKarakas
      @MilanKarakas 8 ปีที่แล้ว +1

      // Ultrasonic parametric speaker by
      // Milan Karakaš, Croatia
      // wildlab.org
      // Free to use, modify, redistribute
      uint8_t i;
      int on=32; //halfway between 0 and 64
      void setup()
      {
      DDRB |= (1

    • @MilanKarakas
      @MilanKarakas 8 ปีที่แล้ว

      This code above is made in just few hours, while watching yor excellent video.

  • @Winacro
    @Winacro 10 ปีที่แล้ว

    as you have ADLAR=0; THEN the ADCL register has the 8-bit value which you should map to the dutyCycle variable which in turn loads into the output pin OCR0A register.

  • @QuettierGaetan
    @QuettierGaetan 3 ปีที่แล้ว

    How to use multiple adc pins of the microcontroller ?

  • @absolutleharlequin
    @absolutleharlequin 11 ปีที่แล้ว

    so if I want to also set this up for analog pins a0-a3, I have to set them up in the ADMUX... but how would you write that... i don't understand why you shifted MUX0 and MUX2...
    Thank you for your help. your videos are incredibly helpful.

  • @asarangan
    @asarangan 11 ปีที่แล้ว +1

    Are the codes shown here available on a site somewhere?

  • @Weilin0220
    @Weilin0220 9 ปีที่แล้ว

    Was wondering why my LED dimmed up 4times during turning of the potentiometer. I realized while feeding cows that the times is 8bit and the ADC is 10bit. I made dutycycle = ADC rigth shifted two spaces to get it deduced by 3/4 without forcing the prosseor to do matemetical conversions. I lost 1,2,3 deciamls, but it don't show on the LED.
    Was this a stupid move or?

  • @sacdiyachannel1417
    @sacdiyachannel1417 6 ปีที่แล้ว

    how can i make it with atmega with proteus

  • @bunny.bunbob
    @bunny.bunbob 5 ปีที่แล้ว

    nice video! had to validate the code for my adc-problem.

  • @Sahmad43
    @Sahmad43 11 ปีที่แล้ว

    very nice tutorials ,truly enjoying them .
    what would be the frequency in this example based on the formula in datasheet if you can explain? I know the duty cycle is controlled by the ADC input but curious to know what the frequency is.

  • @jesusreignonhigh6732
    @jesusreignonhigh6732 5 ปีที่แล้ว +1

    So anyone knows how to eliminate that 8bit to 10bit thingy causing 4 messy PWM input?

    • @fachriyasir661
      @fachriyasir661 4 ปีที่แล้ว +1

      I don't know if you're already find out about it, but for me I divided the adc value by 4. the adc is 10 bit and in the range of 0 - 1023 and when i divide it by 4 the range will be the same as 8 bit which is from 0-255 (1024/4 = 256)

  • @pratibhasawant9349
    @pratibhasawant9349 5 ปีที่แล้ว

    I have a water level sensor connected to ATmega 2560 and AVR and I want to read analog input from sensor. How could I do this? How to do the programming? Can anyone tell me?

  • @xxJerry19xx
    @xxJerry19xx 10 ปีที่แล้ว

    Why not ADCSRA |= 0b10001111 ? Or ADCSRA = 0b10001111 if you don't need to preserve values of any bits ?
    Why to use this 4x OR way to do it ?

  • @MostElectronics
    @MostElectronics 11 ปีที่แล้ว

    thanks a ton!

  • @midhunnair1344
    @midhunnair1344 4 ปีที่แล้ว

    Hello Sir! I ve been watching your Avr playlist. Very wonderfully explained! thank you! Could you please do a same playlist for Arm cortex M3?

  • @bobybob5005
    @bobybob5005 10 ปีที่แล้ว

    About prescaller. Conversion value should be less then 200. So you can get right presacller by example:
    /*
    Must be less than 200Khz. So
    chip speed / prescaller value = conversion speed (which must be slower than 200KHz)
    * 1Mhz / 128 = 7.8125KHz (this one OK because less than 200Khz)
    * 1Mhz / 4 = 250KHz (more than 200Khz, means it is not OK ) */
    Thank you for a video.

  • @MrWkirsten
    @MrWkirsten 11 ปีที่แล้ว

    How do I know when to use just an equals sign or when to use: or equals, when setting up register bits? Example: ADMUX = (1

  • @BrusnickiRoberto
    @BrusnickiRoberto 6 ปีที่แล้ว

    Have you noticed that the Single Conversion Mode was never set?!

  • @Industrial.Machineries
    @Industrial.Machineries 6 ปีที่แล้ว

    Thank you so much ++

  • @demetriusdemarcusbartholom8063
    @demetriusdemarcusbartholom8063 2 ปีที่แล้ว

    ECE 312, UofA.

  • @GrizleyD
    @GrizleyD 11 ปีที่แล้ว

    on vcc and aref put capacitor filtering is bettter

  • @bharathg2575
    @bharathg2575 3 ปีที่แล้ว

    Warning :implicit declaration of function 'SetupADC' [-Wimplicit-function-declaration]

  • @doudi463
    @doudi463 3 ปีที่แล้ว

    i have a question can i have your email ?