STM32 마이크로컨트롤러의 ADC는 샘플 앤 홀드 방식으로 아날로그 신호를 디지털 값으로 변환합니다. STM32 ADC 샘플 타임 설정은 변환 정확도와 성능에 큰 영향을 미칩니다. 이 글에서는 STM32 ADC 샘플 타임 설정 방법과 실무 팁을 이론과 실용적으로 설명하겠습니다.(The ADC in STM32 microcontrollers uses a Sample and Hold method to convert analog signals to digital values. STM32 ADC sample time configuration significantly impacts conversion accuracy and performance. This article explains STM32 ADC sample time setup with theoretical and practical insights.)
STM32 ADC 샘플 타임이란?
STM32 ADC 샘플 타임은 입력 전압을 샘플링 캐패시터(\(C_{adc}\))에 충전하는 시간으로써, STM32에서는 ADC 클럭 사이클 단위(예: 1.5, 7.5, 28.5, 55.5 사이클)로 설정됩니다. 샘플 타임이 너무 짧으면 캐패시터가 충분히 충전되지 않아 ADC 값이 부정확해지고, 너무 길면 변환 속도가 느려집니다.(STM32 ADC sample time is the duration to charge the sampling capacitor (\(C_{adc}\)) with the input voltage. In STM32, it is set in ADC clock cycles (e.g., 1.5, 7.5, 28.5, 55.5 cycles). A too-short sample time leads to inaccurate ADC values; a too-long sample time slows conversion.)
STM32 ADC 샘플 타임에 영향을 미치는 요소
STM32 ADC 샘플 타임 설정은 다음 요소에 따라 달라집니다 (STM32 ADC sample time configuration depends on) :
- 소스 임피던스(\(R_{source}\)): 높은 임피던스는 긴 샘플 타임을 요구.( Higher impedance requires longer sample times.)
- 샘플링 캐패시터(\(C_{adc}\)): STM32 데이터시트 기준 4~10pF.( Typically 4~10pF per STM32 datasheet.)
- 기생 캐패시턴스(\(C_{parasitic}\)): PCB 배선이나 외부 회로에서 발생.( Arises from PCB traces or external circuits.)
- ADC 해상도(\(N\)): 12비트 ADC는 더 긴 샘플 타임이 필요.( 12-bit ADC needs longer sample times.)
이 요소들을 고려하면 STM32 ADC 설정의 정확도가 높아집니다. (Considering these factors improves STM32 ADC configuration accuracy.)
STM32 ADC 샘플 타임 계산 방법
STM32 ADC 샘플 타임은 시정수(\(\tau = R_{source} \times (C_{adc} + C_{parasitic})\))를 기준으로 계산됩니다. 정확한 변환을 위해 7~10\(\tau\)가 필요합니다. 최소 샘플 타임 공식은 다음과 같습니다:( (STM32 ADC sample time is calculated using the time constant (\(\tau = R_{source} \times (C_{adc} + C_{parasitic})\)). Typically, 7~10\(\tau\) is needed. The minimum sample time formula is:)
\[ t_{sample} = R_{source} \times (C_{adc} + C_{parasitic}) \times \ln(2^{N+1}) \]
예( Example ): \(R_{source} = 10\,\text{k}\Omega\), \(C_{adc} = 8\,\text{pF}\), \(C_{parasitic} = 2\,\text{pF}\), \(N=12\)일 때:
\[ \tau = 10 \times 10^3 \times (8 \times 10^{-12} + 2 \times 10^{-12}) = 100\,\text{ns} \]
\[ t_{sample} \approx 100\,\text{ns} \times \ln(2^{13}) \approx 900\,\text{ns} \]
ADC 클럭 14MHz(1사이클 = 71.4ns) 기준 약 12~13사이클이 필요합니다.(At 14MHz ADC clock (1 cycle = 71.4ns), about 12~13 cycles are needed.)
실무에서 STM32 ADC 샘플 타임 설정 방법
PCB 기생 성분(\(C_{parasitic}\))은 계산하기 어렵기 때문에 실무적 접근이 중요하니, 다음 단계를 따라해보세요:( Parasitic components (\(C_{parasitic}\)) are hard to calculate, so a practical approach is key. Follow these steps:)
- 소스 임피던스(\(R_{source}\)) 확인: \(R_{source} < 1\,\text{k}\Omega\)면 7.5사이클(cycles), \(R_{source} \geq 10\,\text{k}\Omega\)면 55.5사이클(cycles) 이상.
- STM32 데이터시트 참고: 샘플 타임 표로 초기 값 설정.( Use the sample time table for initial settings.)
- 테스트: 28.5사이클로 시작, 기준 전압(2.5V)으로 오차(\(\pm 1\,\text{LSB}\)) 확인.( Start with 28.5 cycles, test with a reference voltage (2.5V), and check error (\(\pm 1\,\text{LSB}\)).)
- 시스템 요구사항: 오디오(고속)에는 짧은 샘플 타임, 온도 센서(저속)에는 긴 샘플 타임. (Short sample times for high-speed sampling (audio), longer for low-speed signals (temperature sensors).)
STM32 ADC 샘플 타임 설정 실무 팁
- 초기 설정: \(R_{source}\) 불명확 시 28.5 또는 55.5사이클로 시작.( Start with 28.5 or 55.5 cycles if \(R_{source}\) is unclear.)
- 외부 회로: 높은 \(R_{source}\)는 오피앰프(버퍼)로 낮추기.( Use an op-amp (buffer) for high \(R_{source}\).)
- STM32CubeMX: STM32 ADC 설정 테스트 간소화.( Simplifies STM32 ADC configuration testing.)
- 다중 채널: 가장 높은 \(R_{source}\)에 맞춰 설정.( Set based on the highest \(R_{source}\).)
결론: STM32 ADC 샘플 타임 최적화
STM32 ADC 샘플 타임 설정은 이론(\(t_{sample} = R_{source} \times (C_{adc} + C_{parasitic}) \times \ln(2^{N+1})\))과 테스트로 최적화됩니다. \(R_{source}\)와 요구사항에 따라 28.5~55.5사이클로 시작해 하드웨어로 검증하고 STM32 데이터시트와 STM32CubeMX를 활용하면 효율적입니다.(STM32 ADC sample time is optimized using theory (\(t_{sample} = R_{source} \times (C_{adc} + C_{parasitic}) \times \ln(2^{N+1})\)) and testing. Start with 28.5~55.5 cycles based on \(R_{source}\) and requirements, and verify with hardware. STM32 datasheet and STM32CubeMX are efficient tools.)