serial communication problem


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Posts
    5

    Default

    hi aratti...i hv tried to change my temp equation from your information but the temperature still not showing correctly..can you plz check my code..

    INCLUDE "modedefs.bas"
    define FOSC 4
    define LCD_DREG PORTD
    define LCD_DBIT 4
    define LCD_RSREG PORTD
    DEFINE LCD_RSBIT 2
    define LCD_EREG PORTD
    define LCD_EBIT 3
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    'HIGH PORTD.1
    C VAR WORD


    TRISC = %10111111 ' Set TX (PortC.6) to out, rest in
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $20 ' Enable transmit, BRGH = 0
    SPBRG = 25 ' 9600 Baud @ 0.16%
    SPBRGH = 0
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator


    define ADC_BITS 10
    define ADC_CLOCK 3
    define ADC_SAMPLEUS 50

    lmtemp var word
    temp var byte
    vout var byte
    quanta con 1250
    TRISE = %111
    ADCON1 = 0


    MAIN:

    ADCIN 6, lmtemp
    vout = lmtemp/205
    temp = (Vout*100)-50

    LCDOUT $FE,1
    LCDOUT " Programmed by"
    LCDOUT $FE,$C0
    lcdout "YAN^S TEMP="
    LCDOUT #temp
    LCDOUT " C"
    'HIGH PORTD.1


    HSEROUT [dec temp,10]
    HSerout ["The Temp Are Now ",#temp,"C",13]


    pause 100
    GOTO MAIN
    end

    tq very much...

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825

    Default

    Try this way:

    Code:
    ADCIN 6, lmtemp
    vout =(lmtemp*100)/205
    temp = Vout-50
    Or if you need decimals

    Code:
    ADCIN 6, lmtemp
    vout =(lmtemp*49)-5000
    Integer_Byte = Vout/100
    Decimal_Byte = Vout//100
    Hserout ["Temp = ",Dec Integer_Byte,".",Dec2 Decimal_Byte," °C",13,10]
    Make Vout a word variable ; Interger_Byte and Decimal_Byte byte variables

    Al.
    Last edited by aratti; - 9th March 2010 at 17:29.
    All progress began with an idea

Similar Threads

  1. Replies: 18
    Last Post: - 4th July 2017, 14:26
  2. Replies: 5
    Last Post: - 20th March 2006, 01:34
  3. Serial Communication Problem
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 23rd February 2006, 02:11
  4. Problem in Serial Communication
    By uuq1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th June 2005, 07:17
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

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