| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| gtx15 
 
 
 Joined: 19 May 2018
 Posts: 27
 
 
 
			    
 
 | 
			
				| 18F87K22 A/D |  
				|  Posted: Sat Jul 27, 2019 2:18 pm |   |  
				| 
 |  
				| It appears i need a delay between a/d reads, is this normal? the code below gives correct read for a but b is way off!
 
 
 a=read_adc();
 delay_ms(0);
 b=read_adc();
 
 results are a = 228 b = 2.
 
 if i change delay to 1 ms
 results are a= 228 b = 228
 why is a delay needed? how much time is needed between reads?
 int oscillator 32000000
 
 adc clock = int
 |  | 
	
		|  | 
	
		| temtronic 
 
 
 Joined: 01 Jul 2010
 Posts: 9589
 Location: Greensville,Ontario
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Sat Jul 27, 2019 3:20 pm |   |  
				| 
 |  
				| Yes normal... have a read of the ADC section of the datasheet. It explains most of what you need to know and there's a chart that will show VALID ADC setups depending on PIC clock speed. For more detailed information, go to Microchip's website, find the 'application notes', look for ADC related articles.
 If you expect to get good, repeatable readings pay attention to board layout, filter caps, Vref, and external wiring. All are necessary for 10 or more bit ADC.
 
 Jay
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19967
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Sat Jul 27, 2019 10:39 pm |   |  
				| 
 |  
				| The ADC has to acquire between readings. So, yes a delay is normal.
 However you can program the ADC to automatically perform the
 acquisition delay when it is read. Setting this is down to your setup.
 Many of the older more basic ADC's don't allow this, but yours does.
 The datasheet has a section explaining this, and also giving the limits
 on the source impedance that is required to give accurate readings.
 If you are having to wait longer than the datasheet describes for this
 your source does not have a low enough impedance, and results will
 always be poor.
 |  | 
	
		|  | 
	
		|  |