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


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    May 2007
    Posts
    3

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

    Hi!

    First of all I'm a newbie on all this pic programming, This thread it's cos I need some help with coding on pic basic, I'm gonna make a little explanation about my project hope anyone can help me.

    I gotta make a code that senses temperature using a LM35 temperature sensor, and the optointerrupters have to read the wind direction for example im gonna use 3 kind of discs colored with many positions, and each one of the sensors is gonna sense light in many positions, each one of them is gonna represent 3 different truth tables, and this ones are gonna show many wind directions has north , south , west and many others.

    disk1|disk2|disk3|decimalnumber|direction
    0 0 0 0 NORTHEAST
    0 0 1 1 NORTH
    0 1 0 2 WEST
    0 1 1 3 NORTHWEST
    1 0 0 4 EAST
    1 0 1 5 SOUTHEAST
    1 1 0 6 SOUTHWEST
    1 1 1 7 SOUTH

    I'm using a PIC 16F873A and a max232

    This has to be send using to a computer via serial port, I'm seriously in need, i know there's experienced people around please help with this coding, or at least give me some clues where to start.

    Have to say after all this im gonna send all the data to a program in VB that shows all the data taken from the sensors , im very skilled doing .net and java programming, but i never programmed pics before, i already have a pic programmer, please help!
    Last edited by gerardobe; - 21st May 2007 at 09:38.

  2. #2
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post

    First thing you need to do is draw up a schematic of what your attempting to do. Even better yet again would also include a block diagram and software flow chart. This way you make your intentions clear to yourself and anyone else trying to help you. 16f873A is quite possibly not the best to cut your teeth on. Go for a 16f628a to begin with.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gerardobe View Post
    give me some clues where to start.
    WELCOME

    Start off blinking the LED.

    Get everything working a piece at a time.

    Send data to hyper terminal.

    Read the temperature sensor, ADC.

    Send that to the PC.

    SO ON AND SO ON.

    If you have experience in other programing, you know what I mean.
    HELLO WORLD
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    May 2007
    Posts
    3


    Did you find this post helpful? Yes | No

    Cool reading temperature

    hehehe yeah i know what you mean, ok lets getting started i already have mi pc connected to mi pic and i have signal from the port , know what i have to do to receive temperature readings from it ?

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


    Did you find this post helpful? Yes | No

    Default

    I do not use .net, but if it is anything like VB this might help.

    http://www.rentron.com/serial.htm

    Write code in whatever language you are using to read the serial port or use a terminal program for testing.

    If it is an ADC problem with the PIC the above site has a good example.

    Show some code and it will help us to answer questions.
    Dave
    Always wear safety glasses while programming.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gerardobe View Post
    hehehe yeah i know what you mean, ok lets getting started i already have mi pc connected to mi pic and i have signal from the port , know what i have to do to receive temperature readings from it ?
    So does this mean that you can reliably get a PIC to blink an LED? Yes/No? Can you do basic, rudimentary communications, whether it be thru a serial port or USB, between a PIC and a PC?

  7. #7
    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

  8. #8
    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.

  9. #9
    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

  10. #10
    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.

  11. #11
    Join Date
    Apr 2008
    Posts
    23


    Did you find this post helpful? Yes | No

    Default thermometer


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