Home AMX User Forum NetLinx Studio

Parasound Z-Tuner Rs232

I am currently working on the feedback for a parasound z-tuner, but i am a little stuck atm. Everything seems to be working execpt you have to push the button to go to the preset twice for it to display the feedback correctly. Anyone had any success on this? Or any ideas on how to fix it?

i attached the source file

thanks for taking a look

Chris Ondrovic

Comments

  • jjamesjjames Posts: 2,908
    Ahh - the glorious ZTuner. You're sending the text to the panel BEFORE you're requesting the feedback. I would put the SEND_COMMAND dvTP1,"'TEXT500-',strStationA,'.',strStationB" at the end of Active(nRxMd = 6).

    From my little_bird(), you should expect to see a new ZTuner in not too long. The next version supposedly supports unsolicited feedback, and supposedly the RS-232 structure will be different. A module is supposedly in the works to be hopefuly released when the new ZTuner is out.
  • ondrovicondrovic Posts: 217
    jjames,

    Thanks for the reply I will give that a shot when I get to the office in the morning. I will keep you posted.

    Good to know about the new Ztuner we shall see about it features :)
    Thanks again

    Chris Ondrovic
  • ondrovicondrovic Posts: 217
    Now I am not getting any feed back, lol
  • jjamesjjames Posts: 2,908
    DOH! - Ok, perhaps my logic is a bit off. I'm used to parsing it a completely different way. I've got a ZTuner here, so I'll play with it too.
  • ondrovicondrovic Posts: 217
    thanks I am currently working on it only might have botched it somewhere so i am starting over. Thanks again
  • jjamesjjames Posts: 2,908
    I must be missing something in code, but the variables get filled with the preset, it just doesn't send it to the panel.
  • jjamesjjames Posts: 2,908
    WOW! My brain is completely non-functional in the morning. Are you sure you're not getting feedback? It's sending it to my panel. Here's the code I've got. It wasn't sending to my panel (well, couldn't see it in the notifications) because I didn't have a panel addressed to 10003.

    I had to comment out the modules for it to compile, BTW.
  • ondrovicondrovic Posts: 217
    nope still no feedback going to try something real quick
  • jjamesjjames Posts: 2,908
    can you verify that strStationA and strStationB is getting populated correctly?
  • jjamesjjames Posts: 2,908
    I REALLY need to switch my avatar back to pounding my head into the computer screen!!

    The TEXT command only supports addresses up to 255. Try using ^TXT instead.
    "'^TXT-500,0,',strStationA,'.',strStationB"
    

    But you said you were getting feedback before? How can that bee if the TEXT command only supports addresses up to 255?
  • ondrovicondrovic Posts: 217
    i opened up debugging and added strStationA and strStationB but it looks like they aren't populating

    trying what you said about the ^TXT

    still not getting the stations vars to populate
  • jjamesjjames Posts: 2,908
    Okay - well, that code I posted, is working just fine for me. I'm looking at my panel, and it just got the text. I did however move it out of the ACTIVE, so it's this now:
    Define_Function Parse_Data(Char strData[])
    {
        nRxMd = ATOI(Mid_String(strRxCmd,5,1))
        Select
        {
    		Active(nRxMd = 1):	
    		{
    			nLength = Length_String(strResponse)
    			nPwrStat = ATOI(Left_String(strResponse,nLength))
    			strDebug = 'Process Power Status'
    			strTrash = Remove_String(strResponse,"13",1)
    		}
    		Active(nRxMd = 3):	
    		{
    			nLength = Length_String(strResponse) - 2
    			nTunerPst = ATOI(Left_String(strResponse,nLength))
    			strDebug = 'Process Preset Status'
    			strTrash = Remove_String(strResponse,"13",1)
    			strRxCmd = "'R 1 3 1',13"
    		}
    		Active(nRxMd = 6):
    		{
    			strWork = Remove_String(strResponse,"10",1)
    			nLength = Length_String(strWork) - 2
    			strStationA = Left_String(strWork,nLength)
    			strTrash = Remove_String(strWork,strWork,1)
    			strWork = Remove_String(strResponse,"10",1)
    			nLength = Length_String(strWork) - 2
    			strStationB = Left_String(strWork,nLength)
    			strTrash = Remove_String(strWork,strWork,1)
    			strDebug = 'Process Station Status'
    			strTrash = Remove_String(strResponse,strResponse,1)
    			strRxCmd = "'R 1 6',13"
    			
    		}
        }
    	SEND_COMMAND dvTP1,"'^TXT-500,0,',strStationA,'.',strStationB"
    }
    
  • ondrovicondrovic Posts: 217
    ok i will keep playing with it and see why its not working thanks for all the help
  • ondrovicondrovic Posts: 217
    well i started over clean workspace and was just working on it but i cant seem to get the strStationA & strStationB to populate so I think thats the problem :)


    well that is just strange

    i have 2 ztuners on this job and i switch over to the second one and it worked fine maybe my 1st tuner is fubared LOL thanks again
  • jjamesjjames Posts: 2,908
    Ya Didn't Break It (completely)

    Okay . . . I was going to ask you to monitor the responses from the ZTuner, but you beat me to the punch. When the ZTuner freaks out, it's normally because strings were sent to it too quickly. There must be at least a 200ms delay between strings sent to the device. There seems to be two types of respones protocols in the ZTuner, which I've had to put a band-aid on my code to fix it.

    If it's not sending you the documented protocl, it's more than likely sending you an INTEGER based protocol - much easier to parse. Here's the code I use when it flips out.
    STRING:
    {
    	LOCAL_VAR INTEGER RECIEVED_STRING[2]
    	
    	IF(FIND_STRING(DATA.TEXT,"$0D,$0A",1))
    	{
    		// PARSE IT THE DOCUMENTED WAY . . .
    	}
    	ELSE
    	{
    		IF(LENGTH_ARRAY(DATA.TEXT)=2)
    		{
    			RECIEVED_STRING[1] = DATA.TEXT[1]
    			RECIEVED_STRING[2] = DATA.TEXT[2]
    		}
    		ELSE
    			RECIEVED_STRING[1] = DATA.TEXT[1]
    		SELECT
    		{
    			ACTIVE(nRADIO_REQ=nRADIO_POWER_REQ):
    			{
    				ZTUNER_STATUS[ZTUNER_POWER][1]=RECIEVED_STRING[1]
    				
    				WAIT 2.5
    				{
    					nRADIO_REQ=nRADIO_PRESET_REQ
    					SEND_STRING dvZTUNER,"'R 1 3 1',13" // Request Preset
    				}
    			}
    			ACTIVE(nRADIO_REQ=nRADIO_PRESET_REQ):
    			{
    				ZTUNER_STATUS[ZTUNER_PRESET][1]=RECIEVED_STRING[1]
    				
    				WAIT 2.5
    				{
    					nRADIO_REQ=nRADIO_BAND_REQ
    					SEND_STRING dvZTUNER,"'R 1 8',13" // Request Band
    				}
    			}
    			ACTIVE(nRADIO_REQ=nRADIO_BAND_REQ):
    			{
    				ZTUNER_STATUS[ZTUNER_BAND][1]=RECIEVED_STRING[1]
    				
    				WAIT 2.5
    				{
    					nRADIO_REQ=nRADIO_FREQ_REQ
    					SEND_STRING dvZTUNER,"'R 1 6',13" // Request frequency
    				}
    			}
    			ACTIVE(nRADIO_REQ=nRADIO_FREQ_REQ):
    			{
    				ZTUNER_STATUS[ZTUNER_FREQ][1]=RECIEVED_STRING[1]
    				ZTUNER_STATUS[ZTUNER_FREQ][2]=RECIEVED_STRING[2]
    				
    				IF(ZTUNER_STATUS[ZTUNER_BAND][1]=nFM)
    					cRADIO_FREQ_TEXT="ITOA(ZTUNER_STATUS[ZTUNER_FREQ][1]),'.',ITOA(ZTUNER_STATUS[ZTUNER_FREQ][2])"
    				ELSE
    					cRADIO_FREQ_TEXT="ITOA(ZTUNER_STATUS[ZTUNER_FREQ][1]),ITOA(ZTUNER_STATUS[ZTUNER_FREQ][2])"
    				
    				// USED FOR RADIO STATION ICON DISPLAY
    				FOR (nLOOP_COUNT = 1;nLOOP_COUNT<=LENGTH_ARRAY(RADIO_STATIONS_TEXT);nLOOP_COUNT++)
    				{
    					IF(FIND_STRING(cRADIO_FREQ_TEXT,RADIO_STATIONS_TEXT[nLOOP_COUNT],1))
    					{
    						
    						SEND_LEVEL dvLIB_TP,2,nLOOP_COUNT
    						BREAK
    					}	
    					ELSE IF(nLOOP_COUNT>=LENGTH_ARRAY(RADIO_STATIONS_TEXT))
    						SEND_LEVEL dvLIB_TP,2,16
    				}
    				SEND_COMMAND dvLIB_TP,"'^TXT-126,0,You',39,'re listening to |',cRADIO_FREQ_TEXT, ' '"
    				WAIT 2.5
    					nRADIO_REQ=nRADIO_REQ_FINISHED
    			}
    		}
    	}
    }
    

    Since the ZTuner can send you "'1',CR" for different querry requests, you should keep track of what you asked it.

    Of course there's variables and constants defined above the data_event, but this code block should be pretty straight forward. This code is closely based off of parsing the documented protocol, so thanks the Programming Master in the Chicago area for help with the documented prptocol parsing.

    As you should already know, if you unplug it, and then power it back up - all will be fine.

    One last thing - this code took maybe 10-20 minutes to write, so I'll be sending a hefty bill to all who use it. :D
  • ondrovicondrovic Posts: 217
    thanks i will try that because the only other issue that i seem to be having is that the feedback is locking up with the autotune up and down or if you have it to step up, step down it freaks out the feedback
Sign In or Register to comment.