Skip to main content

7. ADC Conversion Flowchart

BerikutHere adalahis alurthe kerjacomplete lengkapworkflow penggunaanfor using the ADC padaon the ATmega328p:

image

FlowchartThe diflowchart atasabove menggambarkanillustrates the proses pembacaan ADC padareading process on the ATmega328p dalam modein single conversion denganmode metodeusing the polling method, denganwith konfigurasithe sebagaifollowing berikut:configuration:

  1. Conversion Mode konversi:
    The ADC bekerjaoperates padain single conversion mode, yaitumeaning setiapeach konversiconversion dimulaistarts secaramanually manualby dengansetting mengeset bitthe ADSC = 1. bit.

  2. MetodeSynchronization sinkronisasiMethod:
    StatusThe selesaiconversion konversicompletion diperiksastatus menggunakanis checked using polling terhadapof bitthe ADIF padabit registerin the ADCSRA, bukanregister, menggunakaninstead interupsi.of using interrupts.

  3. Auto triggerTrigger:
    FlowchartThis iniflowchart mengasumsikanassumes ADATE = 0, sehinggaso konversiconversions tidakdo berjalannot otomatisrun automatically danand harusmust dimulaibe ulangrestarted olehby the program setiapeach kalitime pembacaana dilakukan.reading is taken.

  4. ADC Interrupt: This flowchart does not use ADC:
    Flowchartinterrupts, ini tidak menggunakan interrupt ADC, sehinggaso ADIE = 0.

  5. Input Channel input:
    ContohThe konfigurasiconfiguration padaexample in the flowchart menggunakanuses ADC0 (pin A0 / PC0) sebagaias kanalthe analog input analog.channel.

  6. TeganganReference referensiVoltage:
    FlowchartThis iniflowchart mengikutifollows contohan assembly program assemblyexample yangthat menggunakanuses the teganganinternal referensireference internalvoltage melaluivia konfigurasithe bitconfiguration of the REFS1:REFS0 padabits registerin the ADMUX. register.

  7. Conversion Data Format data hasil konversi:
    HasilThe ADC disimpanresult dalamis formatstored in right-justified format (ADLAR = 0), sehinggaso nilaithe full 10-bit dibacavalue penuhis melaluiread duathrough register:two registers:

    • ADCL sebagaias the low-byte
    • ADCH sebagaias the high-byte
  8. UrutanData pembacaanRegister registerReading dataOrder:
    RegisterThe ADCL harusregister dibacamust terlebihbe dahuluread first, kemudianfollowed by ADCH, agarto ensure the conversion data hasilremains konversi tetap konsisten.consistent.

  9. ADC Prescaler ADC:
    ContohThis iniexample menggunakanuses a prescaler CLK/128 prescaler (ADPS2:ADPS0 = 111).
    JikaIf the system clock sistemis 16 MHz, makathe ADC clock ADC menjadi:becomes:

    image

    NilaiThis inivalue beradais dalamwithin rentangthe kerjarecommended ADC yangoperating direkomendasikan.range.

RingkasanSummary Konfigurasiof yangConfiguration DigunakanUsed

  • ADC Mode: Single Conversion
  • Trigger Mode: Manual (ADSC = 1)
  • Polling / Interrupt: Polling (ADIF)
  • Auto Trigger: NonaktifDisabled (ADATE = 0)
  • Interrupt ADC: NonaktifDisabled (ADIE = 0)
  • Channel: ADC0 / A0 / PC0
  • Data Alignment: Right-justified (ADLAR = 0)
  • Prescaler: CLK/128
  • ADC Clock ADC: 125 kHz (jikaif F_CPU = 16 MHz)