Menu

Get pic to do big math

Help
2009-08-12
2013-05-30
  • Nobody/Anonymous

    using this:
    sub Bin2ascii2 (LCDValue)#NR
    SERCEN = 0 
    SERDEC = 0 
    SERUN = 0 
    LCDValueTemp = 0
      'If LCDValue >= 100 Then
    if sertho = 51 then
    LCDValueTemp = LCDValue + 768
    end if
    if sertho = 49 then
    LCDValueTemp = LCDValue + 256
    end if
    if sertho = 50 then
    LCDValueTemp = LCDValue + 512
    end if
    if sertho = 48 then
    LCDValueTemp = LCDValue
    end if
    lcdvaluetemp = lcdvaluetemp *10
    lcdvaluetemp = lcdvaluetemp - 255
    lcdvaluetemp = lcdvaluetemp  * 18
    lcdvaluetemp = lcdvaluetemp / 10
    lcdvaluetemp = lcdvaluetemp + 16

    lcdvaluetemp = lcdvaluetemp / 100
    SERCEN = LCDValueTemp + 48
    Xmit_RS232(SerCen)
    LCDValue = LCDValue - LCDValueTemp * 100 
    'end if
    'IF LCDValueTemp > 0 OR LCDValue >= 10 then 
    LCDValueTemp = LCDValue / 10 
    SERDEC = LCDValueTemp + 48 
    Xmit_RS232(Serdec)
    LCDValue = LCDValue - LCDValueTemp * 10 
    'end if

    SERUN = LCDValue + 48 
    Xmit_RS232(Serun)
    end sub

    I have to make the modifications to the number to make adjustments that involve decimals and the pic does not seem to handle decimals, so i have to multiply the numbers then divide them back down, but when the number gets too large it loses the high byte  of the number and gives a false result. how can i get get by this?

     
    • Edward LaBudde

      Edward LaBudde - 2009-08-12

      Are you using word variables?

       
    • Nobody/Anonymous

      yes

       
    • Santiago

      Santiago - 2009-08-13

      I think it should work if you use:

      Dim lcdvaluetemp as word

      And LCDValue > 26 to avoid negatives

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.