Serin serout problem


Closed Thread
Results 1 to 40 of 337

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yes the positive values works just fine,
    I dont why you are doing 2,s compliment twice in the zerotemp.
    I saw that program , but there was too many things I did not understand, like this line:
    Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value

    Why multiply by 625..


    I also tryed it as is: ( it get stuck at 0.00 C and stays there)

    loop:
    '24
    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
    '40
    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
    '58
    Zerotemp: ' cases when zero celcius and positive Fahrenheit

    Dummy = 625 * ~temperature+1' Multiply to load internal registers with 32-bit value
    TempC = DIV32 10 ' Use Div32 value to calculate precise deg C
    TempF = ~temperature / 16 ' Begin conversion from -C to deg +/-F
    IF TempF >=18 THEN ' Check for -degrees F "-18 C = -0.4 F"
    TempF = ((((TempF + 50) * 9) /5) -122) ' -C to -F below -17 deg C
    lcdout $FE,1, "TempF: " ,"-" , DEC TempF,$DF,"F "
    lcdout $FE,$C0, "TempC: ", "-",DEC TempC DIG 4, DEC TempC DIG 3,".",DEC3 TempC, $DF,"C "

    ELSE ' Else result = +deg F
    TempF = ((((-TempF + 50) * 9) /5) -58)' -C to +F below 32.0 deg F to -17 deg C
    lcdout $FE,1, " TempF: " , "+", DEC TempF, $DF,"F "
    lcdout $FE,$C0, " TempC: ","-" ,DEC TempC DIG 4,DEC TempC DIG 3,".",DEC3 TempC,$DF,"C "

    ENDIF
    goto loop

    end
    Last edited by lerameur; - 29th December 2006 at 22:36.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    yes the positive values works just fine,
    I dont why you are doing 2,s compliment twice in the zerotemp.
    I saw that program , but there was too many things I did not understand, like this line:
    Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value

    Why multiply by 625..

    end
    I'm not doing the 2's compliment twice, the first one is commented out, the 2nd is for the + case, the 3rd is for the - case. It won't get done more than once.

    Do you have your PBP manual handy by chance?
    I'm still looking at the rest of your code in your last post, I wanna show you some stuff about 32 bit math in the PBP manual that might help.
    Last edited by skimask; - 29th December 2006 at 23:20.

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    ya the manual is right here:

    I get this code , still not working , but better:

    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
    temp1 = temperature
    temperature = ( ~ temperature ) + 1 '----- do this later, right before displaying it
    '63
    tempc =temperature
    temperature = ((( temperature ) *100)- 25) + (((count_per_c - count_remain) * 100) / count_per_c)
    tempF = ((temperature /5) * 9) + 3200

    if tempF <= 0 then goto ZeroF

    'lcdout $FE,1, bin temp1 , ".", bin temperature ," ",$DF,"C"
    'lcdout $FE,$C0, bin tempc , ".", dec tempc/2 ," ",$DF,"F"

    '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

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    [QUOTE=lerameur;30245]ya the manual is right here:

    Page 33-35, 32 bit math, that will explain the code from Rentron.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post

    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
    That 2nd conversion is done twice... once after Zerotemp & once after ZeroF.

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    That 2nd conversion is done twice... once after Zerotemp & once after ZeroF.
    O yes, I removed it, anyway I cant test that cold yet

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    O yes, I removed it, anyway I cant test that cold yet
    No, but you can simulate it at the transmitter end with a loop instead of reading the temp sensor....duh!!!

    Just set up the transmitter to send out a slowly changing temperature that goes up the scale, resets to the low end, climbs back up again, whatever works for you.
    Or do it at the receiver end, put a couple of buttons in there, one button-temp goes up, another button-temp goes down.

  8. #8
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    ok , I get that now,
    I want to concentrate on the cold but not that cold part for now.. the sensor is sticking outsid now, its about -11C
    I wanted to see what was behing calculated..
    The 2's compliment, the binary value gives me a good degree (tempc)
    when I put it in the equation it then screws up, I think the 2 byte count_per_c AND count_remain and different since it is in negative mode... hummm
    Nothing is siad about this in the specsheet either, and the program on Rentron does not use that part.

    here is the code:

    Zerotemp: '------------- cases when zero celcius and positive Fahrenheit
    temp1 = temperature
    temperature = ( ~ temperature ) + 1 '----- do this later, right before displaying it
    tempc =temperature
    temperature = ((( temperature ) *100)- 25) + (((count_per_c - count_remain) * 100) / count_per_c)
    tempF = ((temperature /5) * 9) + 3200
    if tempF <= 0 then goto ZeroF
    lcdout $FE,1, dec temp1 , ".", dec temperature ," ",$DF,"C"
    lcdout $FE,$C0, dec temperature, dec tempc , ".", dec tempc/2 ," ",$DF,"F"
    temperature," ",$DF,"C"

    goto loop

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