ADC trouble with PIC16F88


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2008
    Posts
    18

    Default ADC trouble with PIC16F88

    Hello all,

    I'm newbie, the goal of my project it's to use only RA0 in ADC mode and
    the rest of TRISA in a digital input but, in this setting don't work.

    Any help will be appreciated.

    Thanks a lot and regards

    giorgio

    The Code :

    '************************************************* ***************
    '* Name : CONTROLLER.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 26/11/2008 *
    '* Version : 1.0 *
    '* Notes : *
    '* Chip : PIC16F88 *
    '************************************************* ***************
    INCLUDE "MODEDEFS.BAS"
    define OSC 4
    adval VAR BYTE
    i var BYTE
    RPM VAR BYTE




    ADCON0.7 = 1 ' right justify result
    ANSEL = %00000001 ' set AN0 analog, rest digital
    CMCON = 7 ' analog comparators off

    TRISA = %00001111 'RA.0:3 Input
    TRISB = %00000000 'all PORTB output

    Output PORTB.4 ' set RB0 as output
    Output PORTB.5 ' set RB1 as output

    loop:
    ADCIN 0,adval
    IF adval < 90 THEN
    HIGH PORTB.4
    endif

    IF adval > 100 THEN
    LOW PORTB.4
    endif

    COUNT PORTA.2,250,RPM
    for i = 1 to rpm
    toggle PORTB.5
    PAUSE 25
    NEXT i
    LOW PORTB.5
    GOTO loop 'repeat

  2. #2
    Join Date
    Jun 2007
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Do you have a resistor

    Hi and welcome,

    The code appears to be okay to me ( another newbie).
    You don't need these lines as you already set TRISB = 0
    Output PORTB.4 ' set RB0 as output
    Output PORTB.5 ' set RB1 as output

    I just wondered if you have a resister on RA0 to limit the current into the pin.
    If you don't you may damage the PIC.
    Hope this may help.

    Mike

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Howdy,

    This
    Code:
     
    ADCON0.7 = 1 ' right justify result
    should be
    Code:
    ADCON1.7 = 1 ' right justify result
    This may help also
    http://rentron.com/PIC12C67XAD.htm
    Different PIC, same type of ADC.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Nov 2008
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mikendee View Post
    Hi and welcome,

    The code appears to be okay to me ( another newbie).
    You don't need these lines as you already set TRISB = 0
    Output PORTB.4 ' set RB0 as output
    Output PORTB.5 ' set RB1 as output

    I just wondered if you have a resister on RA0 to limit the current into the pin.
    If you don't you may damage the PIC.
    Hope this may help.

    Mike
    Thanks , it was a mistake

  5. #5
    Join Date
    Nov 2008
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Howdy,

    This
    Code:
     
    ADCON0.7 = 1 ' right justify result
    should be
    Code:
    ADCON1.7 = 1 ' right justify result
    This may help also
    http://rentron.com/PIC12C67XAD.htm
    Different PIC, same type of ADC.
    Hello Dave, thanks a lot, but the very big problem it's the IC-PROG and JDM Programmer, that apparently don't give any error but the PIC is not programmed.
    Tomorrow try to unreverse the serial communications signal in the JDM section.

    TNX
    giorgio

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Save your headaches and look to getting a PICKIT2 from MicroChip.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Nov 2008
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Pickit2 buyed

    Quote Originally Posted by mackrackit View Post
    Save your headaches and look to getting a PICKIT2 from MicroChip.
    Hello Dave,
    pickit buyed and running, I've too mounted a 18 pin in a board connected with the ICSP signal.
    It's all ok with pic 16f628, but with 18f88 have this alarm message


    The code :
    '************************************************* ***************
    '* Name : CONTROLLER.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 26/11/2008 *
    '* Version : 1.0 *
    '* Notes : *
    '* Chip : PIC16F88 *
    '************************************************* ***************
    INCLUDE "MODEDEFS.BAS"
    TRISA = %11111111 'RA.0:3 Input
    TRISB = %00000000 'all PORTB output

    ANSEL=%00000001'only porta.0 is analogue
    ADCON1=%00000010'right justify the result(top bits are read as zero)
    CMCON = 7 'Turn off comparators

    adval VAR BYTE
    i var BYTE
    RPM VAR BYTE

    ' 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
    PAUSE 500

    loop:
    ADCIN 0,adval

    serout PORTB.6,n2400, [$FE, 1]
    serout PORTB.6,n2400, [$FE, 2, "pressione ", #adval]
    serout PORTB.6,n2400, [$FE, $C0, "giri", #rpm]

    IF adval < 90 THEN
    HIGH PORTB.4
    endif

    IF adval > 120 THEN
    LOW PORTB.4
    endif

    COUNT PORTA.2,250,RPM
    for i = 1 to rpm
    toggle PORTB.5
    PAUSE 25
    NEXT i
    LOW PORTB.5
    GOTO loop 'repeat

    Any help will be apreciated,
    Thanks a lot

    giorgio

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Can you post you inc file with the config settings?
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Nov 2008
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Hi Dave , I'm at home now, but have the original one from MPASM 8.10 ans pbc Pro 2.50. MicoCode Studio Plus last release.

    Tomorrow (now it's 23,20 pm) I'll post the file.

    tnx

  10. #10
    Join Date
    Nov 2008
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Hi Dave , I've posted the files in a PicBasicPro forum:


    http://www.picbasic.co.uk/forum/showthread.php?t=10207

Similar Threads

  1. ADC Problem with PIC16F88 Configuration
    By robert.quaas in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th April 2009, 17:46
  2. Trouble with PIC16F88 (chip hangs up)
    By nobner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th January 2009, 09:23
  3. PICKIT2 - PBC Pro - PIC16F88 TROUBLE
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 3rd December 2008, 23:37
  4. ADC Vref+ on PIC16F88
    By kblim in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd December 2008, 10:14
  5. ADC conversion trouble
    By PICante in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 30th April 2008, 20:42

Members who have read this thread : 1

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