Multi-digit word variable to string


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    According to the manual of the display and the VISI GENIE OS.

    The following is an example.

    Name:  command2.png
Views: 4002
Size:  81.8 KB

    I'm missing something, because right now as the code is, returning from the Checksum calculation, the HSEROUT command is set right. But i do get HEX result. Right?

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    The number is just the same either hex, binary or decimal. 128 is the same as %10000000 or $80. You show it in different way.

    The trackbar object, what exactly is?

    Ioannis

  3. #3
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    Trackbar is only an object ID in VISI GENIE OS for the Display like the following.

    Name:  command3.png
Views: 3569
Size:  54.5 KB

    in our case we do use the LEDDIGITS which the OBJECT ID is $0F

    Name:  command4.png
Views: 3328
Size:  37.8 KB

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    OK, I see.

    So, if you want to move the trackbar to position $28 you will use

    Code:
    HserOut [$01,$05,$00,$00,$28,$2C]
    and the slider will goto position $28.

    But I guess you have to set beforehand the two ends of the trackbar? I mean the zero can be 100 and the maximum position 200, or whatever.

    Can you try and see if you can move the trackbar just by sending straight in values? and the CRC computed by hand.

    Then you may do more complicated things.

    Ioannis

  5. #5
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    in my case i do not use the trackbar, but the LED digits as shown below.

    Name:  command5.png
Views: 3421
Size:  90.0 KB

    In the software 4D SYstems they have, you can set manually a number for example 167, and will show you the command as shown in the SET DIGIT VALUE:

    Name:  command6.png
Views: 3419
Size:  36.4 KB

    I have tried to give manually a constant number and it worked!

    what i did is:

    i set a new var mTEMP ' for manually hex number and
    a new var mTEMPIR ' for manually hex number as well.

    In our case the number 167 for:

    Code:
    mTEMP = $00
    mTEMPIR = $a7
    then i did the CS calculation and return to the HSEROUT command.

    Code:
    IRCS=0
    IRCS= $01^$0F^$00^mTEMP
    IRCS = IRCS ^ mTEMPIR
    I placed it with:

    Code:
    HSEROUT [$01,$0F,$00,mTEMP,mTEMPIR,IRCS)
    then i got the right result on the display.

    The problem is that when i use the variables i cannot get the right values.
    Last edited by astanapane; - 18th December 2021 at 23:14.

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,705


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    i assume the real question in this jumble is how do i sent a word var as a binary number msb first using hserout

    Temp var word
    Temp=167


    HSEROUT [$01,$0F,$00,Temp.highbyte,Temp.lowbyte,IRCS)
    Warning I'm not a teacher

  7. #7
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    Richard!!!!

    it really worked!!!

    Code:
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '                         VAR for IR to LCD          '
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    IRCS         var byte       ' this is the checksum for the IR required in external display command
    TEMP         var word       ' this is the word variable for TEMP 
    temperature  var word       ' for result and output to lcd 
    TEMPIR       var word       ' set a variable tempir 
    Remainder    var word       ' Get the remainder = tempir//50
    
    '------------------------------------------------------------------------------*
    '                    Measure IR object temp sent to uLCD                          *
    '------------------------------------------------------------------------------*
    object:
    
    reg    = $07             ' based on the datasheet $07 is the object's temp
    addr   = %10110100       ' $B4  binary value: %10110100
    i2cwrite SDA, scl, addr  ' send write command, shift the address B4, 8 bits where LSB is W = 0
    i2cwrite sda, scl, reg   ' register is $07
    
    addr   = %10110101       ' $B5  Binary value: %10110101
    i2cwrite sda, scl, addr  ' sends read command, shift the address B5, 8 bits where LSB is R = 1, clock idles low
    i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte] ' reg = $07
    
    tempir = (temp.highbyte << 8) + temp.lowbyte
    
    temperature  = tempir/50         ' based on the manual we need to divide by 50 or 0.02
    temperature  = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15
    remainder    = (tempir*2)//100   ' multiply x 2 and get the remainder //100
    
    pause 100
    gosub display
    return
    
    '------------------------------------------------------------------------------*
    '                    IR  Display 1 the parameters                              *
    '------------------------------------------------------------------------------*
    display: ' IR TEMP 
    hserout2 [$73,$00,$02,$12,$00,$ff,"IR TEMP:",00]
    Hserin2  timeout,error,[wait(6)]
    hserout2 [$73,$08,$02,$12,$F8,$00,dec2 temperature,".",dec2 remainder,"*C",00] 'this one works on display 1 which doesnt require CS 
    Hserin2  timeout,error,[wait(6)]
     
    
    gosub checksum2    
    HSEROUT [$01,$0F,$00,temperature.highbyte,temperature.lowbyte,IRCS)   ' this one works.
    Hserin  timeout,error,[wait(6)]
    return
    
    '------------------------------------------------------------------------------|
    '                               CHECKSUM IR                                    |
    '------------------------------------------------------------------------------|
    checksum2:
    IRCS = 0
    IRCS = $01 ^ $0F ^ $00 ^ temperature
    'IRCS = IRCS ^ remainder ' commended this as i need to figure out how to import it in the HSEROUT command.
    return
    Now i'm trying to figure out how to add the remainder in the command.

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