Using two AtoD channels - they're interacting?!


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Thanks for taking the time to reply.

    I had a look, here's what I found...

    Code:
    ' ADCIN1X4.BAS
    '  For PIC12F683 and melabs PICBASIC PRO Compiler
    '
    ' Display result of 10-bit A/D conversion on LCD
    
    Include "modedefs.bas"		' Mode definitions for Serout
    
    ' Define ADCIN parameters
    Define	ADC_BITS	10	' Set number of bits in result
    Define	ADC_CLOCK	3	' Set clock source (3=rc)
    Define	ADC_SAMPLEUS	50	' Set sampling time in uS
    
    
    LCD	Var	GPIO.1		' LCD TX pin
    
    adval	Var	Word		' Create adval to store result
    
    
    	ADCON0.7 = 1		' Right justify result
    	ANSEL = %00111000	' Set AN3 analog, rest digital
    	CMCON0 = 7		' Analog comparators off
    
    	Pause 500		' Wait .5 second for LCD to init
    
    mainloop:	ADCIN 3, adval		' Read channel 3 to adval
    
    	Serout LCD, T2400, [$fe, 1]	' Clear screen
    	Serout LCD, T2400, ["Value: ", #adval]	' Display the decimal value  
    
    	Pause 100		' Wait .1 second
    
    	Goto mainloop		' Do it forever
    
    	End
    Unfortunately, that example only uses one channel.

    Pretty much after I posted, I sorted my problem (how does that always work then?!).

    Two things were the root of my issue...

    1. I'm using a sig gen, rectifying a sine wave from it & feeding into & low pass filter (the resulting extracted DC level feeds into one AtoD channel) ....I was getting over zealous with the sig gen output amplitude - and the rectified DC level breached 5V - which sends the PICs AtoD results a bit whacky (which is hardly surprising) ...one channels starts seriously impacting the sample from a totally different channel! So Hank makes amental note - be careful with the input voltage magnitude fed into an AtoD pin!

    2. The other problem was that I wasn't allowing sufficient time between using successive AtoD channels - I'm finding that in my setup, it needs at least 30ms between successive AtoD channels 'samples' - hey ho.

  2. #2
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    I'm finding that in my setup, it needs at least 30ms between successive AtoD channels 'samples' - hey ho.
    This is the case with every PIC, and for each and every a/d reading. It is called the "charge time" for the sampling capacitor, and is most often the bottleneck for sampling rates. (Some PICs charge it faster.) With a single channel it is often not noticed because the sampling cap is charged while doing other things, or because you get an "old" reading from the same channel.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts