Serin serout problem


Results 1 to 40 of 337

Threaded View

  1. #30
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    ok I changed it a bit, but it is still getting confused about the zero mark.
    stll showing +655.XX celcius
    another thing, the decimal values are going the opposite way in the negative ,
    meaning, -1.96 to -1.90 instead of -1.90 to -1.96
    I have dec2 temperature for the decimal I tried
    1- dec2 temperature but it do not work ...
    end

    So, I can assume that the positive temperature readings are all correct?

    Why are the 2nd and 3rd temp conversion formula's different from the 1st?
    t = 3200 - *5 / 9 instead of t = T*5/9 + 3200 (shortened, you know what they are)

    temperature = ( ~temperature ) + 1 try that also





    loop:
    '23
    waitfor55:
    serin portb.2 , n2400 , temp : if temp <> $55 then goto waitfor55

    waitforaa:
    serin portb.2 , n2400 , temp : if temp <> $aa then goto waitforaa

    serin portb.2, n2400, encoded11.HighBYTE : serin portb.2, n2400, encoded11.LowBYTE
    serin portb.2, n2400, encoded22.HighBYTE : serin portb.2, n2400, encoded22.LowBYTE
    serin portb.2, n2400, encoded33.HighBYTE : serin portb.2, n2400, encoded33.LowBYTE
    serin portb.2, n2400, encoded44.HighBYTE : serin portb.2, n2400, encoded44.LowBYTE

    For counter=0 TO 7 'decoding
    encoded1.0[counter]=encoded11.0[counter*2] : encoded2.0[counter]=encoded22.0[counter*2]
    encoded3.0[counter]=encoded33.0[counter*2] : encoded4.0[counter]=encoded44.0[counter*2]
    Next counter
    '41
    temperature= encoded1 ' putting back together as the original temperature
    For counter=0 TO 7
    temperature.0[counter+8]=encoded2.0[counter+8]
    Next counter

    temperature.LowBYTE = encoded1
    temperature.HighBYTE = encoded2
    count_remain = encoded3
    count_per_c = encoded4

    IF temperature.11 = 1 Then goto Zerotemp
    temperature = ((( temperature >> 1) *100)- 25) + (((count_per_c - count_remain) * 100) / count_per_c)
    tempF = (((temperature /5) *9 ) + 3200)

    lcdout $FE,1, "TempC: ", "+", dec (temperature / 100) , ".", dec2 temperature," ",$DF,"C"
    lcdout $FE,$C0, "TempF: ", "+", dec2 (tempF / 100) , ".", dec2 (tempF // 100)," ",$DF,"F"
    goto loop

    Zerotemp: '------------- cases when zero celcius and positive Fahrenheit
    'temperature = ( ~ temperature ) + 1 ----- do this later, right before displaying it
    '63
    temperature = ((( temperature >>1 ) *100)- 25) + (((count_per_c - count_remain) * 100) / count_per_c)
    tempF = ((temperature /5) * 9) + 3200

    if tempF <= 0 then goto ZeroF

    temperature = ( ~ temperature ) + 1 : tempf = ( ~ tempF ) + 1 ' added this
    lcdout $FE,1, "TempC: ", "-", dec (temperature / 100) , ".", dec2 temperature," ",$DF,"C"
    lcdout $FE,$C0, "TempF: ", dec (tempF / 100) , ".", dec2 tempF ," ",$DF,"F"
    goto loop

    ZeroF: '---------------- cases when zero celcius and 0 Fahrenheit
    tempF = ((temperature /5) * 9) + 3200

    temperature = ( ~ temperature ) + 1 : tempf = ( ~ tempF ) + 1 ' added this
    lcdout $FE,1, "TempC: ", "-", dec (temperature / 100) , ".", dec2 temperature," ",$DF,"C"
    lcdout $FE,$C0, "TempF: ", "-", dec (tempF / 100) , ".", dec2 tempF ," ",$DF,"F"

    goto loop

    end



    Try that....

    I just did an edit... You might have to do the correction/conversion/calculation before you do the 2's complement conversion. I've modified the program for that.
    Last edited by skimask; - 29th December 2006 at 22:01. Reason: Changed program again!

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. serout and serin problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th April 2006, 19:44
  4. Replies: 11
    Last Post: - 13th July 2005, 19:26
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

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