Temperature using LM35 and wind direction using 3 optointerrupters with a 16F873A PIC


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    May 2007
    Posts
    3


    Did you find this post helpful? Yes | No

    Unhappy Programming help...

    I already got the whole circuit working, I already tried turn on a led and it worked, so I need some help with this code, hope anyone can help me, thanks


    DEVICE = 16F873A
    CONFIG WDT_OFF, XT_OSC, CP_OFF, PWRTE_ON, BODEN_OFF , LVP_OFF , DEBUG_OFF
    XTAL = 4
    SYMBOL LED = PORTA.2
    'SYMBOL DIRECTION = PORTB
    DIM TEMPERATURE AS BYTE
    DIM READ AS BYTE
    DIM DIR0 AS BIT
    DIM DIR1 AS BIT
    DIM DIR2 AS BIT
    TRISA=%00000001 'make in porta.0
    ADCON1=%00001010 'analogic porta.0 y digital porta.2

    ADIN_RES = 8 'bits to take un count
    ADIN_TAD = FRC 'oscilator frecuency
    ADIN_STIME = 50 'capacitor's charge time


    DECLARE HSERIAL_BAUD =2400
    DECLARE HSERIAL_RCSTA =%10010000
    DECLARE HSERIAL_TXSTA = %00100010
    DECLARE HSERIAL_CLEAR = ON
    'DECLARE HSERIAL_PARITY = OFF

    TEMPERATURE = ADIN 0
    'HSERIN [DEC READ]
    DELAYMS 600
    WHILE 1
    'HSERIN [DEC READ]
    HSEROUT ["T"]
    HSEROUT [DEC TEMPERATURE]
    HSEROUT ["D"]
    DIR0 = PORTB.0
    DIR1 = PORTB.1
    DIR2 = PORTB.2
    IF DIR0=0 AND DIR1=0 AND DIR2=0 THEN HSEROUT [0]
    IF DIR0=0 AND DIR1=0 AND DIR2=1 THEN HSEROUT [1]
    IF DIR0=0 AND DIR1=1 AND DIR2=0 THEN HSEROUT [2]
    IF DIR0=0 AND DIR1=1 AND DIR2=1 THEN HSEROUT [3]
    IF DIR0=1 AND DIR1=0 AND DIR2=0 THEN HSEROUT [4]
    IF DIR0=1 AND DIR1=0 AND DIR2=1 THEN HSEROUT [5]
    IF DIR0=1 AND DIR1=1 AND DIR2=0 THEN HSEROUT [6]
    IF DIR0=1 AND DIR1=1 AND DIR2=1 THEN HSEROUT [7]
    HSERIN [WAIT(","),DEC LEER]
    DELAYMS 500
    HSEROUT [LEER]
    'IF LEER=1 THEN LED=1 GOTO NEXT
    'SIG:
    'IF LEER=0 THEN LED=0 GOTO NEXT2:
    'SIG2:
    WEND
    END


    I'm having some issues reading temp, can anyone give me some help i dont know what to do now

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


    Did you find this post helpful? Yes | No

    Default

    Did you read the articles on this site?
    http://www.rentron.com/pic.htm
    Are you using Pic Basic?
    Dave
    Always wear safety glasses while programming.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gerardobe View Post
    I'm having some issues reading temp, can anyone give me some help i dont know what to do now
    I'm sure somebody at the correct forums could help.
    PicBasicPro <> Proton Basic

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


    Did you find this post helpful? Yes | No

    Default

    If you're using DEC in HSERIN, you want to use DEC in HSEROUT as well. You USART settings seems weird to me, this following..
    Code:
    DECLARE HSERIAL_TXSTA = %00100010
    But HSEROUT should take care of it. You could still try...
    Code:
    HSERIAL_RCSTA=$90
    HSERIAL_TXSTA=$20
    HSERIAL_SPBRG=25 ' 2400 Bauds
    HSERIAL_CLEAR=ON
    This set manually the PIC USART register.

    Proton forum
    Steve

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

  5. #5
    Join Date
    Apr 2008
    Posts
    23


    Did you find this post helpful? Yes | No

    Default thermometer


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