Wednesday, April 05, 2006

Sending ASCII Volume Commands in Crestron SIMPL - Pansonic PT-LB20U Projector

As our last example involved parsing an ASCII serial string for volume level, it seems only fitting that we now discuss sending volume in a similar protocol. This is a response to Crestron Yahoo! Group post number 54920 by jourabchid, regarding sending volume commands to a Panasonic projector from a Crestron processor. The projector's protocol did not include a "volume up" or "volume down" command, forcing the programmer to send discrete volume levels for all 64 possible volume levels. The following example is a summary of techniques outlined by Matt, which I have modified slightly to use Crestron SIMPL Windows entirely, without any SIMPL+.

As in the last example, I don't have this projector here to test, so this code is for demonstration purposes only. The projector I have selected for this example is a Panasonic PT-LB20U. You can download a copy of the user manual, and find the RS-232 protocol information on pages 64 and 65.

The basic format of the serial strings is: Command:Parameter. STX is the start byte, \x02. The command is always three bytes. A colon separates the command and the parameter. The parameter is also always three bytes. ETX is the end byte, \x03.

The AVL command will allow us to adjust the projector's volume. The parameter is the desired volume level, ranging from 000 to 063.

We'll start by inserting a RAMPL (Analog Ramp Bounds Limited) symbol. We will tie the up and down inputs to our volume buttons on the touchpanel (projector_volume_up and projector_volume_down). The aout signal will be called projector_volume. The ramp time will be the total amount of time des
ired for the volume to go from 0% to 100%. 5s, or 5 seconds, is a good starting point. Our lower limit will be 0d, and our upper limit will be 63d. This will give us the range of values required by the projector. The mute level should be 0d, although I'm not going to go into the specifics of adding a mute button in this example (use a toggle, the same way you would with a regular analog ramp controlling a Crestron volume control)

The next step is to split the volume into tens and units bytes. We'll use a DIVMOD (Analog Divmod) signal. Run the signal "projector_volume" into the ain. Enter a divisor of 10d, since we need to divide by ten. The quotient will contain the tens digit, and the remainder will contain the units digit.

Now that we have the tens and units digits, we need to convert from decimal to ASCII. For this, we will utilize two ASCALEL symbols (Analog Scaler with I/O Limits). Run each signal into an ain1. Set the input lower limit to 0d, and the input upper limit to 9d. The output lower limit is 48d (0 in ASCII) and the output upper limit is 57d (9 in ASCII). The format is 0d as the value is unsigned.


We'll now format the string we are going to send to the projector. Insert an ATOS symbol (Analog to Serial). The digital (blue) trigger line will have a new signal, "projector_volume_go" When this trigger is pulsed, the symbol will send the data in the first parameter field, followed by the first analog, then the 2nd parameter field, 2nd analog, and so on. To set this up, expand the analog (red) inputs and connect the two ASCII volume signals. The first parameter field contains the header, which in our case is \x02AVL:0 (the start byte, the command bytes, the colon, and the first parameter byte which will be constant). The second parameter field contains "", which is how we indicate an empty field. The third parameter field contains \x03, which is the end byte. Set the format to 256d, as no checksum calculation is necessary. The serial output is routed to the transmit of the RS-232 port.

We now need a trigger to send the strings. Insert an AOS (Serial/Analog One-Shot) signal. Connect the signal "projector_volume_units_ascii" to the rx$. Set the parameter to .05s. Name the output "projector_volume_go" This will give us a trigger (to send a string) each time the volume level changes.

Last but not least, it's possible you'll also want to display a bar graph on your touchpanel. If you do, insert another ASCALEL. The ain is "projector_volume" (which is the 0-63 range signal we started with). The aout is "projector_volume_touchpanel" for display on a full-range gauge. Input lower limit is 0d, input lower limit is 63d. Output upper limit is 0%, output upper limit is 100%. Format is 0d as the values are unsigned.

As always, I welcome any suggestions on improvements to this logic. This isn't meant to be the "only way" to accomplish this task... It's just one example to get people thinking.