Home AMX User Forum NetLinx Studio

Barco Projector Hex

So I am trying to get the lamp hours out of a Barco SLM R6 Performer. I don't quite understand how they are sending me the data and what I have to do to just put it in an integer. Here is their explanation of it:

Description : Read the lamp run time in hours.
Command : Command[0] \x64
Data : No data bytes.
Return data : The return data-transfer being the lamp run time in hours
consists of four data bytes. The first byte is the most
significant byte !
Formula : Lamp run time (hours)
= Data[0]*256^3 + Data[1]*256^2 + Data[2]*256 + Data[3]

Example :
Read the lamp run time of a projector with address \x01.
Suppose the lamp run time is 100 hours.

Transmit:
Start \xfe
Projector address \x01
Command[0] \x64
Checksum \x65
Stop \xff

Receive (acknowledge):
Start \xfe
Projector address \x01
Command[0] \x00
Command[1] \x06
Checksum \x07
Stop \xff

Receive (answer)
Start \xfe
Projector address \x01
Command[0] \x64
Data[0] \x00
Data[1] \x00
Data[2] \x00
Data[3] \x64
Checksum \xc9
Stop \xff
lamp run time =
\x00 * 256^3 + \x00 * 256^2 + \x00 * 256 + \x64

Thanks,
Ryan

Comments

  • joelwjoelw Posts: 175
    ryanww wrote:
    So I am trying to get the lamp hours out of a Barco SLM R6 Performer. I don't quite understand how they are sending me the data and what I have to do to just put it in an integer.

    ...

    Receive (answer)
    Start \xfe
    Projector address \x01
    Command[0] \x64
    Data[0] \x00
    Data[1] \x00
    Data[2] \x00
    Data[3] \x64
    Checksum \xc9
    Stop \xff
    lamp run time =
    \x00 * 256^3 + \x00 * 256^2 + \x00 * 256 + \x64

    Thanks,
    Ryan


    For explanation sake, let's say it sends you:
    Data[0] = $01
    Data[1] = $02
    Data[2] = $03
    Data[3] = $04
    

    Then calculate it this way:
    lamphour = 
    (Data[0] << 24) +
    (Data[1] << 16) +
    (Data[2] <<  8) +
    (Data[3])
    
    $01 << 24 = $1000000
    $02 << 16 =   $20000
    $03 <<  8 =     $300
    $04       =       $4
    ---------------
    Sum         $1020304
    
    << or LSHIFT // Left Shift operator.
    

    It returns an unsigned 32 bit value. This would be data type LONG in NetLinx. So be sure to define your lamp time variable as a LONG data type.
  • ryanwwryanww Posts: 196
    Thank you.. I was thinking it was bit wise.. but I really have avoided bitwise as much as I can.. lol.. for obvious reasons.

    Now even though the integer will be 32 bits, the value doesn't needed to be converted down to a 16 bit normal number. It will still have the same value in it correct?

    Thanks again,
    Ryan
  • ryanwwryanww Posts: 196
    I mean in the sense that if it was 100 hours, it would have a value of 100 correct?

    Thanks,
    Ryan
  • joelwjoelw Posts: 175
    ryanww wrote:
    I mean in the sense that if it was 100 hours, it would have a value of 100 correct?

    Thats right.

    In Windows open calculator:
    Start, run, type - calc, then enter.

    Click the hex radio button. Type in 64, then click the Dec radio button. This is a good way for making hex/decimal decimal/hex conversions.
  • ryanwwryanww Posts: 196
    My other question. I have had this stuff running on access for a while now and have just always manually calculated out the checksum bytes for the checksum using a calculator. (I am redoing the system in netlinx, which is why I want to add more functionality.

    But I have never used the mod function that the manual says to do. I have just always added the projector address and the command hex and put the sum in the checksum and it has always worked. But when I went back through the manual, it says your supposed to do this:

    Checksum byte :
    The "checksum byte" is used to detect errors during
    transmission or reception.
    Formula :
    Checksum byte = (Projector address + Command bytes + Data bytes) modulo 256

    So I added this code: nChecksumAdd = ((nProjectorAddress + nCommand_0)%256)

    That should work correct?

    Thanks again,
    Ryan
  • joelwjoelw Posts: 175
    ryanww wrote:
    Checksum byte :
    The "checksum byte" is used to detect errors during
    transmission or reception.
    Formula :
    Checksum byte = (Projector address + Command bytes + Data bytes) modulo 256

    So I added this code: nChecksumAdd = ((nProjectorAddress + nCommand_0)%256)

    That should work correct?

    Yes that is correct. It returns the lower byte of the checksum.

    Another way this could be written would be to use a bitwise AND operator:
    nChecksumAdd = ((nProjectorAddress + nCommand_0) & 0xFF)
  • ryanwwryanww Posts: 196
    Awesome!

    Thanks for the help!

    Ryan
Sign In or Register to comment.