نوشته اصلی توسط
maxn
یک نفر عزیز با دستوری که میفرماید مثلا
W = Getadc(adca ,2) مقدار صفر یا همون 200 بر میگردونه و تاغیرات روی پین A.2 رو اصلا متوجه نمیشه!!! این دستور شخصا تست کردین روی سخت افزار؟
سلام
قبلا گفته بودید که 20 تا پرش داره ؟
عدد 200 که بر میگرده ، ثابت هست و به خاطر خود adc هست و مشکلی نداره ، اما 20 تا پرش مشکل داره و ممکنه از مواردی که گفتم باشه .
عدد 200 از کجا میاد ؟
برای adc های سری atxmega چهار تا مد کاری برای اعمال ولتاژ ورودی پیش بینی شده ( دستوری که جلوی دستور _inp قرار میگیره ) :
• Differential measurement without gain
The ADC must be in signed mode when differential input is used
Pin 0...Pin 7 can be selected as positive input
Pin 0...Pin 3 can be sleected as negative input
'
' +--------------+
' | |
' Pina.0 -----+ differnential|
' | without gain |
' | |
' Pina.1 -----+ ADC |
' | |
' +--------------+
'
• |
Differential measurement with gain |
The gain is selectable to 1/2x, 1x, 2x, 4x, 8x, 16x, 32x and 64x gain
The ADC must be in signed mode when differential input is used
Pin 0...Pin 7 can be selected as positive input
Pin 4...Pin 7 can be sleected as negative input
'
' +--------------+
' | |
' Pina.0 -----+ differnential|
' | with gain |
' | |
' Pina.4 -----+ ADC |
' | |
' +--------------+
'
• Single ended input (signed mode)
The ADC is differential, so for single ended measurements the negative input is connected to a fixed internal value.
The negative input is connected to internal ground (GND) in signed mode.
'
' +--------------+
' | |
' Vinp -----+ single ended |
' | signed mode |
' | |
' GND -----+ ADC |
' | |
' +--------------+
'
• |
Single ended input (unsigned mode) |
In unsigned mode the negative input is connected to half of the voltage reference (Vref) voltage minus a fixed device specific negative offset
The approximate value corresponding to ground is around 200. This value corresponds to the digital result of ΔV (0.05 * 4096).
This value also depend on the selected voltage reference so you should measure the real value by first selecting the voltage reference.
(ΔV = Vref * 0.05)
How to measure the offset ?
Connect the ADC input pin (Vinp) to GND and measure the offset.
This is also called offset calibration. This value can be stored for example in EEPROM and is therefore available for all other measurements.
See also example below.
This offset calibration value is then subtracted to each ADC output
The offset enables the ADC to measure for example zero crossing in unsigned mode.
'
' +--------------+
' | |
' Vinp -----+ single ended |
' | unsigned mode|
' | |
' (Vref/2)-dV -----+ ADC |
' | |
' +--------------+
'
• Internal input
The ADC is differential, so for single ended measurements the negative input is connected to a fixed internal value
توی برنامه نوشته شده ما داریم از مد Single ended و unsigned mode استفاده میکنیم ، و باید ولتاژ رفرنس ایجاد شده رو از مقدار تبدیل شده کم کنیم :
اطلاعات بیشتر در آدرس زیر وجود داره :
CONFIG ADCx
نوشته اصلی توسط
maxn
این دستور شخصا تست کردین روی سخت افزار؟
متاسفانه نه
همون طور که توی تاپیک کتاب هم گفته شده ، برخی از فصل های این کتاب ناقص هستند ،بعضی از مباحث هم اصلا روشون بحث نشده . adc های سری atxmega هم یکی از بخش های ناقص هست .