Problem with ADC


Results 1 to 14 of 14

Threaded View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default Problem with ADC

    I have this configuration in my program

    Code:
    ' ******************************** LCD **************************************
    
        DEFINE LCD_DREG PORTB		    'Selection of the port B
        DEFINE LCD_DBIT 4
        DEFINE LCD_RSREG PORTB		    'RS on port RA1
        DEFINE LCD_RSBIT 2
        DEFINE LCD_EREG PORTB		    'E on port RA0
        DEFINE LCD_EBIT 3
        DEFINE LCD_BITS 4		        'Mode 4 bits
        DEFINE LCD_LINES 4		        'LCD 4 lines of 16 caracter
        
    	PAUSE 500
    
    ' Define ADCIN parameters
        
        DEFINE  ADC_BITS        8     	'Set number of bits in result
        DEFINE  ADC_CLOCK       3     	'Set clock source (3=rc)
        DEFINE  ADC_SAMPLEUS    50    	'Set sampling time in uS
    	
        INCLUDE "LCDbar_INC.bas"        'Include the BARgraph routines
    		
        CMCON = 7                       'PortA = digital I/O    
    	ANSEL = %00000111               'Will set RA2 as analog and all others as digital
    and this asm: (is for frequency meter)

    Code:
    Asm
    	movlw   0x10	       ;PORTA 4 in entry
    	movwf   0x5
    	MOVLW	0x37
            option      	   ;charge 00110111 in the register option
    	MOVLW	0x10		   ;init freq with RA4 in entry
    	MOVWF	_trisabuf
    EndAsm
    and this asm: (is for frequency meter)

    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;    AUTHORIZATION OF COUNTING
    
    	       clrf    TMR0		        ; RAZ timer
    	       bsf	    _trisabuf,3	    ; RA4 in entry and RA3 in entry authorization counting
    	       movf 	_trisabuf,W
    	       tris	   PORTA
    	
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;    BASE TIME  
          
    	       movf	   _TEMPS,W
               movwf   _COUNT1
    dxxx	   nop
    	       decfsz  _COUNT1
    	       GoTo	dxxx
    	       nop
    	       nop
    	       Call delay
    	       Call delay
    	       Call delay
    	       Call delay
    	       Call delay
    	
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;      STOP OF COUNTING
    
    	       bcf     _trisabuf,3	 ;RA4 in entry and RA3 at Exit to block counting
    	       movf    _trisabuf,W         
    	       tris    PORTA
    My problem is the pot not adjust the volt. Show on lcd only if it is full. If i turn litle the pot the volt go to 0volt on lcd.
    If i remove the two code : tris PORTA on asm code at the end of code the pot adjust linear, but the frequency meter
    is not show properly.
    In the image the resistor is 47omh and the pot 47kohm
    Attached Images Attached Images  
    Last edited by savnik; - 22nd November 2006 at 12:37.

Similar Threads

  1. pic12f675 ADC problem
    By radu022003 in forum mel PIC BASIC
    Replies: 3
    Last Post: - 1st September 2009, 10:13
  2. PIC18F2423, ADC problem
    By mistergh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th March 2009, 01:31
  3. Mutliple ADC problem with PIC16F877
    By andyto in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd October 2007, 17:47
  4. ADC problem with PIC16F917
    By eetech in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th March 2007, 21:22
  5. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46

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