How to make a word as decimal in if then else statement


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Yeah, I'm using the pro version.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Your lines look to be an uncontrolled mix of Basic and C languages ...

    So, it will be rather difficult to help you ...

    BTW "Jeroen" ... that reminds me something...
    what's your mother language ???

    I'd bet Dutch ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Jan 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    You're correct. I'm from Holland, a dutch guy...

  4. #4
    Join Date
    Jan 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    I will explain what I am trying to do... maybe it helps... in bad english, lol

    I've got 2 components, a DS1820 and a simple LED, both on other ports.
    When the DS1820 gets on 21,2celcius for example, the LED must blink, on 21,2+ the LED stays on, on 21,2- the LED turns off. The code I've got to control the DS1820 is:

    Code:
    Above clear:
    SYMBOL Convert      = $44 
    SYMBOL RdScratchPad = $BE
    SYMBOL SkipROM      = $CC
    SYMBOL Graad        = 223    
    SYMBOL DS1820       = PORTA.1
    SYMBOL verwarming   = PORTA.6
    
    DIM Temp            AS WORD
    DIM Remain          AS BYTE
    DIM Slope           AS BYTE
    DIM BD1             AS BYTE   
    
    --------
    
      OWRITE DS1820, 1, [SkipROM, Convert]
      OWRITE DS1820, 1, [SkipROM, RdScratchPad]
      OREAD  DS1820, 2, [Temp.LOWBYTE, Temp.HIGHBYTE, BD1, BD1, BD1, BD1, Remain, Slope] ',CRC]
     
      Temp = (((Temp >> 1) * 100) - 25) + (((Slope - Remain) * 100) / Slope)                
                                                                    
      PRINT AT 1, 1, DEC Temp / 100, ".", DEC1 Temp / 10, Graad, "C  "
    [edit]
    by the way, verwarming is dutch... but doens't mather... it's just a symbol
    [/edit]
    But how can i control the LED with the code above? I used a IF then ELSE statement on Temp but Temp shows only symbols (not with DEC in front of it at the PRINT line, so not on LCD with that code)

    [edit2]
    When i use this, just for example what Temp do without DEC, I get the most funnyest symbols and icons on LCD
    Code:
      PRINT AT 1, 1, Temp
    Anyhow... I need to put it in a If then Else statement... to control the led
    [/edit2]
    Last edited by jeroeni; - 24th January 2011 at 15:36.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jeroeni View Post
    I will explain what I am trying to do... maybe it helps... in bad english, lol

    I've got 2 components, a DS1820 and a simple LED, both on other ports.
    When the DS1820 gets on 21,2celcius for example, the LED must blink, on 21,2+ the LED stays on, on 21,2- the LED turns off. The code I've got to control the DS1820 is:

    Code:
    Above clear:
    SYMBOL Convert      = $44 
    SYMBOL RdScratchPad= $BE
    SYMBOL SkipROM      = $CC
    SYMBOL Graad        = 223    
    SYMBOL DS1820       = PORTA.1
    SYMBOL verwarming   = PORTA.6
     
    DIM Temp            AS WORD
    DIM Remain          AS BYTE
    DIM Slope           AS BYTE
    DIM BD1             AS BYTE   
     
    --------
     
      OWRITE DS1820, 1, [SkipROM, Convert]
      OWRITE DS1820, 1, [SkipROM, RdScratchPad]
      OREAD  DS1820, 2, [Temp.LOWBYTE, Temp.HIGHBYTE, BD1, BD1, BD1, BD1, Remain, Slope] ',CRC]
     
      Temp = (((Temp >> 1) * 100) - 25) + (((Slope - Remain) * 100) / Slope)                
     
      PRINT AT 1, 1, DEC Temp / 100, ".", DEC1 Temp / 10, Graad, "C  "
    [edit]
    by the way, verwarming is dutch... but doens't mather... it's just a symbol
    [/edit]
    But how can i control the LED with the code above? I used a IF then ELSE statement on Temp but Temp shows only symbols (not with DEC in front of it at the PRINT line, so not on LCD with that code)
    Try to use PBP commands for the words I've put in RED ...

    Will work much better ... ... IF YOU USE PICBASIC PRO, WHICH IS NOT THE CASE ...

    Alain
    Last edited by Acetronics2; - 24th January 2011 at 16:44.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    calm down Alain

    jeroeni seems you're using another variant of PICBasic compiler, to me it looks like Proton Picbasic whose forum is located at the following link

    http://www.protonbasic.co.uk/forum.php?

    HTH
    Steve

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

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi, Steve

    Sorry ... I couldn't recognise this one ... which is running fine.

    Code:
    ' One-wire temperature for PROTON Board and DS1820
    Include "PROTON_4.INC"
     
    Dim Temperature As Word ' Temperature storage
    Dim Count_remain As Byte ' Count remaining
    Dim Count_per_c As Byte ' Count per degree C
    Dim Dum As Byte ' Dummy variable to pad OWIN
    Symbol DQ = PORTC.0 ' One-wire data pin
    DelayMS 500 ' Wait for PICmicro to stabilise
    Cls
    Mainloop: 
    OWrite DQ, 1, [$CC, $44] ' Start temperature conversion
    While ORead DQ, 4 = 0 : Wend ' Check for still busy converting
    OWrite DQ, 1, [$CC, $BE] ' Read the Temperature
    ORead DQ, 0, [Temperature.LowByte, Temperature.HighByte, Dum,Dum,Dum,Dum, Count_remain, Count_per_c]
    ' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)
    Temperature = (((Temperature >> 1) * 100) - 25) + (((Count_per_c - Count_remain) * 100) / Count_per_c)
    Print $FE, 1, Dec (Temperature / 100), ".", Dec2 Temperature, " C"
    ' Calculate temperature in degrees F to 2 decimal places (not valid for negative temperature)
    Temperature = (Temperature */ 461) + 3200
    Print $FE, $C0, Dec (Temperature / 100), ".", Dec2 Temperature, " F"
    DelayMS 1000 ' Display once a second
    GoTo Mainloop ' Do it forever
    
    mackrackit

    Are you using Pic Basic (PRO) ?
    jeroeni
    Yeah, I'm using the pro version
    Ok, Ok ...
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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