Home AMX User Forum NetLinx Studio

Programing for a Barco Projector

I am trying to figure out how to program code with a Barco r6 performer. For the time being, I was able to make it work with some of the commands it accepts which are just emulating the IR remote.

The thing I am trying to figure out is to send a certain command that it accepts that gives me 5 things of status of which I need. Here is the code from the manual.

Description :
Read the projector status.

Command :
Command[0] $67

Data :
No data bytes.

Return data :

The return data consists of one data byte containing the
projector status. Only bit0 (least significant bit) to
bit3/bit4* are significant.

bit# bit = 0 bit = 1
bit0 projector is off projector is on
bit1 text is off text is on
bit2 video mute is off video mute is on
bit3 picture is not frozen picture is frozen
bit4* no 800-peripheral 800-peripheral


Example :
Read the status of a projector with address $01.
Suppose the status is projector on, text on, video mute off, picture frozen and no 800-peripheral connected.

Transmit
Start $fe
Projector address $01
Command[0] $67
Checksum $68
Stop $ff

Receive (acknowledge)
Start $fe
Projector address $01
Command[0] $00
Command[1] $06
Checksum $07
Stop $ff

Receive (answer)
Start $fe
Projector address $01
Command[0] $67
Data[0] $0b
Checksum $73
Stop $ff


Really the only thing I am concerned with is the power status and the image freeze. I am planning on just running this command often just running a pseudo loop in the code.

Here is my problem. I really don?t understand the bitwise operators. I really don?t know how to go about extracting these values from the byte. I looked at the bitwise operator document but I wouldn?t know where to begin to even get it from the string it self. I am guessing I would have to get it from a mid string command. All I need it to do is set a 0 or a 1 to a variable for power and freeze then I can correspond that with the buttons I need to show status on. Heres the worst part.. I have 2 of these projectors using the same serial card. It is using the rs- 422 and the 2 projectors are individually addressed as #2 and #3. Another side note, I am using axcess. Would upgrading to netlinx make this a whole lot easier? I just have too much to sit there and constantly poll to get the status on. Nothing really auto sends the amx constantly. Also is there an easier way to get the status by sending the string, then analyzing it by using if commands? I cant think of another way to do so.

Thanks, Ryan

Comments

  • JustinCJustinC Posts: 74
    I will post a little bit to get you started.

    If you take your response string and take the $0b, put it into the windows calculator under HEX and then choose binary. You will see that you get 1011.

    Which tells us, reading from the right to the left.

    Bit 0 is 1 which means the projector is on
    Bit 1 is 1 which means the text is on
    Bit 2 is 0 which means video mute is off
    Bit 3 is 1 which means freeze is on

    now you want to test this with lets say a AND bitwise operator. You will use the equivalent of 1001 binary or $09 to test for just the power and freeze functions.

    If two ones are ANDed together you get a 1 and if a 1 and 0 are ANDed together, you get a 0. So from there you just put that together and see what possible results you can get, or you can AND it against each spot individually, its really your choice. If I find some time tomorrow I will give you a sample piece of code that would work for you and I will write it in Axcess for you.
  • YuriyYuriy Posts: 20
    Bitwise operations

    This paper is intended to accomplish these objectives:
    Understand how numbers are represented and how they correlate to the various data types in the Axcess and NetLinx languages.
    Learn the Bitwise operators and how they work.
    See some practical applications of how the operators are used.
  • ryanwwryanww Posts: 196
    Thanks. I have the bitwise document, and I somewhat understand it, but what I am having a hard time trying to figure out is how to make the code look at the bits and then provide me with feedback. A sample code would be great. I am in no rush so whenever you get a chance that would be great.

    Thanks, Ryan
  • JustinCJustinC Posts: 74
    Okay, I put this together really quickly. There are probably better ways to do it, but I don't do this very often.

    DEFINE_DEVICE
    
    dvPROJ		=1     (* BARCO PROJECTOR *)
    
    
    
    DEFINE_VARIABLE
    
    vcPROJ_BUFF[250]	(* VARIABLE TO STORE BUFFER DATA IN *)
    
    vcRESPONSE[20]		(* VARIABLE TO STORE SELECT BUFFER DATA *)
    
    vcEVAL[1]		(* VARIABLE TO STORE DATA IN WHILE EVALUATING *)
    
    vcTRASH[50]		(* STORE DATA NOT NEEDED *)
    
    vnPOWER			(* TRACK POWER STATUS *)
    
    vnFREEZE		(* TRACK FREEZE STATE *)
    
    
    DEFINE_START
    
    SEND_COMMAND dvPROJ, 'SET BAUD 9600,N,8,1 485 DISABLE'
    
    CREATE_BUFFER dvPROJ,vcPROJ_BUFF	(* TIES THE DEVICE TO THE BUFFER *)
    
    
    
    DEFINE_PROGRAM
    
    IF(LENGTH_STRING(vcPROJ_BUFF))		(* ACCESS BUFFER ONLY IF THERE IS DATA IN IT *)
    {
        vcRESPONSE=REMOVE_STRING(vcPROJ_BUFF,"$FF",1)
        SELECT
        {
    	ACTIVE(FIND_STRING(vcRESPONSE,"$FE,$01,$67",1)):
    	{
    	    vcTRASH=REMOVE_STRING(vcRESPONSE,"$FE,$01,$67",1)
    	    vcEVAL=LEFT_STRING(vcRESPONSE,1)
    	    vcEVAL[1]= vcEVAL[1] BAND $09
    	    SELECT
    	    {
    		ACTIVE(vcEVAL="$09"):
    		{
    		    vnPOWER=1
    		    vnFREEZE=1
    		}
    		
    		ACTIVE(vcEVAL="$08"):
    		{
    		    vnPOWER=0
    		    vnFREEZE=1
    		}
    		
    		ACTIVE(vcEVAL="$01"):
    		{
    		    vnPOWER=1
    		    vnFREEZE=0
    		}
    		
    		ACTIVE(vcEVAL="$00"):
    		{
    		    vnPOWER=0
    		    vnFREEZE=0
    		}
    	    }
    	    
    	    vcRESPONSE=""
    	}
        }
    }
    
    
    
  • ryanwwryanww Posts: 196
    Now instead of using:

    IF(LENGTH_STRING(vcPROJ_BUFF))

    to activate everything, could I use:

    IF(FIND_STRING(vcPROJ_BUFF,$FE,$02,$67,$??,$??,$FF",1)

    that way I will know that it is getting the right string since it does kick a response right back after I send the request string then the actual status string and I know it is for the correct projector.

    Also, what is vcRESPONSE="" down at the bottom for? Is it to just clear the variable?

    Thanks! Ryan
  • JustinCJustinC Posts: 74
    You could use the if find_string statement, I never use question marks, so I couldn't tell you if that will work.


    The vcRESPONSE="" does clear the variable.
  • ryanwwryanww Posts: 196
    Does anyone know how the wildcards work with this sort of thing?

    Thanks,
    Ryan
  • JustinCJustinC Posts: 74
    ryanww wrote:
    Now instead of using:

    IF(LENGTH_STRING(vcPROJ_BUFF))

    to activate everything, could I use:

    IF(FIND_STRING(vcPROJ_BUFF,$FE,$02,$67,$??,$??,$FF",1)

    that way I will know that it is getting the right string since it does kick a response right back after I send the request string then the actual status string and I know it is for the correct projector.

    Also, what is vcRESPONSE="" down at the bottom for? Is it to just clear the variable?

    Thanks! Ryan

    Ryan, I would like to point out that this will work for sure every time based on the info you gave me:

    Obviously it won't ever see the command to request it.

    The acknowledge command start with fe,01,00

    Whereas the data comes back with the start of fe,01,67

    Then you can just copy the whole active statement and paste another one below it and change the find string to fe,02,67 and that would give you any info pertaining to a projector at address 02, etc.
  • JustinCJustinC Posts: 74
    This is kind of what Im talking about in the above post:

    edit: I noticed in the post above I had statements to the effect of ON[7,n] which I was using for testing and are not needed, so I removed them from the post.

    DEFINE_PROGRAM
    
    IF(LENGTH_STRING(vcPROJ_BUFF))		(* ACCESS BUFFER ONLY IF THERE IS DATA IN IT *)
    {
        vcRESPONSE=REMOVE_STRING(vcPROJ_BUFF,"$FF",1)
        SELECT
        {
    	ACTIVE(FIND_STRING(vcRESPONSE,"$FE,$01,$67",1)): 
    	{
    	    vcTRASH=REMOVE_STRING(vcRESPONSE,"$FE,$01,$67",1)
    	    vcEVAL=LEFT_STRING(vcRESPONSE,1)
    	    vcEVAL[1]= vcEVAL[1] BAND $09
    	    SELECT
    	    {
    		ACTIVE(vcEVAL="$09"):
    		{
    		    vnPOWER=1
    		    vnFREEZE=1
    		}
    		
    		ACTIVE(vcEVAL="$08"):
    		{
    		    vnPOWER=0
    		    vnFREEZE=1
    		}
    		
    		ACTIVE(vcEVAL="$01"):
    		{
    		    vnPOWER=1
    		    vnFREEZE=0
    		}
    		
    		ACTIVE(vcEVAL="$00"):
    		{
    		    vnPOWER=0
    		    vnFREEZE=0
    
    		}
    	    }
    	    
    	    vcRESPONSE=""
    	}
    
            ACTIVE(FIND_STRING(vcRESPONSE,"$FE,$02,$67",1)):
    	{
    	    vcTRASH=REMOVE_STRING(vcRESPONSE,"$FE,$02,$67",1)
    	    vcEVAL=LEFT_STRING(vcRESPONSE,1)
    	    vcEVAL[1]= vcEVAL[1] BAND $09
    	    SELECT
    	    {
    		ACTIVE(vcEVAL="$09"):
    		{
    		    vnPOWER2=1
    		    vnFREEZE2=1
    		}
    		
    		ACTIVE(vcEVAL="$08"):
    		{
    		    vnPOWER2=0
    		    vnFREEZE2=1
    		}
    		
    		ACTIVE(vcEVAL="$01"):
    		{
    		    vnPOWER2=1
    		    vnFREEZE2=0
    		}
    		
    		ACTIVE(vcEVAL="$00"):
    		{
    		    vnPOWER2=0
    		    vnFREEZE2=0
    		}
    	    }
    	    
    	    vcRESPONSE=""
    	}
        }
    }
    
    
  • ryanwwryanww Posts: 196
    Well I was able to get it to work just fine. I did run into a large problem that took me a while to figure out though. When I sent it the string to request status, it would do the kick back and with the:

    vcRESPONSE=REMOVE_STRING(vcPROJ_BUFF,"$FF",1)

    it was finding that first string and bringing it into the vcresponce which doesn't have any of the correct data to continue on, so nothing was happening. What I ended up doing was putting an additional remove string to trash the first string then have that line above. Works like a charm. Thanks again!
  • DHawthorneDHawthorne Posts: 4,584
    ryanww wrote:
    Does anyone know how the wildcards work with this sort of thing?

    Thanks,
    Ryan
    I don't believe they do. Inside the double quotes, they are seen as a literal '?'.
  • JustinCJustinC Posts: 74
    ryanww wrote:
    Well I was able to get it to work just fine. I did run into a large problem that took me a while to figure out though. When I sent it the string to request status, it would do the kick back and with the:

    vcRESPONSE=REMOVE_STRING(vcPROJ_BUFF,"$FF",1)

    it was finding that first string and bringing it into the vcresponce which doesn't have any of the correct data to continue on, so nothing was happening. What I ended up doing was putting an additional remove string to trash the first string then have that line above. Works like a charm. Thanks again!

    Well what it should have done is pulled that first line through on the first run through mainline and then it should have processed the next command leading up to the $FF when it ran through mainline again. But either way, Im glad you got it to work.
Sign In or Register to comment.