Home AMX User Forum NetLinx Studio

Problems with projector feedback

Hi, I've been working with a couple hitachi projectors and I was hoping to populate some status variables based on the feedback from the projectors. My problem is that the projectors only send back an acknowlegment when they receive a command (06H), other than that they do not send back any data unless talked to first. They have a get status command I can send but I wanted to update the power variable when the projector is done cooling, and it takes 1:15 to finish. Ive tried a few things one being sending the get command in my data_event followed by a select active. This kind of worked however it severely slowed down my network. I was hoping to get some good insight on how some experienced programmers would handle this. Let me know if you need any other info. Thanks in advance.
(here is the basic idea of what I had done)
String:
{
send_string dvProj, "(get command here)"
select
{
active(proj cool):
{
projCooling=1
}
active(proj off):
{
projCooling=0
projPow=0
}
active(proj on):
{
projCooling=0
projPow=1
}


}
}

Comments

  • DHawthorneDHawthorne Posts: 4,584
    I generally make a repeating timeline that polls status every 5 seconds when the device is on. If my code "thinks" it's off, I won't poll at all until I have sent an on command. It's not the best solution, but it helps the busy network syndrome. I still don't quite get why manufacturers think needing to poll is a good idea; at least give me the choice of unsolicited feedback. In every case, it's quicker to process data coming unsolicited, no matter how much there is, than to have to poll and wait for a response.
  • avi_daveavi_dave Posts: 62
    yeah the timeline would clean that up, or just create a structured function and drop it in the define program(mainline) :), don't drop polling the define event bad idea(my opinion). In your function you can poll depending on the status:- if projector is off you dont need the input status so flag that if on you may need both and adjust the timeline to poll less if on :), and poll on a button press.
  • JeffJeff Posts: 374
    I recently had a HORRIBLE projector like this that I spent about a week doing a module for. I'll try and replicate what I did below, minus all the goofy stuff I include in my modules, so you can understand.
    define_constant
    
    PWR_ON		=	1
    PWR_OFF		=	2
    
    ProjTL	=	2001
    
    define_variable
    
    non_volatile long lProjTimes[]  ={100}
    
    non_volatile	integer 	nStringSent
    non_volatile 	integer 	nCmdList[30]
    non_volatile	integer		nNumCmds
    
    non_volatile	integer		x
    
    non_volatile	integer		ProjectorButtonArray[]	=	{1,2}
    
    non_volatile	char		cProjBuffer[200]
    
    define_function SendCommand(nCmd)
    {
    	switch(nCmd)
    	{
    		//Switch Case on nCmd that chooses what command to send to the projector
    	}
    }
    
    define_function parse()
    {
    	select
    	{
    		active(find_string(cProjBuffer,"'POWER_ON',$0D",1)):
    		{
    			off[vdvProj,PWR_OFF]
    			on[vdvProj,PWR_ON]
    		}
    		active(find_string(cProjBuffer,"'POWER_OFF',$0D",1)):
    		{
    			off[vdvProj,PWR_ON]
    			on[vdvProj,PWR_OFF]
    		}
    	}
    }
    
    define_start
    
    create_buffer dvProj,cProjBuffer
    timeline_create(ProjTL,lProjTimes,1,TIMELINE_RELATIVE,TIMELINE_REPEAT)
    
    data_event[dvProj]
    {
    	string:
    	{
    		if(find_string(cProjBuffer,"$0D",1))
    		{
    			Parse()
    			off[nStringSent]
    			cancel_wait 'StringSent'
    		}
    	}
    }
    
    
    timeline_event[ProjTL]
    {
    	if (!nStringSent)
    	{
    		if (nCmdList[1])
    		{
    			SendCommand(nCmdList[1])
    			for(x=1;x<nNumCmds;x++)	nCmdList[x]=nCmdList[x+1]
    			nCmdList[nNumCmds]=0
    			nNumCmds--
    		}
    		on[nStringSent]
    		wait 45 'StringSent' off[nStringSent]
    	}
    }
    
    button_event[dvTP,ProjectorButtonArray]
    {
    	push:
    	{
    		nNumCmds++
    		nCmdList[nNumCmds]=get_last(ProjectorButtonArray)
    	}
    }
    

    So basically, nCmdList is a queue of up to 30 commands that you would send to your projector. Every time you push a button that does something to the projector, it adds itself to the command list. You could also add things to the command list in other ways, this is just an example. you keep track of nNumCmds so that you know how many commands are currently queued up.

    nStringSent is a variable that tells you whether you have already sent a command to the projector. Every 10th of a second the processor checks to see if you're waiting for a response or not. If you're waiting for a response, it does nothing. If not (if nStringSent has been set to 0 because a response was received), then it sends the next command in the list, deletes it, and moves everything in the list down a step.

    The 'StringSent' wait serves to deal with lost commands and stuff so the whole processor doesn't just get stuck. The particular projector I was dealing with always took 2 seconds to respond to anything, but occasionally took up to 4. I didn't want to send strings every 4 seconds because of those occasional commands, so I wrote this. It sends commands as fast as the projector will allow, but no faster.

    I've stripped this down a lot, my actual module does a ton of other stuff, including resending the command until it gets a response that the command has been acknowledged, but for the purposes of your question I think I've included everything relevant. Please feel free to ask questions if you don't get it all or are just curious, as I may have left something important out.

    J
  • SCOTTYPSCOTTYP Posts: 32
    This is great stuff!

    Thanks for all the info! I saw Daves post and got something working pretty quick. over the weekend. as well as learning a few things along the way. I ended up starting the timeline only when the shutoff command was initiated which worked out perfectly.. Im now messing around with Jeff's just because I have some time on my hands and we have a ton of Hitachi projectors here. Again thankyou, since I dont have anyone to learn from this is my only resource for problems I have not seen before. Oh and Dave whether you know it or not this is at least the fourth problem you have helped me out with, so heres a special thanx to you.
Sign In or Register to comment.