Pull-ups on 16F88


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2009
    Posts
    7

    Default Pull-ups on 16F88

    Hi, I am monitoring some sensors which provide 0V to 10V output. I have two 4.7K resistors as a divider and all seemed OK but the accuracy was poor. I set the OPTION_REG bit 7 to turn off the internal pull-ups but no good. Some meassurements and calculations indicate the 10k internal resistor is still present.
    With 8 bit resolution I get 255 at 10V but 51 at 0V. I am certain the 10K pull-ups are not diabled but after going over the data sheet a number of times I can't find how to disable them, other than option_reg. I am using portA to display on LCD and have tried ADCIN 5, val and ADCIN 6, val but both have pull-ups to Vdd.
    Any suggestions please.
    Steve

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You are aware that some 0-10v Sensors don't actually start at 0v (you should get 0v if they're unplugged). I usually use 1K or 1K5 1% Resistor values for this job (with a 1uF and 100nF in parallel across the PIC PIN to kill anything nasty arriving down the line).

  3. #3
    Join Date
    May 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Hi and thanks for the reply Melanie, your right some sensors are really modified from 4-20mA loops and don't go to 0V. However these do, also with the sensor unpluged (ie. PIC input is open circuit) the input goes to 5V which makes me sure that it is pulled up to rail.
    As I understand the device there are no internal weak pull-ups on portA so I am going to try using that to see if I have everything else OK, but I need to find a way to use portB.
    Hope you can provide another possible solution.
    Thanks, Steve

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


    Did you find this post helpful? Yes | No

    Default

    Any time you have problems with a port, be it digital or analog, always first look to see what else is connected to the port. In this case, RB6, T1OSO, PGC, and T1CKI all share AN5. Also on AN6 is RB7, PGD & T1OSI.

    Without your code, we can't even begin to debug it. However, we can suggest you read the d/s to make sure that all of those functions are disabled. Also, it could be a hardware issue... if you are using ICSP, there may be interference with the ANx.

    BTW, I don't see any reference to setting the TRIS properly... this is the most obvious issue.

  5. #5
    Join Date
    May 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Hi Tenaja,here is my code for the A/D part of my project. I have tried it and find that accuracy is better the further away from 0V the input voltage is.

    INCLUDE "modedefs.bas"

    @ DEVICE pic16F88, INTRC_OSC_NOCLKOUT ' system clock options
    SI VAR PORTB.1 ' Serial output pin
    SO VAR PORTB.2 ' Serial Input pin
    dig_num var word
    x var word
    num var word
    remain var word

    TRISA = %00000001 'bit 0 (AN/0) is input
    TRISB = %10000010 'bit 7 (AN6) is input bit 1 is serial in
    OSCCON = %01101000 '4MHz clock
    ANSEL = %01000001 'AN0 and AN6 are analog
    ADCON0 = %11110001 'channel 6 is selected
    ADCON1 = %01000000 'Ref is Vdd and Vss
    OPTION_REG.7=1 'dissable weak pull-ups on portB?
    pause 2000 'let power supply settle
    sens_in:
    serout2 SO,813,["Hello",13,10] 'test serial connection
    'see if all registers are set OK
    serout2 SO,813,["ADCON0 = ",#ADCON0,13,10]
    serout2 SO,813,["ADCON1 = ",#ADCON1,13,10]
    serout2 SO,813,["ANSEL = ",#ANSEL,13,10]
    serout2 SO,813,["OSCCON = ",#OSCCON,13,10]
    serout2 SO,813,["OPTION_REG = ",#OPTION_REG,13,10]
    serout2 SO,813,["Before A/D in",13,10]
    'check digital value of A/D before conversion
    serout2 SO,813,["Digital num = ",#dig_num,13,10]
    pause 5000

    ADCIN 6, dig_num 'use chanel 6 (RB7/AN6) as A/D input dig_num is digital result
    while ADCON0.2=1:WEND ' Check to make sure ADC conversion finished..
    pause 250

    serout2 SO,813,["After A/D in",13,10] 'let meknow A/D is finished
    x = dig_num*39
    num = x/1000
    remain = (x//1000)/100
    serout2 SO,813,["dig_num = ",#dig_num,13,10]
    serout2 SO,813,["x = ",#x,13,10]
    serout2 SO,813,["Result = ",#num,".",#remain,13,10]

    pause 5000

    goto sens_in
    end

    An open input results in a 10V reading. I have looked thru the D/S again as you suggested, but cannot find any ref. to internal pull-ups other than setting OPTION_REG.7, though measurement indicates that they exist.
    Sometimes though you see what you expect to and my reg. settings may well be wrong.
    Thanks for the help
    Steve

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,
    Your config statement has noclockout option for osc, you might try INTRC_OSC, I am not too familiar with the PM assembler, in MPASM it says _INTRC_IO, and does not offer a NO_CLKOUT for this chip. Also the FCMEN_OFF should be in there as Device 2 as it is hooked up to the port you are using, put a scope on that port you might see a 32kc signal there . . . maybe.
    the following is from the pm assembler's file about this chip:
    Code:
    					; *** DEVICE Device Definitions
    PIC16F88	equ     50081003h       ; 14-Bit, 4K Code, 256 EE, ID = 3
    
    					; *** DEVICE Fuses Definitions
    EXTRC_OSC_CLKOUT equ    3FEC0013h       ; XX XXXX XXX1 XX11
    EXTRC_OSC_NOCLKOUT equ  3FEC0012h       ; XX XXXX XXX1 XX10
    EXTRC_OSC       equ     3FEC0012h       ; XX XXXX XXX1 XX10
    INTRC_OSC_CLKOUT equ    3FEC0011h       ; XX XXXX XXX1 XX01
    INTRC_OSC_NOCLKOUT equ  3FEC0010h       ; XX XXXX XXX1 XX00
    INTRC_OSC       equ     3FEC0010h       ; XX XXXX XXX1 XX00
    EXTCLK_OSC      equ     3FEC0003h       ; XX XXXX XXX0 XX11
    EC_OSC          equ     3FEC0003h       ; XX XXXX XXX0 XX11
    HS_OSC          equ     3FEC0002h       ; XX XXXX XXX0 XX10
    XT_OSC          equ     3FEC0001h       ; XX XXXX XXX0 XX01
    LP_OSC          equ     3FEC0000h       ; XX XXXX XXX0 XX00
    WDT_ON          equ     3FFB0004h       ; XX XXXX XXXX X1XX
    WDT_OFF         equ     3FFB0000h       ; XX XXXX XXXX X0XX
    PWRT_ON         equ     3FF70000h       ; XX XXXX XXXX 0XXX
    PWRT_OFF        equ     3FF70008h       ; XX XXXX XXXX 1XXX
    MCLR_ON         equ     3FDF0020h       ; XX XXXX XX1X XXXX
    MCLR_OFF        equ     3FDF0000h       ; XX XXXX XX0X XXXX
    BOD_ON          equ     3FBF0040h       ; XX XXXX X1XX XXXX
    BOD_OFF         equ     3FBF0000h       ; XX XXXX X0XX XXXX
    LVP_ON          equ     3F7F0080h       ; XX XXXX 1XXX XXXX
    LVP_OFF         equ     3F7F0000h       ; XX XXXX 0XXX XXXX
    CPD_ON          equ     3EFF0000h       ; XX XXX0 XXXX XXXX
    CPD_OFF         equ     3EFF0100h       ; XX XXX1 XXXX XXXX
    WRT_1FOURTH     equ     39FF0000h       ; XX X00X XXXX XXXX
    WRT_HALF        equ     39FF0200h       ; XX X01X XXXX XXXX
    WRT_3FOURTHS    equ     39FF0400h       ; XX X10X XXXX XXXX
    WRT_OFF         equ     39FF0600h       ; XX X11X XXXX XXXX
    DEBUG_ON        equ     37FF0000h       ; XX 0XXX XXXX XXXX
    DEBUG_OFF       equ     37FF0800h       ; XX 1XXX XXXX XXXX
    CCPMX_ON        equ     2FFF0000h       ; X0 XXXX XXXX XXXX
    CCPMX_OFF       equ     2FFF1000h       ; X1 XXXX XXXX XXXX
    PROTECT_ON      equ     1FFF0000h       ; 0X XXXX XXXX XXXX
    PROTECT_OFF     equ     1FFF2000h       ; 1X XXXX XXXX XXXX
    
    					; *** DEVICE2 Fuses Definitions
    FCMEN_OFF	equ     3FFE0000h       ; XX XXXX XXXX XXX0
    FCMEN_ON	equ     3FFE0001h       ; XX XXXX XXXX XXX1
    IESO_OFF	equ     3FFD0000h       ; XX XXXX XXXX XX0X
    IESO_ON		equ     3FFD0002h       ; XX XXXX XXXX XX1X
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Weak pull Up 12F629
    By Lionheart in forum General
    Replies: 1
    Last Post: - 9th December 2008, 21:07
  2. UPS serial protocol
    By sougata in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th November 2006, 02:49
  3. Counting better ?
    By Franko in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 25th August 2005, 01:27
  4. @ SLEEP with interrupts 16F88
    By drewlash in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th February 2005, 05:55
  5. 4 line LCD with 16F88
    By anj in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th February 2004, 09:06

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