18f4550 a/d


Results 1 to 7 of 7

Thread: 18f4550 a/d

Threaded View

  1. #1
    Join Date
    Feb 2010
    Posts
    17

    Post 18f4550 a/d

    Hi all.
    I have done A/d to with success with 16f877 and16f887 now I have a problem with 18f4550 the value is fluctuating so much even in the high rail I still get values between 1023 and 1018 and in the low rail some times go up to 8. I think it's a TAD problem but I let you guys help me out.
    Here is the code(nothing fancy just read and display):
    Code:
    ==========================MCU SETUP============================================  
    DEFINE OSC 48
    Include "modedefs.bas"
    '***************************LCD DEFINE******************************* 
    DEFINE LCD_DREG PORTD 'LCD data port 
    DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4 
    DEFINE LCD_RSREG PORTD 'LCD register select port                      
    DEFINE LCD_RSBIT 5 'LCD register select bit , RS=PORTE.2
    DEFINE LCD_EREG PORTD 'LCD enable port 
    DEFINE LCD_EBIT 7 'LCD enable bit E=portE.0 
    DEFINE LCD_RWREG PORTD 'LCD read/write port 
    DEFINE LCD_RWBIT 6 'LCD read/write bit R/W=POTRD.1
    DEFINE LCD_BITS 4 'LCD bus size 4 or 8 
    DEFINE LCD_LINES 4 'Number lines on LCD 
    DEFINE LCD_COMMANDUS 2000 'Command delay time in us 
    DEFINE LCD_DATAUS 50
    '******************************************************************
    DEFINE ADC_BITS 10     ' ADCIN resolution  (Bits)
    DEFINE ADC_CLOCK 3     ' Work around that sets Vref bits in ADCON1
    DEFINE ADC_SAMPLEUS 50 ' ADC sampling time (uSec)
    
    
    '==========================I/O SETUP============================================
    
    
     
    TRISD=0
    TRISE=0
    TRISC=%10000000
    TRISA=%11111111
    TRISB=0
    
    ADCON1=14
    ADCON2=%10000000
     
    
    '================================variables======================================
    adcval var word 
    TX VAR PORTC.6
    RX VAR PORTC.7
    
    '==============================BAUD SETUP=======================================
    N96 con 16416 ' Inverted 19200 baud for the lcd rs232  
    T192 con 32 '19200 TTL 
    T96 CON 84'9600 TTL
    T38 CON 6'38K
    '==========================I/O SETUP============================================
    '======================LCD LINES SETUP==========================================
    L1 CON 1 'LINE1
    L2 CON $C0'LINE2
    L3 CON $94'LINE3
    L4 CON $D4'LINE4
    
    CLEAR
    
    '=============================================================================
    
      
    PAUSE 500
    loop:
    LCDOUT $FE,l1
    PAUSE 50
    LCDOUT "a/d test" 
    
     
    MAIN:
    
    gosub adc0
    lcdout $fe,l2
    lcdout "pot:" ,dec adcval,"  "
    pause 600
     
    GOTO MAIN
    
    
    '=================================ADC0==========================================
    ADC0:
    ADCin 0, adcval
    pause 50
    
    RETURN            
    '==============================================================================
    
    END

    can you please help have a 0.1uf between the input and ground of AN0 the power supply is solid do not change.
    ground wire from PS to MCU and to analog input.
    anything I'm missing.
    tried to change
    DEFINE ADC_CLOCK 3 to 0 then 2 then 6 with no help.
    Last edited by Archangel; - 27th November 2013 at 19:13. Reason: code tags

Similar Threads

  1. 18f4550
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 21st June 2007, 19:03
  2. 18f4550 help, please
    By dalibor in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th June 2007, 21:55
  3. 18f4550
    By alaaodeh in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd February 2007, 18:33
  4. 18f4550
    By vanxn in forum USB
    Replies: 2
    Last Post: - 27th June 2006, 20:40
  5. 18f4550
    By vanxn in forum USB
    Replies: 1
    Last Post: - 27th June 2006, 19:59

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