Adc For 16f88


Closed Thread
Results 1 to 12 of 12

Thread: Adc For 16f88

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

    Default Adc For 16f88

    I am using a 16F88 for a project and i want to show simultaneous conversion of two ADC channels, AN0 and AN1 on LCD.
    My problem is that the LCD shows the clues alternately and no simultaneous
    My code
    Code:
        DEFINE  ADC_BITS        10   
        DEFINE  ADC_CLOCK       3     
        DEFINE  ADC_SAMPLEUS    50    	
    
        adval   VAR WORD			
        adval1  VAR WORD			
    	
        ANSEL = %00000011
        CMCON = 7                      
        TRISA = %00000011		         
        ADCON0 = %11001001            
        ADCON1 = %10000000                    	          	     
        
        INCLUDE "LCDbar_INC.bas"       
     
    loop: 	
        ADCIN 0, adval				
        adval = (adval */ 500)>>2		    
        LCDOut $fe,1,"L:" 
        @ BARgraph  _adval,  1,   2,    16,   100, lines    
        ADCIN 1, adval1				
        adval1 = (adval1 */ 500)>>2		   
        LCDOut $fe,$C0,"R:" 
        @ BARgraph  _adval1,  2,   2,    16,   100, lines        
        PAUSE 300
        GoTo loop

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I'm not clear on the problem you are having.

    What is it doing or not doing? And what should it do instead?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    to show simultaneous conversion of two ADC channels, AN0 and AN1 on LCD.
    My code
    Code:
        DEFINE  ADC_BITS        10   
        DEFINE  ADC_CLOCK       3     
        DEFINE  ADC_SAMPLEUS    50    	
    
        adval   VAR WORD			
        adval1  VAR WORD			
    	
        ANSEL = %00000011
        CMCON = 7                      
        TRISA = %00000011		         
        ADCON0 = %11001001            
        ADCON1 = %10000000                    	          	     
        
        INCLUDE "LCDbar_INC.bas"       
     
    loop: 	
        ADCIN 0, adval				
        adval = (adval */ 500)>>2		    
        ADCIN 1, adval1				
        adval1 = (adval1 */ 500)>>2		   
        LCDOut $fe,1,"L:" 
        @ BARgraph  _adval,  1,   2,    16,   100, lines    
        LCDOut $fe,$C0,"R:" 
        @ BARgraph  _adval1,  2,   2,    16,   100, lines        
        PAUSE 300
        GoTo loop
    Try above code. You may need to pause between the 2 adcin statements.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Not sure that would help, i would suggest to check the analog source impedance first. Must meet the datasheet requirement. You could still increase the ADC_SAMPLEUS and or check what you maths will do.

    As your maximum value range is 100... why not using a 8 Bit conversion instead?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Angry

    Quote Originally Posted by Kamikaze47 View Post
    I'm not clear on the problem you are having.

    What is it doing or not doing? And what should it do instead?
    I want to measure the audio input at the left and the right channel of a stereo coder (is for fm transmitter).
    The left channel show on first line and the right channel show on second line on the 2X16 LCD.
    But the LCD first show the left channel and after show the right channel alternately (very fast).

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    you may want to change the line:

    LCDOut $fe,1,"L:"

    to:

    LCDOut $fe,1,$fe,2,"L:"
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's something obvious that just jump to my face. You're using the default LCD assignment, and this use a.0, a.1... which is also your adc channels.

    so unless you forgot something in your copy/paste, or i totally misunderstood something

    EDIT: one more... Assuming you're using the internal OSC, you want to configure it properly... unless the whole beast will run @32KHz

    OSCCON = %01100000 ' 4MHz

    Don't forget to check your maths range... sure it will overflow the max 100 soon.
    Last edited by mister_e; - 25th March 2008 at 17:15.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    There's something obvious that just jump to my face. You're using the default LCD assignment, and this use a.0, a.1... which is also your adc channels.

    so unless you forgot something in your copy/paste, or i totally misunderstood something

    EDIT: one more... Assuming you're using the internal OSC, you want to configure it properly... unless the whole beast will run @32KHz

    OSCCON = %01100000 ' 4MHz

    Don't forget to check your maths range... sure it will overflow the max 100 soon.
    I use external xtal 4mhz and the below LCD assignment

    Code:
        DEFINE LCD_DREG PORTB		   
        DEFINE LCD_DBIT 4
        DEFINE LCD_RSREG PORTB		   
        DEFINE LCD_RSBIT 2
        DEFINE LCD_EREG PORTB		 
        DEFINE LCD_EBIT 3
        DEFINE LCD_BITS 4		      
        DEFINE LCD_LINES 2

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


    Did you find this post helpful? Yes | No

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    it worked fine here... sorry.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I think Kamikaze47 had the right idea, but mistyped it.

    LCDOut $fe,2,"L:"
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    I think Kamikaze47 had the right idea, but mistyped it.

    LCDOut $fe,2,"L:"
    <br>
    Ok , i will try.

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. 10 bit ADC display on LCD using 16f873
    By pr2don in forum mel PIC BASIC
    Replies: 3
    Last Post: - 6th March 2010, 18:29
  3. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  4. ADC value with 2 decimals on an LCD
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2005, 15:54
  5. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55

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