Wingmax
New Member
Please refer cct diagram:
**broken link removed**
This is an example program to test the ADC function.
Continue from last discussion:
We have to calculate the Acquistion Time.
TACQ= Tamp + Tc + Tcoff
Tamp and Tcoff can be found from the data manual.
Tc can also be found from the manual, but varies by the analogue input source resistance.
We use 10K POT, so max Rs= 10k.
TACQ= 19.72 uS (20 uS approx) (Refer manual).
The conversion time is 11 TAD cycles. Last time we calculated the TAD= 2 uS. So
Conversion time= 11x 2= 22 uS.
We have to allow minimum of 20 + 22= 42 uS for each ADC sample.
In our example we use VDD as voltage reference. The conversion result is in 10 bits, so there are
1024 values (0 to 1023). Each value is equiv to VDD/ 1024= 0.0048828125v.
If we are using 10 LEDs, each one should come on at the increase voltage of 5/10= 0.5v .
The first one should come on at 0.5v (LSB), the third one at 1.5v, and the last one should come on
at 5v(MSB).
Since we only use 8 LEDs and left justified. So the first LED that comes on is the second bit of the conversion result but the 0 bit of ADRESH.
Here is the program code:
View attachment ADC test prog.txt
https://s271.photobucket.com/albums/jj148/wingmax2/?action=view¤t=IMGP1430.flv
URL=http://s271.photobucket.com/albums/jj148/wingmax2/?action=view¤t=IMGP1430.flv]**broken link removed**[/URL]
**broken link removed**
This is an example program to test the ADC function.
Continue from last discussion:
We have to calculate the Acquistion Time.
TACQ= Tamp + Tc + Tcoff
Tamp and Tcoff can be found from the data manual.
Tc can also be found from the manual, but varies by the analogue input source resistance.
We use 10K POT, so max Rs= 10k.
TACQ= 19.72 uS (20 uS approx) (Refer manual).
The conversion time is 11 TAD cycles. Last time we calculated the TAD= 2 uS. So
Conversion time= 11x 2= 22 uS.
We have to allow minimum of 20 + 22= 42 uS for each ADC sample.
In our example we use VDD as voltage reference. The conversion result is in 10 bits, so there are
1024 values (0 to 1023). Each value is equiv to VDD/ 1024= 0.0048828125v.
If we are using 10 LEDs, each one should come on at the increase voltage of 5/10= 0.5v .
The first one should come on at 0.5v (LSB), the third one at 1.5v, and the last one should come on
at 5v(MSB).
Since we only use 8 LEDs and left justified. So the first LED that comes on is the second bit of the conversion result but the 0 bit of ADRESH.
Here is the program code:
View attachment ADC test prog.txt
https://s271.photobucket.com/albums/jj148/wingmax2/?action=view¤t=IMGP1430.flv
URL=http://s271.photobucket.com/albums/jj148/wingmax2/?action=view¤t=IMGP1430.flv]**broken link removed**[/URL]
Last edited: