Skip to main content
  • Press & News
  • Contact Us
  • Login
  • Register

Main menu

  • Technology
  • Business
  • Downloads
  • Community
  • Buy
Join Forum Blog Projects Social 

You are here

Home » Forums » Projects place

Multi zone audio controller rs232 interface

28 posts / 0 new
Log in or register to post comments
Last post
Sun, 06/05/2011 - 15:39
#1
Larry
Offline
Joined: 06/03/2011
Posts: 18
Multi zone audio controller rs232 interface

Here are the details of the project I am just starting.

I have recently purchased a second hand Speakercraft MZC-88 multizone controller. It is a lovely piece of kit which routes audio and video signals for eight sources to eight listening / viewing zones.

The normal setup for these machines is to have a keypad controlling each zone, however the system has a RS232 interface that allows the system to be controlled and monitored. I intend to use the flyport to build a website that will allow me to control each of the 8 zones, and display details about the current state of each zone.

For this I intend to enable a second UART on the flyport. I think this is essential so I can easily debug the code and see what is happening.

The MZC sends out a zone status summary every 2 seconds this includes detail of the source selected in each zone, the on/off status of the zone, volume bass and treble settings. I will need to code the to detect that the status summary is being transmitted and then set variables based on the content of the status summary that can then be displayed on a webpage.

For controlling the unit, the webpages will have various buttons which will result in commands being sent to the MZC via the UART. In order to send commands to the MZC, I have to wait for a particular message from the MZC indicating that I should transmit the command. The transmission window is only open for 20ms. I shall therefore buffer the control commands from the webpage and then when I detect that the window is open, send the relevant command from the buffer.

This is my first attempt at an embedded system....I hope I am not biting off more than I can chew. I have some previous programming experience from a few years ago. I choose the flyport as it seemed like a great platform for what i wanted to achieve, and relatively simple for a novice....let's see.

Top
  • Log in or register to post comments
Tue, 06/07/2011 - 15:17
#2
Gabriele
Offline
Joined: 02/05/2011
Posts: 293

Hi Larry, good project. Controlling wireless rs232 devices can be a very interesting application for Flyport! I have posted the template for two uart in the forum, you can find it here: http://www.openpicus.com/cms/index.php?option=com_ccboard&view=postlist&forum=1&topic=65

i hope it helps

Top
  • Log in or register to post comments
Tue, 06/07/2011 - 21:59
#3
Larry
Offline
Joined: 06/03/2011
Posts: 18

Thanks Gabriele. This will assist in getting things set up correctly, and I have found the PDF on another post showing the mapping between the flyport pins and the PIC pins.

One question I do have is when converting RS232 level to ttl level what is the correct ttl level to use.....is it 5v or 3.3v?

Or will the chip handle either?

Top
  • Log in or register to post comments
Sat, 06/11/2011 - 14:04
#4
Gabriele
Offline
Joined: 02/05/2011
Posts: 293

The PIC pin used for UART RX can handle also 5V signal, so you can use MAX232 or MAX3232 tansceiver...

Top
  • Log in or register to post comments
Wed, 08/03/2011 - 15:25
#5
Larry
Offline
Joined: 06/03/2011
Posts: 18

I almost have my completed project....and will shortly be looking to move the flyport out of it's Nest.

 

I am howvever struggling in a couple of areas so if there is an advice or assistance that could help then that would be greatly appreciated.

 

Firstly, when I need to send a RS232 command to the MZC controller, I need to do this within 20ms of recieving the 'Tramsmission window is open' signal. I have coded it so I prepare the command that I am going to send in advance, and then as soon as I detect the window open signal I send the command (I suspend all other tasks whilst sending). I should then recieve a reply back indicating that the command was successfully sent. What I have found is that the command does not always get recognised, and i think (it is a big assumption) that the flyport is doing other things and hence may have missed the 20ms time limit in which to start sending the command.

I have coded round this for the time being with a re-try mechanism, but it is not that effective and can result in the command being sent more than once. I tried to wrap up some of the code in other suspend all sections, but I believe that when I "suspend all" the data from the UART does not enter the buffer. Any pointers?

 

My second problem is that I get WF _ASSERTION errors which effectivly shut down the flyport. These seem to occur randomly the exact error is "WF ASSERTION: Module Number = 11  Line Number = 666". I have seen that there is another forum post that talks about this error but I have not been able to identify what has caused the error in my case.

Top
  • Log in or register to post comments
Wed, 08/03/2011 - 15:39
#6
Gabriele
Offline
Joined: 02/05/2011
Posts: 293

Hi Larry, for the WF ASSERTION problem, try to replace WFDriverRaw.c file (located in the folder ..MicrochipTCPIP stakWiFi) with the included file. It has a fix for this bug (it happens very rarely, but sometimes it blocks the Flyport).

For the timing problem, there is some solution... first i'd need to know, how do you recognise that the MZC is ready for the command? Maybe a particular string?

 

Top
  • Log in or register to post comments
Wed, 08/03/2011 - 15:47
#7
Larry
Offline
Joined: 06/03/2011
Posts: 18

Thanks for the very swift reply - I will try replacing the file and let you know how I get on.

 

For identification of the 'Transmission Window Open', the MZC sends 0x11. It will then send 0x13 which means transmission window closed 20 ms later, if it has not detected a command being transmitted. There are around 10 transmission windows each second, although this can vary depending on how busy the controller is.

Top
  • Log in or register to post comments
Wed, 08/03/2011 - 16:20
#8
Gabriele
Offline
Joined: 02/05/2011
Posts: 293

Well, it's quite a tricky way to control a device! :P

However, you can accomplish this in some way, tweaking the standard application.

First solution: you could make a check in the UART ISR (the function called each time a character arrives on the uart.

When you want to send a command you set a flag var in the taskflyport.

Then, in the file ISRs.c (you can find it in the folder ..libsFlyport libs), first declare the flag var as extern, and then you can add the code to check the flag. If arrives the char 0x11 and the flag is on, then you send the command. This is done as soon as the char is received, so you'll be sure you don't time out the request. But, how long is the command you have to issue? What is the baud rate?

 

 

Top
  • Log in or register to post comments
Wed, 08/03/2011 - 18:06
#9
Larry
Offline
Joined: 06/03/2011
Posts: 18

I know it is tricky....that is why I am struggling.

I also need to be careful as i could potentially recieve the 0x11 character in one of the other messages that the system sends out....... every 2 seconds it sends out a status message for each tuner and zone....I use these messages to know what the MZC is doing (e.g. which zones are on, what sources they are connected to etc). These messages vary in length but I can handle them in the code using the following logic: The first charcter of a status message is always 0x55, and the second character contains the number of characters in the message.

I guess it is a pretty small chance that the status messages include 0x11, and that the point at which I need to send the command occurs in the middle of a status message.

The baud rate is 57600, and the commands are normally less than 10 characters. I only have to start the transmission within the 20ms. 

I had to clone the UARTwrite function as I sometimes need to send 0x00 within the command - my new function takes in an additional parameter indicating how many charcters need to be sent.

Top
  • Log in or register to post comments
Thu, 08/04/2011 - 15:10
#10
Gabriele
Offline
Joined: 02/05/2011
Posts: 293

Flyport uses the UART buffer to ease the UART managing, but a buffer it's not the best solution if you need a sort of "real-time" processing and response. So you can think if in this particular case you should use it or not... to disable it, in the UART ISR delete the line UARTRxInt(1);

Let's see how to solve the situation without using the UART buffer:

- you can use a "flag variable" in this way:

     * when flag is 0 no chars arrived on UART

     * when flag is -1 you received a 0x55 char, so you are in "header" message

     * when the flag is >0 you are inside status message, and the flag indicates how many chars left        from status message

     * when the flag is -2 you want to send a command to the device. The flag can be set to -2 only           if it is ==0, otherwise you are inside a status message.

- so, in the UART ISR, when do you receive a 0x55 you can set the flag to -1, indicating you are inside the "header".

- When do you receive the second char, you now you are in the header thanks to the flag, so you read the char to know how many chars is the message long, and put it in the flag. Now you are in the "status message".

- any other char arriving is part of the status message, also if it is 0x11 or 0x55. Any time a new char arrive, you decrease the status flag, until it arrives to 0 when the message is finished (and so you are again in the starting situation). You can put the chars inside a buffer variable, if you want to read it from the task flyport.

 

HOW TO SEND COMMANDS TO DEVICE

- in the task flyport you check and set the status flag value to -2. Just check if it's 0.

- in the UART ISR, when a new char arrives, you check it, if it's 0x11 and the flag is -2, then you send the command.

 

i hope it helps, let me know if you solve...

Top
  • Log in or register to post comments
Thu, 08/25/2011 - 23:00
#11
Larry
Offline
Joined: 06/03/2011
Posts: 18

Gabriele - your suggestion has worked perfectly - thank you.

 

I wrote a new custom ISR to handle the incoming data and detect the start of the send window - this results in the command always working - no more timing issues.

 

Now I am struggling with the construction of the final circuit board to host the flyport that will sit separate from the PC....

 

I have built and tested the power supply and Max232 based circuit, and this works fine with the flyport in it's nest powered by the USB with the circuit taking 5V, GND, Tx and Rx from the nest.

This also works fine with the flyport powered by the nest on USB power, and the circuit powered by 6V battery (through LM7805), with the nest and Max232 circuit grounded together.

However as soon as I power both the flyport and the max232 circuit from the same power source (which is not USB), the communication breaks down even though the flyport continues to work....

I have been trying to work this one out for a while now, but with no luck - Any ideas what the problem could be?

 

Top
  • Log in or register to post comments
Fri, 08/26/2011 - 07:08
#12
simmartin
simmartin's picture
This Cat's on a Hot Tin Roof

Online
Joined: 05/03/2011
Posts: 341

In this way I can't understand what you are doing... can you draw a schematic of your circuit?

Have you connected MCLR pin?

 

Another tip: the MAX232 is a great IC, but I think it could not handle the 3.3V signals, but only the 5V... there are some differents versions that works with 3.3V...

This Cat's on a Hot Tin Roof!

Top
  • Log in or register to post comments
Fri, 08/26/2011 - 22:08
#13
Larry
Offline
Joined: 06/03/2011
Posts: 18

Ok - attached is the schematic I have put together for the circuit. I am not too sure which Pin you mean by MCLR.....Only 4 pins of the flyport are connected when it is out of it's nest - GND, 5v, Tx and Rx

The odd thing is that it works perfectly when powered by the USB in the nest, but not when powered without USB.

Perhaps there is something I need to add to my circuit to get it to work correctly....

 

Or perhaps I shoud use the 3.3v output from the flyport to power a different MAX 232 chip - the Max3232 - Update - I tried this and this did not work either.........

Top
  • Log in or register to post comments
Sat, 08/27/2011 - 07:44
#14
simmartin
simmartin's picture
This Cat's on a Hot Tin Roof

Online
Joined: 05/03/2011
Posts: 341

Ok, the MCLR (or Master Clear) is the Reset Pin.

If you power the flyport with NEST the MCLR is pulled down by the DTR signal, and it can be programmed. If you don't want to program again the Flyport, you could choose to not put this signal, but I suggest to put at least a normally open swtich between MCLR and Ground, so you can reset your Flyport.

Another tip: The max 232 can be in difficult to handle 3.3V... you should check the MAX232 converter datasheet.

You should put some transistors in TX and RX before the MAX232 to get a 5V level, or put a voltage shifter (3.3v to 5v). Check Google for transistors (pay attention to non invert signals)

This Cat's on a Hot Tin Roof!

Top
  • Log in or register to post comments
Sun, 08/28/2011 - 23:58
#15
peter a
Offline
Joined: 06/14/2011
Posts: 158

have you tried a DVM on the output of the LM7805 ?, one pdf on the 7805 says the input should be 2 volt more than the output.

Top
  • Log in or register to post comments
Mon, 08/29/2011 - 07:54
#16
simmartin
simmartin's picture
This Cat's on a Hot Tin Roof

Online
Joined: 05/03/2011
Posts: 341

I saw the Maxim max232 datasheet, and it is made for 5V logic. If you would like to use this kind of voltage translators, you could use the MAX3232 that is "3.3v up to 5v power".
http://www.maxim-ic.com/datasheet/index.mvp/id/1068

This Cat's on a Hot Tin Roof!

Top
  • Log in or register to post comments
Fri, 10/28/2011 - 12:43
#17
Larry
Offline
Joined: 06/03/2011
Posts: 18

The Project is now complete. Many thanks to everyone that assisted me in getting over the hurdles that I faced. Template file for project attached for anyone that wants to reuse.

 

I have created a YouTube video of the Flyport in action:

http://www.youtube.com/watch?v=bq3QNvb1NtQ

Top
  • Log in or register to post comments
Fri, 10/28/2011 - 13:17
#18
simmartin
simmartin's picture
This Cat's on a Hot Tin Roof

Online
Joined: 05/03/2011
Posts: 341

very very very nice project!

This Cat's on a Hot Tin Roof!

Top
  • Log in or register to post comments
Sat, 10/29/2011 - 09:13
#19
7strings
Offline
Joined: 09/26/2011
Posts: 43

Many compliments... it is nice to see a complete and working project using Flyport!!

A question: for video, I saw you have embedded a IP address

<div id="Sky4" class="hidden">

&nbsp;&nbsp;&nbsp;&nbsp;

<img id="vid" src="http://192.168.1.143/GetData.cgi" width="352" height="288" />

</div>

 

... can you explain what are you doing please? I'm very curious!!! what is the video source? can you integrate a IP webcan or anything else?

 

Best regards 

Top
  • Log in or register to post comments
Sat, 10/29/2011 - 17:34
#20
Larry
Offline
Joined: 06/03/2011
Posts: 18

The Video feed comes from an Aviosys 9100A Video server that sits on the home network - the hard coded IP address is the address that this is currently set to.

This video server can take upto 4 separate video feeds, however I think you need to put on some better firmware (YOICS) if you want to access these separatly without using ActiveX.

Yes - you could easily integrate a IP web camera feed.

Top
  • Log in or register to post comments
Sun, 01/01/2012 - 01:26
#21
scurvyrat
Offline
Joined: 01/01/2012
Posts: 3

Awesome project Larry! Very well done.

I've been also playing around with my MZC (MZC-66) and RS232. I have no problem turning on and off the zones via my iPhone app, but I can't get some of the messages to reply (Zone Initialization 0x68 or Source Iinitialization 0x71, or any of the meta data commands). I'm connected via the Control Port on the back of the MZC (the 66 does not have a RS232 port, but from your video it seems you are also connected to the control port). I took a quick look at connecting via the Expansion port but that seems to have some RS232 to RS485 translation going on.

Can you pls confirm that you are connecting via the control port and can run any of the commands?

Thanks!

Top
  • Log in or register to post comments
Sun, 01/01/2012 - 01:27
#22
scurvyrat
Offline
Joined: 01/01/2012
Posts: 3

forgot to say -- Happy New Year!!

Top
  • Log in or register to post comments
Mon, 01/02/2012 - 13:03
#23
Staff - Ionela
Staff - Ionela's picture
Offline
Joined: 12/16/2011
Posts: 97

Happy New Year to all of you! smiley

 

 

Play with your imagination! Play with Flyport!

Top
  • Log in or register to post comments
Tue, 01/24/2012 - 12:17
#24
Larry
Offline
Joined: 06/03/2011
Posts: 18

Scurvyrat,

apologies for the delayed response - I have been pretty busy and did not get any notification that a further reply had been added to this thread.

Did you code from scratch or use the code I uploaded?

As for the connection, I can confirm that I am using the 'Control port' of my MZC-88 to connect to the Flyport - the MZC 88 has 2 control ports - one on the front and one on the back.

The controls I have implemented today are only really emulating keypad button keypresses - I have not done any of the more advanced source initialisation or meta data stuff.

Let me know if you do make any headway on this in getting a response to these commands - it could take the interface to the next level being able to select a music track / album from a list and display the name of the track currently being played

Top
  • Log in or register to post comments
Sat, 02/11/2012 - 01:29
#25
scurvyrat
Offline
Joined: 01/01/2012
Posts: 3

Hi Larry,

Sorry for the late reply. I guess this forum doesn't notify when there are new messages.

I didn't use the code you posted (not sure where it is posted?). I wrote my own code using the control port. At least on my MZC-66, you cannot do the Metadata commands via the Control Port. You have to use the Expansion ports which are RS-485.

I started over and was able to get that to work, but then ran into another issue: the MZC Metadata control protocol is very limited. You get six songs at a time. You can go up and down the list, but you only get six items per transmission. It is obviously and interface made for the Mode 3.1 keypads, not for taking down a long list and along the user to choose.

You can get the current playing song (or at least currently selected song) and the time elapsed, total time, queue length, item num in the queue etc.., but if you want to build a quick list to scroll through the artists, albums or songs, I think we are out of luck.

Top
  • Log in or register to post comments
Fri, 03/23/2012 - 21:48
#26
Sdlwiz
Offline
Joined: 01/03/2012
Posts: 1

Hi Larry,

 

Love the video.  Trying to figure out where the project is so I can download it.

 

Thanks.

 

Peter

 

Top
  • Log in or register to post comments
Wed, 03/28/2012 - 11:44
#27
Larry
Offline
Joined: 06/03/2011
Posts: 18

Peter,

I think that the file containing the code got dropped off when the forum was migrated a few months ago. My replies are delayed as well as I do not get alerts that there thread has been added to.

I plan to greate an updated version of the zip file which shoud work with the new version of the IDE and I hope to post this in the next week or so. I'll then send this in so it can be added to te 'Projects' page and attached to the thread.

Larry.

Top
  • Log in or register to post comments
Mon, 04/09/2012 - 17:34
#28
Larry
Offline
Joined: 06/03/2011
Posts: 18

Uploading a few files for those that want to take a look at the code.......the zip file is a IDE v1 template - not too sure if this will work with the latest V2.2 IDE.

AttachmentSize
MZC88.zip514.17 KB
Using the OpenPicus Flyport to control Speakercraft MZC.pdf242.08 KB
Extra_files.zip10.38 KB
Top
  • Log in or register to post comments
  • Technology
    • Overview
    • Downloads
    • Products
    • Universities
    • Projects
  • Business
    • Overview
    • System integrators
    • Distributors
    • Products
    • Projects
    • Services
  • Downloads
    • Downloads
    • Get Started
    • Projects
    • FAQ
  • Community
    • Join
    • Forum
    • Blog
    • Projects
    • Social
  • Buy
    • Store
    • Retailers
    • Distributors

openPICUS Newsletter

Copyright 2001 © OpenPICUS    -    All rights reserved    -    info@openpicus.com